Need Help with Google Maps API

1 replies
Hi Guys,

I have a site where I need to provide live traffic information, for instance in my sidebar I need to display a small widget or map which will tell my users how long it will take them to get to my store location if they are coming from different areas.

I need to cover about 5 areas. My store is located in Los Angeles. The sidebar widget should provide instant information to my users about how long it will take them to get to my store if for instance they are coming from the valley, another widget below it should tell them how long it will take them to get to my store if they are coming from Santa Monica, etc ..

These will be 6 hard-coded locations, I am not expecting for users to put in their address.. I just need to give them a rough estimate.

Is there a way to do this with Google Maps API?
#api #google #maps
  • Profile picture of the author linuxoctane
    Looks like that could be possible. Since with google maps you could hardcode in the locations in the url. For example I just put in ?saddr=tampa+FL&daddr=Disney+world.
    So you could put in the generic location from some geo cordinates based on an IP and have your business hardcoded.
    Code:
    https://maps.google.com/maps?saddr=tampa+FL&daddr=Disney+world
    Looks like the api has where they can put in there location to your business but it is a manual process. I linked that page for reference below.

    The add location to your position section!
    Add Google Maps to your website

    edit: Actually got bored and I was able to pull out the mileage and directions pretty easy with ruby with nokogiri to output this. Showing the mileage for the main route. Would just need to figure out how to widgetize it.

    Code:
    Mileage:   71.7 mi, 1 hour 7 mins    
    Head east on E Zack St toward N Morgan St
    Turn left at the 3rd cross street onto N Jefferson St
    Continue onto Cass Orange Conectr
    Continue onto N Orange Ave
    Take the ramp on the left onto I-275 N
    Take exit 45B to merge onto I-4 E toward Orlando
    Take exit 67 toward Epcot
    Merge onto FL-536 W/World Center Dr
    Continue onto Epcot Center Dr
    {{ DiscussionBoard.errors[7563363].message }}

Trending Topics