2017-03-23 2 views
1

나는 전단지를 매우 많이 읽었으며 누군가 나를 도울 수 있기를 바랍니다. 내가하려는 것은지도에 두 개의 마커를 추가하고 경로를 따라 다른 마커를 만드는 것입니다.경로를 따라 사용자 정의 전단지 마커를 움직이는 방법?

도움이 될만한 몇 가지 플러그인을 발견했지만 이러한 플러그인은지도 위에 마커를 만들고 특정 경로를 따르지 않습니다. http://ewoken.github.io/Leaflet.MovingMarker/

나는 그것이 Google지도에서 어떻게 이루어 졌는지는 알지만 전단지에서는 그렇지 않다. https://www.youtube.com/watch?v=zbr-F9wVqgU

답변

1

닫기가 완료되었습니다. 당신은 전단지 플러그인을 선택하고 꽤 정확한 목표를 가지고 있습니다. here의 설명을 따라하면됩니다.

// here is the path (get it from where you want) 
var coordinateArray = [ [0,1], [1,1], [1,0] ]; 
// or for example 
var coordinateArray = existingPolyline.getLatLngs(); 
// here is the line you draw (if you want to see the animated marker path on the map) 
var myPolyline = L.polyline(coordinateArray); 
myPolyline.addTo(map); 
// i don't know if i understood your question correctly 
// if you want to put a marker at the beginning and at the end of the path : 
var mstart = L.marker(coordinateArray[0]).addTo(map); 
var mend = L.marker(coordinateArray[coordinateArray.length - 1]).addTo(map); 
// here is the moving marker (6 seconds animation) 
var myMovingMarker = L.Marker.movingMarker(coordinateArray, 6000, { 
    autostart: false 
}); 
map.addLayer(myMovingMarker); 
myMovingMarker.start(); 
+0

작동 감사 :

은의 그 구현하자 –