3

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?

dormitkon
  • 2,526
  • 4
  • 39
  • 60
  • Did you make it ? I am exactly looking at this and can't find anything on google.. :/ Can you please give me a hand on the way you did it ? Thx – Marc Oct 19 '11 at 19:56

1 Answers1

3

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

James Bedford
  • 28,702
  • 8
  • 57
  • 64
  • Use `- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate` from the *MKAnnotation* protocol. – James Bedford Mar 29 '11 at 12:06
  • it works now (I declared to read write). But, I want to see pin where will be centered. How to show this pin while I moving map (pin that is positioned in center of my screen)? – dormitkon Mar 29 '11 at 12:07
  • If you're talking about keeping this "pin" centred in the view as you scroll over the map, then what you really want is a *MKOverlayView* or subclass of it. See http://developer.apple.com/library/ios/#DOCUMENTATION/MapKit/Reference/MKOverlayView_class/Reference/Reference.html – James Bedford Mar 29 '11 at 12:09