leaflet-city-mapper
Your data, on a rotated and pitched Leaflet map: a small 3D rendering engine (WebGPU) packaged onto standard L.Layer. Available sources: extruded GeoJSON, glTF models, raster PMTiles, COG, MVT/PBF and terrain layers.
For a working example see one of the following demos:
- City of Paris in 3D
- Ancient Rome in 3D
- Matterhorn in 3D
- Elevation profile on a 3D map
- Native Leaflet layers on WebGPU
- Vector tiles
How to use
Just load Leaflet before this plugin:
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9/dist/leaflet.css">
<script src="https://unpkg.com/leaflet@1.9/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-city-mapper@0.1.2/dist/leaflet-city-mapper.js"></script>
And then create a native L.Layer:
new L.Layer({ source: { /* source options */ } })
For example, here is how you can load a geojson object:
const buildings = new L.Layer({
source: {
type: 'vector',
data: GeoJSON,
style: ({ properties }) => ({ top: properties.height, color: properties.color }),
tooltip: ({ properties }) => `${properties.name}: ${properties.height} m`,
roofTexture: true,
wallTexture: 0.75,
},
}).addTo(map);
Time and walk controls
The walk camera follows vertical ascent and descent as well as horizontal movement. Releasing Space lets the walker land on loaded building roofs; walking off an edge resumes falling toward the terrain or the next roof below.
const time = new L.Control.Time({ position: 'bottomright' }).layer.addTo(map);
const walk = new L.Control.Walk({ speed: 6, distance: 20 }).addTo(map);
Update demo data
The examples makes extensive use of PMTiles to ensure offline access / long-term availability of the maps. To update them:
npm run pmtiles
node build/pmtiles.js --only=trees
node build/pmtiles.js --only=colosseum
node build/pmtiles.js --jobs=6
node build/pmtiles.js --self-test
Paris archives use the buildings bbox (default: 2.26,48.835,2.38,48.885). Use --bbox=west,south,east,north to override it.
Build Guide
Within your local development environment:
git clone git@github.com:Raruto/leaflet-city-mapper.git
cd ./leaflet-city-mapper
npm i # install dependencies
npm run dev # start dev server at: http://localhost:8080
npm run build # generate "dist" bundles and minified "libs" files (once)
npm run test # build and run browser tests
After that you can start developing inside the src folder (eg. open “http://localhost:8080/examples” in your browser to preview changes).
Repository guidance
Repository layout and contributor conventions are documented in AGENTS.md.
