学習内容: CSSアニメーションとJavaScriptを使ってマーカーにアニメーション効果を追加します。
ポイント:
// CSSアニメーション用のDivIcon
const pulseIcon = L.divIcon({
className: 'pulse-marker',
html: '<div style="...">📍</div>',
iconSize: [20, 20]
});
// JavaScriptでマーカーを移動
let position = 0;
const route = [[35.68, 139.76], [35.69, 139.77], ...];
function animate() {
position += speed;
if (position >= route.length) position = 0;
marker.setLatLng(route[position]);
requestAnimationFrame(animate);
}