Created
July 31, 2013 03:17
-
-
Save rominirani/6119017 to your computer and use it in GitHub Desktop.
Episode #5 : Firefox OS Tutorial : app.js for HTML5 Geolocation calls
This file contains hidden or 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
$(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