13 - GeoJSONの基本

学習内容: GeoJSON形式のデータを地図上に表示します。

ポイント:

注意: GeoJSONの座標は [経度, 緯度] の順です。Leafletの [緯度, 経度] とは逆なので注意してください。

// GeoJSONデータ
const geojsonData = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": { "name": "東京タワー" },
            "geometry": {
                "type": "Point",
                "coordinates": [139.7454, 35.6586]
            }
        },
        {
            "type": "Feature",
            "properties": { "name": "皇居周辺" },
            "geometry": {
                "type": "Polygon",
                "coordinates": [[...]]
            }
        }
    ]
};

// GeoJSONレイヤーを追加
L.geoJSON(geojsonData).addTo(map);