ios - how to remove particular markers from GMS? -
i asked earlier how show different markerinfowindow in question, , i'm trying delete particular marker when user clicks on button on left corner.
first in .h file :
nsmutablearray *adsmarray; gmsmarker *adsmarker;
then created ads marker this:
(int l=0 ; l<self.ads.count; l++) { cllocationcoordinate2d pos = cllocationcoordinate2dmake([[[self.ads objectatindex:l] objectforkey:@"lati"] doublevalue],[[[self.ads objectatindex:l] objectforkey:@"longi"] doublevalue]); nslog(@"ads:: %f",[[[self.ads objectatindex:l] objectforkey:@"longi"] doublevalue]); adsmarker = [[gmsmarker alloc]init]; adsmarker.position=pos; //marker.infowindowanchor = cgpointmake(0.44f, 0.45f); adsmarker.draggable = no; adsmarker.appearanimation=yes; nsmutablearray*temparray = [[nsmutablearray alloc] init]; [temparray addobject:@"ads"]; [temparray addobject:[self.ads objectatindex:l]]; adsmarker.userdata = temparray; adsmarker.map = mapview_; adsmarker.icon=[gmsmarker markerimagewithcolor:[uicolor bluecolor]]; }
then in ibaction
remove them wrote:
for (int =0; i<self.ads.count; i++) { // adsmarker.map = nil; [adsmarker setmap:nil]; }
when add marker store reference it. when want remove it, set map property nil - remove map.
Comments
Post a Comment