【问题标题】:hide blue dot while retrieving google map current location in IOS在IOS中检索谷歌地图当前位置时隐藏蓝点
【发布时间】:2014-06-15 06:17:05
【问题描述】:

我正在尝试添加默认按钮以返回到谷歌地图中的当前位置。我使用

添加了按钮
self.mapView.myLocationButton = YES 

但无法隐藏 蓝点,这在我的情况下不需要。

如果我设置

self.mapView.myLocationEnabled = NO

它会删除按当前位置按钮返回当前位置的功能。

下面是我实现的代码

 - (void)viewDidLoad
 {
     [super viewDidLoad];
     // Do any additional setup after loading the view.

     self.mapView.delegate = self;

     self.mapView.settings.myLocationButton = YES;
     self.mapView.myLocationEnabled = YES;

 }

【问题讨论】:

    标签: ios google-maps-sdk-ios currentlocation gmsmapview


    【解决方案1】:

    您可以简单地添加注释视图:

    -(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
    {
        MKAnnotationView *note= [mapView viewForAnnotation:mapView.userLocation];
        note.hidden = YES;
    }
    

    这样,地图仍会接收用户的位置更新,但蓝点会被隐藏。请记住,由于这是一个委托方法,因此您应该正确设置委托。

    【讨论】:

    • 问题是关于 GMSMapView 而不是 MKMapView。
    【解决方案2】:
    1. self.mapView.myLocationEnabled = NO 隐藏蓝点。
    2. 设置一个类来实现CLLocationManagerDelegate来跟踪用户的位置。

    【讨论】:

      【解决方案3】:

      试试

          self. mapView.showsUserLocation=NO;
      

      【讨论】:

      【解决方案4】:

      更简单的方法是将注释替换为颜色为 clearColor 的视图。这样,我们当前的位置就会用一个不可见的注释来显示;-)

      【讨论】:

        【解决方案5】:

        只需使用 ma​​pView_.myLocationEnabled = NO;

        它解决了你的问题

        【讨论】:

          【解决方案6】:

          Swift 4x -

          mapView.delegate = self
          mapView.settings.myLocationButton = true
          mapView.isMyLocationEnabled = true
          

          【讨论】:

          • 设置mapView.isMyLocationEnabled = false
          猜你喜欢
          • 2013-12-10
          • 1970-01-01
          • 2013-08-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多