Skip to main content

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:

#FileGlobal
1wemap-maths.umd.jsWemap.Maths
2wemap-utils.umd.jsWemap.Utils
3wemap-camera.umd.jsWemap.Camera
4wemap-geo.umd.jsWemap.Geo
5wemap-core.umd.jsWemap.Core
6wemap-osm.umd.jsWemap.Osm
7wemap-map.umd.jsWemap.Map (maplibre inlined — self-contained)
8wemap-routers.umd.jsWemap.Routers
9wemap-providers.umd.jsWemap.Providers
10wemap-routing.umd.jsWemap.Routing
11wemap-positioning.umd.jsWemap.Positioning

Load only the SDKs you need, plus their transitive dependencies:

PackageLoad first (besides its own script)
@wemap/maths, @wemap/utils, @wemap/camera(none)
@wemap/geomaths, utils
@wemap/core, @wemap/osmmaths, utils, geo
@wemap/mapmaths, utils, geo, core (maplibre is inlined)
@wemap/routersmaths, utils, geo, core, osm
@wemap/routingmaths, utils, geo, core, osm, routers
@wemap/providersmaths, utils, geo, camera, core, osm, routers
@wemap/positioningmaths, 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 localhost in development). Browsers block getUserMedia and 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).