Browse Source

quelques ameillorations

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


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

@ -4,7 +4,9 @@
<div class="px-4 py-5 my-5 text-center">
<h1 class="display-5 fw-bold text-body-emphasis">{{ long_title }}</h1>
<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="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">
<a class="btn btn-primary btn-lg px-4 gap-3" href="{{ path('app_project') }}">Voir les projets</a>
</div>


Loading…
Cancel
Save