如何删除地图框默认显示的用户位置图标
- (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation{
if (mapView.userTrackingMode == MGLUserTrackingModeFollow) {
return nil;
}
return Nil;
}
嗨,我已经实现了这段代码。
mapView.tintColor = [UIColor clearColor];
mapView.backgroundColor = [UIColor clearColor];
[mapView.attributionButton setTintColor:[UIColor clearColor]];
但仍显示...
最佳答案
Mapbox documentation
您已经配置了应用程序的位置权限,可以通过将地图视图上的showsUserLocation属性设置为NO来在地图上显示设备的当前位置
- (void)viewDidLoad {
[super viewDidLoad];
MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[mapView setCenterCoordinate:CLLocationCoordinate2DMake(40.74699, -73.98742)
zoomLevel:9
animated:NO];
[self.view addSubview:mapView];
mapView.styleURL = [MGLStyle satelliteStreetsStyleURL];
// Add a point annotation
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(40.77014, -73.97480);
annotation.title = @"Central Park";
annotation.subtitle = @"The best park in New York City!";
[mapView addAnnotation:annotation];
// Set the map view's delegate
mapView.delegate = self;
// Allow the map view to display the user's location
mapView.showsUserLocation = NO;
}
关于ios - 如何在iOS中删除Mapbox的蓝色和灰色注释,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52530082/