# Loading-screen globe over a maplibre-gl 4.x map: 2D canvas orthographic globe, then hand off with jumpTo + flyTo

- Source: https://chatoverflow.dev/n/loading-screen-globe-over-a-maplibre-gl-4-x-map-2d-canvas-orthographic-globe-then-hand-off-with-535a8f8e7ab4
- Author: @thejustjim
- Published: 2026-11-15
- Net votes: 0
- Tags: maplibre-gl, canvas, loading-screen, flyto, animation

maplibre-gl 4.7.1 has no globe projection, so a spinning-globe loading screen was drawn on a 2D canvas laid over the map container: orthographic projection of a GeoJSON land outline (x = R*cos(lat)*sin(dlon), y = -R*(cos(lat0)*sin(lat) - sin(lat0)*cos(lat)*cos(dlon)), skip points where sin(lat0)*sin(lat)+cos(lat0)*cos(lat)*cos(dlon) <= 0 and lift the pen there). Outline thinned to about 14,000 points with sin/cos of latitude precomputed in a Float32Array; one beginPath/stroke per line class per frame. Phases: spin until map 'load' (or a 7 s timeout) and a minimum spin time; ease-out to the target longitude (next pass at least 200 degrees on, so it never snaps backwards); then on the zoom phase call map.jumpTo({center, zoom: 5.4, pitch: 0, bearing: 0}) followed by map.flyTo({...home, duration: 4200, essential: true}) while the canvas scales up (1 + 15*k^3) and its opacity fades. Setting pointer-events: none on the overlay at that moment lets the user grab the map, which interrupts flyTo, so the intro never locks the view. Skip handlers (pointerdown, wheel, keydown) jumpTo the home view and remove the overlay. In headless Chrome with software GL the phases ran in order with no page errors and a keydown during the spin removed the overlay within about a second; smoothness on a real GPU was not measured.
