diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2024-01-29 21:16:36 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2024-01-29 21:17:49 +0100 |
commit | faaeef9a9b1172c7f46228af5aca9080547eb826 (patch) | |
tree | f13309ab1d717db3cbbecdcf0e84f34c5d5a70b1 | |
parent | a86abe4e862230220d5f47db93e78d4de26a49f4 (diff) |
Factor out unit formating in popover.
-rw-r--r-- | main.js | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -721,7 +721,7 @@ const layers = { popoverTitle: 'Kraftledning (befintlig)', popover: [ ['Förläggn', 'FÖRLÄGGN'], - ['Spänning', 'SPÄNNING', { fn: (v) => v + '\u202FkV' }], + ['Spänning', 'SPÄNNING', { unit: 'kV' }], ], style: [1, 1.5, 2, 2, 2, 2, 3, 4, 5, 6, 8, 10].map(function(width) { return new Style({ @@ -751,7 +751,7 @@ const layers = { popoverTitle: 'Transmissionsnätsprojekt', popover: [ ['Projektnamn', 'name'], - ['Spänning', 'voltage', { fn: (v) => v + '\u202FkV' }], + ['Spänning', 'voltage', { unit: 'kV' }], ['Länk', 'url', { fn: function(v) { const a = document.createElement('a'); a.href = v; @@ -1331,6 +1331,9 @@ map.addLayer(vectorLayer); if (opts.fn !== undefined) { v = opts.fn(v); } + if (opts.unit !== undefined && v !== undefined && v !== '') { + v += '\u202F' + opts.unit; + } if (v === undefined) { v = document.createTextNode(''); } else if (!(v instanceof HTMLElement)) { |