欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

如何用php根據(jù)地址獲取經(jīng)緯度

 更新時(shí)間:2021年04月20日 10:05:22   作者:蒸蒸日上y  
這篇文章主要介紹了php根據(jù)地址獲取經(jīng)緯度,對地址經(jīng)緯度感興趣的同學(xué),可以參考下

這里用的是百度地圖的接口,你需要先申請百度的服務(wù)秘鑰(ak)。
百度地圖有這樣一個(gè)接口:地理編碼

1.php代碼:

/**
 * 根據(jù)地址獲取經(jīng)緯度 -- 百度地圖
 */
public function queryAddress(){
    $ak = '你的ak'; //填寫你的ak
    $address = '北京市海淀區(qū)上地七街'; //要獲取的位置
    $url = 'http://api.map.baidu.com/geocoding/v3/?output=json&address='.$address.'&ak='.$ak;
    $data = file_get_contents($url);
    $data = json_decode($data);
    $data =  json_decode(json_encode($data),true); //轉(zhuǎn)換成數(shù)組形式
    print_r($data);
}

2.打印出來的效果:

Array

(

    [status] => 0

    [result] => Array

        (

            [location] => Array

                (

                    [lng] => 116.31222544088

                    [lat] => 40.051939649312

                )

            [precise] => 0

            [confidence] => 30

            [comprehension] => 100

            [level] => 道路

        )

)

注意:

創(chuàng)建你的ak的時(shí)候應(yīng)用類型選擇瀏覽器端即可,下面有個(gè)Referer白名單,填寫 * 表示任何域名都可以訪問

以上就是如何用php根據(jù)地址獲取經(jīng)緯度的詳細(xì)內(nèi)容,更多關(guān)于php獲取經(jīng)緯度的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論