Newer
Older
matsugaoka / web / map / test.mado / sample2.js
@mamadoka mamadoka on 1 Aug 2019 547 bytes geojson読み込むためのもの
//leaflet-omnivoreロード

var customLayer = L.geoJson(null, {
    onEachFeature: function(f, layer) {
	let p = f.progrties;
	if (p) {
	    let name = p.name, disc = p.description;
	    let popup = "<h3>" + name + "</h3>" + "<p>" + (desc||"") + "</p>";
	    layer.bindPopup(popup);
	}
    }
})

//geojson読み込みは次の行

var gjl = omnivore.geojson("sample.geogson", null, customLayer);

gjl.on("ready", function() {
    mymap.fitBounds(gjl.getBounds());
});
gjl.addTo(mymap);
L.control.layers(null, {"なにこれ": gjl}).addTo(mymap);