Make MKMapView only zoom in on the centerCoordinate?

匆匆过客 提交于 2019-12-02 20:12:06

问题


I have a MKPinAnnotationView that is always in the center of the map. When panning and zooming the pin gives me the center coordinates (lat/long) of the map.

Currently when you zoom in, it just zooms into wherever your directing the map to zoom into.

I'd really like to lock the zoom onto the pin.

Any ideas on how I'd achieve this?


回答1:


Assuming by MKPinAnnotation you mean MKPinAnnotationView, you can access the annotation's coordinate and use that to create a region and subsequently set the region of the mapView to that region centered on the coordinate:

MKCoordinateRegion region = MKCoordinateRegionMake(pin.annotation.coordinate, MKCoordinateSpanMake(.05, .05));
[self.mapView setRegion:region animated:YES];


来源:https://stackoverflow.com/questions/25577813/make-mkmapview-only-zoom-in-on-the-centercoordinate

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