CargoCanvas / Examples / Events

Events

Click the map to drop a stop on the route; click a stop to remove it. Every event that fires is logged below, newest first.

What to notice

Removing listeners. off matches on the function reference, so an inline arrow function can never be removed. Keep a reference to anything you intend to detach later — especially inside a control's onAdd, where onRemove has to undo it.
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, Marker, Polyline} from 'cargocanvas';