I\'m trying to figure out a straightforward way to determine in Google Maps for iOS if a given GMSMarker is within the bounds of the visible map. There seems to be solution
A code example based on Andy's helpful response:
- (void)snapToMarkerIfItIsOutsideViewport:(GMSMarker *)m{
GMSVisibleRegion region = _mapView.projection.visibleRegion;
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion:region];
if (![bounds containsCoordinate:m.position]){
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:m.position.latitude
longitude:m.position.longitude
zoom:_mapView.camera.zoom];
[self.mapView animateToCameraPosition: camera];
}
}