h5獲取手機地理位置

由於這兩天在做公司的班車信息,要獲取人所在的位置,用h5的 navigator.geolocation 獲取手機地理定位,主要方法比較簡單:
getlocationpoint:function () {
      if (navigator.geolocation){
          navigator.geolocation.getCurrentPosition(
              function (position) {
                 latitude = position.coords.latitude;//獲取緯度
                 longitude = position.coords.longitude;//獲取經度
              });
      }else{
         alert("不支持定位功能");
      }
  }
坑: ios獲取地理定位需要https請求,因此頁面放的服務器爲https服務器。

訪問路徑如下:https://appinter.sunwoda.com/download/pda/busfoeweixin/busfoweixin/busall.html


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章