Skip to content

Instantly share code, notes, and snippets.

@YutaWatanabe
Created August 31, 2014 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YutaWatanabe/18e2cec357475088be18 to your computer and use it in GitHub Desktop.
Save YutaWatanabe/18e2cec357475088be18 to your computer and use it in GitHub Desktop.
PhoneGap get geo code
var onSuccess = function(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
//エラーのコールバック
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
document.getElementById("eventButton")
.addEventListener("click", function(){
navigator.geolocation.getCurrentPosition(onSuccess, onError);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment