17 - スケールコントロールとその他のコントロール

学習内容: 地図にスケール(縮尺)やその他の標準コントロールを追加します。

ポイント:

// スケールコントロールを追加
L.control.scale({
    maxWidth: 200,
    metric: true,      // メートル法
    imperial: true,    // マイル法
    position: 'bottomleft'
}).addTo(map);

// ズームコントロールの位置を変更
map.zoomControl.setPosition('topright');

// カスタムコントロールを作成
const customControl = L.Control.extend({
    options: { position: 'bottomright' },
    onAdd: function(map) {
        const container = L.DomUtil.create('div', 'custom-control');
        container.innerHTML = 'カスタム情報';
        return container;
    }
});
new customControl().addTo(map);