7

My question is quite similar to this, except MKMapView. How can I do the same process(resize the map to fit all annotations/markers on screen at once) with Google Maps? As I understand I have to convert MKCoordinateRegion to GMSProjection, is my way right?

1 Answer 1

13

Thats very simple, just:

@property (nonatomic, strong) GMSMapView *mapView;

- (void)didTapFitBoundsWithMarkers:(NSArray *)markers
{
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];;

for (GMSMarker *marker in markers) {
    bounds = [bounds includingCoordinate:marker.position];
}

GMSCameraUpdate *update = [GMSCameraUpdate fitBounds:bounds];
[self.mapView moveCamera:update];
[self.mapView animateToViewingAngle:50];
}
1
  • Thanks for your attention. When I posted question I couldn't find this method (includingCoordinate) in earler version of GMapsSDK. And API didn't include the GMSCameraUpdate class
    – hash3r
    Jun 25, 2013 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.