mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-13 15:51:00 +00:00
fix(maps): narrow the PDF map container and assert the 3D toast by its key
The offscreen container is built inside buildGlMap's closure, where the let lost its narrowing; a const of its own keeps it an HTMLDivElement. The stage tests hand the stage a t that returns the key, so the toast reads map.webgl2.terrain there. One floating promise fewer lowers the eslint baseline to 164.
This commit is contained in:
@@ -50,18 +50,20 @@ export async function renderTripMapImage(
|
||||
try {
|
||||
const gl = (await importChunk(() => import('../Map/engines/maplibre'))).default
|
||||
|
||||
container = document.createElement('div')
|
||||
// A const of its own: the map is built inside a closure, where the let's narrowing is gone.
|
||||
const box = document.createElement('div')
|
||||
container = box
|
||||
// Off-screen rather than hidden: MapLibre needs a laid-out box with real
|
||||
// dimensions, and `display:none` gives it a zero-sized canvas.
|
||||
container.style.cssText =
|
||||
box.style.cssText =
|
||||
`position:fixed;left:-10000px;top:0;width:${width}px;height:${height}px;pointer-events:none;`
|
||||
document.body.appendChild(container)
|
||||
document.body.appendChild(box)
|
||||
|
||||
const bounds = new gl.LngLatBounds()
|
||||
for (const [lat, lng] of points) bounds.extend([lng, lat])
|
||||
|
||||
const instance = buildGlMap(() => new gl.Map({
|
||||
container,
|
||||
container: box,
|
||||
style: normalizeStyleForProvider('maplibre-gl', opts.style),
|
||||
bounds,
|
||||
fitBoundsOptions: { padding: 42, animate: false },
|
||||
|
||||
Reference in New Issue
Block a user