[英]Phonegap geoLocation not working on Android
So i am trying to make geoLocation work on android. 所以我试图让geoLocation在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 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)
(当然是android)
How are you testing on an android device? 您如何在Android设备上进行测试? PhoneGap Desktop?
PhoneGap桌面? Or are you building your app (Adobe PhoneGap Build) and then testing on the device?
还是要构建您的应用程序(Adobe PhoneGap Build),然后在设备上进行测试?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.