哪些设备支持通过 navigator.geolocation 进行 Javascript 地理定位?
iPhone 通过以下调用支持移动 Safari 中的地理定位:
navigator.geolocation.getCurrentPosition(
function(pos){
var lat = pos.coords.latitude;
var long = pos.coords.longitude;
},
function(){
/* Handler if location could not be found */
}
);
我想建立一个具有以下功能之一的良好设备列表:
- 开箱即用支持此功能,或者
- 通过以下方式支持此功能:升级,或
- 使用其他一些 Javascript 片段支持具有同等数据保真度的地理定位。
我只熟悉我自己的设备,所以这是我到目前为止的列表:
开箱即用:
- iPhone 3GS
支持,但仅支持更新
- iPhone 3G
- iPhone 2G(?)
- 装有 Firefox 3.5 的 PC 或 Mac 计算机
支持其他一些设备片段
?
Blackberry、Android 手机等的支持级别如何?
The iPhone supports geolocation in mobile Safari via the following call:
navigator.geolocation.getCurrentPosition(
function(pos){
var lat = pos.coords.latitude;
var long = pos.coords.longitude;
},
function(){
/* Handler if location could not be found */
}
);
I'd like to build a good list of devices that have one of the following:
- support this feature out of the box, or
- support this feature with an upgrade, or
- support geolocation with equivalent fidelity of data with some other snippet of Javascript.
I'm only familiar with my own device, so this is my list so far:
Out of the box:
- iPhone 3GS
Supported, but only with an update
- iPhone 3G
- iPhone 2G (?)
- PC or Mac computer with Firefox 3.5
Supported with some other snippet
?
What is the level of support in Blackberry, Android phones, etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
截至今天,W3C 地理定位 API(与(尽管技术上不是 HTML 5 的一部分)以下主要桌面浏览器支持:
)至少有两个实现 Geolocation API 的移动浏览器:
在所有这些平台上,您应该能够使用 navigator.geolocation.getCurrentPosition 等。
As of today, the W3C Geolocation API (widely associated with, though not technically part of, HTML 5) is support in the following major desktop browsers:
There are at least two mobile browsers that implement the Geolocation API:
On all of these platforms, you should be able to use navigator.geolocation.getCurrentPosition, etc.
尽管我认为对(顺便说一下,草案)进行标准化是一个很好的做法 W3C Geolocation API,值得注意的是,浏览器中还有一些其他选项,如果您需要定位较旧的平台,这些选项会特别有用。
的调用navigator.geolocation
具有非常相似的语法。Although I think it's a great practice to standardize on the (draft, by the way) W3C Geolocation API, it's worth noting that there are a few other options in the browser, which can be particularly helpful if you need to target an older platform.
navigator.geolocation
with very similar syntax.来自最近的一个类似主题:
“我正在开发一个开源库,它支持所有符合 W3C 标准的支持 javascript 定位的手机。到目前为止,它支持 iPhone、Android、BlackBerry 和一些在浏览器中运行的边缘浏览器平台。该库也可以在为诺基亚 OVI 和 Palm WebOS 编写 Web 堆栈独立应用程序时使用
http 。 ://code.google.com/p/geo-location-javascript/”
From a similar more recent topic:
"I'm working on an open source library that supports all javascript location capable phones with the W3C standard. So far it supports iPhone, Android, BlackBerry and some fringe browser platforms running in a browser. The lib can also be used when writing web stack standalone apps for Nokia OVI and the Palm WebOS.
http://code.google.com/p/geo-location-javascript/"
W3C 版本适用于 android 2.*。在 android 1.6 上,您可以回退到齿轮,其工作方式几乎相同。理论上,W3C 标准也应该适用于 Firefox mobile (Fennec),该标准目前可用于诺基亚的 Maemo 设备,并将成为 MeeGo 的标准。
The W3C version works on android 2.*. On android 1.6 you can fallback to gears, which will work pretty much the same way. In theory the W3C standard should also work on Firefox mobile (Fennec), which currently is available for Nokia's Maemo devices and will be standard on MeeGo.
您不必拥有最新的手机即可使用 GPS 和地理定位 API。几乎每个移动浏览器(没有代理服务器)都可以用来从内置 GPS 读取位置。如果您的手机中有 Java 和 GPS – 您可以使用 mobile-gps-web-gate – 请参阅 http://code.google.com/p/mobile-gps-web-gate/
You don’t have to have the newest mobile phone to use GPS and Geolocation API. Almost every mobile browser (without proxy server) can be used to read position from buidin GPS. If You have Java and GPS in Your phone – You can use mobile-gps-web-gate – see at http://code.google.com/p/mobile-gps-web-gate/
我知道这是一个老问题,但您可以在这里找到支持地理定位的设备列表:http:// /www.quirksmode.org/webkit.html。该列表由网站作者维护,因此应该保持最新。
I know this is an old question, but you'll find a list of devices that support geolocation here: http://www.quirksmode.org/webkit.html. This list is being maintained by the site author so it should stay up to date.
Franson 的 GPSGate 是一款商业产品,可以将 Windows 计算机的硬件 GPS 暴露给任何人浏览器通过javascript。不过该接口与 W3C 的实现略有不同。
更新:Express(精简版)GPSGate 版本是免费的。
Franson's GPSGate is a commercial product that can expose a Windows machine's hardware GPS to any browser through javascript. The interface is a little different from the W3C's implementation though.
Update: the Express (lite) version of GPSGate is free.