up pages
This commit is contained in:
parent
2bb77d2300
commit
98c40b2447
16 changed files with 1836 additions and 361 deletions
|
@ -44,6 +44,8 @@ class DemoMainResource:
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>OpenEventDatabase Demo</title>
|
||||
<link rel="icon" type="image/png" href="/static/oedb.png">
|
||||
<link rel="icon" type="image/png" href="/static/oedb.png">
|
||||
<script src="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.js"></script>
|
||||
<link href="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.css" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||
|
@ -287,38 +289,24 @@ class DemoMainResource:
|
|||
<script>
|
||||
// Fonction pour gérer les listes dépliantes et sections collapsibles
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const endpointsHeader = document.getElementById('endpoints_list_header');
|
||||
const endpointsList = document.getElementById('endpoints_list');
|
||||
const demoPagesHeader = document.getElementById('demo_pages_list_header');
|
||||
const demoPagesList = document.getElementById('demo_pages_list');
|
||||
const infoPanelHeader = document.getElementById('info_panel_header');
|
||||
const infoPanelContent = document.getElementById('info_panel_content');
|
||||
const filtersPanel = document.getElementById('filters_panel');
|
||||
const filtersHeader = document.getElementById('filters_header');
|
||||
|
||||
// Fonction pour basculer l'affichage d'une liste ou section
|
||||
function toggleList(header, list) {
|
||||
header.addEventListener('click', function() {
|
||||
if (list.style.display === 'none' || list.style.display === '') {
|
||||
list.style.display = 'block';
|
||||
header.classList.add('active');
|
||||
} else {
|
||||
list.style.display = 'none';
|
||||
header.classList.remove('active');
|
||||
}
|
||||
});
|
||||
if (header && list) {
|
||||
header.addEventListener('click', function() {
|
||||
if (list.style.display === 'none' || list.style.display === '') {
|
||||
list.style.display = 'block';
|
||||
header.classList.add('active');
|
||||
} else {
|
||||
list.style.display = 'none';
|
||||
header.classList.remove('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Initialiser les listes et sections comme repliées
|
||||
endpointsList.style.display = 'none';
|
||||
demoPagesList.style.display = 'none';
|
||||
infoPanelContent.style.display = 'none';
|
||||
|
||||
// Ajouter les écouteurs d'événements
|
||||
toggleList(endpointsHeader, endpointsList);
|
||||
toggleList(demoPagesHeader, demoPagesList);
|
||||
toggleList(infoPanelHeader, infoPanelContent);
|
||||
|
||||
// Toggle pour le panneau de filtres via le titre "Filtres"
|
||||
if (filtersHeader && filtersPanel) {
|
||||
filtersHeader.addEventListener('click', function() {
|
||||
|
@ -331,8 +319,9 @@ class DemoMainResource:
|
|||
}
|
||||
});
|
||||
|
||||
// Variable globale pour stocker les marqueurs d'événements
|
||||
// Variables globales pour stocker les marqueurs d'événements et le premier chargement
|
||||
window.eventMarkers = [];
|
||||
window.isFirstLoad = true;
|
||||
|
||||
function addEventsToMap(geojsonData) {
|
||||
if (!geojsonData || !geojsonData.features) return;
|
||||
|
@ -533,6 +522,8 @@ class DemoMainResource:
|
|||
|
||||
// Function to fetch events from the API
|
||||
function fetchEvents() {
|
||||
console.log('🔄 Chargement des événements...', isFirstLoad ? '(Premier chargement)' : '(Rechargement)');
|
||||
|
||||
// Fetch events from the API - using the local API endpoint
|
||||
fetch('https://api.openeventdatabase.org/event?')
|
||||
.then(response => response.json())
|
||||
|
@ -542,8 +533,8 @@ class DemoMainResource:
|
|||
addEventsToMap(data);
|
||||
// Render histogram for retrieved events
|
||||
try { renderEventsHistogram(data.features); } catch(e) { console.warn('Histogram error', e); }
|
||||
|
||||
// Fit map to events bounds
|
||||
|
||||
// Fit map to events bounds (seulement au premier chargement)
|
||||
fitMapToBounds(data);
|
||||
} else {
|
||||
console.log('No events found');
|
||||
|
@ -826,23 +817,29 @@ class DemoMainResource:
|
|||
return (currentTime - createTime) > oneHourInMs;
|
||||
}
|
||||
|
||||
// Function to fit map to events bounds
|
||||
// Function to fit map to events bounds (only on first load)
|
||||
function fitMapToBounds(geojson) {
|
||||
if (geojson.features.length === 0) return;
|
||||
|
||||
if (geojson.features.length === 0 || !window.isFirstLoad) return;
|
||||
|
||||
console.log('🎯 Premier chargement - Ajustement de la vue sur les événements');
|
||||
|
||||
// Create a bounds object
|
||||
const bounds = new maplibregl.LngLatBounds();
|
||||
|
||||
|
||||
// Extend bounds with each feature
|
||||
geojson.features.forEach(feature => {
|
||||
bounds.extend(feature.geometry.coordinates);
|
||||
});
|
||||
|
||||
|
||||
// Fit map to bounds with padding
|
||||
map.fitBounds(bounds, {
|
||||
padding: 50,
|
||||
maxZoom: 12
|
||||
});
|
||||
|
||||
// Marquer que le premier chargement est terminé
|
||||
window.isFirstLoad = false;
|
||||
console.log('✅ Vue initiale définie, les prochains rafraîchissements ne déplaceront plus la carte');
|
||||
}
|
||||
|
||||
// Function to update user information display
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue