科尔多瓦地理定位不准确

cordova geolocation not accurate

我有一个 ionic 4 应用程序,它使用 cordova 和 google 地图 api。我正在使用 HTML5 geoloction 插件,它会在用户移动时监视设备的位置,然后生成一个新的 googleMaps 标记并将其显示在地图上。

this.watchLocation = await this.geolocation
  .watchPosition()
  .subscribe(location => { 
    this.map.animateCamera({
      target: {
        lat: location.coords.latitude,
        lng: location.coords.longitude
      },
      zoom: 16,
      duration: 1000
    });
this.marker.setPosition({
              lat: location.coords.latitude,
              lng: location.coords.longitude
            });

使用上面的代码,我已经在 Samsung note 9 上测试了该应用程序,结果 100% 准确。我还在其他 android 设备(Galaxy A20 和华为 Y5)上测试了相同的应用程序,但结果不准确,而是标记从我的位置跳出大约 50 到 200 米的位置。

银河注 9 结果:

尝试将 enableHighAccuracy 选项设置为 truedocs 描述如下:

The PositionOptions.enableHighAccuracy property is a Boolean that indicates the application would like to receive the best possible results. If true and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if false (the default value), the device can take the liberty to save resources by responding more quickly and/or using less power.

另请参阅相关线程