mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
00cac02665
The imagery toggle has been there for a while and only ever worked on Leaflet, so anyone on MapLibre or Mapbox — which is the default since the vector basemap landed — had a switch they could not see and a view they could not reach. Leaflet swaps its whole tile layer for the imagery. A GL map cannot: its basemap is a style with dozens of layers in it. So the same tokenless ESRI source goes on as a raster layer of its own, inserted before the first layer TREK draws, which leaves the route, the pins and the tracks on top and legible. Switching back hides it rather than tearing it down, so going to and fro does not re-fetch a tile. Built on demand rather than once at load, because a basemap change rebuilds the style from scratch and takes every source with it; the styledata event is subscribed for the same reason. The switch reads the setting the Leaflet map already stores, so the choice survives an instance changing renderer, and it sits in the same corner with the same offsets.