Spaces:
Running
Running
Download mapa.html from ravamarcos/paws-paths-community: direct link, hf CLI and curl.
- Browser
- Download file 24.1 kB
-
https://huggingface.co/spaces/ravamarcos/paws-paths-community/resolve/main/mapa.html
- Command line
-
hf download hf://spaces/ravamarcos/paws-paths-community/mapa.html
-
curl -L -o mapa.html https://huggingface.co/spaces/ravamarcos/paws-paths-community/resolve/main/mapa.html
24.1 kB
| <html lang="es" x-data="{ filtersOpen: false }"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Mapa Interactivo - Paws & Paths</title> | |
| <link rel="icon" type="image/x-icon" href="/static/favicon.ico"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js" defer></script> | |
| <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" /> | |
| <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script> | |
| <style> | |
| body, html { | |
| height: 100%; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| #map { | |
| height: 100vh; | |
| width: 100%; | |
| z-index: 0; | |
| } | |
| .leaflet-div-icon { | |
| background: transparent; | |
| border: none; | |
| } | |
| .custom-icon { | |
| background: white; | |
| width: 40px; | |
| height: 40px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| border-radius: 50%; | |
| border: 3px solid white; | |
| box-shadow: 0 0 10px rgba(0,0,0,0.2); | |
| } | |
| .custom-icon i { | |
| width: 24px; | |
| height: 24px; | |
| stroke-width: 2; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <!-- Header with improved controls --> | |
| <div class="bg-white shadow-md"> | |
| <div class="max-w-7xl mx-auto px-4 py-4 flex items-center justify-between"> | |
| <a href="index.html" class="flex items-center text-gray-800 hover:text-green-600"> | |
| <i data-feather="arrow-left" class="mr-2"></i> | |
| <span class="font-medium">Mapa Comunitario</span> | |
| </a> | |
| <div class="flex items-center space-x-4"> | |
| <button @click="filtersOpen = !filtersOpen" class="bg-gray-100 p-2 rounded-full hover:bg-gray-200 transition"> | |
| <i data-feather="filter"></i> | |
| </button> | |
| <button @click="openReport()" class="bg-green-600 text-white p-2 rounded-full hover:bg-green-700 transition"> | |
| <i data-feather="plus"></i> | |
| </button> | |
| <button @click="locateUser()" class="bg-blue-100 text-blue-600 p-2 rounded-full hover:bg-blue-200 transition"> | |
| <i data-feather="crosshair"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Map Container with Sidebar --> | |
| <div class="flex flex-col md:flex-row h-[calc(100vh-64px)]"> | |
| <!-- Sidebar --> | |
| <div x-show="sidebarOpen" @click.away="sidebarOpen = false" | |
| class="w-full md:w-80 bg-white shadow-lg z-10 overflow-y-auto"> | |
| <div class="p-4"> | |
| <h3 class="text-lg font-semibold mb-4 flex items-center"> | |
| <i data-feather="map-pin" class="mr-2 text-green-600"></i> | |
| Puntos cercanos | |
| </h3> | |
| <div class="space-y-4"> | |
| <div class="bg-gray-50 p-3 rounded-lg border border-gray-200 hover:border-green-300 cursor-pointer"> | |
| <div class="flex items-start"> | |
| <div class="bg-green-100 p-2 rounded-full mr-3"> | |
| <i data-feather="users" class="text-green-600"></i> | |
| </div> | |
| <div> | |
| <h4 class="font-medium">Grupo de paseo</h4> | |
| <p class="text-sm text-gray-500">10-12am en Plaza Mayor</p> | |
| <div class="flex items-center mt-1 text-xs text-gray-400"> | |
| <i data-feather="user" class="w-3 h-3 mr-1"></i> | |
| <span>5 personas confirmadas</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-gray-50 p-3 rounded-lg border border-gray-200 hover:border-green-300 cursor-pointer"> | |
| <div class="flex items-start"> | |
| <div class="bg-yellow-100 p-2 rounded-full mr-3"> | |
| <i data-feather="alert-triangle" class="text-yellow-600"></i> | |
| </div> | |
| <div> | |
| <h4 class="font-medium">脕rea con obras</h4> | |
| <p class="text-sm text-gray-500">Calle Alcal谩 100-120</p> | |
| <div class="flex items-center mt-1 text-xs text-gray-400"> | |
| <i data-feather="clock" class="w-3 h-3 mr-1"></i> | |
| <span>Reportado hoy</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Main Map --> | |
| <div id="map" class="flex-1"></div> | |
| </div> | |
| <!-- Bottom Controls --> | |
| <div class="fixed bottom-4 left-1/2 transform -translate-x-1/2 flex space-x-4 z-10"> | |
| <button @click="toggleSidebar()" class="bg-white p-3 rounded-full shadow-lg hover:bg-gray-50"> | |
| <i data-feather="list"></i> | |
| </button> | |
| </div> | |
| <!-- Report Modal --> | |
| <div x-show="reportOpen" @click.away="reportOpen = false" | |
| class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4"> | |
| <div class="bg-white rounded-xl p-6 w-full max-w-md"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-semibold text-green-700">Reportar en el mapa</h3> | |
| <button @click="reportOpen = false" class="text-gray-500 hover:text-gray-700"> | |
| <i data-feather="x"></i> | |
| </button> | |
| </div> | |
| <div class="space-y-4"> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Tipo de reporte</label> | |
| <select x-model="reportType" class="w-full border border-gray-300 rounded-md p-2"> | |
| <option value="meetup">Quedada para pasear</option> | |
| <option value="warning">Advertencia (obras, peligros)</option> | |
| <option value="lost">Mascota perdida</option> | |
| <option value="other">Otro</option> | |
| </select> | |
| </div> | |
| <div x-show="reportType === 'meetup'"> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Fecha y hora</label> | |
| <input type="datetime-local" class="w-full border border-gray-300 rounded-md p-2"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Descripci贸n</label> | |
| <textarea class="w-full border border-gray-300 rounded-md p-2" rows="3" placeholder="Proporciona detalles..."></textarea> | |
| </div> | |
| <div class="flex justify-end space-x-3"> | |
| <button @click="reportOpen = false" class="px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-50"> | |
| Cancelar | |
| </button> | |
| <button @click="submitReport()" class="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 flex items-center"> | |
| <i data-feather="send" class="w-4 h-4 mr-1"></i> Enviar | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| feather.replace(); | |
| // Alpine.js data | |
| const app = { | |
| sidebarOpen: true, | |
| reportOpen: false, | |
| reportType: 'meetup', | |
| userLocation: null, | |
| userMarker: null, | |
| markers: [], | |
| map: null, | |
| loading: false, | |
| error: null | |
| }; | |
| // Friendly messages | |
| const messages = { | |
| locationError: 'No pudimos obtener tu ubicaci贸n. Por favor activa los permisos de ubicaci贸n o intenta nuevamente.', | |
| reportSuccess: '隆Reporte enviado con 茅xito! Se ha agregado al mapa.', | |
| genericError: 'Algo sali贸 mal. Por favor intenta nuevamente.' | |
| }; | |
| // Initialize map with better defaults | |
| app.map = L.map('map', { | |
| center: [40.4168, -3.7038], | |
| zoom: 14, | |
| zoomControl: false, // We'll add our own | |
| touchZoom: true, | |
| scrollWheelZoom: true, | |
| doubleClickZoom: true, | |
| boxZoom: true, | |
| dragging: true | |
| }); | |
| // Add tile layer with better contrast | |
| L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png', { | |
| attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>', | |
| subdomains: 'abcd', | |
| maxZoom: 19 | |
| }).addTo(app.map); | |
| // Better controls | |
| L.control.zoom({ | |
| position: 'topright' | |
| }).addTo(app.map); | |
| L.control.scale({ | |
| position: 'bottomleft', | |
| imperial: false | |
| }).addTo(app.map); | |
| // Improved custom icons with tooltips | |
| function createIcon(type) { | |
| let iconClass, color, tooltip; | |
| switch(type) { | |
| case 'user': | |
| iconClass = 'user'; | |
| color = '#3b82f6'; | |
| tooltip = 'Tu ubicaci贸n'; | |
| break; | |
| case 'meetup': | |
| iconClass = 'users'; | |
| color = '#10b981'; | |
| tooltip = 'Grupo de paseo'; | |
| break; | |
| case 'warning': | |
| iconClass = 'alert-triangle'; | |
| color = '#f59e0b'; | |
| tooltip = 'Advertencia'; | |
| break; | |
| case 'lost': | |
| iconClass = 'heart'; | |
| color = '#ef4444'; | |
| tooltip = 'Mascota perdida'; | |
| break; | |
| default: | |
| iconClass = 'map-pin'; | |
| color = '#6b7280'; | |
| tooltip = 'Punto de inter茅s'; | |
| } | |
| return L.divIcon({ | |
| className: 'custom-icon-container', | |
| html: ` | |
| <div class="custom-icon" style="border-color: ${color}" | |
| title="${tooltip}" data-toggle="tooltip"> | |
| <i data-feather="${iconClass}" style="color: ${color}"></i> | |
| </div> | |
| `, | |
| iconSize: [40, 40], | |
| iconAnchor: [20, 40], | |
| popupAnchor: [0, -40] | |
| }); | |
| } | |
| // Improved locate user function with feedback | |
| app.locateUser = function() { | |
| app.loading = true; | |
| app.error = null; | |
| if (navigator.geolocation) { | |
| navigator.geolocation.getCurrentPosition( | |
| position => { | |
| const { latitude, longitude } = position.coords; | |
| app.userLocation = [latitude, longitude]; | |
| // Remove previous user marker if exists | |
| if (app.userMarker) { | |
| app.map.removeLayer(app.userMarker); | |
| } | |
| // Add new marker with better popup | |
| app.userMarker = L.marker([latitude, longitude], { | |
| icon: createIcon('user') | |
| }).addTo(app.map) | |
| .bindPopup(` | |
| <div class="p-2"> | |
| <h3 class="font-bold text-blue-600">Est谩s aqu铆</h3> | |
| <p class="text-sm text-gray-600">Precisi贸n: ${position.coords.accuracy.toFixed(0)} metros</p> | |
| </div> | |
| `).openPopup(); | |
| // Center map on user with smooth transition | |
| app.map.flyTo([latitude, longitude], 16, { | |
| duration: 1, | |
| easeLinearity: 0.25 | |
| }); | |
| app.loading = false; | |
| }, | |
| error => { | |
| console.error('Geolocation error:', error); | |
| app.error = messages.locationError; | |
| app.loading = false; | |
| // Show error in UI | |
| const errorElement = document.getElementById('locationError'); | |
| if (errorElement) { | |
| errorElement.textContent = app.error; | |
| errorElement.classList.remove('hidden'); | |
| setTimeout(() => errorElement.classList.add('hidden'), 5000); | |
| } | |
| }, | |
| { | |
| enableHighAccuracy: true, | |
| timeout: 15000, | |
| maximumAge: 30000 | |
| } | |
| ); | |
| } else { | |
| app.error = 'Tu navegador no soporta geolocalizaci贸n'; | |
| app.loading = false; | |
| } | |
| }; | |
| // Enhanced report submission with validation | |
| app.submitReport = function() { | |
| if (!app.userLocation) { | |
| app.error = messages.locationError; | |
| return; | |
| } | |
| const description = document.getElementById('reportDescription').value; | |
| if (!description || description.length < 10) { | |
| app.error = 'Por favor ingresa una descripci贸n detallada (m铆nimo 10 caracteres)'; | |
| return; | |
| } | |
| app.loading = true; | |
| try { | |
| // Simulate API call | |
| setTimeout(() => { | |
| const marker = L.marker(app.userLocation, { | |
| icon: createIcon(app.reportType) | |
| }).addTo(app.map) | |
| .bindPopup(` | |
| <div class="p-2"> | |
| <h3 class="font-bold mb-1 ${app.reportType === 'meetup' ? 'text-green-600' : | |
| app.reportType === 'warning' ? 'text-yellow-600' : 'text-red-600'}"> | |
| ${app.reportType === 'meetup' ? 'Quedada' : | |
| app.reportType === 'warning' ? 'Advertencia' : 'Mascota perdida'} | |
| </h3> | |
| <p class="text-sm text-gray-600">${new Date().toLocaleString()}</p> | |
| <p class="mt-2 text-gray-700">${description}</p> | |
| </div> | |
| `).openPopup(); | |
| app.markers.push(marker); | |
| app.reportOpen = false; | |
| app.loading = false; | |
| // Show success message | |
| const successElement = document.getElementById('reportSuccess'); | |
| successElement.textContent = messages.reportSuccess; | |
| successElement.classList.remove('hidden'); | |
| setTimeout(() => successElement.classList.add('hidden'), 3000); | |
| }, 1000); | |
| } catch (error) { | |
| console.error('Error submitting report:', error); | |
| app.error = messages.genericError; | |
| app.loading = false; | |
| } | |
| }; | |
| // Initialize with better sample data | |
| function addSampleMarkers() { | |
| const sampleMarkers = [ | |
| { | |
| lat: 40.4168, | |
| lng: -3.7038, | |
| type: 'meetup', | |
| title: 'Grupo de paseo Retiro', | |
| description: 'Quedada los s谩bados a las 10am. Todos los tama帽os bienvenidos!', | |
| date: new Date().toLocaleDateString() | |
| }, | |
| { | |
| lat: 40.4152, | |
| lng: -3.7015, | |
| type: 'warning', | |
| title: 'Obras en acera', | |
| description: 'Acera cerrada por obras hasta el 15/06. Usar el otro lado de la calle.', | |
| date: new Date().toLocaleDateString() | |
| }, | |
| { | |
| lat: 40.4175, | |
| lng: -3.7050, | |
| type: 'lost', | |
| title: 'Gato perdido', | |
| description: 'Gato atigrado con collar azul. Se perdi贸 el 10/05. Recompensa.', | |
| date: '10/05/2023' | |
| } | |
| ]; | |
| sampleMarkers.forEach(marker => { | |
| const m = L.marker([marker.lat, marker.lng], { | |
| icon: createIcon(marker.type) | |
| }).addTo(app.map) | |
| .bindPopup(` | |
| <div class="p-2"> | |
| <h3 class="font-bold ${marker.type === 'meetup' ? 'text-green-600' : | |
| marker.type === 'warning' ? 'text-yellow-600' : 'text-red-600'}"> | |
| ${marker.title} | |
| </h3> | |
| <p class="text-xs text-gray-500">${marker.date}</p> | |
| <p class="mt-2 text-gray-700">${marker.description}</p> | |
| ${marker.type === 'lost' ? | |
| `<button class="mt-2 w-full bg-red-100 text-red-700 py-1 rounded text-xs"> | |
| <i data-feather="bell" class="w-3 h-3 inline mr-1"></i> Reportar avistamiento | |
| </button>` : ''} | |
| </div> | |
| `); | |
| app.markers.push(m); | |
| }); | |
| } | |
| // Initialize | |
| document.addEventListener('alpine:init', () => { | |
| Alpine.data('mapApp', () => ({ | |
| ...app, | |
| init() { | |
| addSampleMarkers(); | |
| this.locateUser(); | |
| // Add event listeners for all buttons | |
| document.querySelectorAll('[x-on\\:click]').forEach(button => { | |
| const action = button.getAttribute('x-on:click'); | |
| if (action === 'locateUser()') { | |
| button.addEventListener('click', () => this.locateUser()); | |
| } else if (action === 'submitReport()') { | |
| button.addEventListener('click', () => this.submitReport()); | |
| } | |
| }); | |
| // Update UI when loading changes | |
| this.$watch('loading', (value) => { | |
| const loader = document.getElementById('loader'); | |
| if (loader) loader.style.display = value ? 'block' : 'none'; | |
| }); | |
| }, | |
| toggleSidebar() { | |
| this.sidebarOpen = !this.sidebarOpen; | |
| }, | |
| openReport() { | |
| this.reportOpen = true; | |
| } | |
| })); | |
| }); | |
| // Make sure buttons work on page load | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const mapApp = Alpine.data('mapApp'); | |
| if (mapApp) { | |
| const appInstance = mapApp(); | |
| document.querySelector('[x-on\\:click="locateUser()"]').addEventListener('click', () => appInstance.locateUser()); | |
| document.querySelector('[x-on\\:click="submitReport()"]').addEventListener('click', () => appInstance.submitReport()); | |
| } | |
| }); | |
| // Initialize tooltips | |
| feather.replace(); | |
| // Add UI feedback elements | |
| const loader = document.createElement('div'); | |
| loader.id = 'loader'; | |
| loader.className = 'hidden fixed top-4 right-4 bg-white p-3 rounded-lg shadow-lg flex items-center'; | |
| loader.innerHTML = ` | |
| <div class="animate-spin rounded-full h-5 w-5 border-b-2 border-green-600 mr-2"></div> | |
| <span>Cargando...</span> | |
| `; | |
| document.body.appendChild(loader); | |
| const errorElement = document.createElement('div'); | |
| errorElement.id = 'locationError'; | |
| errorElement.className = 'hidden fixed top-4 right-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded'; | |
| document.body.appendChild(errorElement); | |
| const successElement = document.createElement('div'); | |
| successElement.id = 'reportSuccess'; | |
| successElement.className = 'hidden fixed top-4 right-4 bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded'; | |
| document.body.appendChild(successElement); | |
| }); | |
| </script> | |
| <style> | |
| /* Improved styles for better UX */ | |
| .custom-icon-container { | |
| filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); | |
| } | |
| .custom-icon { | |
| transition: all 0.2s ease; | |
| } | |
| .custom-icon:hover { | |
| transform: scale(1.1); | |
| box-shadow: 0 0 15px rgba(0,0,0,0.2); | |
| } | |
| .leaflet-popup-content { | |
| margin: 12px ; | |
| min-width: 200px; | |
| } | |
| .leaflet-popup-content-wrapper { | |
| border-radius: 12px ; | |
| box-shadow: 0 3px 14px rgba(0,0,0,0.15); | |
| } | |
| .leaflet-control-layers { | |
| border-radius: 8px ; | |
| overflow: hidden; | |
| box-shadow: 0 1px 5px rgba(0,0,0,0.15); | |
| } | |
| #loader, #locationError, #reportSuccess { | |
| z-index: 1001; | |
| animation: fadeIn 0.3s ease; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(-10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .report-modal { | |
| animation: modalFadeIn 0.3s ease; | |
| } | |
| @keyframes modalFadeIn { | |
| from { opacity: 0; transform: scale(0.9); } | |
| to { opacity: 1; transform: scale(1); } | |
| } | |
| </style> | |
| </body> | |
| </html> | |