From 8ce37a96b2c1378cd0545eb91541be2eedfa7652 Mon Sep 17 00:00:00 2001 From: Zsolt Ero Date: Fri, 17 Oct 2025 11:46:44 +0200 Subject: [PATCH] debug --- website/public/debug/lang/colon.js | 39 ++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/website/public/debug/lang/colon.js b/website/public/debug/lang/colon.js index 8c3b0d6..3214f73 100644 --- a/website/public/debug/lang/colon.js +++ b/website/public/debug/lang/colon.js @@ -29,17 +29,14 @@ function modifyStyle({ style, langCode }) { separator = '\n' } - // the default is "en", not "int" - let parts - if (langCode === 'int') { - parts = [['get', 'name']] - } else { - parts = [ - ['get', `name_${langCode}`], - ['get', `name:${langCode}`], - ['get', 'name'], - ] - } + const nameUnderscore = `name_${langCode}` + const nameColon = `name:${langCode}` + + // Construct parts with exactly name_ and name: versions only (no int special case, no 'name' fallback) + const parts = [ + ['get', nameUnderscore], + ['get', nameColon], + ] layer.layout['text-field'] = [ 'case', @@ -47,6 +44,22 @@ function modifyStyle({ style, langCode }) { ['concat', ['get', 'name:latin'], separator, ['get', 'name:nonlatin']], ['coalesce', ...parts], ] + + // Set color to red if both exist and are different, black otherwise + if (!layer.paint) layer.paint = {} + + layer.paint['text-color'] = [ + 'case', + // If both name_ and name: exist and are different, show red + [ + 'all', + ['has', nameUnderscore], + ['has', nameColon], + ['!=', ['get', nameUnderscore], ['get', nameColon]] + ], + '#ff0000', // Red when different + '#000000' // Black when same or only one exists + ] } } @@ -62,8 +75,8 @@ function applyLanguage() { map.on('load', () => { // Add default hash if not present if (!window.location.hash) { - alert('To change the map language, modify the language code in the URL.\n\nExamples:\n• #en → English\n• #de → German\n• #fr → French\n• #es → Spanish\n• #int → International names\n\nDefault language set to: en (English)') - window.location.hash = '#es' + alert('To change the map language, modify the language code in the URL #.\nLabels will be RED if name_xx and name:xx differ') + window.location.hash = '#en' // The hashchange event will trigger applyLanguage() } else { applyLanguage()