So i am trying to make geoLocation work on android. I have used the code below and i have to say that in the browser it works perfectly, however when i run this on a device it doesn't work. This is my code :
Index.html
<p id="lat">Stad :</p>
<p id="lng">Straat :</p>
<script>
window.onload = function(){
document.addEventListener("deviceready", init, false);
}
function init(){
navigator.geolocation.getCurrentPosition(positionSucces, positionError);
}
function positionSucces(position){
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
document.getElementById("lat").innerHTML = latitude;
document.getElementById("lng").innerHTML = longitude;
}
function positionError(error){
alert(error.message);
}
</script>
Does somebody have hints on how to make this work for mobile devices? (certainly android)
How are you testing on an android device? PhoneGap Desktop? Or are you building your app (Adobe PhoneGap Build) and then testing on the device?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.