Ios 根据用户位置动态绘制RMShape

Ios 根据用户位置动态绘制RMShape,ios,mapbox,Ios,Mapbox,通过将用户的当前位置添加到数组中,我正在创建一个表示用户创建的路径的数组。每次添加新点时,我都会删除以前的注释,然后添加新注释。然后,在地图视图上使用RMShape和layerForAnnotation绘制新路径。问题是,每次绘制RMSape层时,它都像是幻灯片过渡 我有两个问题: 如何修复这种“滑动”效果,并平滑地绘制一条代表用户路径的连续线 有没有更好的方法来跟踪用户的路径 -(void)mapView:(RMMapView*)mapView didUpdateUserLocation:(

通过将用户的当前位置添加到数组中,我正在创建一个表示用户创建的路径的数组。每次添加新点时,我都会删除以前的注释,然后添加新注释。然后,在地图视图上使用
RMShape
layerForAnnotation
绘制新路径。问题是,每次绘制
RMSape
层时,它都像是幻灯片过渡

我有两个问题:

  • 如何修复这种“滑动”效果,并平滑地绘制一条代表用户路径的连续线
  • 有没有更好的方法来跟踪用户的路径
  • -(void)mapView:(RMMapView*)mapView didUpdateUserLocation:(RMUserLocation*)userLocation
    {
    如果(路径){
    [self.mapView removeAnnotation:path];
    }
    路径=[[RMShapeAnotation alloc]initWithMapView:mapView点:点];
    [地图视图添加注释:路径];
    }
    -(RMMapLayer*)地图视图:(RMMapView*)地图视图图层注释:(RMANotation*)注释
    {
    if(annotation.isUserLocationAnnotation){
    返回零;
    }
    if([annotation isKindOfClass:[RMShapeAnotation class]]{
    对于(int i=0;i
    我会直接更新注释层,而不是不断替换注释和注释层。您可以通过获取
    annotation.layer
    ,将其强制转换为
    RMShape
    ,然后使用
    -addLineToCoordinate:
    等方法来更新它

    也许它会帮助你!使用RMPolylineAnnotation绘制简单直线。当我画直线时,我删除了RMPolylineAnnotation,并添加了新的RMPolylineAnnotation和增加的cordite。
    -(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;
    }