W3C 对geolocation的解释是“defines an API that provides scripted access to geographical location information associated with the hosting device”。
目前html5已经提供了对geolocation的支持,至于哪些浏览器支持,可以看下面的连接:
http://html5demos.com/
如果你的浏览器不支持,也可以使用google gears的Geolocation API曲线救国来玩(关于这一点请参考JerryQu同学早一段时间写的文章)。
可以发现firefox在解释geolocatio时,也是使用的google的loc接口。
一个有帮助的帖子是:
http://www.ivershuo.com/2010/03/geolocation/
下面是无线本,通过wifi,浏览器使用Firefox获取当前位置坐标的例子:
<script type="text/javascript"><!-- var gl = null; function displayPosition(position) { //获取坐标点信息 alert(position.coords.latitude + "," + position.coords.longitude); } function displayError(positionError) { alert("sorry,can not find your position.") } try { if (typeof (navigator.geolocation) == 'undefined') { gl = google.gears.factory.create('beta.geolocation'); } else { gl = navigator.geolocation; } } catch (e) { } if (gl) { var position = gl.getCurrentPosition(displayPosition, displayError); } else { alert("I'm sorry, but geolocation services are not supported by your browser."); } // --> </script>