MapBox:如何去除一个形状并绘制另一个形状? [英] MapBox: How to remove a shape and draw another shape?
问题描述
我为形状创建了注释
I created annotation for shape
_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每次重绘都会更好。
But how to remove all shapes from the map and add new shape. Now the shape lay to the shape, it's not correct. Will be better if _lineBetweenTwoBeacon redraw every time.
谢谢你的帮助!
推荐答案
当您手动创建一个 RMShape
时,您需要告诉它在哪里移动,并使用 -moveToCoordinate:
和 -addLineToCoordinate:
。如果您只是有基本需求,我会建议您尝试 RMPolylineAnnotation
,它为您处理图形。
When you manually create an RMShape
, you need to tell it where to move and to draw after creating it with methods like -moveToCoordinate:
and -addLineToCoordinate:
. If you just have basic needs, I would recommend trying RMPolylineAnnotation
, which handles the drawing for you.
这篇关于MapBox:如何去除一个形状并绘制另一个形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!