CargoCanvas / Examples / Layers and controls

Layers and controls

Two interchangeable base maps, two overlays you can toggle independently, a scale bar, and a custom control of your own — all over Curitiba.

What to notice

Control positions. Every control accepts position: 'topleft', 'topright', 'bottomleft' or 'bottomright'. Several controls in the same corner stack in the order they were added.
Why the UMD build? Loading it as a classic script is what lets this page work when opened straight from disk. In an application with a bundler, install the package and import the classes instead — everything after that line is identical:
import {CargoMap, TileLayer, LayersControl, ScaleControl, Control, LayerGroup, Marker, Circle, DomUtil} from 'cargocanvas';