GeoLocation error
Unanswered
Naeemgg posted this in #help-forum
NaeemggOP
how can we get users lat and long?
this method is not working:
I'm getting error
this method is not working:
export function getGeolocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
position => {
const { latitude, longitude } = position.coords;
return { latitude, longitude };
},
error => console.error('Error getting geolocation:', error)
);
} else {
console.error('Geolocation is not supported by this browser.');
}
}I'm getting error
navigator not defined in both client & server components