简体   繁体   English

如何使用MapBox iOS SDK跟踪用户的位置并显示行进路径

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

how to display path using RMShape? 如何使用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 https://github.com/tracyharton/mapbox-ios-sdk/commit/31cda12f5bcc04dad42db2e07558b95eb43604a7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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