<script type='text/javascript'>//<![CDATA[
$(document).ready(function(){
$("#test").gmap3({
getroute:{
options:{
origin:"<?php echo $pickup; ?>",
destination:"<?php echo $destination; ?>",
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL
},
callback: function(results){
if (!results) return;
$(this).gmap3({
map:{
options:{
zoom: 13
}
},
directionsrenderer:{
//container: $(document.createElement("div")).addClass("googlemap").insertAfter($("#test")),
options:{ directions:results }
}
});
}
}
});
});//]]>
</script>
So this the code, using gmap3 (gmap3.net)
So, problem is, it is showing the quickest way in minute.
If i want to go from A to B, may be it have 3 different route where 50 minutes 30 miles, 55 minutes 17 miles, 57 minutes 19 miles and it will first select 50 minutes/30miles route. But i need the route with minimum miles (55min/17miles).
is there any way i can do that?
results
will contain an array with the 3 routes
.
Find the desired route within this array(should be the 2nd in this case) and pass the index of the route via the routeIndex
-property options
(default is 0):
options:{ directions:results, routeIndex: 1 }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.