地理位置无法在Windows 7/XP上的Safari 5.x上运行 [英] Geolocation not working on Safari 5.x on Windows 7/XP

查看:113
本文介绍了地理位置无法在Windows 7/XP上的Safari 5.x上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我创建了一个精简版本,并将其托管在Google Apps Engine上,因此您可以查看以下代码:

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.

这几乎是 Google上的示例的直接转换Map API DevGuide .有趣的是,Google托管的示例在Windows 7的Safari 5.0.x中也不起作用(但在与我的应用相同的所有其他平台上也能正常工作),例如

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.

通过一些调试(警报(我在这里"):-):似乎在Safari中,它确实执行了navigator.geolocation.getCurrentPosition(myCallback),但它似乎从未达到myCallback……好像从来没有达到过从getCurrentPosition返回.我还看到,如果整夜打开浏览器窗口,那么当我早上回到浏览器窗口时,就会出现警报和地图(尽管并非总是如此).我还尝试添加了一个errorCallback navigator.geolocation.getCurrentPosition(myCallback,errorCallback),但它也从不执行该操作,再次表明它从未从getCurrentPosition调用中返回.

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.

为什么会这样?

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

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?

推荐答案

尝试打开您的Wi-Fi.似乎Safari依靠wi-fi连接工作. 我遇到了完全相同的问题,打开了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

这篇关于地理位置无法在Windows 7/XP上的Safari 5.x上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆