PhoneGap 手表位置不适用于 Android
我正在尝试使用 Android 计算手表位置,但它不起作用!
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady()
{
watchID = navigator.geolocation.watchPosition(onSuccess, onError,{enableHighAccuracy: true,frequency: 3000 });
}
// onSuccess Geolocation
//
function onSuccess(position)
{
alert("Successful!!");
}
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
I'm trying to work out the watch position with android but its not working!!
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady()
{
watchID = navigator.geolocation.watchPosition(onSuccess, onError,{enableHighAccuracy: true,frequency: 3000 });
}
// onSuccess Geolocation
//
function onSuccess(position)
{
alert("Successful!!");
}
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查phonegap.js 的路径。当我更改您的代码片段以匹配 asset/www 目录中的phonegap-1.1.0.js 时,成功了!为我弹出警报。
Check the path to phonegap.js. When I changed your snippet to match the phonegap-1.1.0.js in my assets/www directory, the Successful!! alert popped up for me.