【问题标题】:How to remove the Blue and gray annotions of mapbox in iOS如何在iOS中去除mapbox的蓝色和灰色注释
【发布时间】:2018-09-27 05:38:23
【问题描述】:

如何删除地图框默认显示的用户位置图标

 - (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation{
if (mapView.userTrackingMode == MGLUserTrackingModeFollow) {
    return  nil;
}
return Nil;
}

嗨,我已经实现了这段代码。我查看了didload试过这个

    mapView.tintColor = [UIColor clearColor];
mapView.backgroundColor  = [UIColor clearColor];
[mapView.attributionButton setTintColor:[UIColor clearColor]];

但仍然显示...

【问题讨论】:

  • 显示您尝试过的代码。
  • R u 使用谷歌地图,如果是,请使用此功能 yourMapView.myLocationEnabled = false
  • 我。更新了我的代码@Anbu.karthik
  • 我正在使用 mapbox @iOS
  • 试试这个 mapView.showsUserHeadingIndicator = false

标签: ios objective-c mapbox


【解决方案1】:

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;

}

【讨论】:

【解决方案2】:

如果您检查documentation,您会发现mapView.showsUserLocation = false 应该可以解决问题。

【讨论】:

  • 如果我这样做,那么我无法获得当前位置@Geru
  • @RKios - 那么你想尝试的,你想删除的,否则
  • 我只想获取没有那个蓝点的当前位置
  • @RKios - 然后像这样:禁用您的mapView.showsUserLocation = NO; 并使用核心定位框架获取用户位置。
  • 那么您应该仍然使用此选项并使用您自己的 CoreLocationManager 来接收位置。我个人不喜欢地图框位置管理器,因为您无法真正配置它。您不应该依赖 mapbox 中的用户位置。
猜你喜欢
  • 2020-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多