问题
I have add Polygons in google map using below codes
for(int i = 0; i < [[polygon valueForKey:@"coordinates"] count]; i++){
[self.path addCoordinate:CLLocationCoordinate2DMake([[[[polygon valueForKey:@"coordinates"] objectAtIndex:i] objectAtIndex:1] floatValue],[[[[polygon valueForKey:@"coordinates"] objectAtIndex:i] objectAtIndex:0] floatValue])];
}
GMSPolygon *rectangle = [GMSPolygon polygonWithPath:self.path];
rectangle.fillColor = [UIColor colorWithRed:255.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.4];
rectangle.map = self.mapView;
rectangle.strokeColor=[UIColor redColor];
[self.restrictedLocations addObject:rectangle];
CLLocation *userLocation = [[mymanager sharedManager] userLocation];
[self.mapView bringSubviewToFront:self.locationMarkerView];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:userLocation.coordinate.latitude
longitude:userLocation.coordinate.longitude
zoom:7];
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
I can see polygon in my map and i added following code to remove Polygon from map .
[self.mapView clear];
and this is not working, i can still see polygon in google map .
Please help me
UPDATE
My GSMMapView is not programmatically created , actually added one UIView and changed its class to GSMMApView. is that the issue ?
When i added log and run this adding polygon method, So i got following values
First time i can see polygons on map and that time my log
NSLog(@"%@",[mapView description]);
shows like this
<GMSMapView: 0x1610eb760; frame = (0 0; 320 504); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x16127e4f0>; layer = <GMSMapLayer: 0x1610ebc10>>
Then i tried to run [mapView clear]
and its not working so i got log for that also
second time my log
NSLog(@"%@",[mapView description]);
shows like this
<GMSMapView: 0x15ff9c550; frame = (0 0; 0 0); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x162340e30>; layer = <GMSMapLayer: 0x15ffca4b0>>
来源:https://stackoverflow.com/questions/36114766/gmsmapview-clear-method-is-not-removing-gmspolygon-ios