地理定位不适用于Windows 7 / XP上的Safari 5.x [英] Geolocation not workin on Safari 5.x on Windows 7/XP

查看:141
本文介绍了地理定位不适用于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不支持地理位置,所以这也包括在内。



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



这几乎是对示例的直接转换在 Google地图API DevGuide 上。有趣的是,Google托管的示例在Windows 7上的Safari 5.0.x中也不起作用(但它们可以在所有其他平台上正常工作,与我的应用程序相同),例如 http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation .html 显示与我的APP完全相同的问题,没有显示地图,网页只是保持灰色。



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



任何人都可以想法为什么发生这种情况?

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

解决方案

请尝试开启您的wi-fi。看来,Safari依靠Wi-Fi连接工作。
我遇到了完全相同的问题,打开了我的Wi-Fi连接并完美工作。



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

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.

Anybody any ideas 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???

解决方案

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天全站免登陆