【发布时间】:2019-12-18 21:25:21
【问题描述】:
我正在使用来自 @ionic-native/geolocation/ngx 的 Geolocation 来显示用户在进入查看传单地图时的位置,我的代码适用于我的浏览器和 IOS 手机(我运行 ionic serve --devapp)。
我从 Android 手机收到错误消息,它是“[object GeolocationPositionError]”,错误消息是“只允许安全来源(请参阅:goo.gl/Y0ZkNV)。”。有人可以帮我吗?
此外,应用程序会自动请求使用 GPS 的权限,我的应用程序中还没有请求权限的代码。
this.geolocation.getCurrentPosition().then((resp) => {
resp.coords.latitude;
resp.coords.longitude;
let marker = L.marker([resp.coords.latitude, resp.coords.longitude]).addTo(this.map)
.bindPopup('Your Location')
.openPopup();
this.map.setView([resp.coords.latitude, resp.coords.longitude], 15);
console.log(resp.coords.latitude+" "+ resp.coords.longitude);
}).catch((error) => {
console.log('Error getting location ', error);
});
我还需要做些什么才能使代码适用于 Android 吗?
非常感谢:)
【问题讨论】:
标签: javascript android typescript geolocation ionic4