【问题标题】:Android not giving Geolocation ionic 4Android 不提供 Geolocation ionic 4
【发布时间】: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


    【解决方案1】:

    当应用程序部署到设备上时,华为设备将提供地理定位,使用 Cordova 或 Ionic 4 的电容器,但它不适用于 ionic serve --devapp。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-22
      • 1970-01-01
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      • 2019-09-05
      • 2016-12-12
      相关资源
      最近更新 更多