iPhone: Get Selected zoom level of Google map

久未见 提交于 2019-12-11 02:56:25

问题


We need to get the current selected zoom level of MKMapView when user either zooms-in or zooms-out on the Google Maps using Mapkit.

The solution we have tried is running fine on simulator but not on real device (iPhone 3GS having iOS 3.0.1). We need to get it running on iOS 3+ (including iOS 4)

Following is the code we are using to get the zoom-level:-

On zoom-in/out, Mapkit calls this delegate:-

(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated

which in turns calls our Mapzoomlevel function:-

#define MERCATOR_RADIUS 85445659.44705395

-(float) Mapzoomlevel {
  return 21 - round(log2(_mapView.region.span.longitudeDelta *
    MERCATOR_RADIUS * M_PI / (180.0 * _mapView.bounds.size.width)));
}

This code was taken from (see get zoom level example first comment posted on this blog):-

http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/


回答1:


https://github.com/jdp-global/MKMapViewZoom

-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
    int zoomLevel = [mapView zoomLevel];

}


来源:https://stackoverflow.com/questions/4763281/iphone-get-selected-zoom-level-of-google-map

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!