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 proper lat and longs #337

Open
manzoorsofi opened this issue Oct 3, 2024 · 0 comments
Open

geloaction isnt giving proper lat and longs #337

manzoorsofi opened this issue Oct 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@manzoorsofi
Copy link

with this code
import Geolocation from '@react-native-community/geolocation';

/**

  • Utility function to fetch the current location (latitude and longitude).
  • @returns {Promise<{ latitude: number, longitude: number } | { error: string }>} - A promise that resolves to an object with latitude and longitude or an error message.
    */
    export const getCurrentLocation = async () => {
    return new Promise((resolve, reject) => {
    Geolocation.getCurrentPosition(
    (position) => {
    const { latitude, longitude } = position.coords;
    resolve({ latitude, longitude });
    },
    (error) => {
    console.error('Error fetching location:', error);
    reject({ error: 'Unable to fetch location' });
    },
    {
    enableHighAccuracy: true, // Set to true for better accuracy
    timeout: 15000,
    maximumAge: 10000,
    },
    );
    });
    };
@manzoorsofi manzoorsofi added the bug Something isn't working label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant