离子Google Maps电容器 [英] Ionic Google Maps Capacitor

查看:132
本文介绍了离子Google Maps电容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将此带有电容器的Ionic Google Maps插件使用( https://github.com/mapsplugin/cordova-plugin-googlemaps-doc )?我尝试

Can I use this Ionic Google Maps plug-in with capacitor( https://github.com/mapsplugin/cordova-plugin-googlemaps-doc ) ? I Try

npm安装cordova-plugin-googlemaps npm install @ ionic-native/googlemaps

npm install cordova-plugin-googlemaps npm install @ionic-native/googlemaps

但是没有成功.如何与电容器一起安装?以及我如何获得当前职位?我正在使用Angular.

But without success. How I install it with capacitor ? And how I get the current position ? I'm using Angular.

我需要使用它,因为本地地理位置不适用于旧的Android版本.

I need use it because the native Geolocation does't work with old Android versions.

推荐答案

特定于电容器的Google地图可以完美运行.

Specific for Capacitor, google maps works perfectly.

我建议您遵循以下教程.如果不需要,可以忽略本教程中的nativegeocoder实现.

I would suggest you follow this tutorial. You can ignore the nativegeocoder implementation in the tutorial if you don't need it.

以上教程基于将javascript api包含在index.html文件中,然后在您的代码中引用它.

The above tutorial is based on including the javascript api in your index.html file and then referencing it in your code.

与google javascript文档中提到的所有功能完美配合.

Works perfectly with all the functionalities mentioned in the google javascript docs.

有两种方法可以在离子电容器应用中实现Google地图.

There are two ways of implementing google maps in an ionic capacitor app.

  1. 使用cordova插件(集成了Google Maps本机SDK)
  2. 使用Google Maps JavaScript API

阅读本文以了解区别

实现Google地图的另一教程

在将.ts文件中的语句导入到需要访问地图的地方之后,不要忘记将其放置在该位置.

Do not forget to put this after you import statements in your .ts file where you need to access the map.

声明var google;

declare var google;

像在本教程中一样完成对它的集成之后,对于Google地理位置,请添加它.

Once you have integrated it like it is done in the tutorial, for Google geolocation, add this..

this.googleGeocoder = new google.maps.Geocoder();
this.googleGeocoder.geocode({'location': latlng},(results,status)=>{
  if (status === 'OK') {
     // do your stuff
  }
})

这篇关于离子Google Maps电容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆