我之前问过如何在这个问题中显示不同的markerInfoWindow ,现在我试图在用户单击左角的按钮时删除特定的标记。
首先在 .h 文件中:
NSMutableArray *ADSMarray;
GMSMarker *adsMarker;
然后我创建了这样的广告标记:
for (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]];
}
然后在IBAction
删除它们时,我写道:
for (int i =0; i<self.ADS.count; i++) {
// adsMarker.map = nil;
[adsMarker setMap:nil];
}