【发布时间】:2016-07-05 15:48:04
【问题描述】:
我在 GMSMapView 中添加了 GMSPolygon,当我单击按钮更新多边形的纬度和经度时,它根本没有更新。我只能看到旧的多边形。
这是我从 NSArray 获取坐标并显示多边形的代码,它运行良好。
-(void)loadAreasInMap{
for(NSArray *polygon in [[vehicle model] area]){
self.path = [GMSMutablePath path];
for(int i = 0; i < [[polygon valueForKey:@"polygon_coordinates"] count]; i++){
[self.path addCoordinate:CLLocationCoordinate2DMake([[[[polygon valueForKey:@"polygon_coordinates"] objectAtIndex:i] objectAtIndex:1] floatValue],[[[[polygon valueForKey:@"polygon_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;
}
[self.mapView bringSubviewToFront:self.locationMarkerView];
CLLocation *userLocation = [[locManager sharedManager] userLocation];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:userLocation.coordinate.latitude
longitude:userLocation.coordinate.longitude
zoom:7];
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
}
现在,当我单击按钮时,我将调用此方法来更新我的坐标并重新绘制多边形,但我可以看到所有说明方法正常工作但地图未更新的日志。
-(void)buttonClicked{
[self.mapView clear];
[self.loadAreasInMap];
}
请告诉我如何更新地图
【问题讨论】:
标签: ios objective-c google-maps google-maps-api-3 google-maps-markers