From 715b1ba39abf5242ab8065c38298b8d68b14497d Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sun, 7 Dec 2025 15:18:30 -0800 Subject: [PATCH] Switch to shortbread style with absolute URLs This style and associated assets are served with CORS headers that allow use by openstreetmap.org or 127.0.0.1 --- app/assets/javascripts/leaflet.shortbread.js | 22 ++------------------ 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/leaflet.shortbread.js b/app/assets/javascripts/leaflet.shortbread.js index 46826c074..6298b9625 100644 --- a/app/assets/javascripts/leaflet.shortbread.js +++ b/app/assets/javascripts/leaflet.shortbread.js @@ -3,26 +3,8 @@ L.OSM.Shortbread = L.OSM.MaplibreGL.extend({ onAdd: function (map) { L.OSM.MaplibreGL.prototype.onAdd.call(this, map); - const styleURL = "https://vector.openstreetmap.org/demo/shortbread/" + this.options.styleName; - this.getMaplibreMap().setStyle(styleURL, { - transformStyle: (previousStyle, nextStyle) => ({ - ...nextStyle, - sprite: [...nextStyle.sprite.map(s => { - return { - ...s, - url: new URL(s.url, styleURL).href - }; - })], - // URL will % encode the {} in glyph and source URL so assemble them manually - glyphs: (new URL(styleURL)).origin + nextStyle.glyphs, - sources: { - "versatiles-shortbread": { - ...nextStyle.sources["versatiles-shortbread"], - tiles: [(new URL(styleURL)).origin + nextStyle.sources["versatiles-shortbread"].tiles[0]] - } - } - }) - }); + const styleURL = "https://vector.openstreetmap.org/styles/shortbread/" + this.options.styleName; + this.getMaplibreMap().setStyle(styleURL); }, onRemove: function (map) { L.OSM.MaplibreGL.prototype.onRemove.call(this, map); -- 2.39.5