Skip to content

Instantly share code, notes, and snippets.

@wadey
Created December 21, 2010 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wadey/750728 to your computer and use it in GitHub Desktop.
Save wadey/750728 to your computer and use it in GitHub Desktop.
SimpleGeo JavaScript getLocation examples
client.getLocation({enableHighAccuracy: true}, function(err, position) {
if (err) {
// Could not retrieve location information. Check err for more information
} else {
// Latitude and longitude available in position.coords
}
});
client.getLocationFromIP(function(err, position) {
centerMap(err, position);
client.getLocationFromBrowser({enableHighAccuracy: true}, function(err, position) {
centerMap(err, position);
});
});
function centerMap(err, position) {
if (err) {
// Handle error
} else {
// center your map with position.coords
}
}
position = {
coords: {
latitude: 39.7437,
longitude: -104.9793,
accuracy: 100000
},
timestamp: [object Date],
source: "simplegeo"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment