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服务器。

 

h5获取手机地理位置_第1张图片

你可能感兴趣的:(h5地理定位)