[英]Android not giving Geolocation ionic 4
我正在使用来自@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?
非常感谢:)
当使用cordova或capcitor for Ionic 4将应用程序部署到设备上时,华为设备将提供地理定位,但它不适用于ionic serve --devapp。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.