function EmbedDamcardMap(p, w, h) { var self = this; self.places = p; self.map = null; self.width = (w) ? w : '80'; self.height = (h) ? h : '250'; self.initialize(); } EmbedDamcardMap.prototype.initialize = function() { var self = this; document.write('
'); var head = document.getElementsByTagName('head')[0]; var css = document.createElement('link'); css.rel = 'stylesheet'; head.appendChild(css); css.href = 'https://unpkg.com/leaflet@1.3.0/dist/leaflet.css'; var js = document.createElement('script'); js.src = 'https://unpkg.com/leaflet@1.3.0/dist/leaflet.js'; head.appendChild(js); var loaded = false; js.onload = js.onreadystatechange = function() { if (!loaded && (!this.readyState || self.readyState === "loaded" || self.readyState === "complete")) { loaded = true; self.view(); loaded.onload = loaded.onreadystatechange = null; if (js.parentNode) { head.removeChild(js); } } }; }; EmbedDamcardMap.prototype.view = function() { var self = this; self.marker = L.icon({iconUrl: 'https://damcard.net/img/pin.embed.png', iconSize: [32,40], iconAnchor: [16, 40]}); self.map = L.map('embeddamcardmap', { center: [35.41, 139.45], zoom: 14 }) self.map.addLayer(new L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors | Powered by ダムこれ!'})); self.addMarkers(); } EmbedDamcardMap.prototype.addMarkers = function() { var self = this; if (!self.places) { return; } var b = null; self.map.panTo([self.places[0][1], self.places[0][2]], {animate: false}); b = self.map.getBounds(); for (var i = self.places.length; i; i --) { var p = self.places[i - 1]; self.addMarker(p); b.extend([p[1] - 0.004, p[2] - 0.004]); b.extend([parseFloat(p[1]) + 0.004, parseFloat(p[2]) + 0.004]); } self.map.fitBounds(b); } EmbedDamcardMap.prototype.addMarker = function(p) { var self = this; L.marker([p[1], p[2]], {title: p[0], icon:self.marker}).on('click', function() { self.navigate(p[3]); }).on('dblclick', function() { self.navigate(p[3]); }).addTo(self.map); if (p[4]) { var l = L.marker([p[1], p[2]], {title: p[0], icon: L.divIcon({iconSize: [21,6], iconAnchor: [11, 35], html: p[4]})}).on('click', function() { self.navigate(p[3]); }).on('dblclick', function() { self.navigate(p[3]); }).addTo(self.map); e = l.getElement(); e.style.background = 'none'; e.style.border = 'none'; e.style.fontWeight = 'bold'; e.style.color = '#fff'; e.style.textShadow = '0px 0px 2px #000'; e.style.fontSize = '15px'; e.style.textAlign = 'center'; } } EmbedDamcardMap.prototype.navigate = function(i) { window.open('https://damcard.net/dam/' + i + '/', '_blank'); } var embeddamcardmap = new EmbedDamcardMap([["\u5948\u826f\u4e95\u30c0\u30e0","35.935410518548295","137.8099652932976","115-09"]],'','500');