CargoCanvas / Examples / Custom icons

Custom icons

Three ways to change what a marker looks like: resize the bundled icon, point Icon at your own image, or drop the image entirely and use a DivIcon built from HTML and CSS.

What to notice

Setting a default for every marker. Rather than passing icon to each marker, you can override the prototype default once with Marker.mergeOptions({icon: myIcon}).
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, Icon, DivIcon} from 'cargocanvas';