1
我想用反轉地理編碼獲取座標的城市和國家。反向地理編碼:獲得城市和國家
這裏有兩個例子:
我總是需要第一address_components
,然後將兩種類型的價值觀[ "locality" ]
和[ "country", "political" ]
但我不知道該如何對付它們。
我有什麼至今:
$url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . get_wpgeo_latitude($post_id) . ',' . get_wpgeo_longitude($post_id) . '&language=de';
$data = @file_get_contents($url);
$jsondata = json_decode($data, true);
print_r($jsondata['results'][0]['address_components'][0]);
完美的作品,很多很多的感謝! – user1706680
當循環沒有進入if條件時會發生什麼?如何處理'else'? – smartmouse