接受请求时的地理位置反馈
我猜,地理定位的实现非常好,需要观察的步骤很少,但只是缺少一些东西。 我无法查看用户是否接受了请求(在我获取位置对象之前),我不知道用户是否只是忽略了我的请求(在超时期间)或者请求是否丢失了(并且失败回调没有得到)无故打电话)。
当用户接受请求时设置时间戳会很有用,我找不到任何可以给我这种响应的东西。
the geolocation implementation is quite good and got few steps to observe but only on thing is missing, i guess.
Im not able to see if the user accepted the request or not ( before i get the position object ), i dunno if the user just ignores my request ( during my timeout ) or if the request just get lost ( and the failure callback doesnt get called for no reason ).
It would be useful to set a timestamp when the user accepts the request, i couldnt find anything which gives me that kind of response.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据我对你所追求的新的理解,你想要这样的东西。
(测试:在 Opera 中 - 有效,Firefox 3.6 和 Chrome 8 - 不太好(我需要更多时间来调试))
场景:
页面尝试获取位置...但用户完全忽略提示,因此没有(接受或拒绝),并且由于从未发送位置请求,因此也没有超时!
基于此,您可能需要添加自己的逻辑来处理这种情况。为了这个例子,我将制作我自己的“包装器”方法的原型。 (对于挑剔的人 - 我不容忍使用全局变量等。我只是想让一些东西发挥作用)
这个概念是首先设置一个计时器(如果未设置,则默认为 30 秒)。如果用户在计时器到期之前没有执行任何操作,则会调用 timeoutCallback。
注意:
Based on my new understanding of what you are after, you want something like this.
(Tested: in Opera - works, Firefox 3.6 & Chrome 8 - not so much (I need more time to debug))
Scenario:
Page attempts to get location... but user ignores the prompt completely thus there is no (accept or deny) and since the request for the location is never sent, there is no timeout either!
Based on this you may want to add your own logic to handle this scenario. For the sake of this example, I'm going to prototype my own "wrapper" method. (for the picky - I'm not condoning using globals etc. I was just trying to get something to work)
The concept is to set up a timer first (defaults to 30 seconds if not set). If the user doesn't do anything before the timer expires, a timeoutCallback is called.
Notes:
它是 Geolocation API 的一部分:
如果您指定 errorCallback..然后您可以跟踪用户是否拒绝提供访问权限。
可能的错误代码包括:
It is part of the Geolocation API:
If you specify the errorCallback... then you can track if the user has declined to provide access.
Possible error codes include:
在 FF 3.5、Opera 10.6、Chrome8、IE6-8 中测试成功。
通过该解决方法,我们知道请求是否超时,即使之后调用成功/失败回调。
Tested it successful in FF 3.5, Opera 10.6, Chrome8, IE6-8..
With that workaround we know if the request timedout, even when the succeess / failure callback get called afterwards.