2014-12-31 3 views
3

Google 지오 코드 api에서 우편 번호를 받으려고합니다.google api에서 postal_code 데이터 만 가져 오는 방법은 무엇입니까?

가져 오기 전용 우편 번호.

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" 
} 

제발 도와주세요.

답변

2
string _Postcode = (from x in gpr.results[0].address_components.AsQueryable() 
               where x.types.Contains("postal_code") 
               select x.long_name).FirstOrDefault(); 
관련 문제