fix unknown latlng when no output guessed
This commit is contained in:
parent
8089d5c6a3
commit
18a18e58af
46
js/main.js
46
js/main.js
@ -9,8 +9,8 @@ import utils from './utils.js'
|
|||||||
import colorUtils from './color-utils.js'
|
import colorUtils from './color-utils.js'
|
||||||
|
|
||||||
console.log('config', config)
|
console.log('config', config)
|
||||||
let geojsondata
|
let geojsondata;
|
||||||
|
let lastLatLng;
|
||||||
|
|
||||||
// serveurs de tuiles: https://wiki.openstreetmap.org/wiki/Tile_servers
|
// serveurs de tuiles: https://wiki.openstreetmap.org/wiki/Tile_servers
|
||||||
// https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png
|
// 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 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)
|
const layerControl = L.control.layers(baseLayers, overlays, {collapsed: true}).addTo(map)
|
||||||
tileGrey.addTo(map)
|
tileGrey.addTo(map)
|
||||||
@ -186,7 +189,7 @@ function createJOSMEditLink(feature) {
|
|||||||
|
|
||||||
function supprimerMarqueurs() {
|
function supprimerMarqueurs() {
|
||||||
all_stations_markers.clearLayers()
|
all_stations_markers.clearLayers()
|
||||||
stations_much_speed_wow.clearLayers()
|
// stations_much_speed_wow.clearLayers()
|
||||||
|
|
||||||
map.eachLayer((layer) => {
|
map.eachLayer((layer) => {
|
||||||
if (layer instanceof L.Marker) {
|
if (layer instanceof L.Marker) {
|
||||||
@ -433,7 +436,17 @@ function eachFeature(feature, layer) {
|
|||||||
} else if (zoom <= 18) {
|
} else if (zoom <= 18) {
|
||||||
ratio_circle = 0.25
|
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) {
|
if (!outPowerGuessed) {
|
||||||
radius = radius * ratio_circle
|
radius = radius * ratio_circle
|
||||||
} else {
|
} else {
|
||||||
@ -466,22 +479,21 @@ function eachFeature(feature, layer) {
|
|||||||
// montrer les détails quand on est proche
|
// montrer les détails quand on est proche
|
||||||
// afficher moins de couleur, montrer le centre plus précis
|
// afficher moins de couleur, montrer le centre plus précis
|
||||||
if (zoom > 15) {
|
if (zoom > 15) {
|
||||||
opacity = 0.25
|
|
||||||
let circle_center = L.circle(layer._latlng, {
|
let circle_center = L.circle(layer._latlng, {
|
||||||
color: 'black',
|
color: 'black',
|
||||||
fillColor: color,
|
fillColor: color,
|
||||||
fillOpacity: 1,
|
fillOpacity: 1,
|
||||||
radius: 0.1
|
radius: 0.1
|
||||||
})
|
}).addTo(all_stations_markers);
|
||||||
if (!outPowerGuessed) {
|
// if (!outPowerGuessed) {
|
||||||
|
//
|
||||||
circle_center.bindTooltip("?", {
|
// circle_center.bindTooltip("?", {
|
||||||
permanent: true,
|
// permanent: true,
|
||||||
className: "my-label",
|
// className: "my-label",
|
||||||
offset: [0, 0]
|
// offset: [0, 0]
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
circle_center.addTo(all_stations_markers);
|
// circle_center.addTo(all_stations_markers);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ const utils = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('outputPower', outputPower)
|
||||||
feature.properties.outputPower = outputPower
|
feature.properties.outputPower = outputPower
|
||||||
return outputPower
|
return outputPower
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user