我通过将用户的当前位置添加到数组来创建表示用户所做路径的数组。每次添加新点时,我都会删除以前的注释,然后添加一个新注释。然后使用RMShape
和layerForAnnotation
在mapView上绘制新路径。问题是,每次绘制RMSape
图层时,它都像幻灯片过渡一样。
我有两个问题:
-(void)mapView:(RMMapView *)mapView didUpdateUserLocation:(RMUserLocation *)userLocation
{
if (path) {
[self.mapView removeAnnotation:path];
}
path = [[RMShapeAnnotation alloc] initWithMapView:mapView points:points];
[mapView addAnnotation:path];
}
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation) {
return nil;
}
if ([annotation isKindOfClass:[RMShapeAnnotation class]]) {
for (int i = 0; i < points.count; i++) {
CLLocation *location = points[i];
[self.path addLineToCoordinate:location.coordinate];
}
return self.path;
}
return nil;
}
答案 0 :(得分:1)
我会直接更新您的注释图层,而不是不断更换注释,从而更换图层。您可以通过获取annotation.layer
,将其投放到RMShape
,然后使用-addLineToCoordinate:
等方法对其进行更新来实现此目的。