Can anyone provide any sample code/instructions for implementing draggable pins in OS 4.0 using the MapKit framework?
Pins are essentially locations in Apple Maps that you mark yourself. Before you learn how to rename pins in Apple Maps, it’s useful to do a quick rundown on what they are (and what they aren’t). Open up Maps on your iPhone or iPad. Then, just tap and hold on a location.
While Apple Maps supports saved pins and label renaming, it isn’t the most intuitive thing to find. Pins are, of course, a useful way to save locations to your Favorites or a collection. But that usefulness only extends as far as your Maps organization goes. So here’s how to rename a pin in Maps. What are pins in Apple Maps?
Here’s how. Drop a pin in Apple Maps. Tap on the pin to bring up the options pane. Swipe up on this menu to see more options. Tap on Add to Favorites. Now, the next time you open a Maps window, the pin will be there. Near the Favorites tab, click on See All. Tap the “i” icon next to your Marked Location.
Open up Maps on your iPhone or iPad. Then, just tap and hold on a location. If there’s no business or point of interest there, you should see a pin appear with the name “Marked Location.” Not in the right place? Just tap and drag it to a new location. Note that you can only have one pin at a time.
Sure thing buddy (yes I'm talking to myself),
In your custom annotation add:
@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate;
This satisfies the requirement of implementing setCoordinate, as mentioned inhttp://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html#//apple_ref/occ/instp/MKAnnotationView/draggable
In your MapView delegate add:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState
{
//..Whatever you want to happen when the dragging starts or stops
}
and in your AnnotationView set draggable to true, so for example:
customAnnotationView.draggable = YES;
I think that was everything that I did to get it working. Tell me if you have troubles.
Check out MapKitDragAndDrop by Ching-Lang Huang and the author's accompanying blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With