Events

Views Navigation

Event Views Navigation

Today

function useFallback(reason) { failed = true; [loadTimer, tileTimer, pollTimer].forEach(timer => window.clearTimeout(timer)); root.dataset.mapState = "fallback"; root.dataset.mapFallbackReason = reason; canvas.setAttribute("aria-hidden", "true"); canvas.inert = true; fallback.hidden = false; if (pin) pin.setMap(null); }

function mapsReady() { return typeof window.google?.maps?.Map === "function" && typeof window.google?.maps?.OverlayView === "function"; }

function initialize() { if (failed || initialized) return; if (!mapsReady()) return useFallback("api-unavailable"); initialized = true; window.clearTimeout(loadTimer); window.clearTimeout(pollTimer); try { const maps = window.google.maps; map = new maps.Map(canvas, { center: position, zoom: 16, mapTypeId: "roadmap", renderingType: maps.RenderingType.RASTER, backgroundColor: palette.land, gestureHandling: "cooperative", keyboardShortcuts: true, clickableIcons: false, mapTypeControl: false, streetViewControl: false, cameraControl: false, fullscreenControl: true, zoomControl: true, zoomControlOptions: { position: maps.ControlPosition.RIGHT_BOTTOM }, styles: [ { elementType: "geometry", stylers: [{ color: palette.land }] }, { elementType: "labels.text.fill", stylers: [{ color: palette.labels }] }, { elementType: "labels.text.stroke", stylers: [{ color: palette.land }, { weight: 3 }] }, { featureType: "administrative.land_parcel", elementType: "labels", stylers: [{ visibility: "off" }] }, { featureType: "poi", elementType: "geometry", stylers: [{ color: palette.land }] }, { featureType: "poi", elementType: "labels.icon", stylers: [{ visibility: "off" }] }, { featureType: "poi.business", elementType: "labels", stylers: [{ visibility: "off" }] }, { featureType: "poi.park", elementType: "geometry", stylers: [{ color: palette.parks }] }, { featureType: "poi.park", elementType: "labels.text.stroke", stylers: [{ color: palette.parks }] }, { featureType: "road", elementType: "geometry.fill", stylers: [{ color: palette.roads }] }, { featureType: "road", elementType: "geometry.stroke", stylers: [{ color: palette.road_edges }] }, { featureType: "road", elementType: "labels.text.stroke", stylers: [{ color: palette.roads }, { weight: 3 }] }, { featureType: "transit", elementType: "geometry", stylers: [{ color: palette.road_edges }] }, { featureType: "transit", elementType: "labels.icon", stylers: [{ saturation: -80 }] }, { featureType: "water", elementType: "geometry", stylers: [{ color: palette.water }] }, { featureType: "water", elementType: "labels.text.stroke", stylers: [{ color: palette.water }] } ] }); if (failed) return; class VenuePin extends maps.OverlayView { constructor() { super(); this.location = new maps.LatLng(position); this.anchor = template.content.firstElementChild.cloneNode(true); } onAdd() { this.getPanes().overlayMouseTarget.append(this.anchor); maps.OverlayView.preventMapHitsAndGesturesFrom(this.anchor); } draw() { const point = this.getProjection().fromLatLngToDivPixel(this.location); if (point) { this.anchor.style.left = point.x + "px"; this.anchor.style.top = point.y + "px"; } } onRemove() { this.anchor.remove(); } } pin = new VenuePin(); pin.setMap(map); tileTimer = window.setTimeout(() => useFallback("tiles-timeout"), 16000); maps.event.addListenerOnce(map, "tilesloaded", () => { if (failed) return; window.clearTimeout(tileTimer); root.dataset.mapState = "styled"; delete root.dataset.mapFallbackReason; canvas.removeAttribute("aria-hidden"); canvas.inert = false; fallback.hidden = true; }); } catch { useFallback("map-initialization"); } }

function waitForExistingMaps() { if (failed) return; if (mapsReady()) return initialize(); pollTimer = window.setTimeout(waitForExistingMaps, 100); }

function loadMap() { root.dataset.mapState = "loading"; const previousAuthFailure = window.gm_authFailure; window.gm_authFailure = function () { useFallback("authentication"); if (typeof previousAuthFailure === "function") previousAuthFailure.call(window); }; if (mapsReady()) return initialize(); loadTimer = window.setTimeout(() => useFallback("api-timeout"), 16000); if (typeof window.google?.maps?.importLibrary === "function") { Promise.resolve().then(() => window.google.maps.importLibrary("maps")).then(initialize, () => useFallback("api-load")); return; } const existing = Array.from(document.scripts).find(script => /^https?://maps.(?:googleapis|google).com/maps/api/js(?:[?/#]|$)/i.test(script.src)); if (existing) { existing.addEventListener("error", () => useFallback("api-load"), { once: true }); waitForExistingMaps(); return; } const key = "AIzaSyDUt_Ntnc8J3T_dOblGh9S3Xi9Ryzzgd_g"; if (!key || key.startsWith("__")) return useFallback("no-key"); window.minnaInitDirectionsMap = initialize; const parameters = new URLSearchParams({ key, loading: "async", callback: "minnaInitDirectionsMap", v: "quarterly", language: "en", region: "US" }); const script = document.createElement("script"); script.src = "https://maps.googleapis.com/maps/api/js?" + parameters; script.async = true; script.onerror = () => useFallback("api-load"); document.head.append(script); }

if ("IntersectionObserver" in window) { const observer = new IntersectionObserver(entries => { if (entries.some(entry => entry.isIntersecting)) { observer.disconnect(); loadMap(); } }, { rootMargin: "200px" }); observer.observe(root); } else { loadMap(); } })();

 

Powered by