GMSMapView显示空白地图

F. *_*uti 3 google-maps ios swift

我将GMSMapView添加到我的屏幕中,但我只能看到我的位置图标和我添加的标记.为什么我看不到道路,建筑等?

这是我的代码:

let camera = GMSCameraPosition.cameraWithLatitude(latitude,
longitude: longitude, zoom: 11.5)
let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)

mapView.myLocationEnabled = true
mapView.settings.myLocationButton = true

self.view = mapView

var marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(location.latitude, location.longitude)
marker.title = location.name
marker.snippet = location.address
marker.map = mapView
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

iPr*_*abu 6

拥有空白地图的主要原因之一是密钥设置不正确

您是否正确设置了API密钥?

[GMSServices provideAPIKey:yourAPIKey];
Run Code Online (Sandbox Code Playgroud)

  • 啊,你说得对,我已经添加了 API 密钥,但我忘记更新我的包 ID。非常感谢。 (2认同)
  • 获取空白地图的另一个原因是您尚未在Google API控制台中启用API.以下是如何进入库选项卡 - >选择适用于iOS的Google Maps SDK - >单击"启用"按钮.希望这有助于那些在设置API密钥后仍然获得空白地图的人. (2认同)