0
votes

I am implementing an offline map using MapBox in my app that currently uses mapkit with Apple Maps.

I have an object which describes a point of interest - name, description location etc with an interface as seen below:

#import <Foundation/Foundation.h>
#import <Mapkit/MapKit.h>
#import <MapBox/MapBox.h>

@class CLLocation;

@interface MHGPlace : NSObject <MKAnnotation>

@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

-(NSString *) title;
-(NSString *) subtitle;
-(NSString *) mapid;

@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *description;


@end

The above object gets added to an array and then to mapkit as follows:

[self.mapView addAnnotations:self.places];

However, when dealing with a MapBox mapview I cant add a MKAnnotation object like I do above as it requires an RMAnnotation Object. But when I change my interface to read- <RMAnnotation> instead of <MKAnnotation>, it doesnt seem to exist.

I cant find anything in there documentation about how to add an annotation like this. It would be good to try and do it like this so I can handle callbacks and know which annotation has been tapped etc!

2

2 Answers

1
votes

I'm the maintainer of the MapBox SDK. RMAnnotation is not a protocol, but rather a class. You can most certainly subclass RMAnnotation to add your mapid & other properties as needed. But you probably don't need this as you can also make use of -[RMAnnotation userInfo] and assign it an NSDictionary containing what you need to pass.

You can find more info on this in the official documentation: http://www.mapbox.com/mapbox-ios-sdk/api/#RMAnnotation-class

0
votes

Looking at the official forum, it appears that subclassing cannot be done with this current version so I cant create my own RMAnnotation object