Javascript 如何将熔断器位置API与电容器一起使用?-离子5

Javascript 如何将熔断器位置API与电容器一起使用?-离子5,javascript,angular,ionic-framework,capacitor,Javascript,Angular,Ionic Framework,Capacitor,我正在用电容器构建一个离子应用程序。目前,我正在运行一个需要使用GPS获取用户位置的用例 在挖掘了将近2个小时后,我发现融合的位置才是最好的选择 从官方文件中,我找不到关于如何调用FusedLocation在android上获取地理位置的相关信息。 下面是在浏览器上运行但在设备上失败的测试代码 import { Geolocation } from '@capacitor/core'; export class HomePage implements OnInit { latitude

我正在用电容器构建一个离子应用程序。目前,我正在运行一个需要使用GPS获取用户位置的用例

在挖掘了将近2个小时后,我发现融合的位置才是最好的选择

从官方文件中,我找不到关于如何调用FusedLocation在android上获取地理位置的相关信息。 下面是在浏览器上运行但在设备上失败的测试代码

import { Geolocation } from '@capacitor/core'; 
 
export class HomePage implements OnInit {

 latitude: number;
 longitude: number;

 constructor() {}

  async getCurrentPosition() {
    const coordinates = await Geolocation.getCurrentPosition();
    console.log('Current', coordinates);
  }

  watchPosition() {
    Geolocation.watchPosition({}, (position, err) => {
        this.latitude = position.coords.latitude;
        this.longitude = position.coords.longitude
        console.log(position);
    })
  }
}

如果在模板中看不到位置,则可能需要在NgZone内运行回调:

import { Component, NgZone } from '@angular/core';

// ...

constructor(
    private ngZone: NgZone,
) { }

watchPosition() {
    this.locationWatchId = Geolocation.watchPosition(this.geolocationOptions, (position, err) => {
        this.ngZone.run(() => {
            if (err) {
                console.error('Failed to watch position.', err);
            }

            this.latitude = position.coords.latitude;
            this.longitude = position.coords.longitude
            console.log(position);
        });
    });
}

由于第2版电容器使用熔断位置。请看:我知道电容器使用熔断的位置-但我如何实现这一点?因为我的android设备即使在GPS开启的情况下也无法检测到代码上方的位置。