Skip to content

Examples

Every snippet on these pages assumes you already have const unmap = new Unmap({ key }) from the Quickstart; they show the call, not the setup.

Focused, runnable examples. Each page is one idea: a map, a lookup, or a route. The code beside every live pane is the code that produced it, so you can copy a page into a project and get the same result.

The maps pages follow the same grain as MapLibre GL JS examples and Mapbox GL JS examples: display a map, change how it looks, drop a marker. Geocoding and routing follow the same jobs as the Google Maps Platform and Mapbox guides: forward and reverse geocoding, autocomplete, nearby search, directions, and travel-time areas.

Nothing here assumes you have used a maps API before. If a word like tile, style, or isochrone goes past you, the one-minute glossary on the Overview defines the seven that matter.

Maps

Initialize a map, change its style, mode, or language, apply a theme, show it as a globe, or put a marker on a place.

Display a map
Initialize a map in an HTML element with the unmap SDK.
Open
Change the map style
Switch among the twelve structural styles, each in light and dark.
Open
Dark mode
The same style, drawn for a dark page.
Open
Change the map language
Draw labels in French, English, or any of the 41 languages in the tiles.
Open
Apply a theme
Redraw the map with a colour treatment from the theme builder.
Open
Outdoor map
The outdoor style, with terrain shading where the DEM covers.
Open
Add a marker
Geocode a place and drop a MapLibre marker on the answer.
Open
Navigation controls
Zoom, compass, and how to move or hide them.
Open
Show the globe
The same map, drawn as a sphere.
Open
Canadian overlays
Compose a named catalog layer on a basemap with the overlays option.
Open
Energy map
Compose the energy overlay set with one profile option. Tiles 404 until archives land.
Open
Agriculture map
Compose the agriculture overlay set with one profile option. Tiles 404 until archives land.
Open
Remote map
Compose the remote overlay set with one profile option. Overlay tiles are live on R2.
Open
Mining map
Compose the mining overlay set with one profile option. Tiles 404 until archives land.
Open
Find the elevation of a point
Click anywhere in Canada and read the ground elevation.
Open

Geocoding

Turn text into a coordinate, a coordinate into a place, a partial query into suggestions, a category into the nearest matches, or many addresses into one request.

Search for a place
Forward geocoding. Turn an address or a place name into a coordinate.
Open
Autocomplete as you type
Type-ahead suggestions from a partial query, for a search box.
Open
Reverse geocode a point
Turn a coordinate into the nearest address or place.
Open
Find nearby places
Category search around a point, sorted by distance.
Open
Geocode many addresses
Send up to 100 searches in one POST. The answer is an array aligned to the input.
Open
Place a marker from search
Geocode a query and pin the first result on the map.
Open

Routing

Ask for a path between two points, pick a travel mode, or draw the area you can reach in a given time.

Get directions
A driving route between two points, drawn on the map.
Open
Walking directions
A pedestrian route between two points.
Open
Travel modes
Driving, cycling, walking, and truck routing on the same two points.
Open
Travel-time areas
Isochrones. The area you can reach from a point inside a time budget.
Open