开发者

How to recenter map in iPhone app on zoom in/out using MKMapView

I am developing an iPhone application in which I need to show an image at a specific Latitude & Longitude on a Map. The requirement is - Even if the user zooms in or out on this map screen, the map control should automatically center itself after the zoom, to the same Lat & Long. I am using MKMapView.

I have tried to go through all available documentation. However, I could not come across any callback or other method that will allow me to开发者_如何学运维 achieve the objective.

One alternative is to handle touch events. However, I find that as a very complicated solution. And I hope that a simpler alternative exists. Any ideas on the above?

Can you please help? Any example will be appreciated.


Implement MKMapViewDelegate and then try this:

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
    [mapView setCenterCoordinate:locationManager.coordinate animated:NO];
}

Replace locationManager with whatever the name of your CLLocationManager is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜