在我的React Native应用程序中,我正在显示从用户当前位置到目的地的里程。我正在为此目的使用geodist。下面是我的部分代码:
componentDidMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
error: null,
});
},
(error) => this.setState({ error: error.message }),
{ enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
);
var geodist = require('geodist');
var sLat= this.state.latitude;
var sLong = this.state.longitude;
var dist = geodist({lat: sLat, lon: sLong}, {lat: item.LatL, lon: item.Long2}, 'mi')
我的android文件夹中的androidManifest文件中包含以下代码:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mobileapps.acrapplication">
<uses-permission android:name="android.Manifest.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
当我使用expo发布此应用程序时,在expo链接中,从用户当前位置到目的地的计算里程会直接显示在我的android手机上,但是当我在Google Play商店中发布此应用程序时,miles是错误的。我是否还需要在Google Play商店或代码中做任何事情,以便Google Play商店显示正确的里程。看来Google Play商店中的当前用户位置错误。以下是我正在使用的React本机版本:
React-native-cli: 2.0.1
react-native : 0.57.1
任何帮助将不胜感激,