【问题标题】:Google Map flickering in iOS谷歌地图在iOS中闪烁
【发布时间】:2015-08-28 09:32:38
【问题描述】:

我正在通过 pod 在我的应用中使用适用于 iOS 的 Google Maps SDK 版本:1.10.17867.0。但是当我在特定位置初始化地图时,所有标题和地图都开始闪烁。 示例代码(快速):

import UIKit
import GoogleMaps

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor.whiteColor();
    var camera = GMSCameraPosition.cameraWithLatitude(19.0176147, longitude: 72.8561644, zoom:18) 
    // even try this: 28.6469655, longitude: 77.0932634, zoom:10 
    var mapView = GMSMapView.mapWithFrame(CGRectZero, camera:camera)

    var marker = GMSMarker()
    marker.position = camera.target
    marker.snippet = "Hello World"
    marker.appearAnimation = kGMSMarkerAnimationPop
    marker.map = mapView

    self.view = mapView
  }
}

【问题讨论】:

  • 您的代码没有问题,您应该尝试不同的模拟器或设备。

标签: ios swift google-maps cocoapods google-maps-sdk-ios


【解决方案1】:

我已经找到原因了。

如果您使用了不正确的 google maps api 密钥,或者权限不足的正确密钥,则会发生这种情况。这是我们的后一个原因。

为了进一步阅读,documentation link,尽管在任何地方都没有提到上述行为。它应该记录一条错误消息。

【讨论】:

  • 很晚的评论。我遵循了来自 youtube 的教程,每次坐标更改时我的谷歌地图都会闪烁的原因是因为我在 didUpdateLocations 函数中使用了 view = googleMapView。您需要做的是制作一张静态地图,将其添加到视图中。然后您可以在地图内的didUpdateLocations 函数内使用标记和userLocation。就像你为 iOS 原生地图做的那样。
猜你喜欢
  • 2020-05-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多