jquery - Google Maps API, Directions From Marker To Marker -


so have map lots of markers plotted. want able right click marker , select "start point", right click marker , select "destination point".

i remove markers , show 2 markers ive clicked directions drawn on map.

i have no idea begin here, new jquery. here code far have stripped out non important code make small possible:

    window.onload = function () {          var markerarray = new array();          var mapoptions = {             center: new google.maps.latlng(markers[0].lat, markers[0].lng),             zoom: 6,             maptypeid: google.maps.maptypeid.roadmap         };            var infowindow = new google.maps.infowindow();         var map = new google.maps.map(document.getelementbyid("map-canvas"),      mapoptions);         var image = 'marker.png';          (i = 0; < markers.length; i++) {              var data = markers[i]             var mylatlng = new google.maps.latlng(data.lat, data.lng);             var ischeckedd4 = $('#<%= d4.clientid %>').is(':checked');             var icon = "";             var fred;              if (ischeckedcat == true) {                 switch (data.category) {                     case 'a1':                         if (ischeckeda1 == true) {                             icon = "http://www.googlemapsmarkers.com/v1/a1/0066ff/ffffff/ff5050";                             fred = true;                         }                         else {                             icon = "";                             fred = false;                         }                         break;                                             }                          }               var marker = new google.maps.marker({                 position: mylatlng,                 map: map,                 title: data.title,                  icon: new google.maps.markerimage(icon),                 visible: fred,                 draggable: false,                 animation: google.maps.animation.drop             });              markerarray.push(marker);              (function (marker, data) {                 var markernameprev;                 google.maps.event.addlistener(marker, "click", function (e) {                      infowindow.setcontent(data.name);                     infowindow.open(map, marker);                      (var = 0; < markerarray.length; i++) {                         markerarray[i].setanimation(null);                     }                      marker.setanimation(google.maps.animation.bounce);                  });              })(marker, data);         }     } 

any appreciated. thank you.

well, need directions api , marker docs. after read these carefully, can

  1. add clicklistener markers
  2. using 2 selected markers' lat/lng info generate direction (there's need learn in link given above).

hope gives starting point.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -