The map has a bearing — the compass heading that points up on the screen. Drag the slider, spin the view, and notice that markers, popups and controls stay upright while the world turns underneath them. The needle at the top right always points north; click it to snap back. You can also rotate straight on the map, Mapbox-style: drag with the right pointer button — or hold Ctrl and drag — and move vertically to tilt.
setBearing(deg) rotates the view; getBearing() reports it,
normalized to [0, 360). Bearing 0 is north-up,
90 puts east at the top. A bearing map option sets the
initial rotation.
rotate event after every change — that is what drives
the compass needle here.
latLngToContainerPoint, click events'
latlng, and friends) account for the bearing — dragging, scroll zoom
and popups keep working at any angle.
getBounds() under rotation returns the geographical bounding box of the
four rotated viewport corners — slightly larger than what is strictly visible.
import {CargoMap, TileLayer, Marker, Polygon, Polyline, Control, DomUtil, DomEvent} from 'cargocanvas';