"use strict"; // Variables for global usage const zLevelHide = 16; const zoomLevelToRotate = 19; const mapRotateDegrees = 90; let disableClicks = false; let lotAndFloorplanData = {}; const baseUrl = 'https://jekyllseasideretreat.com/'; // Replace with your actual domain const theme = 'seasideretreat'; let map; let salesCenterLat = 31.040952; let salesCenterLng = -81.414055; const initialZoom = 11; const targetZoom = 18; const animationDelay = 1000; const cookieName = "mapZoomPlayed"; let zoomLevel = initialZoom; function initMap() { const centerLat = 31.03988; const centerLng = -81.41382; const mapCenter = new google.maps.LatLng(centerLat, centerLng); const siteSVG = document.querySelector('#siteplanSVG'); const siteMapBounds = new google.maps.LatLngBounds( new google.maps.LatLng(31.0384, -81.41474), new google.maps.LatLng(31.04132, -81.41264) ); const mapOptions = { zoom: initialZoom, center: mapCenter, scrollwheel: false, mapTypeControl: true, fullscreenControl: false, streetViewControl: false, mapId: 'ae63ecc734886ff6' }; map = new google.maps.Map(document.getElementById('map_canvas_full'), mapOptions); class sitePlanSVGOverlay extends google.maps.OverlayView { constructor(bounds, svg, map) { super(); this.bounds = bounds; this.svg = svg; this.map = map; this.setMap(map); } onAdd() { const panes = this.getPanes(); panes.overlayMouseTarget.appendChild(this.svg); this.svg.style.display = 'block'; this.svg.style.position = 'absolute'; this.svg.style.zIndex = 10; this.attachEvents(); } attachEvents() { const lotElements = this.svg.querySelectorAll('[id*="Lot"]'); lotElements.forEach(el => { el.addEventListener('click', (e) => { handleLotClick(e, el); }); }); } draw() { const projection = this.getProjection(); const sw = projection.fromLatLngToDivPixel(this.bounds.getSouthWest()); const ne = projection.fromLatLngToDivPixel(this.bounds.getNorthEast()); Object.assign(this.svg.style, { left: `${sw.x}px`, top: `${ne.y}px`, width: `${ne.x - sw.x}px`, height: `${sw.y - ne.y}px` }); } show() { this.svg.style.display = 'block'; } hide() { this.svg.style.display = 'none'; } } const sitePlanOverlay = new sitePlanSVGOverlay(siteMapBounds, siteSVG, map); handleMapEvents(map, sitePlanOverlay); addTreesOverlay(); if (!getCookie(cookieName)) { setTimeout(() => { animateZoom(zoomLevel, targetZoom); }, animationDelay); setCookie(cookieName, "true", 5); // Set the cookie for 5 days } else { map.setZoom(targetZoom); } } function animateZoom(currentZoom, finalZoom) { let zoom = currentZoom; // Create an interval to increase the zoom level gradually const interval = setInterval(() => { if (zoom >= finalZoom) { clearInterval(interval); } else { zoom += .1; // Increment the zoom value (Adjust for smoother/slower zoom) map.setZoom(Math.round(zoom)); } }, 100); // Adjust interval time for the desired animation speed } function stepZoom() { if (zoomLevel >= targetZoom) { map.setZoom(targetZoom); } else { zoomLevel += 0.05; // Increment the zoom value for smoother zoom map.setZoom(Math.round(zoomLevel)); requestAnimationFrame(stepZoom); } } function loadGoogleMapsAPI() { const apiKey = 'AIzaSyAwiTTETlNIim29ien_PiMWP30pnXKNAoc'; // Replace with your actual Google Maps API key const script = document.createElement('script'); script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&callback=initMap`; script.async = true; script.defer = true; document.head.appendChild(script); } if (typeof google === 'undefined' || typeof google.maps === 'undefined') { loadGoogleMapsAPI(); } else { initMap(); } function handleMapEvents(map, overlay) { google.maps.event.addListener(map, 'zoom_changed', () => { const zoomLevel = map.getZoom(); console.log('zoomLevel',zoomLevel); /*if (zoomLevel >= zLevelHide) { overlay.show(); } else { overlay.hide(); }*/ }); } async function getLotsAndFloorplans(phase = 0) { try { const url = new URL(`${baseUrl}/themes/${theme}/modules/siteplan/siteplan.cfc?method=getLotsAndFloorplans`); url.searchParams.append('phase', phase); const response = await fetch(url.toString(), { method: 'GET', headers: { 'Content-Type': 'application/json' } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const lot_data = await response.json(); return lot_data; } catch (error) { console.error('Failed to fetch lots and floorplans:', error); return null; } } getLotsAndFloorplans().then(data => { lotAndFloorplanData = JSON.parse(data); setLotStatus(); }).catch(error => { console.error('Error fetching data:', error); }); function setLotStatus() { lotAndFloorplanData.lots.forEach(lot => { $('#Lot' + lot.lotNumber).attr("class", lot.lotSalesStatus); }); } function handleLotClick(e, element) { e.stopPropagation(); if (!disableClicks) { createAndShowLotModal(element.id); } } function createAndShowLotModal(lotNumber) { const lotInfo = getLotByNumber(lotAndFloorplanData, lotNumber.replace('Lot', '')); if (lotInfo) { const lotSize = Number(lotInfo.lotSize).toLocaleString(); $('.modal').remove(); const modalContent = `