设为首页 加入收藏

TOP

php+高德地图webapi 高德jsapi 实现 当前位置与目标位置距离 并按照距离排序(坐标逆转换)(一)
2019-08-23 00:42:12 】 浏览:86
Tags:php 高德 地图 webapi jsapi 实现 当前 位置 目标 距离 按照 排序 坐标 转换
<script type="text/java script" src="https://api.map.baidu.com/api?v=2.0&ak='自己申请'&s=1"></script>
<script type="text/java script" charset="utf-8">


        var geolocation = new BMap.Geolocation();
        geolocation.getCurrentPosition(function (r) {
            if (this.getStatus() == BMAP_STATUS_SUCCESS) {
                var lat = r.point.lat;
                var lng = r.point.lng;
            }
            // return;
            var data = {'lat': lat, 'merchid': "{$item['id']}",'classid': "{$classitem['id']}", 'lng': lng};
            $.ajax({
                url: "{php echo mobileUrl('shop/category/ajaxcodot')}",
                data: data,
                cache: false
            }).done(function (result) {
                var data = jQuery.parseJSON(result);
                if (data.status == 1) {
                    if(data.result.code == 1){
                        console.log(data.result.code)
                        $(".shop").html(data.result.html)
                        // $("#coll").hide()
                    }else{
                        $(".shop").hide()
                        $(".noinfo").show()
                    }
                } else {
                    alert("微信接口繁忙,请稍后再试!");
                    
                }
            });  
        })
 
</script>
首先定位当前位置
    public function ajaxdot()//查询结果页
    {
         global $_W;
        global $_GPC;

        $province = $_GPC['province'];
        $city = $_GPC['city'];
        $area = $_GPC['area'];
        $classid = $_GPC['classid'];

        
        $lat = floatval($_GPC['lat']);
        $lng = floatval($_GPC['lng']);

        $merch = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_merch_user') . ' WHERE id = '.$_GPC['merchid']);           
        $where = 'where 1';
        $where.= " and province = '$province'";
        if($merch['cateid'] != 6)
        $where.= " and company_number = '{$merch['company_number']}'";
        if(!empty($city)){
            $where.= " and city = '$city'";
        }        
        if(!empty($area)){
            $where.= " and area = '$area'";
        }
        
        
        if($merch['cateid'] == 1 && $classid){
          //  var_dump($classid);exit;
             $class = pdo_fetch('SELECT class_type FROM ' . tablename('ewei_shop_merch_user_class') . ' WHERE id = '.$classid);  
             $class_type = $class['class_type'];
          $where.= " and class_type = '$class_type'";
        }        
 
        
        if(!empty($_GPC['classid'])){
            $classitem = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_merch_user_class') . ' WHERE id = :classid',array('classid' => $_GPC['classid']));            
        }
        
        $table = tablename('ewei_shop_merch_user_address');
        if($merch['cateid'] == 6){
            if($merch['company_number'] == 'TXDX001'){
                 $where.= " and class_type = 'DX'";
            }else if($merch['company_number'] == 'TXDX002'){
                $where.= " and class_type = 'YD'";
            }else if($merch['company_number'] == 'TXDX003'){
                $where.= " and class_type = 'LT'";
            }
           $table =tablename('ewei_shop_merch_tx_address');
        }
        
        
        $detail = pdo_fetchall("SELECT * FROM $table " ."$where");
        
                // var_dump($detail);
        
        if($detail){
            $html = '';
            foreach ($detail as $key=>$v) {
                if($v['lat'] == '' || $v['lng'] == ''){
                       $lntarr = $this->addresstolatlag($v['detail']);
                    $store['lng'] = $lntarr[0];
                    $store['lat'] = $lntarr[1]; 
                    // var_dump($lntarr);
                    $lat_num = explode('.', $store['lat']);
                    if (1 < sizeof($lat_num)) {
                        $decimal = end($lat_num);
                        $count = strlen($decimal);
                        if ($count <= 6) {
                            $gcj02 = $this->Convert_GCJ02_To_BD09($store['lat'], $store['lng']);
                            $store['lat'] = $gcj02['lat'];
                            $store['lng'] = $g
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇php比较两个数组的差异array_diff.. 下一篇DedecmsV5.7本地上传缩略图无法自..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目