diff --git a/documentation/how-to.md b/documentation/how-to.md index 7a5d03390..732ba701c 100644 --- a/documentation/how-to.md +++ b/documentation/how-to.md @@ -304,7 +304,10 @@ https:///dx-maps///index.html?provider=maplibre ``` `maplibre` runs token-free on the OpenFreeMap style (the right GL script/CSS is injected -automatically); the geocoder search bar keeps working in both engines. `mapbox` behaves exactly +automatically); the geocoder search bar keeps working in both engines. Its **place** results come +from Mapbox geocoding, on either engine, and only with a token: without one no request goes to Mapbox, +the box says "place search needs a Mapbox token", and people-group, language, religion and country +search (local data) keep working. `mapbox` behaves exactly as before, and an embed that passes a token keeps getting Mapbox under `auto`. > Status: **on `main`.** Generated pages honor `provider:'maplibre'` end-to-end — the page diff --git a/library/components/map-controls/GeocoderComponent.vue b/library/components/map-controls/GeocoderComponent.vue index aea677258..08388ff66 100644 --- a/library/components/map-controls/GeocoderComponent.vue +++ b/library/components/map-controls/GeocoderComponent.vue @@ -222,7 +222,13 @@ const props = defineProps({ }) // Effective placeholder: explicit prop > i18n default -const effectivePlaceholder = computed(() => props.placeholder || t('search.placeholder')) +// PLACE SEARCH IS MAPBOX'S. Under MapLibre without a real (pk.…) token no Mapbox call is made at all, and the +// box SAYS so instead of silently returning no places; people-group, language, religion and country search +// are local and keep working. With a token, places come from Mapbox geocoding, on either engine (documented +// in documentation/how-to.md). A keyless place geocoder is a separate decision. +const hasPlaceToken = computed(() => /^pk\./.test(String(props.accessToken || ''))) +const effectivePlaceholder = computed(() => props.placeholder || + (props.provider === 'maplibre' && !hasPlaceToken.value ? t('search.placeholderNoPlaces') : t('search.placeholder'))) const emit = defineEmits(['result', 'people-group-result', 'aggregate-result', 'clear', 'error']) @@ -512,7 +518,8 @@ async function ensureMaplibreGeocoder() { function makeMapboxForwardGeocode(token, getLang) { return async (config) => { const empty = { features: [] } - if (!token || !config?.query) return empty + // No REAL token (none, or the snippet's YOUR_MAPBOX_TOKEN placeholder): no request to Mapbox at all. + if (!/^pk\./.test(String(token || '')) || !config?.query) return empty try { const lang = Array.isArray(config.language) ? config.language[0] : (config.language || getLang() || 'en') const params = new URLSearchParams({ diff --git a/library/i18n/locales/ar/search.json b/library/i18n/locales/ar/search.json index 3251e1012..3bcbd0b2e 100644 --- a/library/i18n/locales/ar/search.json +++ b/library/i18n/locales/ar/search.json @@ -1,5 +1,6 @@ { "placeholder": "شعب، مكان، لغة، ديانة", + "placeholderNoPlaces": "شعب، لغة، ديانة (البحث عن الأماكن يتطلب رمز Mapbox)", "labels": { "people": "الشعب:", "place": "المكان:", diff --git a/library/i18n/locales/de/search.json b/library/i18n/locales/de/search.json index 8b84d2011..0f4bfc59d 100644 --- a/library/i18n/locales/de/search.json +++ b/library/i18n/locales/de/search.json @@ -1,5 +1,6 @@ { "placeholder": "Volk, Ort, Sprache, Religion", + "placeholderNoPlaces": "Volk, Sprache, Religion (Ortssuche braucht ein Mapbox-Token)", "labels": { "people": "Volk:", "place": "Ort:", diff --git a/library/i18n/locales/en/search.json b/library/i18n/locales/en/search.json index b433f3414..d8856d263 100644 --- a/library/i18n/locales/en/search.json +++ b/library/i18n/locales/en/search.json @@ -1,5 +1,6 @@ { "placeholder": "People, place, language, religion", + "placeholderNoPlaces": "People, language, religion (place search needs a Mapbox token)", "labels": { "people": "People:", "place": "Place:", diff --git a/library/i18n/locales/es/search.json b/library/i18n/locales/es/search.json index b8f183451..872a88fdd 100644 --- a/library/i18n/locales/es/search.json +++ b/library/i18n/locales/es/search.json @@ -1,5 +1,6 @@ { "placeholder": "Pueblo, lugar, idioma, religión", + "placeholderNoPlaces": "Pueblo, idioma, religión (buscar lugares requiere un token de Mapbox)", "labels": { "people": "Pueblo:", "place": "Lugar:", diff --git a/library/i18n/locales/fr/search.json b/library/i18n/locales/fr/search.json index 5c72c8663..18a610d88 100644 --- a/library/i18n/locales/fr/search.json +++ b/library/i18n/locales/fr/search.json @@ -1,5 +1,6 @@ { "placeholder": "Peuple, lieu, langue, religion", + "placeholderNoPlaces": "Peuple, langue, religion (la recherche de lieux requiert un jeton Mapbox)", "labels": { "people": "Peuple :", "place": "Lieu :", diff --git a/library/i18n/locales/hi/search.json b/library/i18n/locales/hi/search.json index 118511ce4..d0a40d9b7 100644 --- a/library/i18n/locales/hi/search.json +++ b/library/i18n/locales/hi/search.json @@ -1,5 +1,6 @@ { "placeholder": "लोग, स्थान, भाषा, धर्म", + "placeholderNoPlaces": "लोग, भाषा, धर्म (स्थान खोज के लिए Mapbox टोकन चाहिए)", "labels": { "people": "लोग:", "place": "स्थान:", diff --git a/library/i18n/locales/it/search.json b/library/i18n/locales/it/search.json index a87ee0080..b47241146 100644 --- a/library/i18n/locales/it/search.json +++ b/library/i18n/locales/it/search.json @@ -1,5 +1,6 @@ { "placeholder": "Popolo, luogo, lingua, religione", + "placeholderNoPlaces": "Popolo, lingua, religione (la ricerca di luoghi richiede un token Mapbox)", "labels": { "people": "Popolo:", "place": "Luogo:", diff --git a/library/i18n/locales/pt/search.json b/library/i18n/locales/pt/search.json index c5f5345ab..82993a453 100644 --- a/library/i18n/locales/pt/search.json +++ b/library/i18n/locales/pt/search.json @@ -1,5 +1,6 @@ { "placeholder": "Povo, local, língua, religião", + "placeholderNoPlaces": "Povo, língua, religião (a busca de locais requer um token do Mapbox)", "labels": { "people": "Povo:", "place": "Local:", diff --git a/library/i18n/locales/ro/search.json b/library/i18n/locales/ro/search.json index 70a3476c1..d5fef2445 100644 --- a/library/i18n/locales/ro/search.json +++ b/library/i18n/locales/ro/search.json @@ -1,5 +1,6 @@ { "placeholder": "Popor, loc, limbă, religie", + "placeholderNoPlaces": "Popor, limbă, religie (căutarea locurilor necesită un token Mapbox)", "labels": { "people": "Popor:", "place": "Loc:", diff --git a/library/i18n/locales/ru/search.json b/library/i18n/locales/ru/search.json index bfd8bbc54..ca600d390 100644 --- a/library/i18n/locales/ru/search.json +++ b/library/i18n/locales/ru/search.json @@ -1,5 +1,6 @@ { "placeholder": "Народ, место, язык, религия", + "placeholderNoPlaces": "Народ, язык, религия (для поиска мест нужен токен Mapbox)", "labels": { "people": "Народ:", "place": "Место:", diff --git a/library/i18n/locales/zh/search.json b/library/i18n/locales/zh/search.json index 83d9b6374..55a57f103 100644 --- a/library/i18n/locales/zh/search.json +++ b/library/i18n/locales/zh/search.json @@ -1,5 +1,6 @@ { "placeholder": "民族、地点、语言、宗教", + "placeholderNoPlaces": "民族、语言、宗教(地点搜索需要 Mapbox 令牌)", "labels": { "people": "民族:", "place": "地点:",