Skip to content

Instantly share code, notes, and snippets.

@paganotoni
Forked from wadey/get_location_1.js
Created May 12, 2011 21:32
Show Gist options
  • Save paganotoni/969499 to your computer and use it in GitHub Desktop.
Save paganotoni/969499 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