地理位置在 Windows 7/XP 上的 Safari 5.x 上不起作用

发布于 2024-09-18 19:03:15 字数 1454 浏览 3 评论 0原文

我正在开发一个使用 W3C 标准地理定位 API 的应用程序,但我一生都无法让它在我的 Windows 7 和 XP PC 上的 Safari 上运行。它在我的 iPad 和 iPhone 上运行良好。它还可以在 Chrome(5、6、7 和 Canary 版本)和 Firefox (3.6) 上完美运行。我没有 Mac,所以无法对其进行测试。 IE 尚不支持地理定位,因此也涵盖了这一点。

我创建了一个精简版本,并将其托管在 Google Apps Engine 上,以便您可以查看代码:http://html5-geolocator.appspot.com/。所有(简化的)javascript 都在 html 中,因此您应该能够右键单击并调试/查看源代码。

这几乎是 Google Map API DevGuide 上的示例的直接转换。有趣的是,Google 托管的示例在 Windows 7 上的 Safari 5.0.x 中也无法运行(但它们在所有其他平台上运行良好,与我的应用程序相同),例如 http://code.google.com/apis/maps/documentation/javascript/examples/map- geolocation.html 表现出与我的应用程序完全相同的问题,没有地图出现,网页只是保持灰色。

通过一些调试(alert(“我在这里”):-),似乎在Safari中,它确实执行navigator.geolocation.getCurrentPosition(myCallback),但它似乎永远不会到达myCallback......就好像它永远不会从getCurrentPosition返回一样。我还发现,如果我让浏览器窗口打开过夜,当我早上返回时,警报和地图就会出现(尽管并非总是如此)。我还尝试添加 errorCallback navigator.geolocation.getCurrentPosition(myCallback, errorCallback) 但它也永远不会执行该操作,再次表明它永远不会从 getCurrentPosition 调用返回。

为什么会出现这种情况?

编辑: 只是做了一些更多的测试,我添加了超时选项 (navigator.geolocation.getCurrentPosition(myCallback, errorCallback, {timeout: 5000});) ,实际上它总是超时,无论我将其设置多高,所以它永远不会从 Google 地理定位服务中返回,但为什么呢?

I am working on an app that uses the W3C standard geolocation API but I cannot for the life of me get it to work on Safari on my Windows 7 and XP PC. It works fine on my iPad and my iPhone. It also works perfect on Chrome (5, 6, 7 and the Canary build) and on Firefox (3.6). I don't have a Mac so I can't test it on that. IE doesn't support geolocation yet so that's covered too.

I created a stripped down version and I am hosting it on the Google Apps Engine so you can have a look at the code: http://html5-geolocator.appspot.com/ . All the (simplified) javascript is in the html so you should be able to right-click and debug/view source.

It is pretty much a straight conversion of the examples on the Google Map API DevGuide. Interestingly enough, the examples that Google is hosting are also NOT WORKING in Safari 5.0.x on Windows 7 (but they work fine on all those other platforms, same as my app), for example http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html exhibits exactly the same issue as my APP, no map appears, the webpage just stays grey.

Through some debugging (alert("I am here") :-) it seems that in Safari, it does execute navigator.geolocation.getCurrentPosition(myCallback), but it never seems to reach myCallback ... as if it never returns from getCurrentPosition. I have also seen that if I leave the browser window open overnight, when I get back to it in the morning the alert and map have appeared (though not always). I also tried added a errorCallback navigator.geolocation.getCurrentPosition(myCallback, errorCallback) but it also never executes that, again suggesting it never returns from the getCurrentPosition call.

Why this happens?

EDIT:
Just did some more testing, I added the timeout option (navigator.geolocation.getCurrentPosition(myCallback, errorCallback, {timeout: 5000});) , and indeed it it timing out all the time, no matter how high I set it so it is never returning from the Google geolocation service, but why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万水千山粽是情ミ 2024-09-25 19:03:26

尝试打开你的无线网络。 Safari 似乎依赖 wi-fi 连接来工作。
我遇到了完全相同的问题,打开我的无线网络连接,它工作得很好。

我现在正在研究如何检测这个问题 - 如果找到解决方案,我会更新

Try turning on your wi-fi. It appears that Safari relies on the wi-fi connection to work.
I was having exactly the same issues, turned my wi-fi connection on and it work perfectly.

I'm now looking at how to detect this - will update if I find a solution

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文