up emojis
This commit is contained in:
parent
205d77e2f6
commit
65956ff6be
8 changed files with 657 additions and 79 deletions
|
@ -221,6 +221,51 @@ class DemoMainResource:
|
|||
background-color: #0056b3;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Styles pour les marqueurs personnalisés avec forme de goutte */
|
||||
.custom-marker {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.marker-drop {
|
||||
width: 36px;
|
||||
height: 46px;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
border-radius: 50% 50% 50% 0;
|
||||
transform: rotate(-45deg);
|
||||
filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.marker-drop:after {
|
||||
content: '';
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
position: absolute;
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.marker-emoji {
|
||||
font-size: 18px;
|
||||
transform: rotate(45deg);
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.custom-marker:hover .marker-drop {
|
||||
transform: rotate(-45deg) scale(1.1);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -287,6 +332,63 @@ class DemoMainResource:
|
|||
</div>
|
||||
|
||||
<script>
|
||||
// Configuration des critères d'emojis pour les marqueurs de carte
|
||||
window.EMOJI_CRITERIA = {
|
||||
// Emoji mammouth pour les événements contenant "mammouth"
|
||||
mammoth: {
|
||||
emoji: '🦣',
|
||||
criteria: (name, description, what) => {
|
||||
const text = (name + ' ' + description).toLowerCase();
|
||||
return text.includes('mammouth');
|
||||
}
|
||||
},
|
||||
// Emoji notes de musique pour orchestres, concerts, fanfares ou types musicaux
|
||||
music: {
|
||||
emoji: '🎵',
|
||||
criteria: (name, description, what) => {
|
||||
const text = (name + ' ' + description + ' ' + what).toLowerCase();
|
||||
return text.includes('orchestr') || text.includes('concert') ||
|
||||
text.includes('fanfare') || text.includes('music');
|
||||
}
|
||||
},
|
||||
// Emoji éclair pour les types contenant "power"
|
||||
power: {
|
||||
emoji: '⚡',
|
||||
criteria: (name, description, what) => {
|
||||
return (what || '').toLowerCase().includes('power');
|
||||
}
|
||||
},
|
||||
// Emoji vélo pour les types contenant "bike"
|
||||
bike: {
|
||||
emoji: '🚴',
|
||||
criteria: (name, description, what) => {
|
||||
return (what || '').toLowerCase().includes('bike');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Fonction pour déterminer l'emoji approprié pour un événement
|
||||
function getEventEmoji(properties) {
|
||||
const name = properties.name || properties.label || '';
|
||||
const description = properties.description || '';
|
||||
const what = properties.what || '';
|
||||
|
||||
// Parcourir les critères dans l'ordre de priorité
|
||||
for (const [key, config] of Object.entries(window.EMOJI_CRITERIA)) {
|
||||
if (config.criteria(name, description, what)) {
|
||||
return config.emoji;
|
||||
}
|
||||
}
|
||||
|
||||
// Emoji par défaut selon le type d'événement
|
||||
if (what.includes('traffic')) return '🚗';
|
||||
if (what.includes('weather')) return '🌤️';
|
||||
if (what.includes('gathering')) return '👥';
|
||||
if (what.includes('incident')) return '⚠️';
|
||||
|
||||
return '📍'; // Emoji par défaut
|
||||
}
|
||||
|
||||
// Fonction pour gérer les listes dépliantes et sections collapsibles
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const filtersPanel = document.getElementById('filters_panel');
|
||||
|
@ -327,27 +429,16 @@ class DemoMainResource:
|
|||
if (!geojsonData || !geojsonData.features) return;
|
||||
|
||||
geojsonData.features.forEach(feature => {
|
||||
// Créer un élément HTML pour le marqueur
|
||||
// Créer un élément HTML pour le marqueur avec emoji et forme de goutte
|
||||
const el = document.createElement('div');
|
||||
el.className = 'event-marker';
|
||||
el.style.width = '20px';
|
||||
el.style.height = '20px';
|
||||
el.style.borderRadius = '50%';
|
||||
el.className = 'custom-marker';
|
||||
|
||||
// Déterminer la couleur selon le type d'événement
|
||||
let color = '#0078ff';
|
||||
const eventType = feature.properties.what;
|
||||
if (eventType) {
|
||||
if (eventType.includes('traffic')) color = '#F44336';
|
||||
else if (eventType.includes('weather')) color = '#4CAF50';
|
||||
else if (eventType.includes('gathering')) color = '#FF9800';
|
||||
else if (eventType.includes('incident')) color = '#9C27B0';
|
||||
}
|
||||
|
||||
el.style.backgroundColor = color;
|
||||
el.style.border = '2px solid white';
|
||||
el.style.boxShadow = '0 0 5px rgba(0,0,0,0.3)';
|
||||
el.style.cursor = 'pointer';
|
||||
// Créer la forme de goutte en arrière-plan
|
||||
el.innerHTML = `
|
||||
<div class="marker-drop">
|
||||
<div class="marker-emoji">${getEventEmoji(feature.properties)}</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Créer le contenu de la popup
|
||||
const popupContent = createEventPopupContent(feature);
|
||||
|
@ -399,6 +490,29 @@ class DemoMainResource:
|
|||
}
|
||||
}
|
||||
|
||||
// Fonction pour lire les paramètres de requête
|
||||
function getUrlParams() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return {
|
||||
lat: params.get('lat'),
|
||||
lon: params.get('lon'),
|
||||
zoom: params.get('zoom')
|
||||
};
|
||||
}
|
||||
|
||||
// Fonction pour mettre à jour l'URL avec les paramètres de position de la carte
|
||||
function updateUrlParams(lat, lon, zoom) {
|
||||
const url = new URL(window.location);
|
||||
url.searchParams.set('lat', lat.toFixed(6));
|
||||
url.searchParams.set('lon', lon.toFixed(6));
|
||||
url.searchParams.set('zoom', zoom.toFixed(2));
|
||||
window.history.replaceState(null, '', url);
|
||||
}
|
||||
|
||||
// Vérifier si des paramètres de position sont présents dans l'URL
|
||||
const urlParams = getUrlParams();
|
||||
const hasPositionParams = urlParams.lat && urlParams.lon && urlParams.zoom;
|
||||
|
||||
// Map style URLs
|
||||
const mapStyles = {
|
||||
default: 'https://tiles.openfreemap.org/styles/liberty',
|
||||
|
@ -427,12 +541,22 @@ class DemoMainResource:
|
|||
}
|
||||
};
|
||||
|
||||
// Déterminer le centre et le zoom initial
|
||||
let initialCenter = [2.3522, 48.8566]; // Default center (Paris)
|
||||
let initialZoom = 4;
|
||||
|
||||
if (hasPositionParams) {
|
||||
initialCenter = [parseFloat(urlParams.lon), parseFloat(urlParams.lat)];
|
||||
initialZoom = parseFloat(urlParams.zoom);
|
||||
console.log(`📍 Position depuis l'URL: lat=${urlParams.lat}, lon=${urlParams.lon}, zoom=${urlParams.zoom}`);
|
||||
}
|
||||
|
||||
// Initialize the map with default style
|
||||
const map = new maplibregl.Map({
|
||||
container: 'map',
|
||||
style: mapStyles.default,
|
||||
center: [2.3522, 48.8566], // Default center (Paris)
|
||||
zoom: 4
|
||||
center: initialCenter,
|
||||
zoom: initialZoom
|
||||
});
|
||||
|
||||
// Add navigation controls
|
||||
|
@ -451,6 +575,18 @@ class DemoMainResource:
|
|||
map.addControl(new maplibregl.AttributionControl({
|
||||
customAttribution: '© <a href="https://www.openstreetmap.org/copyright" >OpenStreetMap</a> contributors'
|
||||
}));
|
||||
|
||||
// Ajouter un listener pour mettre à jour l'URL quand la carte bouge
|
||||
let updateUrlTimeout;
|
||||
map.on('moveend', function() {
|
||||
// Utiliser un timeout pour éviter de trop nombreuses mises à jour
|
||||
clearTimeout(updateUrlTimeout);
|
||||
updateUrlTimeout = setTimeout(() => {
|
||||
const center = map.getCenter();
|
||||
const zoom = map.getZoom();
|
||||
updateUrlParams(center.lat, center.lng, zoom);
|
||||
}, 300); // Attendre 300ms après la fin du mouvement
|
||||
});
|
||||
|
||||
// Style switcher functionality
|
||||
let currentStyle = 'default';
|
||||
|
@ -743,12 +879,16 @@ class DemoMainResource:
|
|||
iconColor = '#23d160'; // Green
|
||||
}
|
||||
|
||||
// Create custom HTML element for marker
|
||||
// Create custom HTML element for marker with emoji and drop shape
|
||||
const el = document.createElement('div');
|
||||
el.className = 'marker';
|
||||
el.innerHTML = `<span class="icon" style="background-color: white; border-radius: 50%; padding: 8px; box-shadow: 0 0 5px rgba(0,0,0,0.3);">
|
||||
<i class="fas fa-${iconClass}" style="color: ${iconColor}; font-size: 16px;"></i>
|
||||
</span>`;
|
||||
el.className = 'custom-marker';
|
||||
|
||||
// Créer la forme de goutte en arrière-plan avec emoji
|
||||
el.innerHTML = `
|
||||
<div class="marker-drop">
|
||||
<div class="marker-emoji">${getEventEmoji(properties)}</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Add marker with popup and store reference
|
||||
const marker = new maplibregl.Marker(el)
|
||||
|
|
|
@ -517,9 +517,9 @@ button:hover {
|
|||
}
|
||||
|
||||
#report_issue_button{
|
||||
position: fixed;
|
||||
bottom: 0.5rem;
|
||||
right: 0.5rem;
|
||||
/*position: fixed;*/
|
||||
/*bottom: 0.5rem;*/
|
||||
/*right: 0.5rem;*/
|
||||
padding: 2rem 1rem;
|
||||
}
|
||||
|
||||
|
@ -634,4 +634,8 @@ button{
|
|||
|
||||
.maplibregl-ctrl-attrib + .maplibregl-ctrl-attrib {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.icon{
|
||||
/*background-color: white; border-radius: 50%; padding: 8px; box-shadow: 0 0 5px rgba(0,0,0,0.3);*/
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
|
||||
// Variable globale pour les données de l'événement
|
||||
let eventData = null
|
||||
|
||||
// Initialize the map
|
||||
const map = new maplibregl.Map({
|
||||
container: 'map',
|
||||
|
@ -18,9 +22,7 @@ map.addControl(new maplibregl.AttributionControl({
|
|||
let marker = new maplibregl.Marker({
|
||||
draggable: true
|
||||
});
|
||||
|
||||
// Variable globale pour les données de l'événement
|
||||
let eventData = null;
|
||||
;
|
||||
|
||||
// Function to populate form with event data
|
||||
function populateForm() {
|
||||
|
|
|
@ -247,12 +247,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="photo">Photos</label>
|
||||
<input type="file" id="photo" name="photo" accept="image/*" multiple>
|
||||
<div class="note">Vous pouvez ajouter plusieurs photos (optionnel)</div>
|
||||
<div id="photoPreview" class="photo-preview-container"></div>
|
||||
</div>
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label for="photo">Photos</label>-->
|
||||
<!-- <input type="file" id="photo" name="photo" accept="image/*" multiple>-->
|
||||
<!-- <div class="note">Vous pouvez ajouter plusieurs photos (optionnel)</div>-->
|
||||
<!-- <div id="photoPreview" class="photo-preview-container"></div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="required">Localisation</label>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue