Skip to content

Latest commit

 

History

History
115 lines (82 loc) · 3.22 KB

getting-started.md

File metadata and controls

115 lines (82 loc) · 3.22 KB

Getting started

Minimal path: install packages → style function → config JSON → mount a map. No municipal stack required.

Mapsight in this repository is WIP — the steps below reflect the npm library contract; production CMS deployments add host builds, data pipelines, and ops layers (see Integration overview).


Prerequisites

  • Node 24+, pnpm (monorepo) or npm/yarn in your app
  • A DOM container (<div id="map">)

Install

pnpm add @mapsight/ui @mapsight/core @mapsight/lib-ol @mapsight/traffic-style

Add peer dependencies (react, react-dom, ol, …) as required by your bundler — see @mapsight/ui on npm.


1. Style function

Mapsight needs a compiled vector styleFunction (OpenLayers styling). Fastest path: build from @mapsight/traffic-style or @mapsight/vector-style-compiler — see traffic-style README.


2. Minimal config

const mapsightConfig = {
	map: {
		layers: {
			osm: {
				type: "TileLayer",
				options: {
					source: {
						type: "OsmSource",
						options: {
							url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
						},
					},
				},
			},
		},
	},
	featureSources: {
		pois: {type: "xhr-json", url: "/data/pois.geojson"},
	},
	list: {
		featureSource: "pois",
		visible: true,
	},
};

Validated in development via Zod — see Config reference.

Basemaps: raw OSM URLs are fine for local dev. Production hosts usually use a self-hosted or proxied basemap — see Ecosystem § basemaps.


3. Mount in the browser

import {create} from "@mapsight/ui";

import styleFunction from "./generated/styleFunction";

const el = document.getElementById("map");
if (el) {
	create(el, styleFunction, mapsightConfig);
}

4. CMS embed path

CMS hosts use Vite lib mode, stable asset URLs, and browserEmbed from @mapsight/ui/embed/browser:

import browserEmbed from "@mapsight/ui/embed/browser";

import {simpleMap} from "./presets/simpleMap";

browserEmbed(containerElement, simpleMap({/* inline options */}));

Full build + snippet pattern: CMS_PHP, the reference starter starters/mapsight-host-starter, and @mapsight/vite-host-embed.

For count-aggregator CMS pages (full app shell, not lib-mode map embeds), see count-aggregator-ui.


Next steps

Goal Read
Full config anatomy CONFIG_REFERENCE
SPA integration REACT_SPA
Next.js NEXTJS
Municipal data pipeline PULP
Architecture depth Redux architecture