MapBox: How to remove a shape and draw another sha

2019-05-30 05:31发布

I created annotation for shape

    _path = [RMAnnotation annotationWithMapView:_mapView
                                         coordinate: _userLocation.coordinate
                                           andTitle:@"Path"];
     [_mapView addAnnotation:_path];

in delegate I wrote

- (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;
    }
}

Next step I draw shape

[_lineBetweenTwoBeacon addQuadCurveToCoordinate:firstBeaconCoord controlCoordinate:secondBeaconCoord];

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.

Thank you, for help!

标签: ios map mapbox
1条回答
够拽才男人
2楼-- · 2019-05-30 06:21

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.

查看更多
登录 后发表回答