export const getGeo = () => {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition((position) => {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
let API_KEY = 'AIzaSyCYYb9Zt3681daQpJ7fvsU-Tm-x_o9rKIkzc';
let url =
"https://maps.googleapis.com/maps/api/geocode/json?latlng=" +
latitude + "," + longitude +
"&key=" + API_KEY + "&language=en";
return url;
})
} else {
console.log("Geolocation is not supported by this browser.");
}
}
const API_KEY = 'AIzaSyCYYb9Zt3681daQpJ7fvsU-Tm-x_o9rKIkzc';
const API_URL = 'https://maps.googleapis.com/maps/api/geocode/json?';
function makeUrl({ coords }) {
return `${API_URL}latlng=${coords.latitude},${coords.longitude}&key=${API_KEY}&language=en`;
}
export const getGeo = () => {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(makeUrl);
} else {
console.log("Geolocation is not supported by this browser.");
}
}