Skip to content

Instantly share code, notes, and snippets.

@wbamberg
Created April 19, 2013 20:34
Show Gist options
  • Save wbamberg/5423045 to your computer and use it in GitHub Desktop.
Save wbamberg/5423045 to your computer and use it in GitHub Desktop.
manifest:
{
"name": "Where am I?",
"description": "A simple web app",
"launch_path": "/index.html",
"icons": {
"128": "/style/icons/earth.png"
},
"permissions": {
"geolocation": {
"description": "something important?"
}
}
}
code:
var whereami = document.getElementById('where-am-i');
var whereiam = document.getElementById('where-i-am');
whereami.onclick = function() {
navigator.geolocation.getCurrentPosition(success, error);
};
function success(position) {
whereiam.innerHTML = position.coords.latitude + ", " + position.coords.longitude;
}
function error(error) {
console.log(error.code + " : " + error.message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment