@mapprism/mapprism-2d
v1.1.2
Published
Vanilla TypeScript library wrapping MapLibre GL JS for 2D maps in the MapPRISM platform. User-facing docs live in [`docs-site/`](docs-site/).
Readme
mapprism-2d
Vanilla TypeScript library wrapping MapLibre GL JS for 2D maps in the MapPRISM platform. User-facing docs live in docs-site/.
Library (this package)
npm install
npm run build # same as npm run build:lib
npm run lintOutputs under dist/: ESM, CJS, index.d.ts, and mapprism-2d.css. Consumers need maplibre-gl installed (peer dependency).
CDN alternative (R2 public bucket):
- Base URL:
https://pub-78d8b203e7a5426d953b50368fb4be3f.r2.dev/cdn/mapprism-2d/latest/dist - ESM:
.../index.esm.js - CSS:
.../mapprism-2d.css
For browser-only integration details (including MapLibre shim/import map), see docs-site/guide/getting-started.md.
Measurement API highlights:
map.tools.measurement.startLine()/startArea()to begin drawing.- Press Enter to finalize and keep drawing more measurements.
map.tools.measurement.startDelete()to remove a drawing by clicking it.map2d.tools.measurement.controls(defaulttrue) toggles built-in top-right tool buttons.- Labels auto-scale units: distance (
m/ft->km/mi) and area (m2/ft2->km2/mi2) using metric thresholds.
Potree sync highlight:
- Optional runtime sync can be enabled by passing
map2d.syncwith a live Potree viewer reference:
const map = new MapPrism2D(container, {
map2d: {
// ... normal map2d config ...
sync: {
enabled: true,
master: "auto", // "auto" | "map2d" | "potree"
mapPriorityMs: 1200,
potree: {
viewer: window.viewer,
throttleMs: 50,
},
},
},
})viewer is runtime-only (in-memory object reference), not a field expected in backend JSON.
Potree + 2D demo (demo/)
The live dual-panel viewer (Potree 3D + MapPrism 2D) lives in demo/index.html. MapLibre and the built library are copied into demo/vendor/ so the demo folder is self-contained for hosting.
- Live URL: https://mapprism-2d.pages.dev
npm install
npm run dev:site # syncs vendor assets, then serves repo root — open /demo/index.htmlnpm run build:demo— runsscripts/sync-demo-vendor.mjs: builds the library ifdist/is missing, then copies MapLibre +dist/intodemo/vendor/. Generated files are gitignored.npm run deploy:demo—build:demothen uploadsdemo/to Cloudflare Pages projectmapprism-2d(requireswrangler login).
Public docs + demo deployment (Cloudflare)
This repository deploys through Cloudflare Pages.
- Build command:
npm run build:cloudflare - Build output directory:
cloudflare-dist - Root directory: repository root (blank/default)
The Cloudflare build output serves:
- docs at
/ - demo at
/demo/index.html
If your Pages project still uses npm run build:demo with output demo, the demo is served at / (not under /demo/). Update the project to npm run build:cloudflare and output cloudflare-dist so docs and /demo/index.html match this README. Until then, demo/_redirects redirects /demo/index.html → /index.html so the hero “Open Demo” link does not 404.
Library release delivery
Release automation now supports both npm and Cloudflare R2 artifact delivery:
- CI checks:
.github/workflows/ci.yml(lint + build on PR/main) - Release pipeline:
.github/workflows/release.yml(mainpush -> semantic-release -> npm + R2 when releasable commits exist)
Required repo configuration is documented in docs/DELIVERY.md (secrets, variables, and object paths).
Legacy React demo
The original React + react-map-gl proof-of-concept lives in _react-archive/ as a separate package:
cd _react-archive && npm install && npm run devDocs
- Public docs (VitePress):
docs-site/(deployed via Cloudflare Pages) - Internal docs (developer/AI only):
docs/ - Internal project tracker:
docs/PROJECT.md
