gpt4 book ai didi

react-native - react native 应用程序 : Not authorized to use location services

转载 作者:行者123 更新时间:2023-12-04 13:19:20 32 4
gpt4 key购买 nike

我目前正在开展一个使用手机地理定位服务的项目。
我目前在使用此服务时遇到问题,它表示未授权地理定位。

我试过在互联网上查看,有几个人遇到了同样的问题,但我没有设法解决它...

  componentDidMount() {
const { coordinate } = this.state;

this.requestCameraPermission();

this.watchID = navigator.geolocation.watchPosition(
position => {
const { routeCoordinates, distanceTravelled } = this.state;
const { latitude, longitude } = position.coords;

const newCoordinate = {
latitude,
longitude
};
console.log({ newCoordinate });

coordinate.timing(newCoordinate).start();

this.setState({
latitude,
longitude,
routeCoordinates: routeCoordinates.concat([newCoordinate]),
distanceTravelled:
distanceTravelled + this.calcDistance(newCoordinate),
prevLatLng: newCoordinate
});
},
error => console.log(error),
{
enableHighAccuracy: true,
timeout: 20000,
maximumAge: 1000,
distanceFilter: 10
}
);
}


我没有出现在我当前的位置,而是在旧金山(这是 map 上的默认位置)。
函数 navigator.geolocation.watchPosition 得到错误:
"code": "E_LOCATION_UNAUTHORIZED",
"message": "未授权使用定位服务",
“watchId”:1,

我的手机是三星 S9 并且启用了定位服务...所以我真的很好奇我现在遇到的问题。

最佳答案

感谢您的回答,我设法解决了我的问题,显然由于某种原因,expo 不允许使用我的位置,所以我只是用以下命令强制它:

  Location.requestPermissionsAsync();

关于react-native - react native 应用程序 : Not authorized to use location services,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55833426/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com