【发布时间】:2015-05-13 07:27:35
【问题描述】:
我正在开发一个混合移动应用程序,并试图让 HTML5 Geolocation 在 iPhone IOS8 上运行,但没有运气。有谁知道任何已知的问题?我尝试了很多示例,但没有一个甚至提示用户允许地理定位。它在浏览器中运行良好,但是一旦上传到 PhoneGap Build 并安装在我的手机上,它就什么也做不了。
我尝试过的一些示例代码是:
<!DOCTYPE html>
<html>
<body>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
我会使用 PhoneGap 插件,但无法正常工作。
谢谢。
【问题讨论】:
-
您是否包含地理定位插件?
-
@jcesarmobile 是的,我相信我做对了。
我把它放在 config.xml 的顶部
标签: javascript html cordova permissions geolocation