我正在尝试从 google geocode api 获取邮政编码。
只获取邮政编码。
{
"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();
关于c# - 如何仅从 google api 获取 postal_code 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27720344/