Skip to content

Instantly share code, notes, and snippets.

@kylehotchkiss
Last active December 11, 2015 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylehotchkiss/4640438 to your computer and use it in GitHub Desktop.
Save kylehotchkiss/4640438 to your computer and use it in GitHub Desktop.
Easy coordinates-to-location-name via Google Maps API. You're welcome.
jQuery.getJSON("http://maps.googleapis.com/maps/api/geocode/json?address=" + latitude + ',' + longitude + "&sensor=true", function( data ) {
var components = data.results[0].address_components;
for ( level in components ) {
if (components[level].types[0] === "locality" || components[level].types[0] === "administrative_area_level_2" || components[level].types[0] === "administrative_area_level_1" ) {
locale = components[level].short_name;
break;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment