开发者

Drop pin in center of the screen, MKMapView

I have a function that drop pin with this code:

ParkPlaceMark *placemark=[[ParkPlaceMark alloc] initWithCoordinate:location];
[mapView addAnnotation:placemark];

How to put this pin on center of the screen?

I want something similar to Uber app: http://cl.ly/362q153W461Y1g3X1o04

User is located, dropped is red pin. Then, user can set custom location (in Uber's case, where they want to be picked with taxi cab), and when tap to button to confirm that location. When user setting custom location, custom location pin is centered on screen, and only map is开发者_Go百科 moving.

There is some sample with this on the Internet, or can you help me with some short sample?


Assuming that placemark implements the MKAnnotation protocol, you can set the coordinate property of placemark to the value of the centerCoordinate property of your mapView object.

This will mean that the placemark will always be placed on the map at the coordinate that is at the centre of where the mapView is currently looking.

Hope this helps. :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜