mapbox-gl-directions에 두 마커 사이의 간단한 경로를 계산하려고합니다. .on('route')
이벤트를 사용하려고하지만 결코 실행되지 않습니다. docs에 표시된 예제를 다시 작성하려고 시도했지만 성공하지는 못했습니다. 다음을 수행했습니다.Mapbox-gl-directions 이벤트가 실행되지 않습니다
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8'
});
var directions = new mapboxgl.Directions({
unit: 'metric', // Use the metric system to display distances.
profile: 'driving', // Set the initial profile to walking.
container: 'directions' // Specify an element thats not the map container.
});
map.on('load', function() {
directions.setOrigin([77.5045504332, 13.0386169339]); // On load, set the origin to "Toronto, Ontario".
directions.setDestination([77.5075504332, 13.0386169339]); // On load, set the destination to "Montreal, Quebec".
});
directions.on('route', function(e) {
alert("FIRE!")
});
왜이 이벤트가 실행되지 않습니까? 여기에 JS FIDDLE도 있습니다.