MapBox:如何删除一个形状并绘制另一个形状?
我为形状创build了注释
_path = [RMAnnotation annotationWithMapView:_mapView coordinate: _userLocation.coordinate andTitle:@"Path"]; [_mapView addAnnotation:_path];
在我写的代表中
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation { if ([annotation.title isEqualToString:@"Path"]) { _lineBetweenTwoBeacon = [[RMShape alloc] initWithView:mapView]; _lineBetweenTwoBeacon.lineColor = [UIColor redColor]; _lineBetweenTwoBeacon.lineWidth = 10.0f; return _lineBetweenTwoBeacon; } else { marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"userPin"]]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)]; imageView.contentMode = UIViewContentModeScaleAspectFit; marker.leftCalloutAccessoryView = imageView; return marker; } }
下一步我画形状
[_lineBetweenTwoBeacon addQuadCurveToCoordinate:firstBeaconCoord controlCoordinate:secondBeaconCoord];
但是,如何从地图中删除所有的形状,并添加新的形状。 现在这个形状已经形成了,这是不正确的。 如果_lineBetweenTwoBeacon每次都重绘会更好。
谢谢你的帮助!
当你手动创build一个RMShape
,你需要通过-moveToCoordinate:
和-addLineToCoordinate:
等方法来告诉它在哪里移动和绘制。 如果你只是有基本的需求,我会build议尝试RMPolylineAnnotation
,为您处理绘图。