Geolocation.getCurrentPosition返回错误的坐标(0; 0)

iamr0man

我尝试获取用户位置(权限步骤没有问题),但是Google用他的程序包react-native-geolocation-service和方法getCurrentPosition返回此方法:

{"coords": {"accuracy": 3, "altitude": 0, "heading": 0, "latitude": 0, "longitude": 0, "speed": 0}, "mocked": false, "timestamp": 1580744874000}

我使用代码(来自官方文档的示例)。

在信中:

Geolocation.getCurrentPosition(
        (position) => {
          this.setState({ location: position, loading: false });
          console.log(position);
        },
        (error) => {
          this.setState({ location: error, loading: false });
          console.log(error);
        },
        { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 添加到AndroidManifest.xml

巴赫

您可能已经成功获得了位置许可,但是您确定设备已启用位置信息吗?

您可以使用此库来要求用户启用其GPS:https : //github.com/Richou/react-native-android-location-enabler

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

geolocation.getCurrentPosition问题

Chrome navigator.geolocation.getCurrentPosition()错误403

Google Map Geolocation错误

Cordova navigator.geolocation.getCurrentPosition中的错误(代码:2)

Android Google Geolocation API返回403错误

navigator.geolocation.getCurrentPosition无法正常工作

如何强制 navigator.geolocation.getCurrentPosition 失败

CLLocationManager有时会返回(0,0)坐标

nativescript-geolocation 插件错误

无法在React中返回带有Geolocation坐标的JSX

strtol()错误地返回0

EnumProcessModules返回0,错误299

navigator.geolocation.getCurrentPosition()永远不会在Android的WebView中返回

无法从react-native中的navigation.geolocation.getCurrentPosition()返回位置

在Android Webview的navigator.geolocation.getCurrentPosition()中获取“位置信息不可用”错误

反应本机 GeoLocation 空引用错误

Navigator.geoLocation.getCurrentPosition无法正常工作的问题

navigator.geolocation.getCurrentPosition()未从googleapi获得响应

navigator.geolocation.getCurrentPosition在React Native中不起作用

navigator.geolocation.getCurrentPosition 不适用于 onClick

带有logscale的直方图的Gnuplot错误(标签的坐标为0)

Tkinter错误的#坐标:预期0或4,得到5

使用request.getRemoteAddr()返回0:0:0:0:0:0:0:0:1

Tkinter:在画布底部设置0、0坐标

Jcanvas坐标不是从(0,0)开始

如何从(0,0)坐标移动面板

为什么在 navigator.geolocation.getCurrentPosition() 为对象赋值并返回后,我无法访问对象中的值?

%〜dp0返回错误的路径

SecKeyEncrypt返回错误-50和0 cipherSize