通过坐标获取周边地址信息

首先你要在http://lbs.qq.com/webservice_v1/index.html这里注册一个号,并获取一个KEY

通过下面程序,你就能获取到周边的地址信息了

<?php
function httpGet($url) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_TIMEOUT, 500);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_URL, $url);

    $res = curl_exec($curl);
    curl_close($curl);

    return $res;
}
$x=$_GET['x'];
$y=$_GET['y'];
$key='DBBBZ-M24RO-*-SVTN3-*-5MBN4'; # 你注册的KEY
$url="http://apis.map.qq.com/ws/geocoder/v1/?location={$x},{$y}&key={$key}&get_poi=1&coord_type=1&parameter={%22poi_num%22:20}";
$data=json_decode(httpGet($url));
//print_r($data);
$addr=$data->result;
?>
<!DOCTYPE html>
<html>
    <head>
        <title>选择</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

    </head>
    <body>
        <div>
        <select >
        <option><?php echo $addr->formatted_addresses->recommend?>[默认]</option>
        <?php foreach ($addr->pois as $li ){ ?>
            <option><?php echo $li->title ?></option>
        <?php } ?>
        </select>
        </div>
    </body>
</html>

效果如下

1