我正在开发Iphone应用程序并使用谷歌地图。在谷歌地图上绘制多个多边形。但是删除地图上删除最后一个多边形的多边形并不是删除谷歌地图上的所有绘制多边形。请事先帮助感谢。
code..
// Draw Polygon
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
if (buttonClicked == true) {
NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude);
_latLongDict = @{@"lat":@(coordinate.latitude), @"long":@(coordinate.longitude)};
[_clickCoordinate addObject:_latLongDict];
NSLog(@"%@",_clickCoordinate);
_path = [GMSMutablePath path];
CLLocationCoordinate2D event;
for (NSDictionary *dic in _clickCoordinate) {
event.latitude = [[dic valueForKey:@"lat"] floatValue];
event.longitude = [[dic valueForKey:@"long"] floatValue];
[_path addCoordinate:event];
}
_polygun = [GMSPolygon polygonWithPath:_path];
_polygun.fillColor = [UIColor colorWithRed:0.25 green:0 blue:0 alpha:0.05];
_polygun.strokeColor = [UIColor blackColor];
_polygun.strokeWidth = 2;
_polygun.map = mapView;
}
// Delete Polygon
- (IBAction)cancelButton:(id)sender {
for (int i = 0; i < _path.count; i++) {
_polygun.map = nil;
[_clickCoordinate removeAllObjects];
[_path removeAllCoordinates];
NSLog(@"%@",_clickCoordinate);
}
}