gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 12:47:38 24 4
gpt4 key购买 nike

我为形状创建了注释

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

在委托(delegate)中我写了

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

但是如何从 map 中删除所有形状并添加新形状。现在形形色色,这是不正确的。如果_lineBetweenTwoBeacon 每次都重绘会更好。

谢谢你的帮助!

最佳答案

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

关于ios - MapBox:如何删除一个形状并绘制另一个形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23254551/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com