mle 0930 - izudon/izudon.github.io GitHub Wiki

0930 Fit to the bounds of a LineString

  • map.fitBounds() ใ™ใ‚‹ใŸใ‚ใฎใƒใ‚ฆใƒณใƒ‡ใ‚ฃใƒณใ‚ฐใƒœใƒƒใ‚ฏใ‚นใ‚’ใ•ใฆใฉใ†ใ‚„ใฃใฆ็ฎ—ๅ‡บใ™ใ‚‹ใ‹ใ€‚
const bounds = coordinates.reduce((bounds, coord) => {
    return bounds.extend(coord);
}, new maplibregl.LngLatBounds(coordinates[0], coordinates[0]));

ใ†ใพใ„ใจๆ€ใฃใŸ๏ผˆใปใ‹ใซๅฟœ็”จใ‚‚ๅŠนใใใ†๏ผ‰ใ€‚