我正在尝试查找位置方位/方向。
我尝试使用GoogleMap.getMyLocation()
返回bearing
作为undefined
this.map.getMyLocation({
enableHighAccuracy: true
}).then((loc:MyLocation)=>{
console.log(loc.bearing) //always undefined
})
即使LocationService.getMyLocation()
也会返回undefined
LocationService.getMyLocation(option).then((location: MyLocation) => {
console.log('location.bearing,',location.bearing);//undefined
});
我也尝试使用geolocation
,但是heading
返回null
this.watchsubscription = this.geolocation.watchPosition(
{
maximumAge: 0,
timeout: 1000,
enableHighAccuracy: true
}
).pipe(
filter((p) => p.coords !== undefined)//Filter Out Errors
)
.subscribe(position => {
console.log(position.coords.heading) // null
});
作为最后的选择,我尝试使用deviceOrientation
,它返回magneticHeading
和trueHeading
,但是magneticHeading
始终等于trueHeading
,它们是没有给出我在GoogleMap应用中看到的正确方位。
this.Orientationsubscription = this.deviceOrientation.watchHeading().subscribe(
(data: DeviceOrientationCompassHeading) =>{
console.log(data); //
});
如何在Android Ionic上获得方位/方位?