MapKit : Add custom callout - iphone

I want to add custom annotationView callout which contains
1. Title
2. subtitles
3. a button
The button can display on the right (rightCalloutAccessoryView) or left leftCalloutAccessoryViewsides of the callout. I want to add the button in the middle of the callout and under title->subtitle. How can I do?

There is no API for this. You could try not using the standard callout (canShowCallout = NO), catch the taps and drags on the AnnotationView manually and show your own UI by adding custom Views based on the position of the AnnotationView. This seems very fragile, though.

Related

iOS; Swift; How do I keep an annotation open even when the screen is tapped within a MapBox map view?

I have my screen split; 50% for the map and 50% for a list of elements. As the list of elements is scroll, the annotation will pop around the map based off whichever element is in the top of the list. This part is working fine.
However, when the user taps on the map, I don't want the annotation to disappear. I really want the user's tap to interactive with the MapView instead of the AnnotationView.
Is this possible? If so, can someone point me in the right direction? Thanks.
You have a couple of options:
You can intercept the built-in tap gesture recognizer or add a custom tap gesture recognizer. When the user taps the map, check if an annotation is selected. If one is selected, call mapView:selectAnnotation: to keep it selected.
You can call mapView:selectAnnotation: in the relevant mapView:deselectAnnotation: or mapView:deselectAnnotationView: delegate method.

Hide popup when annotation tapped on MapView

I'm creating an iPhone app that shows a large number of pins on a map. I need the app to push another view that will show lots of information for that location, when the pin is tapped.
In my viewDidAppear i have a piece of code that sets the title and subtitle values of the pin just for test purposes.
-(void)viewDidAppear:(BOOL)animated
{
pin.title = #"Some title";
pin.subtitle = #"Some subtitle";
}
in my didSelectAnnotationView delegate i have something along this lines
- (void)mapView:(MKMapView *)mapView
didSelectAnnotationView:(MKAnnotationView *)view
{
[self performSegueWithIdentifier:#"showPinDetails" sender:self];
}
Now, when i tap on the pin, a popover appears for a brief moment, showing the title and subtitle in a popup, and then the segue pushes the details view. When I tap the back buton to retun me to the map view, the popup is still visible.
How can I somehow completely hide or disable the popup? If i don't set the title and subtitle values the didSelectAnnotationView delegate doesn't get called at all. I will gladly post additional code if you need me to, I just wanted to keep things as simple as I could.
Am I doing this wrong? Should I use some different method to achieve what I need to do? Thanks
You are not setting canShowCallout
canShowCallout -> A Boolean value indicating whether the annotation view is able to display extra information in a callout bubble.
Discussion ->
If the value of this property is YES, a standard callout bubble is shown when the user taps a selected annotation view
For More info you can visit MKAnnotationView Class Reference
Ok, I was stupid, when adding pins all i needed to do is to set the pin property canShowCallout:
annotationView.canShowCallout = NO;

how to detect a callout of an annotation is showing on mapview?

I have a checkin related app. When user clicks a venue on map, callout will popup and show its name and address. At the same time, if the venue is within 1000m from current location, a check in button will be displayed.
To a venue that can checkin, all I want is,
when callout is popup, check in button shows. when callout is disappear, that button disappears too.
Now show button works well, but I don't know how to detect callout visible status. Is there any callback method that callout show/hide?
Thanks in advance!
Callout appears when annotation is selected - you can use mapView:didSelectAnnotationView: method in delegate to track that event. Callout hides when annotation is deselected - use mapView:didDeselectAnnotationView: method to track that event.
As you can see here it is about selected property of MKAnnotationView, which is saying that If the property contains YES, the annotation view is displaying a callout bubble.
You may additionally implement an observer for this property, to implement your functionality.

Google map on iphone apps : current location

I am working on an iPhone app in which I am implementing a map view. When the map loads, a purple pin is displayed at the current location. My problem is that I want to show the current location on a new view when the user touches this purple pin.
Any idea?
Please help.
Thanks,
Aaryan
When a user taps an annotation pin, callout annotation and accessory views can be displayed. The callout accessory views can be controls (buttons) with associated actions.
If callout views will not meet your needs, you could instead put invisible buttons with your own actions over the pins on the map view.
In either case, you can display views, navigate, etc in the method(s) called by the button actions.

How to display callout in MKPinAnnotationView?

I need to display the callout without tapping on the pin in the MKView.
I tried setSelected:animated method call but it doesn't seems to work.
Once the pin is dropped to the map, the callout should be displayed right away.
Use MKMapView:selectAnnotation:animated.