Get LatLng from Zip Code - Google Maps API

前端 未结 6 710
我在风中等你
我在风中等你 2020-12-04 09:09

All I want is some simple example code that shows me how to obtain a latlng element from an inputted zip code OR a city/state.

6条回答
  •  时光取名叫无心
    2020-12-04 09:47

    Just a hint: zip codes are not worldwide unique so this is worth to provide country ISO code in the request (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).

    e.g looking for coordinates of polish (iso code PL) zipcode 01-210:

    https://maps.googleapis.com/maps/api/geocode/json?address=01210,PL

    how to obtain user country code?

    if you would like to get your user country info based on IP address there are services for it, e.g you can do GET request on: http://ip-api.com/json

提交回复
热议问题