-
-
Save zaycker/7db32cd4ab4267684982db00f741bcd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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); | |
const currentData = await new Promise(function(resolve, reject) { | |
geocoder.geocode( | |
{ latLng }, | |
(results, status) => { | |
if (status === google.maps.GeocoderStatus.OK) { | |
resolve(results.filter(item => item.types[0] === 'administrative_area_level_1')); | |
} else { | |
reject('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