Dragging a custom pin on a Map View - iphone

I've managed to create a custom image for the pin which is dropped on a map, using MKAnnotationView...
My question is how do I make this custom image draggable on the map? So I can move the image to other parts of the map?

Have a look at the MKAnnotationView docs. There's a property called draggable there, and you have to also implement the MKAnnotation protocol setCoordinate: method to update the position of the annotation.
Don't forget that it's only supported in iOS 4.0 and above.

You can look this tutorial : mapkit-annotation-drag-and-drop-with

Related

How to place a view next to an MKRoute in a MapKit app

I have an app that is using MapKit's MKRoute. I want to place a UIView on the route on the map, similar to how Apple annotates routes in Maps with an estimated travel time popover:
http://www.siprog2.com/pjx/fichiers/mkroute.jpg
You can use MKAnnotation to annotate a specific coordinate point on your route. Your MKMapView's delegate will then be asked to return an MKAnnotationView if your annotation is in the currently visible area of the map.
Apple has sample code for adding custom annotation views to a map (it's not using a route, but all you need to change is annotate a point on your route).

Remove the Standard callout from MapView

I need to remove the Standard Callout from the mapview and want to display my custom callout. My custom Callout is having image and many fields. I am designing my custom callout in interface builder.
How I can display my custom callout ?
I have referred to the link "Custom callout Bubble", But I want to display the custom callout from xib.
It's not simple, but you can do it.
You need to create an alternative MKAnnotationView (BubbleView) and show it when you select the first one.
It's possible to differentiate the AnnotationView from BubbleView in delegate.
You have a lot of work to do, this tutorial can help you to understand the passages, but pay attention on iOS 6, some things are changed and there are some problems in BubbleView positioning
http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/
Custom callouts are nearly impossible to implement. You have to simulate a callout by adding your own custom MKAnnotationView to your MKAnnotations, listen to their selection, then listen to your MKANnotationView's didMoveToSuperView callbacks to handle your own animations and drawing.
My implementation on the iPad took weeks to get right and if I were to do it again I wouldn't use Apple's MapKit at all. I'd use another mapping framework altogether that made the process easier.
tldr - you can't do it - trust me

Change Custom annotation Label without removing it from Map in iPhone

I am diplaying a Custom annotation in the center of the map. Which continues need to update its label how far is it from the center of the map.
P.S. Center of the map means the centre of the visible region in the map.
So by default my annotation is in the center of the map with label 0 then when I move the map it must update itself.
Currently on each move I am removing the annotation and adding the annotation with updated text. But its not the correct way..
Kindly help.... Thanks in advance....
I'd add a UIView with the label on it on the view that contains map right after adding map view. The size of this new view should be the same to size of the map. The tricky part is handling touches on it and then transferring them to the map view. You can dig into this tutorial. It is not map view but web view, nevertheless principles are the same.
If you choose that way you don't have to add this label as an annotation.

Custom MKAnnotation with drag & drop animation

I have an annotation with custom image and drag'n'drop support. But I need to animate the annotation the same way default Google pin is animated. That means the annotation should "jump up" when I drag it and "fall down" when I release it.
I was quite surprised that this animation isn't working anymore when I change annotation's image.
Thanks.
I have found the answer here: Subclassing MKAnnotationView and overriding setDragState. I used bad keywords when I was trying to find the answer before.

MKAnnotationView in both hovering and pinned states

I'm trying to add a pin (MKAnnotation and MKAnnotationView) to my MKMapView and allow the user to drag it around.
I'd also like to make the dragging of the pin animated and interactive like the iPhone's Map App.
My question is how do I change the state of the MKAnnoationView so that it's hovering over the map (so the pin isn't actually inside the map)?
I'm not 100% sure how to do this.
At present, my colleague as found an hovering image that he swaps with the default MKAnnotationView, but that means I can't easily animate between the two.
Not sure what you exactly want to do but I have used Apple's example in the iPhone App Programming Guide (Handling Events in an Annotation View) to implement the draggable pin.
It has a partial code but tha may be enough for you to figure it out.
Basically, you must subclass the MKAnnnotation and MKPinAnnotationView and in your CustomAnnotationView class you have to implement delegate methods to handle touch events, as shown in the Apple example.
There was a bit of filling out or modification needed because the code snippet was not complete, but I have reproduced the behaviour of the pin on the Apple's iPhone Map app exactly (except that I did not implement the right accessory button).
In it, the pin feels like it is hovering. So, I suspect that you have no need for the hovering image you have mentioned.
I also presume that by providing a BOOL property, you could make the pin draggable or "fixed" programmatically.
Does this help?