gpt4 book ai didi

ios - 我无法在 MapBox Sdk 上绘制当前位置

转载 作者:行者123 更新时间:2023-11-28 21:51:43 26 4
gpt4 key购买 nike

我使用MapBox Sdk 实现离线和在线 map 。我尝试绘制一个蓝色半透明圆圈来显示我在 MapBox Sdk map 上的实际 GPS 位置,但它没有显示圆圈。找不到当前位置。提前致谢

- (void)viewDidLoad {

[super viewDidLoad];

RMMBTilesSource *offlineSource = [[RMMBTilesSource alloc] initWithTileSetResource:@"control-room-0.2.0" ofType:@"mbtiles"];

self.mapView = [[RMMapView alloc] initWithFrame:CGRectMake(0,70, 320, 500) andTilesource:offlineSource];
[self.mapView removeAllAnnotations];
self.mapView.delegate = nil;

self.mapView.userTrackingMode = NO;

[ self.mapView setDelegate:self];
[self.view addSubview: self.mapView];
self.mapView.showsUserLocation = YES;



// default zoom
self.mapView.zoom = 4;
// hard code minimal zoom. Try to run in without it to see what happens.
self.mapView.minZoom = 1;

self.mapView.maxZoom = 8;

self.mapView.tileSourcesMinZoom=5.0;
self.mapView.tileSourcesMaxZoom=16.0;

// hide MapBox logo
self.mapView.showLogoBug = NO;
// hide bottom right "i" icon
[self.mapView setHideAttribution:YES];

self.mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.mapView.adjustTilesForRetinaDisplay = YES; // these tiles aren't designed specifically for retina, so make them legible

[ self.mapView setUserTrackingMode:RMUserTrackingModeFollow animated:true];

}

最佳答案

你必须使用这个方法:

self.mapView.showsUserLocation = YES;

此外,如果您想更改该 RMAnnotaiton 的图标,您可以使用:

- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
RMMarker *marker;

if (annotation.isUserLocationAnnotation) {
marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"pin-con-halo.png"]];
}
return marker;
}

关于ios - 我无法在 MapBox Sdk 上绘制当前位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28081839/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com