使用HTML5的geolocation API
来源:互联网 发布:淘宝被虚假交易怎么办 编辑:程序博客网 时间:2024/05/03 02:00
转载:http://201211131343.iteye.com/blog/1814951
如何在网页中定位当前位置呢?
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <title>显示当前位置</title>
- <script src="code.js"></script>
- </head>
- <body>
- <div id="position">正在定位当前位置...</div>
- </body>
- </html>
- window.onload = getPosition; // 加载完页面后执行getPosition方法
- function getPosition() {
- if (navigator.geolocation) {
- // 如果geolocation不为null
- navigator.geolocation.getCurrentPosition(displayPosition); // 获取当前位置,传递Position参数给函数displayPosition
- } else {
- alert("Not supported");
- }
- }
- function displayPosition(position) {
- var latitude = position.coords.latitude;
- var longitude = position.coords.longitude;
- var accuracy = position.coords.accuracy;
- // 以下属性和设备和实现相关,可能为null
- var heading = position.coords.heading;
- var speed = position.coords.speed;
- var text = document.getElementById("position");
- text.innerHTML = "Latitude:" + latitude + ",Longitude:" + longitude
- + ",accuracy:" + accuracy + ",heading:" + heading + ",speed:"
- + speed;
- }
- 使用HTML5的geolocation API
- HTML5的Geolocation API
- HTML5 geolocation API的用法
- HTML5 的定位api geolocation
- HTML5之Geolocation API
- HTML5 Geolocation API
- 使用jQuery、Yahoo API和HTML5的geolocation来开发一个天气预报web应用
- 使用jQuery、Yahoo API和HTML5的geolocation来开发一个天气预报web应用
- HTML5地理位置定位 Geolocation API
- 【HTML5初探之Geolocation API】让我们获取女神的地址
- 基于IP地址的HTML5地理位置定位 Geolocation API实例
- html5 geolocation / 百度地图api Geolocation 定位当前城市信息
- html5 geolocation/ 百度地图api Geolocation 定位当前城市信息
- html5 geolocation / 百度地图api Geolocation 定位当前城市信息
- HTML5 - 使用Geolocation(地理定位)获取用户的位置
- Ionic2使用百度地图和html5 geolocation的一些注意事项
- HTML5 之Geolocation API (地理位置应用程序接口)
- HTML5中的地理定位API(Geolocation)
- 二叉树非递归讲解
- 【CXY】JAVA基础 之 StringBuffer
- 用GIF图片来告诉大家程序猿的真实生活
- proc_fs文件的操作
- 【CXY】JAVA基础 之 StringBuilder
- 使用HTML5的geolocation API
- LDD3读书笔记-----Linux 设备模型
- mysql读写性能测试
- 11个Visual Studio调试小技巧
- JAVA中去掉空格
- Oracle In和exists not in和not exists的比较
- 我所热衷的编程生涯 连载(5)
- c++的隐式转换和强制转换
- AS3游戏常用三角形各种定理公式