Skip to content

Instantly share code, notes, and snippets.

Created May 2, 2017 16:06
Show Gist options
  • Save anonymous/604567d6c5f17bfe9696a07bd50c602e to your computer and use it in GitHub Desktop.
Save anonymous/604567d6c5f17bfe9696a07bd50c602e to your computer and use it in GitHub Desktop.
/**
* @param {Object} locations
* @param {Number} locations.lat
* @param {Number} locations.lon
*/
export default async function (locations) {
const lat = locations.lat;
const lng = locations.lng;
const geocoder = new google.maps.Geocoder();
const latLng = new google.maps.LatLng(lat, lng);
let currentData = [];
await geocoder.geocode(
{ latLng },
(results, status) => {
if (status === google.maps.GeocoderStatus.OK) {
currentData = results.filter(item => item.types[0] === 'administrative_area_level_1');
} else {
alert('No results found');
}
},
);
console.log(currentData);
// const currentCityName = currentData[0] ? currentData[0].formatted_address : '';
// console.log(currentCityName);
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment