【问题标题】:GMSMapView Initial drawing failsGMSMapView 初始绘制失败
【发布时间】:2014-04-23 18:19:12
【问题描述】:

我正在使用以下代码在自定义 UIView 中创建 GMSMapView 实例作为子视图

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:position.latitude
                                                        longitude:position.latitude
                                                             zoom:CAMZOOM];

if(camera)
{
    self.googleMapView =  [GMSMapView mapWithFrame:self.frame camera:camera];
    self.googleMapView.myLocationEnabled = YES;
    self.googleMapView.delegate=self;

}

我在这个视图中添加了多个 UIbutton 和 GMSMarker,它们是可见的,没有任何问题,但我经常得到如下的地图绘制(发生)

我有触发动画到当前位置的按钮(参考以下代码),地图绘制没有任何问题

[self.googleMapView animateToLocation:self.googleMapView.myLocation.coordinate];

已修复

在我删除视图动画(alpha 0.0 到 1.0,持续时间 1 秒)后,这个问题得到了解决。现在我的地图实例加载时闪烁,但我可以忍受。

【问题讨论】:

  • 请将您的解决方案移至自己的答案,谢谢。

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


【解决方案1】:

您的坐标为空,因此您看到的是蓝色海洋,值是纬度 = 0.0 和经度 =0.0。尝试通过分配一些已知值来手动设置坐标以查看它是否有效。最终,您需要学习如何使用代表来读取可用的坐标。

【讨论】:

  • 这解决了我的问题,因为我对我的位置进行了硬编码,但我需要显示用户的当前位置,该位置可以是国家/地区的不同位置。我正在使用以下代码。会不会影响性能? [self.googleMapView animateToLocation:self.googleMapView.myLocation.coordinate]; )
  • 您需要实现 CLLocationManagerDelegate 委托以确保您已准备好读取设备位置并实现 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *) 您将使用 self 的位置.googleMapView animateToLocation:self.googleMapView.myLocation.coordinate
  • 感谢您回答我的问题,我已经实现了 CLLocationManagerDelegate 并将有效坐标发送到 GMSMapView。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-25
  • 2012-11-17
  • 2017-12-10
  • 2018-09-17
  • 1970-01-01
  • 2018-10-13
  • 2014-03-13
相关资源
最近更新 更多