移动网络:GPS 关闭时请求用户位置
我正在构建一个包含地理位置的移动网络应用程序。在 Android 浏览器 (OS 2.0+) 上,如果用户关闭了 GPS,则不会显示来自我的网络应用程序的获取其位置的请求。如果他们的 GPS 已打开,则会显示位置权限请求。
我知道在 GPS 关闭时从浏览器请求用户位置是可能的,因为 Gowalla 的移动网络应用 能够触发的请求。我查看了他们的sprocket.js 文件,它看起来非常简单。你知道这里有什么秘密吗?
I'm building a mobile web app that incorporates GeoLocation. On the Android browser (OS 2.0+) if the user has GPS turned off, a request from my web app to get their location does NOT show up. If their GPS is turned on, then a location permission request does show up.
I know that requesting a user's location from the browser when GPS is off is possible as Gowalla's mobile web app is able to trigger the request. I looked through their sprocket.js file and it looks pretty straight forward. Any ideas what the secret is here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
他们只是尝试不同的框架(Google Gears、Blackberry 等),如果其中一个有效,他们就会使用它。
如果 GPS 被停用,您可以使用最后的位置(如果不是太旧),或者在最坏的情况下,您可以尝试使用 IP 和地理定位数据库,尽管结果根本不准确。
They just try different frameworks (Google Gears, Blackberry, and so on) and if one works they use it.
If GPS is deactivated you can either use the the last location (if it's not too old) or in the worst case you can try something with the IP and a geolocation-DB, although the results won't be accurate at all.
您可以在调用 Web 视图之前在 Java 中启动位置管理器。只要您的清单中具有精细位置访问权限,您就可以打开地理定位。
You could start a location manager in your java before you call the web view. As long as you have the have the fine location access in your manifest, you might be able to turn on geolocation.