Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not sure what you want to get but maybe you could use directionsService.</p> <p>Global variables:</p> <pre><code>var directionDisplay; var directionsService = new google.maps.DirectionsService(); var startLocation; var markerStart; </code></pre> <p>In function initialize():</p> <pre><code>directionsDisplay = new google.maps.DirectionsRenderer(); directionsDisplay.setMap(map); google.maps.event.addListener(map, 'click', function(event) { mapZoom = map.getZoom(); startLocation = event.latLng; setTimeout("placeMarkerStart()", 600); }); </code></pre> <p>And more global staff:</p> <pre><code>function placeMarkerStart() { if(mapZoom == map.getZoom()){ markerStart = new google.maps.Marker({ position: startLocation, map: map, title: "start" }); } } function calcRoute(num) { var request = { origin: markerStart.getPosition(), destination: markers[num].getPosition(), travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function(result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); } </code></pre> <p>If you want to test this you could add:</p> <pre><code>&lt;div id="locationField"&gt; ... &lt;input type="button" onclick="calcRoute(0);" id="start" value="0"/&gt; &lt;input type="button" onclick="calcRoute(1);" id="start" value="1"/&gt; &lt;input type="button" onclick="calcRoute(2);" id="start" value="2"/&gt; &lt;/div&gt; </code></pre> <p>... and change map's position:</p> <pre><code>#map_canvas { position: absolute; width: 399px; height: 399px; top: 55px; left: 0px; border: 1px solid grey; } </code></pre> <p>This is only idea and doesn't work perfect but you could rebuild this if you like this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload