哪些设备通过navigator.geolocation支持Javascript Geolocation?

Mac*_*iek 25 javascript gps mobile-phones geolocation mobile-website

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 */
  }
);
Run Code Online (Sandbox Code Playgroud)

我想建立一个包含以下其中一项的良好设备列表:

  1. 支持此功能开箱即用,或
  2. 通过升级支持此功能,或
  3. 使用其他一些Javascript片段支持具有等效数据保真度的地理定位.

我只熟悉自己的设备,所以到目前为止这是我的列表:

盒子外面:

  1. iPhone 3GS

支持,但仅限更新

  1. iPhone 3G
  2. iPhone 2G(?)
  3. 使用Firefox 3.5的PC或Mac电脑

支持其他一些代码段

Blackberry,Android手机等的支持程度如何?

小智 17

截至今天,W3C Geolocation API(与HTML 5广泛关联,但在技术上并非如此)在以下主要桌面浏览器中得到支持:

  • Firefox(自3.5起)
  • Safari(自5.0起)
  • 谷歌Chrome(版本取决于操作系统)
  • 歌剧(从10.60开始)
  • Internet Explorer(自IE 9起)

至少有两个移动浏览器实现了Geolocation API:

  • Safari Mobile(自iPhone OS 3.0起)
  • Android(至少从Android 1.6开始)

在所有这些平台上,您应该能够使用navigator.geolocation.getCurrentPosition等.


npd*_*oty 7

虽然我认为在W3C Geolocation API标准化(草案,顺便说一句)W3C Geolocation API是一个很好的做法,但值得注意的是浏览器中还有一些其他选项,如果您需要定位较旧的平台,这可能会特别有用.

  • Firefox 3.1支持Geode,它使用navigator.geolocation具有非常相似语法的调用.
  • Loki是由Skyhook构建的插件,可在Internet Explorer 6,Internet Explorer 7,Firefox 2,Firefox 3,Safari和Opera上运行.语法大不相同,但仍然很容易.
  • Google Gears提供的地理位置API的语法与W3C API语法非常相似.您可以在Internet Explorer 6 +,Firefox 1.5 +,Safari,Opera Mobile和IE Mobile上安装Google Gears.