MapBox:如何删除形状并绘制另一个形状?

时间:2014-04-23 20:28:18

标签: ios map mapbox

我为形状

创建了注释
    _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每次重绘都会更好。

谢谢你的帮助!

1 个答案:

答案 0 :(得分:1)

手动创建RMShape时,您需要告诉它移动的位置,并在使用-moveToCoordinate:-addLineToCoordinate:等方法创建后绘制。如果您只是有基本需求,我建议您尝试RMPolylineAnnotation,它会为您处理绘图。

相关问题