dormitkon
dormitkon

Reputation: 2526

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 moving.

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

Upvotes: 3

Views: 8230

Answers (1)

James Bedford
James Bedford

Reputation: 28962

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. :)

Upvotes: 3

Related Questions