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?
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];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With