从启用 GPS 的设备获取当前纬度和经度 [英] get current latitude and longitude from gps enabled device

查看:27
本文介绍了从启用 GPS 的设备获取当前纬度和经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想直接通过网络浏览器从支持 GPS 的移动设备获取当前位置的纬度和经度.我可以知道这可能吗?怎么做?它需要地理定位api吗?一些编码示例会有所帮助.谢谢.

I would like to get the latitude and longitude of current location from gps enabled mobile device right from the web browser. May I know is this possible? how to do it? does it require geolocation api? Some coding example would be helpful. Thanks.

推荐答案

使用 HTML5 Geolocation API,这里是 官方规范和示例.

Use the HTML5 Geolocation API, here's the official spec and examples.

编辑

我已经更新了我的答案以包含当前的浏览器支持.

I've updated my answer to include current browser support.

W3C 地理定位 API 支持

Firefox 3.5+
Safari 5.0+
Chrome 5.0+
Opera
iPhone 3.0+
Android 2.0+

··
上面未列出的其他手机使用 Gears 或它们自己的特定于平台的 API.

· ·
Other phones not listed above use Gears or their own, platform-specific APIs.

啊,我们会不会只有一个 API?:)

Ahh, will we ever have just one single API? :)

非常感谢 Mark Pilgrim 的精彩帖子.

Many thanks to Mark Pilgrim for his awesome post.

这篇关于从启用 GPS 的设备获取当前纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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