以下是我找到的移动标记的代码,但我想在两个坐标之间沿直线路径移动标记,有人可以帮忙吗?这些是坐标:
[90.40237426757811,23.75015391301012],[88.34930419921875,22.573438264572406]
我需要一条线段连接这两个点的坐标。代码如下:
var marker = L.marker([0, 0], {
icon: L.mapbox.marker.icon({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [-77, 37.9]
},
properties: { }
})
});
var t = 0;
window.setInterval(function() {
// making a lissajous curve here just for fun. this isn't necessary
// Reassign the features
marker.setLatLng(L.latLng(
Math.cos(t * 0.5) * 50,
Math.sin(t) * 50));
t += 0.1;
}, 50);
marker.addTo(map);