H5-geolocation学习
生活随笔
收集整理的這篇文章主要介紹了
H5-geolocation学习
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
geolocation——定位PC——IP地址精度比較低IP庫Chrome -> Google手機——GPSwindow.navigator.geolocation單次 getCurrentPosition(成功, 失敗, 參數)enableHighAccuracy 高精度模式——更慢、更費電timeout 超時maximumAge 緩存時間結果:latitude/longitude 緯度/經度altitude 海拔高度accuracy 精確度altitudeAccuracy 高度精確度heading 朝向speed 速度監聽 watchPosition(成功, 失敗, 參數)
demo;
<!DOCTYPE html> <html><head><meta charset="utf-8"><script type="text/javascript">window.οnlοad=function (){let oBtn=document.getElementById('btn1');oBtn.οnclick=function (){if(window.navigator.geolocation){navigator.geolocation.getCurrentPosition(res=>{alert('成功');}, err=>{alert('失敗');}, {/*enableHighAccuracy //高精度模式timeout //超時時間maximumAge //緩存*/});}else{alert('你的瀏覽器不支持定位');}};};</script><title></title></head><body><input type="button" name="" value="定位" id="btn1"></body> </html>
轉載于:https://www.cnblogs.com/chaofei/p/8052552.html
總結
以上是生活随笔為你收集整理的H5-geolocation学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端-html省份、地市级联
- 下一篇: [Odoo] Report PDF 分页