Blogger Information
Blog 26
fans 1
comment 1
visits 35379
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
高德地图php 换取经纬度 地址
Bystander
Original
2106 people have browsed it

/**
 * 根据地址 获取经纬度
 * @param $address
 * @return mixed
 */
function addresstolatlag($address){


    $url='http://restapi.amap.com/v3/geocode/geo?address='.$address.'&key=80051202ff5b334bd3c94e18d20a';
    if($result=file_get_contents($url))
    {
        $result = json_decode($result,true);
        //判断是否成功
        if(!empty($result['count'])){
            return  explode(',',$result['geocodes']['0']['location']);

        }else{
            return false;
        }

    }

}
 


/**
 * 根据经纬度 获取地址
 * @param $address23.2322,12.15544
 * @return mixed
 */
function getaddress($address){


    $url="http://restapi.amap.com/v3/geocode/regeo?output=json&location=".$address."&key=80051202ff5b33334bd3c94e18d20a";
    if($result=file_get_contents($url))
    {
        $result = json_decode($result,true);
        if(!empty($result['status'])&&$result['status']==1){

            return $result['regeocode']['formatted_address'];

        }else{
            return false;
        }


    }

}

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
1 comments
TAO 2019-08-01 10:09:46
赞,赞,赞
1 floor
Author's latest blog post