我可以使用这个带电容的离子谷歌地图插件( https://github.com/mapsplugin/cordova-plugin-googlemaps-doc )吗?我试着
npm install cordova-plugin-googlemaps npm install @ionic native/googlemaps
但没有成功。如何用电容器安装?我怎样才能得到现在的位置?我使用的是Angular。
我需要使用它,因为本地地理位置不能与旧的Android版本一起工作。
发布于 2020-06-28 15:01:32
具体到电容,谷歌地图工作完美。
我建议你遵循这个tutorial。如果你不需要本机编码器,你可以在教程中忽略它。
上面的教程基于在index.html文件中包含javascript api,然后在代码中引用它。
与google javascript文档中提到的所有功能完美配合。
在离子电容器应用程序中实现google地图有两种方法。
Read this article to understand the difference
Another tutorial for implementing google maps
在需要访问映射的.ts文件中导入语句后,不要忘记将其放入其中。
声明变量google;
一旦你像教程中那样集成了它,对于Google geolocation,添加这个。
this.googleGeocoder = new google.maps.Geocoder();
this.googleGeocoder.geocode({'location': latlng},(results,status)=>{
if (status === 'OK') {
// do your stuff
}
})发布于 2020-06-28 13:43:44
您键入了错误的包名,它是@ionic-native/google-maps,而不是@ionic-native/googlemaps。此外,如果您使用的是@ionic-native/google-maps,则不需要安装其他软件包。
要进行安装,首先必须使用create Google Maps API keys.
然后,运行:
npm install @ionic-native/core@beta @ionic-native/google-maps@beta
ionic cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps --variable API_KEY_FOR_ANDROID="..." --variable API_KEY_FOR_IOS="..."将...%s替换为您的API密钥。
关于获取当前位置,您需要使用LocationService.getMyLocation()来获取当前位置。Here是文档和教程。
https://stackoverflow.com/questions/62617991
复制相似问题