iosroute-me

RMPath flickers and "vibrates" while scrolling RMMapView (MapBox SDK)


I'm using the MapBox SDK with an offline map. I'm adding a RMPath overlay to the mapView and everything is shown ok.

problem no. 1: while scrolling the map the RMPath overlay is scrolled also, but sometimes it is drawn with an offset (a location where it was just a moment ago) for just a fraction of a second, after that it gets to it's normal place , and this creates a sensation of flickering. Why this happens and how can I get rid of it?

problem no. 2: while scrolling the map the RMMarker and RMPath overlay "vibrates", it's like the overlay tries to "catch up" with it's normal position when the map is scrolled. It's just a few pixels, but when zoomed it looks pretty bad. this happens most probably because the -draw() method is called only when the map is moved more than just a pixel. How can I make the overlays scroll smoother?

My searches resulted with absolutely nothing, so any help is welcomed.

p.s. tested on iPhone3GS and iPhone4S, same problems on both.


Solution

  • RMPath is deprecated, try using RMShape instead. Also do not forget to set the bounding box of your annotation before adding it to the map (setBoundingBoxFromLocations can be useful).

    Example :

    pathAnnotation = [[RMAnnotation alloc]initWithMapView:mapView    coordinate:CLLocationCoordinate2DMake(long,lat) andTitle:@"path"];
    [pathAnnotation setBoundingBoxFromLocations:pathLocations];
    

    and then in your layerForAnnotation() :

    RMShape *path = [[RMShape alloc] initWithView:mapView] ;
    [path setLineColor:[UIColor colorWithRed:0.2 green:0.7 blue:1 alpha:0.7]];
    [path setLineWidth:4];
    
    // Create real coordinates from data
    for(int idx = 0; idx < pathPoints.count; idx++)
    {
    
        CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(pathPoints[idx].latitude,pathPoints[idx].longitude);
    
        // First point
        if( idx == 0){
            [path moveToCoordinate:coord];
        }else{
            [path addLineToCoordinate:coord];
        }
    }
    return path;