i have following problem:
i have number of pins on map. after touching one, custom popup opens , displays information. works perfect.
my problem is, if select same pin twice, popups not open, have touch 1 or click in map.
my code following:
- (mkannotationview *) mapview:(mkmapview *)mapview viewforannotation:(id <mkannotation>) annotation{ mkannotationview* annotationview = nil; cppointofinterest *myannotation = (cppointofinterest*) annotation; if ([myannotation iskindofclass:[mkuserlocation class]] || myannotation.poi_id <= 0) { return nil; } else { nsstring* identifier = @"pin"; mkpinannotationview* annview = (mkpinannotationview*)[mv_map dequeuereusableannotationviewwithidentifier:identifier]; if(nil == annview) { annview = [[[mkpinannotationview alloc] initwithannotation:myannotation reuseidentifier:identifier] autorelease]; } [annview addobserver:self forkeypath:@"selected" options:nskeyvalueobservingoptionnew context:@"gmap_annotation_selected"]; if(self.nearest_poi == myannotation) { annview.pincolor = mkpinannotationcolorgreen; } else { annview.pincolor = mkpinannotationcolorred; } annview.animatesdrop = yes; annotationview = annview; [annotationview setenabled:yes]; [annotationview setcanshowcallout:no]; return annotationview; } }
observer:
- (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context{ nsstring *action = (nsstring*)context; if([action isequaltostring:@"gmap_annotation_selected"]){ bool annotationappeared = [[change valueforkey:@"new"] boolvalue]; if (annotationappeared) { // show popup } } }
i have tried didselectannotationview methode, works first click event.
i have searched several hours, nothing find... :/
does knows solution problem, please give me hint...
thanks , greetings, mathew
you have deselect annotation through mapview before can select again. try folowing:
-(void)mapview:(mkmapview *)mapview didselectannotationview:(mkannotationview *)view { [mapview deselectannotation:view.annotation animated:no]; }
Comments
Post a Comment