function SetMaker(p, s, nNo) { if (p.length) { IconData.iconUrl = 'https://www.kiilife.jp/image/osm/red-' + nNo + '.png'; var marker = L.marker(p, { icon: L.icon(IconData) }); marker.bindPopup(s); markers.addLayer(marker); if (bounds) { bounds.extend(p); } else { bounds = L.latLngBounds(p); bounds.extend(p); } } } // create a map in the "map" div, set the view to a given place and zoom var bounds; var map = L.map('map', { scrollWheelZoom: false }); var IconData = { iconSize: [24, 42], iconAnchor: [12, 42], popupAnchor: [-0, -40], shadowUrl: 'https://www.kiilife.jp/image/osm/marker-shadow.png', shadowSize: [40, 40], shadowAnchor: [10, 40] }; var markers = L.markerClusterGroup(); var zoom = 0; // add a marker in the given location, attach some popup content to it and open the popup SetMaker([33.77550884557635, 135.50374031066897], '滝尻王子', 1); SetMaker([33.81224944762559, 135.5949329258527], '道の駅 熊野古道中辺路', 2); SetMaker([33.81078026496592, 135.60159662707616], '牛馬童子像', 3); SetMaker([33.81296243649323, 135.60697925000238], 'なかへち美術館前バス停', 4); map.addLayer(markers); // add an OpenStreetMap tile layer L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); map.fitBounds(bounds, {paddingTopLeft: [0, 42]}); if (map.getZoom() > 16) { map.setZoom(16); }