views:

1070

answers:

2

I want to make an app that partially mimics some of the behavior the standard map application has. This has proven difficult. First of all, I don't understand how you make annotations movable. How exactly do you do this?

Second: how do you search for locations?

Thanks

+6  A: 

Moving annotations

I'm assuming you're after the behavior of Maps.app where you tap and hold on to a pin to move it around freely. As far as I know, there is no built in way of moving annotations around. Since annotations are subclasses of UIView though, you can draw them where and how you'd like. You could for example detect a tap-n-hold on the annotation, and when "unlocked" change the centerOffset value of your annotation to move it around with the touch. When the user lets go of the the view, you can note the position on the screen, and use the MKMapView method convertPoint:toCoordinateFromView: to get the coordinates that the pin was released.

Search for location

What you are looking for is called Forward Geocoding. Unfortunately, MapKit only comes with Reverse Geocoding (the process of converting GPS coordinates to country/city/street/etc). There is, however, several alternatives. Here's a few ways:

Note that many geocoding APIs are licensed under Creative Commons, or similar licenses.

alleus
+1  A: 

You should be able to get drag-and-drop annotations going with the help of this blog post. I used it to do the same thing, and it was pretty simple to get going.

MapKit annotation drag and drop with callout info update

alku83