How to hide and show multiple routes for 20 addresses

84 views
Skip to first unread message

frank

unread,
Jun 28, 2011, 12:55:40 PM6/28/11
to google-map...@googlegroups.com
My programmers are having a hell of a time figuring out one feature that I thought you might be able to help with.

I have a home search site.

It allows the user to enter in 1 work address. When they do a search it currently shows the distance in miles to each home for sale. (in a list below it)

But now I want it to show the 20 homes for sale and when you mouseover each pin, I want it to show the driving directions (the lines on the map) from the selected home to the work. 

But they can't for their life figure out how to hide and show the lines. They can have all 20 lines show up, but not hide and show on mouseover.

This solution did not work: 
"Plot all 5 routes with opacity zero. When a mouseover occurs use .setStrokeStyle to change the opacity to make it visible. When a mouseout occurs use setStrokeStyle to set the opacity back to zero."

Any suggestions?

en4ce

unread,
Jun 28, 2011, 3:34:31 PM6/28/11
to Google Maps JavaScript API v3
may just the wrong approach, why not geocode every rout when hovering/
click a pin?, there is no need to set it visi or invisible ;) (yes,
its fast enough ~ usually)

frank

unread,
Jun 30, 2011, 12:08:21 AM6/30/11
to google-map...@googlegroups.com
I will try that. But can you think of a reason why preloading it won't work? Eventually I was going to have up to 100 homes. So mousing over each and offering immediate routes would be ideal.
Thank you for replying!!

Rossko

unread,
Jun 30, 2011, 4:54:29 AM6/30/11
to Google Maps JavaScript API v3
> Eventually I was going to have up to 100 homes.

There are request rate limits in place on the Directions service, to
prevent abuse. Simply banging in 100 requests will break that.
It's manageable by adding delays, but I thought the point was fast
loading page and no bored customers?

It is possible to reduce requests a bit by asking for A-B-A-C-A-.. and
extracting the legs you want.

I'm not sure how it sits with the terms of use to request Directions
that may never get displayed on the map, though I can't imagine Google
would be that picky.
It does seem like a waste of resource that you share with others.
Reply all
Reply to author
Forward
0 new messages