导航地理位置getCurrentPosition不工作 [英] navigator geolocation getCurrentPosition not working
本文介绍了导航地理位置getCurrentPosition不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的html页面:
I have this html page:
<!DOCTYPE html>
<html>
<head>
<title>Geolocation test</title>
</head>
<body>
<script type="text/javascript">
navigator.geolocation.getCurrentPosition(function (position) {
alert(position.coords.latitude + ',' + position.coords.longitude);
}, function (error) {
alert(error.code);
}, {enableHighAccuracy: true, maximumAge: 0});
</script>
</body>
作品上:
- 三星Galaxy 3谷歌浏览器
- 三星Galaxy 3原生的网页浏览器
- Chrome的桌面。
犯规适用于:
- 三星Galaxy S2 Chrome浏览器
- 三星Galaxy S2本地
- 火狐桌面
从来就一直在阅读了很多关于这个问题的问题,但他们都表示,有时候位置不可用,或者可能需要很长的时间去找回它,但是当我打开Android地图应用程序,它显示了一个完美的位置立即(即使我不使用它一段时间)
I´ve been reading a lot of questions about this issue, but all of them says sometimes the position is unavailable or may be take a long time to retrieve it, but when I open the android maps app, it shows a perfect location immediately (even if I dont use it for a while)
我知道我可以使用超时选项来处理错误回调,但那不是一个解决方案给我。
I know I can use the timeout option to handle the error callback, but thats not a solution for me.
谢谢!
推荐答案
这可能是由于应用程序的权限问题。
It may be due to problems of application permissions
https://support.google.com/chrome/answer/142065? HL = EN
这篇关于导航地理位置getCurrentPosition不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文