Google Maps API不会从扩展的邮政编码返回美国的LatLng-美国-9位数的邮政编码

时间:2018-08-18 14:29:31

标签: google-maps google-maps-api-3

以下显示了纬度和经度

https://maps.googleapis.com/maps/api/geocode/json?address=90005

但是使用扩展的邮政编码,就不会

https://maps.googleapis.com/maps/api/geocode/json?address=900053200

{
   "results" : [],
   "status" : "ZERO_RESULTS"
}

是否有针对扩展邮政编码的单独服务?

1 个答案:

答案 0 :(得分:1)

zip + 4所需的格式为90005-3200。

使用该格式会给我一个结果(与邮政编码90005相同)。

https://maps.googleapis.com/maps/api/geocode/json?address=90005-3200&key=MY-API-KEY

返回:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "90005",
               "short_name" : "90005",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Central LA",
               "short_name" : "Central LA",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Los Angeles",
               "short_name" : "Los Angeles",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Los Angeles County",
               "short_name" : "Los Angeles 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" ]
            }
         ],
         "formatted_address" : "Los Angeles, CA 90005, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 34.0637149,
                  "lng" : -118.282294
               },
               "southwest" : {
                  "lat" : 34.05513,
                  "lng" : -118.3393861
               }
            },
            "location" : {
               "lat" : 34.0578814,
               "lng" : -118.3096648
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 34.0637149,
                  "lng" : -118.282294
               },
               "southwest" : {
                  "lat" : 34.05513,
                  "lng" : -118.3393861
               }
            }
         },
         "partial_match" : true,
         "place_id" : "ChIJ0U_geYS4woAR6-RMnUWG2Gc",
         "types" : [ "postal_code" ]
      }
   ],
   "status" : "OK"
}