私のコードは
$result = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=".$stateName.",".$districtName.",".$cityName."&sensor=true");
ここで$stateName
、$districtName
、$cityName
はユーザーが指定した値です Kerala、Ernakulam、AngamalyをstateName、districtName、cityName
として
入力した後、次のような結果が得られました。
{
"results": [
{
"address_components": [
{
"long_name": "Angamaly",
"short_name": "Angamaly",
"types": [
"locality",
"political"
]
},
{
"long_name": "Ernakulam",
"short_name": "Ernakulam",
"types": [
"administrative_area_level_2",
"political"
]
},
{
"long_name": "Kerala State",
"short_name": "Kerala State",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "India",
"short_name": "IN",
"types": [
"country",
"political"
]
}
],
"formatted_address": "Angamaly, Kerala State, India",
"geometry": {
"bounds": {
"northeast": {
"lat": 10.2464704,
"lng": 76.39544959999999
},
"southwest": {
"lat": 10.1585335,
"lng": 76.3500451
}
},
"location": {
"lat": 10.212894,
"lng": 76.380601
},
"location_type": "APPROXIMATE",
"viewport": {
"northeast": {
"lat": 10.2464704,
"lng": 76.39544959999999
},
"southwest": {
"lat": 10.1585335,
"lng": 76.3500451
}
}
},
"types": [
"locality",
"political"
]
}
],
"status": "OK"
}
その場所の緯度と経度が必要です。geometry->bounds->northeastから緯度と経度を取得するにはどうすればよいですか?