2016-09-14 7 views
0

私はDirections on google mapを作成したいと思います。私のコードがあります。 コードには4つのマーカーがあります。 私は、どのマーカーを隠したいのかを決めたいと思っています。 Googleマップのドラッグ可能なdirecionでマーカーを表示するにはどうすればいいですか?Googleマップでマーカーを表示する方法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); 
    } 
    }); 

} 

The picture shows the directions look like.

答えて

-1

あなたはjQueryのを使用している場合は、このようなマーカーになってみてください。また、OPは、特定のプラグインを使用していると仮定し

var markers = $('#map_canvas').gmap('get','markers');

+0

を。表示されているコードではその証拠はありません – charlietfl

関連する問題