1 //= require leaflet.maplibre
3 L.OSM.Shortbread = L.MaplibreGL.extend({
4 onAdd: function (map) {
5 L.MaplibreGL.prototype.onAdd.call(this, map);
6 const styleURL = "https://vector.openstreetmap.org/demo/shortbread/" + this.options.styleName;
7 this.getMaplibreMap().setStyle(styleURL, {
8 transformStyle: (previousStyle, nextStyle) => ({
10 sprite: [...nextStyle.sprite.map(s => {
13 url: new URL(s.url, styleURL).href
16 // URL will % encode the {} in glyph and source URL so assemble them manually
17 glyphs: (new URL(styleURL)).origin + nextStyle.glyphs,
19 "versatiles-shortbread": {
20 ...nextStyle.sources["versatiles-shortbread"],
21 tiles: [(new URL(styleURL)).origin + nextStyle.sources["versatiles-shortbread"].tiles[0]]
27 onRemove: function (map) {
28 L.MaplibreGL.prototype.onRemove.call(this, map);
32 L.OSM.ShortbreadColorful = L.OSM.Shortbread.extend({
34 styleName: "colorful.json"
38 L.OSM.ShortbreadEclipse = L.OSM.Shortbread.extend({
40 styleName: "eclipse.json"