Created
May 2, 2017 16:06
-
-
Save anonymous/604567d6c5f17bfe9696a07bd50c602e 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); | |
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