iOS mapkit - How can I show text on hover of a pin - ios

I am using iOS 9 with Swift 2.
I have been unable to find a way of displaying text on hover of a pin that exists on a map using mapkit.
I would like to do this without having to have a callout, which forces the user to click on the pin.
Any ideas?

There isn't really a "hover" per say like with a web app. There is either tap (selected) or no tap (unselected), but terminology aside, you're going to want to use an MKAnnotationView. Specifically I'd replace it with a UILabel using this method:
func viewForAnnotation(_ annotation: MKAnnotation) -> MKAnnotationView?
That will let you set the view to be whatever you want, so create the UILabel view, then set it to be your annotation view there

Set MKAnnotarion.title property, then you can see the value on TAP. As mentioned above comment, there is no Hover concept in iOS

Related

Mapbox (iOS) user annotations covering/preventing touch events from other annotations - use User annotations hit test

I'm having some difficulties with Mapbox iOS.
I'm adding annotations on my map, but when they are very close (actually overlap) to the user annotation (i.e MGLUserLocation) taps do not pass to the other annotations.
I have tried to play with the z-order both for the user annotation (setting it to. 0/-1 or any lower value) while increasing the value of the other annotations but with no success
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation)
Is always called with the user annotation.
I'm using a custom view for the user annotation and I tried to set its isEnable property false as well. Moreover, when I try to override the override open func tionsetSelected(_ selected: Bool, animated: Bool) In the custom view it is not called (no matter if it's isEnabled is true/false...)
It seems like the "halo" around the user location annotation make any tap to interact with the user annotation only - even if there are other objects that seems to be before it...
I was thinking as a last option to setup aUIGestureRecognizer on the relevant view that the user annotations "hides"... But am I missing something about the special user annotation in Mapbox?
I create a simple project trying to mimic as best as possible the problem in my original project which is not public - Repo
Here is an example of the capability I'm trying to achieve in Google Maps
Found the solution which I think it is utilising Mapbox API in the best way:
MGLUserLocationAnnotationView has a property called hitTestLayer: CALayer?
You can just override it and supply with the size of the clickable layer you wish to enable.... In my case I don't care for user annotation interaction so I set it to zero (I updated the code in the example repo as well)

How to show callout for pin on map without tapping on it?

I have an app with map and in it there are some pins with their annotations.
I don't understand how to show a particular pin's annotation without tapping on it.
Callouts are generally shown when the annotation is "selected". While this is generally achieved by a user tapping on the annotation view (i.e. the pin), you can also programmatically "select" the annotation:
mapView.selectAnnotation(annotation, animated: true)

Swift: MKMapView annotation appears in top left corner after a didDeselectAnnotationView call

I'm drawing a MKMapView in my iOS app, and on this map are some annotations, with custom images representing them. The image changes slightly (has a glow) when a specific annotation is selected.
To do this, I'm using the mapView(mapView: MKMapView!, didSelectAnnotationView view: MKAnnotationView!) delegate method to change the image (by changing view.annotation.image). This seems to work fine.
However, when I use the mapView(mapView: MKMapView!, didDeselectAnnotationView view: MKAnnotationView!) method to change the image back after it's deselected, it redraws the annotation in the upper left corner of the map. Any user interaction with the map then redraws it in its proper place immediately, so it's like the map isn't being refreshed after the method call until a click or something is made.
Is this actually the correct way to change an annotation's image (by overwriting the current view.annotation.image, and if so is there a way to refresh the map?
EDIT: I've also just noticed every time I select a new annotation it drags the map center down by about 100 pixels. Is there something I'm missing that I need to do after calling either of these two methods mentioned above?
You could try removing and re-adding the annotation using mapView.removeAnnotation(yourAnnotation) and mapview.addAnnotation(yourAnnotation) with the new image

ios MapKit have annotation description visible on launch and not on tap

I am using map on my IOS application. I can see the annotation on my map, and when I tap on that there is the description, which I have set. My question is whether I can have this description visible when map first loads and not make the user tap on the annotation to view it?
is that possible?
Thanks.
use an overlay instead of an annotation

Annotations, Annotations, Annotations

So `MKAnnotation's. Fun stuff.
My questions:
What's the difference between an annotation's title and its subtitle and how does that affect the visual component of the annotation?
What's the difference between a MKPinAnnotationView and a MKAnnotationView?
Are there different types of map annotations in iOS apart from pins?
Title is main heading of your pin.
The subtitle is actually displaying the address/(common info) of the dropped pin.You can store other deeply information of related to title that is puted on pin.
MKAnnotation is a protocol you need to adopt if you wish to show your object on a MKMapView. The coordinate property tells MKMapView where to place it. title and subtitle properties are optional but if you wish to show a callout view you are expected to implement title at a minimum.
MKAnnotationView visually presents the MKAnnotation on the MKMapView. The image property can be set to determine what to show for the annotation. However you can subclass it and implement drawRect: yourself.
MKPinAnnotationView is a subclass of MKAnnotationView that uses a Pin graphic as the image property. You can set the pin color and drop animation.
Don't forget about the leftCalloutAccessoryView and the rightCalloutAccessoryView properties of MKAnnotationView that can be used to customize the callout view.
The title and subtitle are displayed when a pin is selected on the map. The subtitle simply falls below the title.
MKPinAnnotationView is simply an specialized form of MKAnnotationView that knows how to draw a pin (and a shadow) and also allows setting the pin color. It's the only built-in annotation view with an image, you have to make your own if you want something different (but it's very easy to do).

Resources