获取经度 纬度

1 web端

if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(
        function (position) {  
            var longitude = position.coords.longitude;  
            var latitude = position.coords.latitude;  
            console.log(longitude)
            console.log(latitude)
            },
            function (e) {
             var msg = e.code;
             var dd = e.message;
             console.log(msg)
             console.log(dd)
        }
      ) 
   }

2 微信小程序

wx.getLocation({  
      type: 'wgs84',  
      success: function (res) {  
        console.log(res)  
        var latitude = res.latitude  
        var longitude = res.longitude  
        that.setData({  
          wd: latitude,  
          jd: longitude  
        })  
      }  
    })  

微信小程序接入地图参考: https://blog.csdn.net/crazy1235/article/details/55004841

3 安卓获取经纬度 参考 https://blog.csdn.net/u011159417/article/details/49866451

猜你喜欢

转载自my.oschina.net/jamescasta/blog/1817250