简体   繁体   中英

How to track a user's location and display the path travelled using MapBox iOS sdk

how to display path using RMShape?

I want to do live tracker and drawing travel line.

- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(KRRMAnnotation *)annotation
{
    if (annotation.isUserLocationAnnotation)
        return nil;

    KRCalloutView *calloutView = [[[UINib nibWithNibName:@"KRRMCalloutView" bundle:nil] instantiateWithOwner:self options:nil] lastObject];
    calloutView.maxTitleLabelWidth = 250.0f;
    [calloutView setTitle:annotation.placeModel.title withAttributes:[KRStyleUtilities mapViewCalloutTextAttributes]];

    KRRMMarker *marker = [[KRRMMarker alloc]initWithUIImage:annotation.placeModel.pinImage andContentView:calloutView inMapView:mapView];
    marker.delegate = self.markerDelegateHandler;
    marker.cornerRadius = 10.0f;
    marker.correctCalloutPositionEnabled = YES;
    marker.canShowCallout = NO;

    return marker;
}

You can either remove and re-add the annotation, forcing an annotation layer redraw, or you can look into this patch which will allow you to call for a layer redraw:

https://github.com/tracyharton/mapbox-ios-sdk/commit/31cda12f5bcc04dad42db2e07558b95eb43604a7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM