Last active
December 11, 2015 18:19
-
-
Save kylehotchkiss/4640438 to your computer and use it in GitHub Desktop.
Easy coordinates-to-location-name via Google Maps API. You're welcome.
This file contains hidden or 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
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