如何仅从谷歌 API 获取postal_code数据
本文关键字:postal code 数据 获取 API 何仅 谷歌 | 更新日期: 2023-09-27 18:35:56
我正在尝试从谷歌地理编码 api 获取邮政编码。
仅获取邮政编码。
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=API_KEY
{
"results" : [
{
"address_components" : [
{
"long_name" : "231",
"short_name" : "231",
"types" : [ "street_number" ]
},
{
"long_name" : "Millway Avenue",
"short_name" : "Millway Ave",
"types" : [ "route" ]
},
{
"long_name" : "Concord",
"short_name" : "Concord",
"types" : [ "sublocality_level_1", "sublocality", "political" ]
},
{
"long_name" : "Vaughan",
"short_name" : "Vaughan",
"types" : [ "locality", "political" ]
},
{
"long_name" : "York Regional Municipality",
"short_name" : "York Regional Municipality",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Ontario",
"short_name" : "ON",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Canada",
"short_name" : "CA",
"types" : [ "country", "political" ]
},
{
"long_name" : "L4K",
"short_name" : "L4K",
"types" : [ "postal_code_prefix", "postal_code" ]
}
],
"formatted_address" : "231 Millway Avenue, Vaughan, ON L4K, Canada",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 43.7991508,
"lng" : -79.5280784
},
"southwest" : {
"lat" : 43.7991481,
"lng" : -79.5280964
}
},
"location" : {
"lat" : 43.7991481,
"lng" : -79.5280964
},
"location_type" : "RANGE_INTERPOLATED",
"viewport" : {
"northeast" : {
"lat" : 43.80049843029149,
"lng" : -79.52673841970849
},
"southwest" : {
"lat" : 43.7978004697085,
"lng" : -79.5294363802915
}
}
},
"partial_match" : true,
"types" : [ "street_address" ]
}
],
"status" : "OK"
}
请帮助我。
string _Postcode = (from x in gpr.results[0].address_components.AsQueryable()
where x.types.Contains("postal_code")
select x.long_name).FirstOrDefault();