Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone mapkit drag and get center location

HI,

I have a Mapview with some marker points + a marker for current location.

Now, what I want to do here is, when user drag or traverse through mapview, I want to find coordinate (latitude, longitude) of the new center location after map has been dragged.

I want to clarify once again, I am not talking about dragging the marker/point, I am talking about dragging the map with touch.

Thanks in advance.

like image 715
Ruchir Shah Avatar asked Feb 27 '23 10:02

Ruchir Shah


2 Answers

Look for theMapView.region.center or theMapView.centerCoordinate (should be the same) in your MapView's delegate -mapView:regionDidChangeAnimated: method.

like image 109
Johan Kool Avatar answered Mar 07 '23 20:03

Johan Kool


Judging by this document:

http://developer.apple.com/iphone/library/DOCUMENTATION/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html

You can get that with the centerPosition property of your MKMapView. To tell when the location changes, implement the -mapView:regionDidChangeAnimated: method in your MKMapViewDelegate.

like image 36
Ian Henry Avatar answered Mar 07 '23 21:03

Ian Henry