mirror of
https://forge.chapril.org/tykayn/libre-charge-map
synced 2025-06-20 01:34:43 +02:00
add osmose count
This commit is contained in:
parent
c1a76c9701
commit
f1bdb81723
5 changed files with 32 additions and 13 deletions
|
@ -341,6 +341,9 @@ function calculerPourcentage(partie, total, reduc) {
|
|||
return ((partie / total) * 100 * coef_reduction).toFixed(1)
|
||||
}
|
||||
|
||||
// Ajouter une variable globale pour stocker le nombre d'issues Osmose
|
||||
let osmoseIssuesCount = 0;
|
||||
|
||||
function displayStatsFromGeoJson(resultAsGeojson) {
|
||||
let count = resultAsGeojson.features.length;
|
||||
let count_station_output = 0;
|
||||
|
@ -457,6 +460,16 @@ function displayStatsFromGeoJson(resultAsGeojson) {
|
|||
|
||||
$('#found_charging_stations').html(stats_content);
|
||||
$('#bars_power').html(bar_powers);
|
||||
|
||||
// Remplacer la ligne existante par un appel à updateCounters
|
||||
updateCounters();
|
||||
}
|
||||
|
||||
// Ajouter une fonction pour mettre à jour les compteurs
|
||||
function updateCounters() {
|
||||
const stationsCount = geojsondata ? geojsondata.features.length : 0;
|
||||
const osmoseText = osmoseIssuesCount > 0 ? ` (${osmoseIssuesCount} )` : '';
|
||||
$('#count_features_fond').html(`⚡${stationsCount}${osmoseText} stations`);
|
||||
}
|
||||
|
||||
// Modifier bindEventsOnJosmRemote pour cibler les boutons dans un contexte (la popup)
|
||||
|
@ -1074,10 +1087,13 @@ function searchOsmoseIssues(map) {
|
|||
.then(data => {
|
||||
if (!data || !Array.isArray(data.issues)) {
|
||||
console.warn("Réponse Osmose (liste) inattendue ou pas d'issues:", data);
|
||||
osmoseIssuesCount = 0;
|
||||
updateCounters();
|
||||
return;
|
||||
}
|
||||
const issuesList = data.issues;
|
||||
console.log(`Nombre d'issues Osmose (liste) trouvées: ${issuesList.length}`);
|
||||
osmoseIssuesCount = issuesList.length;
|
||||
console.log(`Nombre d'issues Osmose (liste) trouvées: ${osmoseIssuesCount}`);
|
||||
|
||||
issuesList.forEach(issueInfo => {
|
||||
if (issueInfo.lat == null || issueInfo.lon == null || !issueInfo.id) {
|
||||
|
@ -1173,9 +1189,13 @@ function searchOsmoseIssues(map) {
|
|||
|
||||
osmose_markers.addLayer(osmoseMarker);
|
||||
});
|
||||
|
||||
updateCounters(); // Mettre à jour l'affichage après le traitement
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erreur détaillée lors de la recherche de la liste des issues Osmose:', error);
|
||||
osmoseIssuesCount = 0;
|
||||
updateCounters();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue