wip-geocoder

This commit is contained in:
Doxa Maps 2026-09-26 01:36:49 +00:00
parent d01e19c90c
commit cd03a2c6d0
13 changed files with 24 additions and 3 deletions

View file

@ -304,7 +304,10 @@ https://<cdn>/dx-maps/<bundle>/<profile>/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

View file

@ -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({

View file

@ -1,5 +1,6 @@
{
"placeholder": "شعب، مكان، لغة، ديانة",
"placeholderNoPlaces": "شعب، لغة، ديانة (البحث عن الأماكن يتطلب رمز Mapbox)",
"labels": {
"people": "الشعب:",
"place": "المكان:",

View file

@ -1,5 +1,6 @@
{
"placeholder": "Volk, Ort, Sprache, Religion",
"placeholderNoPlaces": "Volk, Sprache, Religion (Ortssuche braucht ein Mapbox-Token)",
"labels": {
"people": "Volk:",
"place": "Ort:",

View file

@ -1,5 +1,6 @@
{
"placeholder": "People, place, language, religion",
"placeholderNoPlaces": "People, language, religion (place search needs a Mapbox token)",
"labels": {
"people": "People:",
"place": "Place:",

View file

@ -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:",

View file

@ -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 :",

View file

@ -1,5 +1,6 @@
{
"placeholder": "लोग, स्थान, भाषा, धर्म",
"placeholderNoPlaces": "लोग, भाषा, धर्म (स्थान खोज के लिए Mapbox टोकन चाहिए)",
"labels": {
"people": "लोग:",
"place": "स्थान:",

View file

@ -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:",

View file

@ -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:",

View file

@ -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:",

View file

@ -1,5 +1,6 @@
{
"placeholder": "Народ, место, язык, религия",
"placeholderNoPlaces": "Народ, язык, религия (для поиска мест нужен токен Mapbox)",
"labels": {
"people": "Народ:",
"place": "Место:",

View file

@ -1,5 +1,6 @@
{
"placeholder": "民族、地点、语言、宗教",
"placeholderNoPlaces": "民族、语言、宗教(地点搜索需要 Mapbox 令牌)",
"labels": {
"people": "民族:",
"place": "地点:",