Skip to content

Instantly share code, notes, and snippets.

@gregsramblings
Created August 17, 2012 01:48
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 gregsramblings/7e61bd48fd57a350a850 to your computer and use it in GitHub Desktop.
Save gregsramblings/7e61bd48fd57a350a850 to your computer and use it in GitHub Desktop.
function updateLocation() {
if (geolocation) {
geolocation.getCurrentPosition(function (position) {
$.getJSON(
"http://ws.geonames.org/findNearestAddressJSON?callback=?",
{
lat : position.coords.latitude,
lng : position.coords.longitude
},
function (data) {
$(function () {
$('#zip').text(data.address.postalcode);
});
}
);
});
}
}
$('#myButton').click(function(){updateLocation()});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment