GetcharZp

腾讯定位的使用

 

通过前端的JS代码获取到定位信息,在通过 POST 方法吧请求提交到后台服务器中

<script type="text/javascript" src="https://apis.map.qq.com/tools/geolocation/min?key=your key&referer=your app name"></script>
<script>
    function clockIn(routeid, shopid) {
        var geolocation = new qq.maps.Geolocation();
        // 获取当前位置
        geolocation.getLocation(sucCallback, errCallback);
        // 成功的回调方法
        function sucCallback(position) {
            console.log(position);
            $.post("请求路径", 请求方法, function (data) {
                util.message(data.message, data.redirect, data.type);
            }, \'json\');
        }
        // 失败的回调方法
        function errCallback() {
            console.log(\'fail\');
        }

        /*
        // 通过微信的 JSSDK 实现定位
     // 获取定位信息 {latitude: 30.5702, longitude: 104.06476, errMsg: "getLocation:ok"} $.post("请求路径", 请求参数, function (data) { wx.config(data); wx.getLocation({ type: \'gcj02\', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入\'gcj02\' success: function (res) { var lat = res.latitude; // 纬度,浮点数,范围为90 ~ -90 var lng = res.longitude; // 经度,浮点数,范围为180 ~ -180。 clock_in_record(routeid, shopid, lat, lng); }, fail:function () { alert(\'请开启手机的定位功能后重试\'); } }); }, \'json\');
*/ } </script>

 

 

分类:

技术点:

相关文章:

  • 2021-04-11
  • 2021-11-21
  • 2021-07-23
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-04-27
  • 2021-11-21
  • 2021-06-25
  • 2021-04-01
相关资源
相似解决方案