mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 05:52:17 +00:00
work
This commit is contained in:
11
biome.jsonc
11
biome.jsonc
@@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
|
||||||
"formatter": {
|
"formatter": {
|
||||||
"indentStyle": "space",
|
"indentStyle": "space",
|
||||||
"lineWidth": 100
|
"lineWidth": 100
|
||||||
},
|
},
|
||||||
"organizeImports": {
|
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
||||||
"enabled": true,
|
|
||||||
"ignore": []
|
|
||||||
},
|
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
@@ -16,7 +13,7 @@
|
|||||||
"noForEach": "off"
|
"noForEach": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ignore": []
|
"includes": ["**"]
|
||||||
},
|
},
|
||||||
"javascript": {
|
"javascript": {
|
||||||
"formatter": {
|
"formatter": {
|
||||||
@@ -26,6 +23,6 @@
|
|||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"maxSize": 100000,
|
"maxSize": 100000,
|
||||||
"ignore": ["venv", "dist", ".astro"]
|
"includes": ["**", "!**/venv", "!**/dist", "!**/.astro"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,52 +20,26 @@ function modifyStyle({ style, langCode }) {
|
|||||||
// highway numbers, etc. - skip ref-only fields
|
// highway numbers, etc. - skip ref-only fields
|
||||||
if (JSON.stringify(textField) === JSON.stringify(['to-string', ['get', 'ref']])) continue
|
if (JSON.stringify(textField) === JSON.stringify(['to-string', ['get', 'ref']])) continue
|
||||||
|
|
||||||
const id = layer.id
|
|
||||||
|
|
||||||
let separator
|
|
||||||
if (id.includes('line') || id.includes('highway')) {
|
|
||||||
separator = ' '
|
|
||||||
} else {
|
|
||||||
separator = '\n'
|
|
||||||
}
|
|
||||||
|
|
||||||
const nameUnderscore = `name_${langCode}`
|
const nameUnderscore = `name_${langCode}`
|
||||||
const nameColon = `name:${langCode}`
|
const nameColon = `name:${langCode}`
|
||||||
|
|
||||||
// Construct parts with exactly name_ and name: versions only (no int special case, no 'name' fallback)
|
// Always display both values
|
||||||
const parts = [
|
layer.layout['text-field'] = ['concat', ['get', nameUnderscore], '\n', ['get', nameColon]]
|
||||||
['get', nameUnderscore],
|
|
||||||
['get', nameColon],
|
|
||||||
]
|
|
||||||
|
|
||||||
layer.layout['text-field'] = [
|
// Color red when they are different
|
||||||
'case',
|
|
||||||
['has', 'name:nonlatin'],
|
|
||||||
['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 = {}
|
if (!layer.paint) layer.paint = {}
|
||||||
|
|
||||||
layer.paint['text-color'] = [
|
layer.paint['text-color'] = [
|
||||||
'case',
|
'case',
|
||||||
// If both name_ and name: exist and are different, show red
|
['!=', ['get', nameUnderscore], ['get', nameColon]],
|
||||||
[
|
|
||||||
'all',
|
|
||||||
['has', nameUnderscore],
|
|
||||||
['has', nameColon],
|
|
||||||
['!=', ['get', nameUnderscore], ['get', nameColon]]
|
|
||||||
],
|
|
||||||
'#ff0000', // Red when different
|
'#ff0000', // Red when different
|
||||||
'#000000' // Black when same or only one exists
|
'#000000', // Default color when same (adjust as needed)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyLanguage() {
|
function applyLanguage() {
|
||||||
const hash = window.location.hash.substring(1); // Remove the '#'
|
const hash = window.location.hash.substring(1) // Remove the '#'
|
||||||
const langCode = hash || null;
|
const langCode = hash || null
|
||||||
|
|
||||||
const style = map.getStyle()
|
const style = map.getStyle()
|
||||||
modifyStyle({ style, langCode })
|
modifyStyle({ style, langCode })
|
||||||
@@ -75,7 +49,9 @@ function applyLanguage() {
|
|||||||
map.on('load', () => {
|
map.on('load', () => {
|
||||||
// Add default hash if not present
|
// Add default hash if not present
|
||||||
if (!window.location.hash) {
|
if (!window.location.hash) {
|
||||||
alert('To change the map language, modify the language code in the URL #.\nLabels will be RED if name_xx and name:xx differ')
|
alert(
|
||||||
|
'To change the map language, modify the language code in the URL #.\nLabels will be RED when different. name_xx on line 1, name:xx on line 2',
|
||||||
|
)
|
||||||
window.location.hash = '#en'
|
window.location.hash = '#en'
|
||||||
// The hashchange event will trigger applyLanguage()
|
// The hashchange event will trigger applyLanguage()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ function modifyStyle({ style, langCode }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyLanguage() {
|
function applyLanguage() {
|
||||||
const hash = window.location.hash.substring(1); // Remove the '#'
|
const hash = window.location.hash.substring(1) // Remove the '#'
|
||||||
const langCode = hash || null;
|
const langCode = hash || null
|
||||||
|
|
||||||
const style = map.getStyle()
|
const style = map.getStyle()
|
||||||
modifyStyle({ style, langCode })
|
modifyStyle({ style, langCode })
|
||||||
@@ -62,7 +62,9 @@ function applyLanguage() {
|
|||||||
map.on('load', () => {
|
map.on('load', () => {
|
||||||
// Add default hash if not present
|
// Add default hash if not present
|
||||||
if (!window.location.hash) {
|
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)')
|
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',
|
||||||
|
)
|
||||||
window.location.hash = '#es'
|
window.location.hash = '#es'
|
||||||
// The hashchange event will trigger applyLanguage()
|
// The hashchange event will trigger applyLanguage()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user