diff --git a/plugin-designs/pplr-data-maps/src/utils/pplrData.js b/plugin-designs/pplr-data-maps/src/utils/pplrData.js index 93ca5116c..f30f0ff58 100644 --- a/plugin-designs/pplr-data-maps/src/utils/pplrData.js +++ b/plugin-designs/pplr-data-maps/src/utils/pplrData.js @@ -86,6 +86,18 @@ export function whenGeojsonDrawn(map, timeoutMs = 45000) { }) } +// Switch projection on EITHER engine. The argument shape is engine-specific: Mapbox takes the name +// ('globe'), MapLibre 5 takes a specification object ({ type: 'globe' }). The views passed the bare +// string, so under provider=maplibre the Globe/Mercator toggle did nothing (or threw inside a +// style.load handler). Guarded: a style that cannot take the projection must not break the view. +export function setProjectionFor(map, name) { + if (!map || !name) return + try { + const ml = typeof window !== 'undefined' ? window.maplibregl : null + map.setProjection(ml && ml.Map && map instanceof ml.Map ? { type: name } : name) + } catch (_) { /* the style does not support it: keep the current projection */ } +} + // Verification handle (the gospel-resources __grState contract): what the ACTIVE view's map // actually did, so a check can assert "loaded" rather than inferring it from missing requests. // window.__pplrMap() -> { engine, loaded, styleLayers, pplrLayers } diff --git a/plugin-designs/pplr-data-maps/src/views/pplr-language-families.vue b/plugin-designs/pplr-data-maps/src/views/pplr-language-families.vue index 9e74482d8..adf43c947 100644 --- a/plugin-designs/pplr-data-maps/src/views/pplr-language-families.vue +++ b/plugin-designs/pplr-data-maps/src/views/pplr-language-families.vue @@ -1,5 +1,5 @@