Feat: Implement map view in sidebar inquiry modal

This commit is contained in:
Kerby Martino (aider) authored and Kerby Martino committed 2025-05-11 04:57:43 +08:00
1 parent fd7e7c3dee
commit 6afc7b2e3e
1 file changed
+64 -1
+64 -1
View File
@@ -18,6 +18,8 @@
<!-- Modal Body -->
<div class="flex-1 overflow-y-auto p-4 sm:p-6">
<!-- Inquiry Form View -->
<div id="inquiry-form-view">
<!-- Modal Content -->
<div class="bg-white h-auto lg:h-full overflow-y-auto">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Cozy coworking space in the heart of the south</h2>
@@ -32,7 +34,7 @@
<div class="w-10 h-10 bg-gray-100 rounded-full flex items-center justify-center hover:border-indigo-700 border-2 border-transparent cursor-pointer">
<img src="assets/svg/icon_call.svg" class="w-4 h-4" alt="Call">
</div>
<div class="w-10 h-10 bg-gray-100 rounded-full flex items-center justify-center hover:border-indigo-700 border-2 border-transparent cursor-pointer">
<div onclick="showMapView()" class="w-10 h-10 bg-gray-100 rounded-full flex items-center justify-center hover:border-indigo-700 border-2 border-transparent cursor-pointer" title="View Map & Directions">
<img src="assets/svg/icon_pin.svg" class="w-4 h-4" alt="Pin">
</div>
<div class="w-10 h-10 bg-gray-100 rounded-full flex items-center justify-center hover:border-indigo-700 border-2 border-transparent cursor-pointer">
@@ -79,8 +81,69 @@
</p>
</div>
</form>
</div> <!-- Closes div class="bg-white h-auto lg:h-full overflow-y-auto" -->
</div> <!-- Closes inquiry-form-view -->
<!-- Map View -->
<div id="inquiry-map-view" class="hidden">
<div class="bg-white h-auto lg:h-full overflow-y-auto">
<!-- Back Button -->
<button type="button" onclick="showFormView()" class="mb-4 inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md bg-gray-100 text-indigo-900 font-semibold py-2 px-4 rounded-lg inline-flex items-center justify-between border-2 border-transparent hover:border-indigo-700">
<svg class="w-5 h-5 mr-2 -ml-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
Back to Inquiry
</button>
<h2 class="text-lg font-semibold text-gray-800 mb-1">Location for Cozy coworking space</h2>
<p class="text-xs text-gray-600 mb-3">Incub8 space, Centennial Road, Brgy. Batong Dalig, Kawit, Cavite</p>
<!-- Map Placeholder -->
<div id="mapbox-map-container" class="h-64 sm:h-80 w-full bg-gray-200 rounded-base mb-4 border border-gray-300 flex items-center justify-center text-gray-500 p-4 text-center">
<!-- This div will be targeted by Mapbox JS for map rendering. -->
Map will load here. Ensure Mapbox GL JS is initialized and targets this container.
</div>
<!-- Directions Button -->
<a href="https://www.google.com/maps/dir/?api=1&destination=Incub8+space,+Centennial+Road,+Brgy.+Batong+Dalig,+Kawit,+Cavite" target="_blank" rel="noopener noreferrer" id="get-directions-link" class="w-full bg-indigo-900 text-gray-100 font-semibold py-2 px-4 rounded-lg inline-flex items-center justify-center border-2 border-transparent hover:border-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Get Directions
</a>
<p class="text-xs mt-2 text-gray-600 font-thin text-center">
Opens Google Maps in a new tab.
</p>
</div>
</div>
<!-- End Map View -->
<script type="text/javascript">
function showMapView() {
document.getElementById('inquiry-form-view').classList.add('hidden');
document.getElementById('inquiry-map-view').classList.remove('hidden');
document.getElementById('inquiry-modal-title').textContent = 'Location & Directions';
// Placeholder: Dynamically set address for directions if needed
// const listingAddress = "Incub8 space, Centennial Road, Brgy. Batong Dalig, Kawit, Cavite"; // Or get from Liquid variable
// const directionsLink = document.getElementById('get-directions-link');
// if (directionsLink) {
// directionsLink.href = `https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(listingAddress)}`;
// }
// Placeholder: Initialize Mapbox map here if it's not already initialized
// This is a conceptual placeholder for actual Mapbox initialization logic.
// e.g., if (typeof mapboxgl !== 'undefined' && !mapInstance) {
// mapInstance = new mapboxgl.Map({ container: 'mapbox-map-container', style: 'YOUR_MAPBOX_STYLE_URL', center: [lng, lat], zoom: 15 });
// new mapboxgl.Marker().setLngLat([lng, lat]).addTo(mapInstance);
// }
}
function showFormView() {
document.getElementById('inquiry-map-view').classList.add('hidden');
document.getElementById('inquiry-form-view').classList.remove('hidden');
document.getElementById('inquiry-modal-title').textContent = 'Inquire this Listing';
}
</script>
</div> <!-- Closing div for "flex-1 overflow-y-auto p-4 sm:p-6" -->
</div> <!-- Closing div for "relative w-full h-full max-w-lg ml-auto..." -->
</aside>
<!-- End Sidebar Inquiry Modal -->