Is there a Google Map event listener for panning or zooming map?

后端 未结 4 1305
刺人心
刺人心 2021-02-19 20:10

I want to be able to detect if the user has zoomed out or moved the map center. I have seen post about an event listener but in Javascript and I am trying to see if there is any

4条回答
  •  天命终不由人
    2021-02-19 20:51

    I use this delegate to detect the camera change, which includes zoom and position:

    - (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position;
    

    EDIT

    with this code you can get the corners of the visibile area:

    NSLog(@"%f,%f",_mapView.projection.visibleRegion.farLeft.latitude,_mapView.projection.visibleRegion.farLeft.longitude);//north west
    NSLog(@"%f,%f",_mapView.projection.visibleRegion.farRight.latitude,_mapView.projection.visibleRegion.farRight.longitude);//north east
    NSLog(@"%f,%f",_mapView.projection.visibleRegion.nearLeft.latitude,_mapView.projection.visibleRegion.nearLeft.longitude);//south west
    NSLog(@"%f,%f",_mapView.projection.visibleRegion.nearRight.latitude,_mapView.projection.visibleRegion.nearRight.longitude);//south east
    

提交回复
热议问题