Leaflet
Keep your Leaflet code, markers and plugins, and draw the Siemens basemap underneath. The base layer is our vector tiles in the Siemens style, rendered by MapLibre inside a Leaflet layer, so the map looks exactly like the embed.
Live
Plain Leaflet controls: drag, wheel or the plus and minus buttons; with the map focused, arrow keys pan and plus and minus zoom. The marker opens a popup.
Install
All packages from npm, pinned; @siemens/maps straight from its URL, no registry or token.
npm install leaflet@1.9.4 maplibre-gl@6.20.0 @maplibre/maplibre-gl-leaflet@0.1.4 pmtiles@4.5.0 \
https://maps.siemens-cdn.com/sdk/1.2.0/siemens-maps-1.2.0.tgz
Code
<div id="map" style="height: 420px"></div>
<script type="module" src="./main.js"></script>
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';
import * as maplibregl from 'maplibre-gl';
import { maplibreGL } from '@maplibre/maplibre-gl-leaflet';
import { Protocol } from 'pmtiles';
import { siemensStyle } from '@siemens/maps/style';
maplibregl.addProtocol('pmtiles', new Protocol().tile);
const map = L.map('map').setView([48.1443, 11.575], 14);
// The base layer: our vector tiles in the Siemens style. Its credits go to Leaflet's control.
maplibreGL({ style: await siemensStyle({ scheme: 'light' }) }).addTo(map);
// Everything else is plain Leaflet.
L.marker([48.1443, 11.575], { title: 'Siemens headquarters, Munich' }).addTo(map);
siemensStyle() takes style (siemens, minimal, contrast, bold), scheme (light, dark) and language. For dark mode, build the layer again with scheme: 'dark' when the page switches. See the package reference.
Content Security Policy
connect-src 'self' https://maps.siemens-cdn.com;
worker-src blob:;
img-src 'self' data: blob:
MapLibre runs its tile work in a worker from a blob: URL. To keep it on your own host, copy node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs next to your bundle, call maplibregl.setWorkerUrl() with its URL and use worker-src 'self'.
Good to know
- Attribution: the base layer passes “© OpenStreetMap contributors” to Leaflet’s attribution control. Keep the control visible.
- Where it works: the tiles answer Siemens apps on
https://*.siemens.zoneandlocalhost. - Why this plugin: it draws our own style, labels and icons included. A Leaflet-only renderer would need a second theme and would not match the embed.
- Library versions on this page:
leaflet1.9.4,maplibre-gl6.20.0,@maplibre/maplibre-gl-leaflet0.1.4,pmtiles4.5.0.