ionic 3 获取当前位置无法在 android phone 上工作
ionic 3 get current location not working on android phone
我的 ionic 3 应用程序尝试使用来自“@ionic-native/geolocation/ngx”的地理定位来获取当前位置。
当我在 android phone 朗姆我的应用时,getLoc() 被调用但 getCurrentPosition() 方法没有被调用。
getLoc() {
alert('getLoc');
this.geolocation.getCurrentPosition().then((resp) => {
resp.coords.latitude
resp.coords.longitude
alert('inside then');
}).catch((error) => {
console.log('Error getting location', error);
alert('catch');
});
}
ionic 3 的正确导入是:
import { Geolocation } from '@ionic-native/geolocation';
尝试更改导入,如果不起作用,请降级地理定位插件版本。
我的 ionic 3 应用程序尝试使用来自“@ionic-native/geolocation/ngx”的地理定位来获取当前位置。
当我在 android phone 朗姆我的应用时,getLoc() 被调用但 getCurrentPosition() 方法没有被调用。
getLoc() {
alert('getLoc');
this.geolocation.getCurrentPosition().then((resp) => {
resp.coords.latitude
resp.coords.longitude
alert('inside then');
}).catch((error) => {
console.log('Error getting location', error);
alert('catch');
});
}
ionic 3 的正确导入是:
import { Geolocation } from '@ionic-native/geolocation';
尝试更改导入,如果不起作用,请降级地理定位插件版本。