Ionic3中的Ionic Native Google Maps只显示Google标志而不是地图(显示灰色空白地图)

6

更新

感谢wf9a5m75的回答。我对API密钥有一个概念上的误解。Android和IOS API密钥是从Google Cloud Platform控制台(https://cloud.google.com/maps-platform/)生成的。我一直在使用https://console.developers.google.com/,这是为Google Maps Javascript设计的,所以当我在Web应用程序上测试API密钥时它可以工作,但是对于移动设备却不行。

对于任何遵循Ionic native google maps指南的人,请使用https://cloud.google.com/maps-platform来生成您的密钥

enter image description here

原问题:

enter image description here

Ionic native google maps无法正确显示地图。 我遵循了Ionic native google maps指南。 我已经使用以下命令安装了最新的ionic native google maps:

npm install @ionic-native/google-maps

通过添加API密钥进行

ionic cordova plugin add cordova-plugin-googlemaps \
  --variable API_KEY_FOR_ANDROID="..." \
  --variable API_KEY_FOR_IOS="..."

启用了Android和IOS的地图SDK。

我使用了ionic cordova run ios -l -c --target="iPhone-7"进行测试。

花费了几个小时删除所有包和平台并重新添加,但没有结果。

我在网上搜索发现可能是API KEY不正确导致此问题,但我已经在一个可以正常显示地图的Web应用程序中尝试了相同的密钥。

有人可以帮忙吗?谢谢!

1个回答

4

嗨wf9a5m75,谢谢你的回复。我已经尝试了同样的API密钥用于Web应用程序和移动应用程序,它可以在Web应用程序中使用。 - Haifeng Zhang
3
cordova-plugin-googlemaps 不使用 Google Maps JavaScript v3。你需要为 Android 和 iOS 应用程序生成 API 密钥。 - wf9a5m75
非常感谢!我犯了一个错误! - Haifeng Zhang
刚刚注意到您是ionic native google maps的作者。您能否更新页面https://github.com/ionic-team/ionic-native-google-maps/blob/master/documents/api_key/generate_api_key.md? - Haifeng Zhang
2
更新了!同时我正在创建故障排除页面。https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/tree/master/troubleshootings - wf9a5m75

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接