javascript - How to set the marker visible on google map draggable direcion -
i make directions on google map , , there code. in code , there 4 markers on it. want can decide markers want hide. how set marker visible on google map draggable direcion?
function initmap() { var map = new google.maps.map(document.getelementbyid('map'), { zoom: 4, center: {lat: 22.65, lng: 120.30} }); var directionsservice = new google.maps.directionsservice; var directionsdisplay = new google.maps.directionsrenderer({ draggable: true, map: map, panel: document.getelementbyid('right-panel') }); directionsdisplay.addlistener('directions_changed', function() { computetotaldistance(directionsdisplay.getdirections()); }); displayroute('22.650927, 120.328185' , '22.656672, 120.307596', directionsservice, directionsdisplay); } function displayroute(origin, destination, service, display) { service.route({ origin: origin, destination: destination, waypoints: [{location:new google.maps.latlng(22.651682, 120.324307)},{location:new google.maps.latlng(22.655168, 120.320009)}], travelmode: google.maps.travelmode.driving, avoidtolls: true }, function(response, status) { if (status === google.maps.directionsstatus.ok) { display.setdirections(response); } else { alert('could not display directions due to: ' + status); } }); }
if using jquery, try getting markers this:
var markers = $('#map_canvas').gmap('get','markers');
Comments
Post a Comment