LoginSignup
1
1

More than 3 years have passed since last update.

leafletを鍛える。その2

Last updated at Posted at 2018-09-13

概要

leafletを鍛えてみる。
kmlを、読んでみた。

写真

サンプルコード

var map = L.map('map').setView([37.9, 140.1], 12);
var mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '&copy; ' + mapLink + ' Contributors',
    maxZoom: 18,
}).addTo(map);


d3.xml('http://jsrun.it/assets/u/n/Z/1/unZ1R', function(kml) {
    var w = kml.documentElement.getElementsByTagName("Placemark");
    for (var i = 0; i < w.length; i++)
    {
        var coord = w[i].getElementsByTagName("coordinates");
        var lines = coord[0].childNodes[0].nodeValue;
        var latlon = lines.split(',');
        var marker = L.marker([latlon[1], latlon[0]]).addTo(map);
    }
});

成果物

https://embed.plnkr.co/uVCnGiaRXvc2HRb8gDuH/
以上。

1
1
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
1
1