最新文章:
- 腾讯九年,他为何选择辞职
- 为什么CTO、技术总监、架构师都不写代码,还这么牛逼
- 有道云笔记MAC客户端无法同步解决办法
- Chrome88稳定版已发布,不再支持 Flash
- node.js版本管理工具n的使用
您的位置:
富录-前端开发|web技术博客
>
JavaScript >
HTML5 Geolocation(地理定位)
HTML5 Geolocation(地理定位)
发布时间:2017年06月11日 评论数:抢沙发阅读数: 32864
运用getCurrentPosition() 方法来获得用户的位置。
HTML:
<div class="geolocation"></div>
js:
var geolocation = { getSite: function() { if(window.navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { $(".geolocation").text("浏览器不支持地理定位!!!") } function showPosition(position) { // 经度 var longitude = position.coords.longitude; // 维度 var latitude = position.coords.latitude; $(".geolocation").text("纬度:" + latitude + "纬度:" + longitude) } }, start: function() { this.getSite() } } geolocation.start()
本文作者:DGF
文章标题:
HTML5 Geolocation(地理定位)
本文地址: http://arbays.com/post-21.html  本文已被百度收录!
版权声明:若无注明,本文皆为“富录-前端开发|web技术博客”原创,转载请保留文章出处。
本文地址: http://arbays.com/post-21.html  本文已被百度收录!
版权声明:若无注明,本文皆为“富录-前端开发|web技术博客”原创,转载请保留文章出处。
相关文章