0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

leafletを鍛える。その36

Last updated at Posted at 2026-01-19

概要

leafletを鍛えてみた。
kml、表示してみた。

写真

image.png

参考にしたページ

サンプルコード


var map = L.map('map').setView([36.850918, 138.284091], 10);

var tileLayer = L.tileLayer('https://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{
  maxZoom: 20,
  subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
});
tileLayer.addTo(map);

fetch('example2.kml').then(res => res.text()).then(kmltext => {
  const parser = new DOMParser();
  const kml = parser.parseFromString(kmltext, 'text/xml');
  const track = new L.KML(kml);
  map.addLayer(track);
  const bounds = track.getBounds();
  map.fitBounds(bounds);
});




成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?