Create custom call out for mapbox in ios - ios

I am using map box sdk for my application to get customized map. I able to change color of land, sea, street,etc. But I also have to make callout customized as show in image below. The small rectangle is closed callout the big rectangle is when call out pop is up.

The documentation contains an example of how to do this.
You have to implement the following delegate method and return your custom marker.
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation

Related

Mapkit Callout Accessory Button Activation

I am using MapKit to display a map with many annotations. Each of these annotations has a callout with a UIButton. Most everything works properly, but any time there is an annotation behind the UIButton, it becomes impossible to activate it. I want the UIButton to be activatable regardless of background annotations. Is there a way to ignore the annotations directly behind the callout?
I have found an appropriate workaround to this issue:
(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
[view.superview bringSubviewToFront:view];
}
https://github.com/danielbarela/ios-map-callout-test/issues/1

Hiding/showing annotations

I want to hide/show annotations on a map based on filters.
My approach is currently to return nil or a RMMapLayer in
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
It works quite as expected but if the filters are changed when the map is visible, the changes are not reflected to the map if it is not paned or zoomed (annotations that go off screen and back in screen are correctly affected -ie hidden/shown- by the filters, but annotations not leaving the screen bounds are not affected).
Is there a way to achieve this without removing and replacing all annotations on the map each time the filters are modified ?
Thanks.
You may want to look into this pull request which was not incorporated but helps with this functionality: https://github.com/mapbox/mapbox-ios-sdk/pull/113

tapOnCalloutAccessoryControl delegate method not getting called on acessory view tap in mapbox mapview

I am working on my app using mapbox sdk(MapBox iOS SDK 1.0.3) and installed the framework using steps as described here.
Now when i add the annotation on the map then i am able to show the title,subtitle,left/right accessory views but the accessory view's tap functionality is not working.
I have tried these solutions as described in these discussions but still i am not able to get tap functionality to work on my left and right accessory view and its driving me nuts to why this is happening as this is just a basic functionality.I have read a lot of discussions in mapbox support and tried most of the solutions but to no use.
Please help me on where i am getting wrong.i have looked into this project too- "weekend-pics".but i am not understanding why these two methods -
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
and
- (void)tapOnCalloutAccessoryControl:(UIControl *)control forAnnotation:(RMAnnotation *)annotation onMap:(RMMapView *)map
are not being called directly on the contrary the should be called as these are delegate methods and should be triggered when accesory view of callout is tapped.
I have tried using [self mapView:mapView layerForAnnotation:annotations]; then i get the compiler to go into this mehtod-
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
but still the - - (void)tapOnCalloutAccessoryControl:(UIControl *)control forAnnotation:(RMAnnotation *)annotation onMap:(RMMapView *)map method doesnot gets called when i try to click on the right accesory view of the annotation.
I have added #import "MapBox/MapBox.h" in my file. do i need to add any other file too for this functionality to work? and i have debugged using Breakpoints but the control never goes inside these two methods as described above.
I am using Mbtile file and using it as an offline map in my app.
Xcode5,ios7
Please guys help me solve this issue.Thanks!!
Are you sure that you are setting your mapView.delegate? These are delegate callback methods. You can do this either in code or in the XIB, if you add your map view that way.

MKMapKit disalow deselection of callout bubble

I would like to know how I can make sure that a callout bubble can't get deselected on a MKMapView.
Whenever I press on the map (background), this view:
Turns to:
Which I do not want to allow. Yet I do want to keep the callOutButton support.
You could just programmatically select your annotation whenever annotations get deselected (using the corresponding delegate method). If you don't animate this selection then it looks as if the annotation never got deselected in the first place.
Example:
// MKMapView Delegate
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view {
// Replace "myAnnotation" with whichever annotation you need to remain selected
[mapView selectAnnotation:self.myAnnotation animated:NO];
}
I tried this in a test project and it works fine (it doesn't flicker or anything). It's not exactly disabling deselection but the resulting effect is the same, so it might be a good workaround.

Map callout expansion animation like the one in Maps when the disclosure button is pressed

When selecting the disclosure button on a callout, the callout animates to the slide over and expand into larger area with more information.
Besides making this component from scratch, does anyone know how to make annotation callouts do this?
According to this: http://www.cocoacontrols.com/controls/gikanimatedcallout
, Apple is using a private API. The link above has code that tries to replicate what Apple does.
you should use below delegate method
(void)mapView:(MKMapView *)mapview annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
then in this delegate method, you should create an disclosure button.
if(buttonType==disclosurebutton) then show custom UIView.
I think that will help overall.

Resources