使⽤腾讯地图api获取定位信息经纬度(需要浏览器⽀持,且需要https)
使⽤腾讯地图库。
DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; chart=UTF-8"> <title>前端定位模块title> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,ur-scalable=no"> <style> * { margin: 0; padding: 0; border: 0; } body { position: absolute; width: 100%; 清晰反义词
开学欢迎标语
height: 100%; text-align: center; } #pos-area { background-color: #009DDC; margin-bottom: 10px; width: 100%; overflow: scroll; text-align: left; color: white; } #demo { padding: 8px; font-size: small; } #btn-area { height: 100px; } button { margin-bottom: 10px; padding: 12px 8px; width: 42%; border-radius: 8px; background-color: #009DDC; color: white; } style> <script type="text/javascript" src="/lightmap/components/geolocation/">script> head> <body> <div id="pos-area"> <p id="demo">点击下⾯的按钮,获得对应信息:<br />p> div> <div id="btn-area"> <button onClick="ation(showPo炖泥鳅
sition, showErr, options)">获取精确定位信息button> <button onClick="ocation(showPosition, showErr)">获取粗糙定位信息button> <button onClick="showWatchPosition()">开始监听位置button> <button onClick="showClearWatch()">停⽌监听位置but感动中国人物
ton> div> <script type="text/JavaScript"> var geolocation = new ation("OB4BZ-D4W3U-B7VVO-4PJWW-肚子疼的英文
6TKDJ-WPB77", "myapp"); mentById("pos-area"). = (Height - 110) + 'px'; var positionNum = 0; var options = {timeout: 8000}; function showPosition(position) { positionNum ++; mentById("demo").innerHTML += "序号:" + positionNum; mentById("demo").appendChild(Element('pre')).innerHTML = ify(position, null, 4); mentById("pos-area").scrollTop = mentById("pos-area").scrollHeight; }; function showErr() { positionNum ++; mentById("demo").innerHTML 关于安全的顺口溜
+= "序号:" + positionNum; mentById("demo").appendChild(Element('p')).innerHTML = "定位失败!"; mentById("pos-area").scrollTop = mentById("pos-area").scrollHeight; }; function showWatchPosition() { mentById("demo").innerHTML += "开始监听位置! osition(showPosition); mentById("pos-area").scrollTop = mentById("pos-area").scrollHeight; }; function showClearWatch() { atch(); mentById("demo").innerHTML += "停⽌监听位置! mentById("pos-area").scrollTop = mentById("pos-area").scrollHeight; }; script> body> html>
";
";
本文发布于:2023-04-27 22:45:51,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/fan/89/851695.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |