Browse Source

quelques ameillorations

master
vincent 3 weeks ago
parent
commit
df3fb6aada
3 changed files with 25 additions and 17 deletions
  1. +11
    -11
      assets/controllers/map_controller.js
  2. +12
    -6
      src/Service/GeoJsonManager.php
  3. +2
    -0
      templates/home/index.html.twig

+ 11
- 11
assets/controllers/map_controller.js View File

@ -37,7 +37,7 @@ export default class extends Controller {
var layer = L.featureGroup(); var layer = L.featureGroup();
var layer2 = L.featureGroup();
var overpassLayer = L.featureGroup();
if (this.overpassResultValue !== '') { if (this.overpassResultValue !== '') {
geojsons = JSON.parse(this.overpassResultValue); geojsons = JSON.parse(this.overpassResultValue);
if (geojsons.elements.length > 0) { if (geojsons.elements.length > 0) {
@ -47,12 +47,12 @@ export default class extends Controller {
color: '#0dcaf0', color: '#0dcaf0',
weight: 6, weight: 6,
opacity: 0.8, opacity: 0.8,
}).addTo(layer2).bindPopup(L.popup({
}).addTo(overpassLayer).bindPopup(L.popup({
overpassElement: element, overpassElement: element,
}).setContent('…')); }).setContent('…'));
}); });
}); });
layer2.on('popupopen', function (event) {
overpassLayer.on('popupopen', function (event) {
var element = event.popup.options.overpassElement; var element = event.popup.options.overpassElement;
delete element.members; delete element.members;
element['map'] = { element['map'] = {
@ -69,11 +69,11 @@ export default class extends Controller {
event.popup.setContent(text); event.popup.setContent(text);
}); });
}); });
layer2.addTo(layer);
overpassLayer.addTo(layer);
} }
} }
var layer1 = L.featureGroup();
var taskLayer = L.featureGroup();
geojsons = JSON.parse(this.geojsonValue); geojsons = JSON.parse(this.geojsonValue);
if (geojsons.length > 0) { if (geojsons.length > 0) {
geojsons.forEach(function (geojson) { geojsons.forEach(function (geojson) {
@ -90,7 +90,7 @@ export default class extends Controller {
} }
return {color: color}; return {color: color};
} }
}).bindTooltip(feature0.name).addTo(layer1).on('click', function (event) {
}).bindTooltip(feature0.name).addTo(taskLayer).on('click', function (event) {
window.location.href = event.layer.feature.properties.url; window.location.href = event.layer.feature.properties.url;
}); });
@ -98,23 +98,23 @@ export default class extends Controller {
icon: icons[feature0.color], icon: icons[feature0.color],
title: feature0.name, title: feature0.name,
clickUrl: feature0.url, clickUrl: feature0.url,
}).addTo(layer1).on('click', function (event) {
}).addTo(taskLayer).on('click', function (event) {
window.location.href = event.target.options.clickUrl; window.location.href = event.target.options.clickUrl;
}); });
}); });
layer1.addTo(layer);
taskLayer.addTo(layer);
} }
layer.addTo(map); layer.addTo(map);
if (this.overpassResultValue !== '') { if (this.overpassResultValue !== '') {
L.control.layers({}, { L.control.layers({}, {
'Overpass': layer2,
'Tâches': layer1,
'Overpass': overpassLayer,
'Tâches': taskLayer,
}).addTo(map); }).addTo(map);
} }
map.fitBounds(layer1.getBounds());
map.fitBounds(taskLayer.getBounds());
} }
} }

+ 12
- 6
src/Service/GeoJsonManager.php View File

@ -29,15 +29,21 @@ class GeoJsonManager
return null; return null;
} }
if (!isset($data['features'][0]['properties'])) {
if (!isset($data['features']) or empty($data['features'])) {
return null; return null;
} }
$data['features'][0]['properties'] = array_merge($data['features'][0]['properties'], [
'name' => $task->getName(),
'url' => $this->router->generate('app_task_show', ['slug' => $task->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
'color' => $this->taskLifecycleStateMachine->getMetadataStore()->getPlaceMetadata($task->getStatus())['color'],
]);
foreach($data['features'] as $index => $feature) {
if (!isset($feature['properties'])) {
continue;
}
$feature['properties'] = array_merge($feature['properties'], [
'name' => $task->getName(),
'url' => $this->router->generate('app_task_show', ['slug' => $task->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
'color' => $this->taskLifecycleStateMachine->getMetadataStore()->getPlaceMetadata($task->getStatus())['color'],
]);
$data['features'][$index] = $feature;
}
return $data; return $data;
} }


+ 2
- 0
templates/home/index.html.twig View File

@ -4,7 +4,9 @@
<div class="px-4 py-5 my-5 text-center"> <div class="px-4 py-5 my-5 text-center">
<h1 class="display-5 fw-bold text-body-emphasis">{{ long_title }}</h1> <h1 class="display-5 fw-bold text-body-emphasis">{{ long_title }}</h1>
<div class="col-lg-6 mx-auto"> <div class="col-lg-6 mx-auto">
<p class="lead mb-4">Gère les tâches, même avec des nœuds (ou pas).</p>
<p class="lead mb-4">L’idée c’est d’avoir un petit outil collaboratif simple et facile à administrer/utiliser pour mapper des trucs de façon coordonnée à un endroit.</p> <p class="lead mb-4">L’idée c’est d’avoir un petit outil collaboratif simple et facile à administrer/utiliser pour mapper des trucs de façon coordonnée à un endroit.</p>
<p class="text-muted mb-4">Si d’aventure vous souhaitez contacter le développeur, merci d’écrire à <a href="mailto:v+osm@caboulot.org?subject={{ short_title }}">v+osm@caboulot.org</a></p>
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center"> <div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
<a class="btn btn-primary btn-lg px-4 gap-3" href="{{ path('app_project') }}">Voir les projets</a> <a class="btn btn-primary btn-lg px-4 gap-3" href="{{ path('app_project') }}">Voir les projets</a>
</div> </div>


Loading…
Cancel
Save