移动 GPS 网络应用程序
我需要开发一个网络应用程序。 (PHP) 100%针对手机,需要从手机GPS中获取信息,才能得到用户当前的位置。我的问题是,我该怎么办?
我了解 PHP,但我对 GPS 部分完全一无所知(以前从未使用过它们)。我所寻找的只是平视一下我是否可以处理这份工作或直接拒绝它。
我听说 W3 地理定位 API 做得非常好,但在测试之后我对其准确性和浏览器支持并不确定。我不想使用 Google 的 gears,因为必须先下载它。
I need to develop a web app. (PHP) 100% for mobile phones and need to get the information from the mobile phone GPS, in order to get the user's current position. My question is, what should I do?
I know PHP but I'm completely clueless about the GPS part (never worked with them before). All i'm looking is for headsup to see if I can handle the job or just reject it.
I've heard that the W3 geolocation API does a very good job but after testing it i'm not convinced about the accuracy and browser support. I don't want to use Google's gears due to the fact that it must be downloaded first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我确实认为 W3C Geolocation API 是一个很好的起点:它在手机上的接受度越来越高,是一个开放标准,并且抽象了所有特定于设备的 API。
确实,准确性可能并不完美,但那是因为手机本身可能并不总是完全知道它在哪里。 API 为您提供了几种解决此问题的方法:如果您需要高精度,您可以使用
enableHighAccuracy
标志向设备暗示您想要准确的结果,即使以功耗/时间为代价,设置较长的超时
参数以允许设备使用 GPS 查找位置。此外,所有位置都会以 95% 置信度的准确度值返回 - 如果错误太高(通常手机会在第一次请求时返回较高错误),您可以再次请求该位置,并指定您不想要该位置缓存的位置。I do think the W3C Geolocation API is a good place to start: it has growing acceptance on mobile phones, is an open standard and abstracts away all the device-specific APIs.
It's true that the accuracy may not be perfect, but that's because the phone itself may not always know perfectly where it is. The API gives you a couple ways to work around this: if you need high accuracy, you can hint to the device that you want an accurate result even at the cost of power/time with the
enableHighAccuracy
flag and set a longtimeout
parameter to allow the device to use GPS to find a location. Also, all positions are returned with an accuracy value for 95% confidence -- if the error is too high (often phones will return a high error on the first request), you can request the location again, specifying that you don't want a cached location.这取决于设备,但一些移动应用程序框架已经为您完成了所有工作,并且有扩展来执行此操作,请查看适用于 iPhone 的 jqTouch:
http://jqtouch.com/
更具体地说:
http:// /code.google.com/p/jqtouch/wiki/Extensions
It depends on the device but some mobile app frameworks have done all the work for you and have Extensions to do this, check out jqTouch for the iPhone:
http://jqtouch.com/
More specifically:
http://code.google.com/p/jqtouch/wiki/Extensions
GPS 坐标可通过 JavaScript 获得 - 在页面加载时放置类似这样的内容:
注释是您想要做一些聪明的事情的地方。您可以填充表单值,或者对后端脚本进行 ajax 调用。
将其与谷歌的一些反向地理编码链接起来,你就赢了!
GPS coords are available with javascript - place something like this on page load:
where the comment is where you want to do something clever. you might populate form values, or do an ajax call to a back end script.
Link that in with some reverse geo-coding from Google and you're onto a winner!!
根据移动设备的不同,您可能可以访问 GPS。然而,在广泛的移动设备中,您可能无法仅从设备的浏览器可靠地获取它。考虑到蜂窝网络的架构,读取 IP 是徒劳的。
这是可以做到的,但你需要建立退化水平。
Depending on the mobile device, you may have access to GPS. However, in the broad spectrum of mobile, you probably can not reliably get it from the device's browser alone. Reading the IP would be futile considering the architecture of cellular networks.
It can be done, but you would need to build in level of degradation.