Created
August 31, 2014 10:31
-
-
Save YutaWatanabe/18e2cec357475088be18 to your computer and use it in GitHub Desktop.
PhoneGap get geo code
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
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