0

Is it possible to plot two routes at same time with Google maps api. For Example

Route from city A to B
and Route from city C to D

In this case A,B and C,D are separated.

Thanks.

Mohit Kanwar
  • 2,962
  • 7
  • 39
  • 59
Ali Asad Sahu
  • 57
  • 1
  • 3
  • 9

1 Answers1

3

Here are two polylines on the same map; there doesn't appear to be a limit.

http://jsfiddle.net/Lqcde/3/

I didn't add the div panels (becomes too cluttered) but you can also show two sets of text directions. It's a bit confusing because both start points are shown as "A" and endpoints, "B". Add the following lines:

directionsDisplay.setPanel(document.getElementById("dir-1"));
directionsDisplay2.setPanel(document.getElementById("dir-2"));

<div id="dir-1"></div>
<div id="dir-2"></div>
Heitor Chang
  • 6,038
  • 2
  • 45
  • 65
  • 1
    You can change the displayed markers by suppressing the default ones, getting the start/finish coordinates from the results and creating your own markers to put at those locations. http://stackoverflow.com/questions/4813728/change-individual-markers-in-google-maps-directions-api-v3 – Andrew Leach Mar 16 '12 at 10:19
  • That's worth mentioning Andrew! I meant the markers that show up in the (text) directions panels; those I have no idea how to modify. – Heitor Chang Mar 16 '12 at 13:14