add keys to display

This commit is contained in:
Tykayn 2024-10-18 00:47:01 +02:00 committed by tykayn
parent 499d79f18d
commit 0d9d327c5a

View File

@ -3,10 +3,13 @@
const overrideQuery = true
const initialZoom = 14
const osmMention = '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors'
let unknown_color = '#676767' // color for unknown power output of the station
// serveurs de tuiles: https://wiki.openstreetmap.org/wiki/Tile_servers
// https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png
// https://a.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png
// https://tile.openstreetmap.org/{z}/{x}/{y}.png
// 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png'
const tileServer = 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png'
// Créer la carte centrée sur Rouen
@ -46,16 +49,33 @@ function buildOverpassApiUrl (map, overpassQuery) {
return resultUrl
}
const tags_to_display_in_popup = ['capacity', 'socket:type_2',
'socket:type2:output',
const tags_to_display_in_popup = [
'name',
'capacity',
'date_start',
'charging_station:output',
'socket:type_2',
'socket:type2:output',
'socket:typee',
'socket:typee:output',
'socket:type2_combo',
'socket:type2_combo:output',
'socket:chademo',
'operator', 'ref:EU:EVSE',
'network',
'opening_hours',
'contact',
'phone']
'phone',
'contact:phone',
'website',
'contact:website',
'ref',
'fee',
'payment',
'payment:contactless',
'authentication:app',
'authentication:debit_card',
]
function supprimerMarqueurs (map) {
map.eachLayer((layer) => {
@ -74,15 +94,16 @@ const colors = [
'#08c1c7',
'#0081f0',
]
function getColor (feature) {
var outputPower = 0
if (feature.properties && feature.properties.tags) {
for (var tag in feature.properties.tags) {
let value = feature.properties.tags[tag]
if (value && tag.toLowerCase().indexOf('output')!==-1) {
if (value && tag.toLowerCase().indexOf('output') !== -1) {
console.log('tag contient output', tag, value)
value = ''+value
if(value.replace){
value = '' + value
if (value.replace) {
value = value.replace(' ')
value = value.replace('kW', '')
}
@ -94,9 +115,10 @@ function getColor (feature) {
}
}
}
if(!outputPower){
if (!outputPower) {
console.log('pas de outputPower', outputPower)
return 'white'
return unknown_color
}
feature.properties.tags.has_output_of_irve_specified = outputPower
var index = Math.min(Math.floor(outputPower / 10), colors.length - 1)
@ -160,11 +182,11 @@ function displayPointsFromApi (points) {
}).addTo(map)
let color = getColor(feature)
let radius = 20;
if(color=='#0081f0'){
radius = 200;
} else if(color=='#08c1c7'){
radius = 100;
let radius = 50
if (color == '#0081f0') {
radius = 200
} else if (color == '#08c1c7') {
radius = 100
}
let circle = L.circle(layer._latlng, {
color: color,