How to easily get a zipcode from a generic address with google maps api?

后端 未结 1 422
醉梦人生
醉梦人生 2021-02-14 01:15

I am trying to get the postal code of a generic address such as \"los angeles, ca\". When I do this:

gcode = new google.maps.Geocoder()
gcode.geocode({\'address         


        
相关标签:
1条回答
  • 2021-02-14 02:05

    Why not using (for instance 1600+Amphitheatre+Parkway,+Mountain+View is your address)

    http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true_or_false
    

    And then parse the JSON for

    "long_name": "94043",
      "short_name": "94043",
      "types": [ "postal_code" ]
    } ]
    

    see here -> http://code.google.com/apis/maps/documentation/geocoding/

    0 讨论(0)
提交回复
热议问题