#学习笔记#(54)geolocation
来源:互联网 发布:java编程试题及答案 编辑:程序博客网 时间:2024/05/29 13:22
测试代码,浏览器基本禁用了这个功能,只有IE支持。。。
实现效果如图:
<!DOCTYPE html><html><head> <title>H5地理位置Demo</title> <meta charset="utf-8"/> <script src="http://api.map.baidu.com/api?v=1.3" type="text/javascript"></script></head><body><div id="btnFindMe"> <button id="findMe">找到我</button></div><div id="myLocation"></div><script> function init(){ var btnFindMe=document.getElementById('findMe'); btnFindMe.addEventListener('click',findMe,false); } function geoSuccess(position){ var dateDisplay=new Date(position.timeStamp); var myLocationDiv=document.getElementById('myLocation'); myLocationDiv.innerHTML='纬度:'+position.coords.latitude+'经度:'+position.coords.longitude; console.log(position); } function findMe(){ var myLocationDiv=document.getElementById('myLocation'); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(geoSuccess); myLocationDiv.innerHTML='正在载入...'; } else { myLocationDiv.innerHTML='浏览器不支持定位'; } } window.addEventListener('load',init,false);</script></body></html>
0 0
- #学习笔记#(54)geolocation
- ES学习笔记九-地理位置(geolocation)
- Geolocation
- geolocation
- react native学习笔记21——常用API(3)Geolocation定位、Keyboard键盘
- html5 笔记4 地理定位(Geolocation)
- js的navigator.geolocation的API笔记
- HTML5培训第15节课堂笔记(HTML5+maps,geolocation)
- html5 geolocation
- PhoneGap-----Geolocation
- navigator.geolocation
- HTML5 Geolocation
- HTML5 Geolocation
- Geolocation software
- HTML5 Geolocation
- Geolocation地理位置
- Geolocation WebAPI
- Geolocation地理位置
- gettid 和pthread_self的区别
- MySQL中去除字段中的回车符和换行符
- Linux--更新(update/upgrade) & 更新源
- postgres压测工具pgbench
- Mybatis原理源码分析
- #学习笔记#(54)geolocation
- SharePoint2013 IT Professional - Limited Access
- 读什么,让你的生活既有诗又有远方
- Spring MVC中处理静态资源的多种方法
- springmvc教程,快速入门,深入分析
- 彻底释放Linux线程的资源
- Your build settings specify a provisioning profile with the UUID “”的解决办法
- ORACLE约束总结
- 2.2.2XML解析(一)