MapBox: How to remove a shape and draw another shape?

♀尐吖头ヾ 提交于 2019-12-08 04:30:43

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/23254551/mapbox-how-to-remove-a-shape-and-draw-another-shape

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!