How can I find if the user zoomed in/out on my mapView (GMSMapView)?
I want to do that if the zoom is bigger than 14 all the markers on the map will disappear and if it's smaller all the markers will reload.
How can I do that?
Thanks!
The below code assumes that the view controller has a property of "markerArray" which holds all of the markers.
-(void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition*)position {
int zoom= mapView.camera.zoom;
if (zoom < 14) {
[mapView_ clear];
}
else{
[self displayAllMarkers];
}
}
-(void) displayAllMarkers{
for (BarObject *barMarker in markerArray){
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = barMarker.location; //
marker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]];
marker.map = mapView_;
}
}