Installation
The Wemap SDK is split into small packages — install only the ones you need.
You can consume them with a bundler (npm) or, for static sites with no build
step, load them directly by <script> tag.
With a bundler (npm)
# Map rendering (maplibre-gl is a peer dependency)
npm install @wemap/core @wemap/geo @wemap/map maplibre-gl
# Positioning, routing, camera
npm install @wemap/positioning @wemap/routing @wemap/camera
Then import what you use:
import { core } from '@wemap/core';
import { WemapMap } from '@wemap/map';
await core.init({ emmid: 'your-map-id', token: 'your-token' });
const map = new WemapMap({ container: 'map' });
Without a build step (<script> tag / CDN)
Every package also ships a minified UMD bundle under dist/cdn/
(wemap-<pkg>.umd.js). Each attaches to a single window.Wemap namespace
(Wemap.Core, Wemap.Map, …) and reads its sibling @wemap/* packages from
that namespace — so shared code is never duplicated, but you must load the
dependency scripts first, in order.
maplibre-gl is the exception: v6 is ESM-only (no UMD global), so
wemap-map.umd.js inlines maplibre and its Web Worker. The map bundle is
fully self-contained — wemap-map.umd.js + wemap-map.css (which also folds in
maplibre's control/popup CSS), with no separate maplibre script or worker setup.
maplibre itself stays reachable at window.Wemap.Map.maplibregl if you need it.
Example: a map with routing
<!-- Wemap dependencies, in order -->
<script src="https://unpkg.com/@wemap/maths/dist/cdn/wemap-maths.umd.js"></script>
<script src="https://unpkg.com/@wemap/utils/dist/cdn/wemap-utils.umd.js"></script>
<script src="https://unpkg.com/@wemap/geo/dist/cdn/wemap-geo.umd.js"></script>
<script src="https://unpkg.com/@wemap/core/dist/cdn/wemap-core.umd.js"></script>
<script src="https://unpkg.com/@wemap/osm/dist/cdn/wemap-osm.umd.js"></script>
<script src="https://unpkg.com/@wemap/routers/dist/cdn/wemap-routers.umd.js"></script>
<!-- the SDKs you actually use -->
<script src="https://unpkg.com/@wemap/map/dist/cdn/wemap-map.umd.js"></script>
<link href="https://unpkg.com/@wemap/map/dist/cdn/wemap-map.css" rel="stylesheet" />
<script src="https://unpkg.com/@wemap/routing/dist/cdn/wemap-routing.umd.js"></script>
<script>
await Wemap.Core.core.init({ emmid: '31668', token: 'YOUR_TOKEN' });
const map = new Wemap.Map.WemapMap({ container: 'map' });
const router = new Wemap.Routing.Router();
</script>
Global load order
Load dependencies before dependents:
| # | File | Global |
|---|---|---|
| 1 | wemap-maths.umd.js | Wemap.Maths |
| 2 | wemap-utils.umd.js | Wemap.Utils |
| 3 | wemap-camera.umd.js | Wemap.Camera |
| 4 | wemap-geo.umd.js | Wemap.Geo |
| 5 | wemap-core.umd.js | Wemap.Core |
| 6 | wemap-osm.umd.js | Wemap.Osm |
| 7 | wemap-map.umd.js | Wemap.Map (maplibre inlined — self-contained) |
| 8 | wemap-routers.umd.js | Wemap.Routers |
| 9 | wemap-providers.umd.js | Wemap.Providers |
| 10 | wemap-routing.umd.js | Wemap.Routing |
| 11 | wemap-positioning.umd.js | Wemap.Positioning |
Load only the SDKs you need, plus their transitive dependencies:
| Package | Load first (besides its own script) |
|---|---|
@wemap/maths, @wemap/utils, @wemap/camera | (none) |
@wemap/geo | maths, utils |
@wemap/core, @wemap/osm | maths, utils, geo |
@wemap/map | maths, utils, geo, core (maplibre is inlined) |
@wemap/routers | maths, utils, geo, core, osm |
@wemap/routing | maths, utils, geo, core, osm, routers |
@wemap/providers | maths, utils, geo, camera, core, osm, routers |
@wemap/positioning | maths, utils, geo, camera, core, osm, routers, providers |
Requirements
- Positioning (geolocation) and VPS (camera) require a secure context — the
page must be served over HTTPS (or
localhostin development). Browsers blockgetUserMediaand the Geolocation API on insecure origins. - A modern evergreen browser (Chrome, Edge, Firefox, Safari). VPS additionally needs a device camera and, on iOS, a user gesture to grant motion/orientation access (see the Positioning guide).