|
|
| 1行目: |
1行目: |
| // GoogleMap表示
| |
| (function() {
| |
| function initGoogleMaps() {
| |
| document.querySelectorAll(".map-embed").forEach(function (el) {
| |
| const name = el.dataset.name;
| |
| if (!name) return;
| |
|
| |
|
| const src = `https://www.google.com/maps/embed/v1/place?key=AIzaSyDOA7e6S9arQa6NvnsFYXxGjX9P_ycwoyM&q=${encodeURIComponent(name)}&zoom=16&maptype=roadmap&language=ja®ion=JP`;
| |
|
| |
| const iframe = document.createElement("iframe");
| |
| iframe.width = "100%";
| |
| iframe.height = "400";
| |
| iframe.style.border = "0";
| |
| iframe.loading = "lazy";
| |
| iframe.allowFullscreen = true;
| |
| iframe.referrerPolicy = "no-referrer-when-downgrade";
| |
| iframe.src = src;
| |
|
| |
| // iframeが読み込まれたらSkeletonを消す
| |
| iframe.addEventListener("load", function() {
| |
| el.classList.add("loaded");
| |
| });
| |
| el.appendChild(iframe);
| |
| });
| |
| }
| |
|
| |
| // DOM準備後に実行
| |
| if (document.readyState === "loading") {
| |
| document.addEventListener("DOMContentLoaded", initGoogleMaps);
| |
| } else {
| |
| initGoogleMaps();
| |
| }
| |
|
| |
| document.querySelectorAll(".streetview-placeholder").forEach(function(el) {
| |
| const url = el.getAttribute("data-url");
| |
| if (!url) return;
| |
|
| |
| const iframe = document.createElement("iframe");
| |
| iframe.src = url;
| |
| iframe.width = "100%";
| |
| iframe.height = "100%";
| |
| iframe.style.border = "0";
| |
| iframe.loading = "lazy";
| |
| iframe.allowFullscreen = true;
| |
| iframe.referrerPolicy = "no-referrer-when-downgrade";
| |
|
| |
| el.appendChild(iframe);
| |
| });
| |
| document.querySelectorAll(".streetview-api-placeholder").forEach(function(el) {
| |
| const name = el.getAttribute("data-name");
| |
| if (!name) return;
| |
|
| |
| const src = `https://www.google.com/maps/embed/v1/streetview?key=AIzaSyDOA7e6S9arQa6NvnsFYXxGjX9P_ycwoyM&location=${name}`;
| |
|
| |
| const iframe = document.createElement("iframe");
| |
| iframe.src = src;
| |
| iframe.width = "100%";
| |
| iframe.height = "100%";
| |
| iframe.style.border = "0";
| |
| iframe.loading = "lazy";
| |
| iframe.allowFullscreen = true;
| |
| iframe.referrerPolicy = "no-referrer-when-downgrade";
| |
|
| |
| el.appendChild(iframe);
| |
| });
| |
| })();
| |