3

I want to show completely GMSCircle on MapView but radius of circle is dynamically changed. When radius is changed then MapView will be automatically adjust to view the complete circle on map to show all marker.

In Swift language, I have found a solution which may be helpful for me as given here: Change Camera Zoom based on Radius Google Maps iOS SDK

But I have to implement this in Objective-c and in Objective-c we didn't have bound property for GMSCircle.

Thanks in Advance,Please guide me.

Community
  • 1
  • 1
Aashish1aug
  • 745
  • 1
  • 7
  • 21

1 Answers1

3

you have to set zoom level according to your radius

 // SET ZOOM LEVEL
    int zoomLevel = 11;
    double radius = raduismeter+ raduismeter / 2;
    double scale = radius / 500;
    zoomLevel = (int) (16 - log(scale) / log(2));
    zoomLevel++;

you have to set and calculate zoom level according to your need. Than you have to set radius circle

  GMSCircle *geoFenceCircle = [[GMSCircle alloc] init];
            geoFenceCircle.position =PinDropCoordinates;
            geoFenceCircle.strokeWidth = 0.5;
            geoFenceCircle.strokeColor = [UIColor redColor];        
            NSLog(@"%@",geoFenceCircle);
            geoFenceCircle.radius =5000.00;
            geoFenceCircle.map = self.mapView;

After setting circle you have to animate your Camera accordingly.

    [CATransaction begin];
        [CATransaction setValue:[NSNumber numberWithFloat:3] forKey:kCATransactionAnimationDuration];
        GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:PinDropCoordinates.latitude
                                                                longitude:PinDropCoordinates.longitude zoom:zoomLevel];
        [self.mapView animateToCameraPosition: camera];


        [CATransaction commit];
Hasham
  • 140
  • 8