dayjournal memo

Total 975 articles!!

MapLibre GL JS #005 - 地理院タイルのラスタタイル表示

Yasunori Kirimoto's avatar


画像



背景に地理院タイルのラスタタイルを表示するメモ。



画像



script.js

// 地理院タイル読み込み
const map = new maplibregl.Map({
    container: 'map',
    style: {
        version: 8,
        sources: {
            t_pale: {
                type: 'raster',
                tiles: ['https://cyberjapandata.gsi.go.jp/xyz/pale/{z}/{x}/{y}.png'],
                tileSize: 256,
                attribution:
                    '<a href="http://www.gsi.go.jp/kikakuchousei/kikakuchousei40182.html" target="_blank">地理院タイル</a>',
            },
        },
        layers: [
            {
                id: 't_pale',
                type: 'raster',
                source: 't_pale',
                minzoom: 0,
                maxzoom: 18,
            },
        ],
    },
    center: [139.767, 35.681],
    zoom: 11,
});

// コントロール関係表示
map.addControl(new maplibregl.NavigationControl());



MapLibre GL JSを手軽に始めるビルド環境公開しています。
maplibregljs-starter



book

Q&A