【发布时间】:2016-06-21 20:59:31
【问题描述】:
我正在尝试在 Unity 中使用来自 google 的地理服务。我是这样做的:
WWW www = new WWW("https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&oe=utf-8&key="+googleKey);
yield return www;
if (!string.IsNullOrEmpty(www.error)){
print(www.error);
} else {
var newobject = JsonConvert.DeserializeObject(www.text);
print ("Object: " + newobject);
}
这部分工作正常,我得到了我想要的结果......但知道我只需要从结果中得到纬度和经度,但不知道该怎么做?
这是我从谷歌得到的结果:
{
"results": [
{
"address_components": [
{
"long_name": "1600",
"short_name": "1600",
"types": [
"street_number"
]
},
{
"long_name": "Amphitheatre Parkway",
"short_name": "Amphitheatre Pkwy",
"types": [
"route"
]
},
{
"long_name": "Mountain View",
"short_name": "Mountain View",
"types": [
"locality",
"political"
]
},
{
"long_name": "Santa Clara County",
"short_name": "Santa Clara County",
"types": [
"administrative_area_level_2",
"political"
]
},
{
"long_name": "California",
"short_name": "CA",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "United States",
"short_name": "US",
"types": [
"country",
"political"
]
},
{
"long_name": "94043",
"short_name": "94043",
"types": [
"postal_code"
]
}
],
"formatted_address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
"geometry": {
"location": {
"lat": 37.422364,
"lng": -122.084364
},
"location_type": "ROOFTOP",
"viewport": {
"northeast": {
"lat": 37.4237129802915,
"lng": -122.0830150197085
},
"southwest": {
"lat": 37.421015019708513,
"lng": -122.0857129802915
}
}
},
"place_id": "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
"types": [
"street_address"
]
}
],
"status": "OK"
}
我想我需要去这个:
"geometry": {
"location": {
"lat": 37.422364,
"lng": -122.084364
},
但是我该怎么做呢?
任何帮助表示赞赏并提前感谢:-)
【问题讨论】:
标签: c# json google-maps unity3d