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.744276, 135.35470299999997], '特別養護老人ホーム田辺の郷', 1); SetMaker([33.744276, 135.35470299999997], 'デイサービスセンター田辺の郷', 2); SetMaker([33.5723337, 135.43041600000004], '特別養護老人ホーム白浜日置の郷', 3); SetMaker([33.5723337, 135.43041600000004], 'デイサービスセンター白浜日置の郷', 4); SetMaker([33.6011667, 135.38787260000004], 'ケアハウス白浜椿の郷', 5); SetMaker([33.7443037, 135.35463579999998], 'ヘルパーステーション 田辺の郷', 6); 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); }