ios - How to add clicked annotations on mapbox using offline mbtiles files -
i have managed use interactive offline mbtiles (created on tilemill) in order to:
- load more 1000 points fast
- make them understand when user clicking each point , show popup name of each point
but can't make bubble name clickable again.
i use following code generate layer annotation of each point
- (rmmaplayer *)mapview:(rmmapview *)mapview layerforannotation:(rmannotation *)annotation{ rmmarker *marker = [[rmmarker alloc] initwithmapboxmarkerimage:@"embassy"]; uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 50, 32)]; imageview.contentmode = uiviewcontentmodescaleaspectfit; imageview.image = annotation.userinfo; marker.leftcalloutaccessoryview = imageview; marker.canshowcallout = yes; return marker; } and how teaser , build annotation mbtiles file:
- (void)singletaponmap:(rmmapview *)mapview at:(cgpoint)point{ [mapview removeallannotations]; rmmbtilessource *source = (rmmbtilessource *)mapview.tilesource; if ([source conformstoprotocol:@protocol(rminteractivesource)] && [source supportsinteractivity]) { nsstring *formattedoutput = [source formattedoutputoftype:rminteractivesourceoutputtypeteaser forpoint:point inmapview:mapview]; if (formattedoutput && [formattedoutput length]) { // parse country name out of content // nsuinteger startofcountryname = [formattedoutput rangeofstring:@"<strong>"].location + [@"<strong>" length]; nsuinteger endofcountryname = [formattedoutput rangeofstring:@"</strong>"].location; nsstring *countryname = [formattedoutput substringwithrange:nsmakerange(startofcountryname, endofcountryname - startofcountryname)]; // parse flag image out of content // nsuinteger startofflagimage = [formattedoutput rangeofstring:@"base64,"].location + [@"base64," length]; nsuinteger endofflagimage = [formattedoutput rangeofstring:@"\" style"].location; uiimage *flagimage = [uiimage imagewithdata:[nsdata datafrombase64string:[formattedoutput substringwithrange:nsmakerange(startofflagimage, endofflagimage)]]]; rmannotation *annotation = [rmannotation annotationwithmapview:mapview coordinate:[mapview pixeltocoordinate:point] andtitle:countryname]; annotation.userinfo = flagimage; [mapview addannotation:annotation]; [mapview selectannotation:annotation animated:yes]; } } } updated figured out how using leftcalloutaccessoryview on marker (i added following @ end of layerforannotation method :
marker.leftcalloutaccessoryview = [uibutton buttonwithtype:uibuttontypedetaildisclosure]; and used following delegate method track event:
-(void)taponcalloutaccessorycontrol:(uicontrol *)control forannotation:(rmannotation *)annotation onmap:(rmmapview *)map{ nslog(@"i pass next screen ! yeah! %@",annotation.title); } the problem want rid off left calloutaccesoryview. suggestions?
none of have here map needed. want callout (which of type smcalloutview, dependent project mapbox sdk using) have clicks registered.
check out issue more details:
Comments
Post a Comment