multiple routes on map?

Showing 1-4 of 4 messages
multiple routes on map? Jon Grubb 3/8/10 4:27 AM
Hi folks. I'm building a web site for a non-profit rescued pet
transport group called "On The Road Again"(OTRA) Pet Transport. Using
V3 for map rendering. Site is http://otrapettransport.org/ . Home page
pulls up a map of the US. Notice that there is a green route showing a
transport from Huntsville, AL to Boston, MA. Unfortunately, there are
actually TWO routes. There is a blue route from Bakersfield, CA to
Vancouver BC that doesn't get displayed - unless you stop the display
loop after the first loop, then it gets displayed. Display loops are
in a the "maps.js" file.

What is the mechanism I should be using to display multiple routes on
one map? Did I miss something in the reference? Also, I,m rendering
the routes anew every time the map is refreshed. I intend to
eventually store the JSON routes (DirectionsService results) in a
MySQL blob and then retrieve and display them rather than having
Google recreate them every time the map comes up.

V3 is a VERY nice package. Keep up the good work. Thanx...

Re: multiple routes on map? Susannah (Google Employee) 3/8/10 4:17 PM
Hi Jon,

You should be able to create two DirectionsRenderer objects, each that
use the same map and different DirectionsResults.

    var map = new
google.maps.Map(document.getElementById("map_canvas"));
    function renderDirections(result) {
      var directionsRenderer = new google.maps.DirectionsRenderer;
      directionsRenderer.setMap(map);
      directionsRenderer.setDirections(result);
    }

    var directionsService = new google.maps.DirectionsService;
    function requestDirections(start, end) {
      directionsService.route({
        origin: start,
        destination: end,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
      }, function(result) {
        renderDirections(result);
      });
    }
    requestDirections('Huntsville, AL', 'Boston, MA');
    requestDirections('Bakersfield, CA', 'Vancouver, BC');

Hope that helps,
Susannah

Re: multiple routes on map? Jon Grubb 3/9/10 4:09 AM
YES! EXCELLENT! That worked. Thank you very much. I understand what I
need to do.

On Mar 8, 7:17 pm, "Susannah (Google Employee)" <susann...@google.com>
wrote:

Re: multiple routes on map? Marvin Divo 3/17/10 7:18 AM
Hello Jon,

I'm planning to have a lot of routs on the map and keep asking Google
to recalculate them every time do not sound good.
I'm wondering did you succeed with your idea to keep DirectionsResult
object in MySQL. Could you share the technique/concepts? :)

Another solution I can think of is to convert (somehow)
DirectionsRoute to array of LatLng (store them in MySQL) then draw a
Polyline form that array.

Any other solutions/ideas?

Thanks.

On Mar 8, 2:27 pm, Jon Grubb <jonwgr...@gmail.com> wrote:
> Hi folks. I'm building a web site
>
> ... skipped ...

>
> Also, I,m rendering
> the routes anew every time the map is refreshed. I intend to
> eventually store the JSON routes (DirectionsService results) in a
> MySQL blob and then retrieve and display them rather than having
> Google recreate them every time the map comes up.