Search code examples
google-mapsgcloud

Google maps API zipcode to zipcode driving directions


I am following Google gCloud guidelines to plot a map (to embed inside an iframe). In my problem, origin and destinations are numeric zipcodes.

This is the URL I use:

https://www.google.com/maps/embed/v1/directions?key=MY_API_KEY&origin=address=07304&destination=90210

This is what I get: enter image description here

When I should get this: enter image description here

This pickups the real origin (Jersey City, NJ), but for the 90210 (Beverly Hills, CA) it picks up a business in Queens, NY (90210 Laser).

Is there a way to specify ZIPCODE origin and ZIPCODE destination in the URL without having to first get lat, lon or city names; just like when "07304" is specified?

I am not limited to Google Maps, any free or low cost service that can encode zip code to zip code directions correctly is a good solution.

Thanks


Solution

  • one option would be: origin=zip 07304&destination=zip 90210

    <iframe width="600" height="450" frameborder="0" style="border:0"
    src="https://www.google.com/maps/embed/v1/directions?key=[API_KEY]&origin=zip 07304&destination=zip 90210" 
    allowfullscreen></iframe>
    

    live example screenshot of live example