Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Positioning GMSMapView to show multiple annotations at once

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?

like image 371
hash3r Avatar asked Mar 26 '13 19:03

hash3r


Video Answer


1 Answers

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];
}
like image 192
kokemomuke Avatar answered Nov 09 '22 19:11

kokemomuke