react-native-geolocation icon indicating copy to clipboard operation
react-native-geolocation copied to clipboard

geloaction isnt giving proper lat and longs

Open manzoorsofi opened this issue 1 year ago • 0 comments
trafficstars

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 avatar Oct 03 '24 16:10 manzoorsofi