Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.