Skip to content

Instantly share code, notes, and snippets.

@rominirani
Created July 31, 2013 03:17
Show Gist options
  • Save rominirani/6119017 to your computer and use it in GitHub Desktop.
Save rominirani/6119017 to your computer and use it in GitHub Desktop.
Episode #5 : Firefox OS Tutorial : app.js for HTML5 Geolocation calls
$(document).ready(function(){
$("#btnLocateMe").click(function(){
findMyCurrentLocation();
});
});
function findMyCurrentLocation(){
var geoService = navigator.geolocation;
if (geoService) {
navigator.geolocation.getCurrentPosition(showCurrentLocation,errorHandler);
} else {
$("#searchResults").html("Your Browser does not support GeoLocation.");
}
}
function showCurrentLocation(position){
$("#searchResults").html("Your location details --> Current Latitude : " + position.coords.latitude + " , Longitude : " + position.coords.longitude);
}
function errorHandler(error){
$("#searchResults").html("Error while retrieving current position. Error code: " + error.code + ",Message: " + error.message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment