Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geloaction isnt giving accurate lat and long from this lib. #344

Open
Devendra7409 opened this issue Dec 2, 2024 · 2 comments
Open

geloaction isnt giving accurate lat and long from this lib. #344

Devendra7409 opened this issue Dec 2, 2024 · 2 comments
Labels
question Further information is requested

Comments

@Devendra7409
Copy link

async ConfirmLocation(type) {
this.setState({
selectedImageBase4: '',
avatarSource: '',
remarksNote: '',
});
Geolocation.getCurrentPosition(
async (position) => {
const { latitude, longitude, accuracy } = position.coords;
this.setState({ newLatLong: position });
if (this.state.flag == '0') {
this.setState({ isLoading: true, latitude, longitude });
} else {
this.setState({ isLoading: true, CheckOutLat: latitude, CheckOutLong: longitude });
}

    if (this.state.flag == '0') {
      const val = await CommonFunctions.A1(latitude, longitude, '', 'ATTN', this.state.userId);
      this.setState({
        GetPreInChecksMobPolicyData: val,
        CheckInDeviation: val.DeviationMsg,
        CheckInAddress: JSON.stringify(val.Address).slice(1, -1).replace(/[']/g, "")
      });
    } else {
      const timeOutVal = await CommonFunctions.CheckOut(latitude, longitude, this.state.latitude, this.state.longitude, '', 'ATTN', this.state.userId);
      this.setState({
        GetPreInChecksMobPolicyData: timeOutVal,
        CheckOutDeviation: timeOutVal?.DeviationMsg,
        CheckOutAddress: JSON.stringify(timeOutVal?.Address).slice(1, -1).replace(/[']/g, "")
      });
    }

    if (type == 'timeinout') {
      this.setState({ timeinout: true });
    }

    this.setState({ isLoading: false, showAlert: true });
  },
  (error) => {
    console.log("Error getting location:", error);
    this.setState({ isLoading: false, showAlert: true, error: error.message });
  },
  { enableHighAccuracy: true, timeout: 200000, maximumAge: 1000, distanceFilter: 0, },
);

}

@Devendra7409 Devendra7409 added the question Further information is requested label Dec 2, 2024
@muhammadasifdotai
Copy link

same issue here.

@Devendra7409
Copy link
Author

Dear All,

I hope this email finds you well.

I am currently working with the @react-native-community/geolocation library in my project, which uses React Native version 0.68.0 and React version 17. The setup for the library works well in general, but I am encountering an issue where the latitude and longitude values fluctuate or are sometimes inaccurate, particularly on Android devices.

Despite the setup being correct, I am unable to consistently retrieve accurate coordinates, which affects the functionality of the app. Could you kindly suggest any solutions or best practices to resolve this issue and ensure more reliable geolocation accuracy?

Thank you for your help, and I look forward to your guidance.

Best regards,
Devendra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants