Created
December 21, 2010 22:27
-
-
Save wadey/750728 to your computer and use it in GitHub Desktop.
SimpleGeo JavaScript getLocation examples
This file contains 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
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 | |
} | |
}); |
This file contains 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
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 | |
} | |
} |
This file contains 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
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