Newer
Older
tokko / map.js
@Ito Yu Ito Yu on 9 Aug 2021 572 bytes Create map.js
var mymap = L.map("mymap").setView([38.89305796,139.81933145], 15);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution:
    '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(mymap);

L.geoJson(sample_json, { 
    style: function (feature) {
	return feature.properties;
    },
    onEachFeature: function(j, layer) {
	let p = j.properties;
	if (p) {
	    let name = p.name, desc = p.description;
	    let popup = "<h3>" + name + "</h3>" + "<p>" + desc + "</p>";
	    layer.bindPopup(popup);
	}
    }
}).addTo(mymap);