【发布时间】:2014-08-18 20:43:03
【问题描述】:
我之前问过如何显示不同的markerInfoWindow in this question, 现在我试图在用户点击左上角的按钮时删除一个特定的标记。
.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];
}
【问题讨论】:
-
查看我对同一问题的回答:stackoverflow.com/a/38952533/4915437
标签: ios objective-c google-maps-markers google-maps-sdk-ios gmsmapview