From 18a18e58afddbdb5d9bed2117e842cd639a04084 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 23 Dec 2024 00:26:13 +0100 Subject: [PATCH] fix unknown latlng when no output guessed --- js/main.js | 46 +++++++++++++++++++++++++++++----------------- js/utils.js | 1 + 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/js/main.js b/js/main.js index 868f1f2..b1ceea7 100644 --- a/js/main.js +++ b/js/main.js @@ -9,8 +9,8 @@ import utils from './utils.js' import colorUtils from './color-utils.js' console.log('config', config) -let geojsondata - +let geojsondata; +let lastLatLng; // serveurs de tuiles: https://wiki.openstreetmap.org/wiki/Tile_servers // https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png @@ -115,9 +115,12 @@ var baseLayers = { } let all_stations_markers = L.layerGroup().addTo(map) // layer group pour tous les marqueurs -let stations_much_speed_wow = L.layerGroup().addTo(map) // layer group des stations rapides +// let stations_much_speed_wow = L.layerGroup().addTo(map) // layer group des stations rapides -let overlays = {stations_bof: all_stations_markers, stations_much_speed_wow} // Si vous avez des calques superposables, ajoutez-les ici +let overlays = { + stations_bof: all_stations_markers + // , stations_much_speed_wow +} // Si vous avez des calques superposables, ajoutez-les ici const layerControl = L.control.layers(baseLayers, overlays, {collapsed: true}).addTo(map) tileGrey.addTo(map) @@ -186,7 +189,7 @@ function createJOSMEditLink(feature) { function supprimerMarqueurs() { all_stations_markers.clearLayers() - stations_much_speed_wow.clearLayers() + // stations_much_speed_wow.clearLayers() map.eachLayer((layer) => { if (layer instanceof L.Marker) { @@ -433,7 +436,17 @@ function eachFeature(feature, layer) { } else if (zoom <= 18) { ratio_circle = 0.25 } - console.log('ratio_circle', ratio_circle) + // console.log('ratio_circle', ratio_circle, feature.properties) + if (!layer._latlng) { + console.error('pas de latlng du layer', layer) + if (lastLatLng) { + + layer._latlng = lastLatLng + } + } else { + console.log('layer._latlng', layer._latlng) + lastLatLng = layer._latlng + } if (!outPowerGuessed) { radius = radius * ratio_circle } else { @@ -466,22 +479,21 @@ function eachFeature(feature, layer) { // montrer les détails quand on est proche // afficher moins de couleur, montrer le centre plus précis if (zoom > 15) { - opacity = 0.25 let circle_center = L.circle(layer._latlng, { color: 'black', fillColor: color, fillOpacity: 1, radius: 0.1 - }) - if (!outPowerGuessed) { - - circle_center.bindTooltip("?", { - permanent: true, - className: "my-label", - offset: [0, 0] - }); - } - circle_center.addTo(all_stations_markers); + }).addTo(all_stations_markers); + // if (!outPowerGuessed) { + // + // circle_center.bindTooltip("?", { + // permanent: true, + // className: "my-label", + // offset: [0, 0] + // }); + // } + // circle_center.addTo(all_stations_markers); } diff --git a/js/utils.js b/js/utils.js index f78a11d..93dee61 100644 --- a/js/utils.js +++ b/js/utils.js @@ -56,6 +56,7 @@ const utils = { } } } + console.log('outputPower', outputPower) feature.properties.outputPower = outputPower return outputPower },