I'm creating an array representing a path made by the user by adding the user's current location to an array. Each time a new point is being added, I remove the previous annotation, and add a new one. then the new path is being drawn on a mapView with RMShape and layerForAnnotation. The problem is that every time the RMSape layer is being drawn, it has like a slide transition.

I have 2 questions:

  1. How do I fix this "slide" effect, and draw a continuous line representing the user's path smoothly?
  2. Is there a better way for tracing user's path?

.

-(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;
}
有帮助吗?

解决方案

I would update your annotation layer directly as opposed to constantly replacing your annotation and thus its layer. You can do this by obtaining annotation.layer, casting it to RMShape, and then using methods like -addLineToCoordinate: to update it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top