【问题标题】:Doesn't Show Current location on google map?不在谷歌地图上显示当前位置?
【发布时间】:2015-08-14 13:56:41
【问题描述】:

我使用的是 google map sdk 版本 1.9.1。

我想显示当前位置的地图。

这是我的代码。

@interface ViewController ()
 {
    GMSMapView *mapView_;
 }

- (void)viewDidLoad {
[super viewDidLoad];
mapView_ = [GMSMapView mapWithFrame:CGRectMake(0.0f, 100.0f, 320.0f, 300.0f) camera:nil];
mapView_.myLocationEnabled = YES;
[self.view addSubview: mapView_];
}

但我无法显示当前位置。 感谢您的帮助。

【问题讨论】:

  • 确保您的应用访问设备的位置:stackoverflow.com/questions/24062509/…。尝试设置 _yourMapView.settings.myLocationButton = YES 并点击此按钮?
  • 我得到了位置,但它给了我错误的位置。它返回“旧金山”的位置@phuongle
  • 让我们尝试其他解决方案,通过 CLLocationManager:didUpdateLocations 方法监听 Apple 位置。然后调用 [_mapView animateToLocation:CLLocationCoordinate2DMake(CLLocationDegrees latitude, CLLocationDegrees longitude)] 更新谷歌地图中的当前位置。
  • 在 DidUpdate 位置我更新 ios 8.3 @phuongle 时位置错误

标签: ios google-maps-sdk-ios


【解决方案1】:

您必须在

中设置您的位置

调试>位置>自定义定位

喜欢

如果您可以在设备中进行测试,请在设置屏幕中启用您的位置

【讨论】:

    【解决方案2】:
    1. 首先,您的应用必须在 ios8 中请求访问用户位置的权限。请参阅此帖子:Location Services not working in iOS 8 或此帖子:iOS: App is not asking user's permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time - Objective-c & Swift

    2. 之后调用位置管理器的 [locationManager startUpdatingLocation] 方法。

    然后您将看到您当前更新的位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-29
      • 1970-01-01
      • 1970-01-01
      • 2020-02-29
      • 2015-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多