The map as a web component

<siemens-map> puts the Siemens map straight into your page, without an iframe: the Siemens styles, the Siemens pin, the place card with route links, search results and routes. It takes the same parameters as the embed URL, sends events when people move the map or pick a place, and works in plain HTML, React and Siemens apps. Version 1.2.0 of @siemens/maps.

Live

The view of this map is kept in the page URL: move it and reload, or share the link.

Search, with the select event

Directions

Events

    Typed client

    Plain HTML

    One script tag with its integrity hash registers the element. The file at this URL never changes; a new release gets a new version path.

    index.html
    <script type="module" src="https://maps.siemens-cdn.com/sdk/1.2.0/siemens-maps.js"
            integrity="sha384-2+MB3QkBttRZi9XWeZC7LiyIMZXqkRC5XmKe0YcX4wyfF0sOWkwWJgz+7JgszmbR" crossorigin="anonymous"></script>
    
    <siemens-map q="Werner-von-Siemens-Str. 1, 80333 München"
                 map-style="siemens" color-scheme="auto"
                 label="Siemens headquarters, Munich" style="height: 400px"></siemens-map>

    npm and any bundler

    Install the package straight from its URL: no registry, no token, the same in a CI pipeline. The lockfile pins it with its hash.

    Terminal
    npm install https://maps.siemens-cdn.com/sdk/1.2.0/siemens-maps-1.2.0.tgz
    main.js
    import { defineSiemensMap, createMapsClient } from '@siemens/maps';
    
    defineSiemensMap();
    const map = document.querySelector('siemens-map');
    map.addEventListener('map-move', (e) => console.log(e.detail.center, e.detail.zoom));
    map.addEventListener('map-select', (e) => console.log(e.detail.place));
    
    const maps = createMapsClient();
    const place = await maps.geocode('Siemens Campus Erlangen');
    const route = await maps.directions({ points: [{ lat: 48.1443, lng: 11.575 }, place.position], mode: 'driving' });

    React

    Office.jsx
    import { SiemensMap } from '@siemens/maps/react';
    
    export function Office() {
      return (
        <SiemensMap mode="search" q="Siemens offices in Berlin" style={{ height: 420 }}
                    onSelect={({ place }) => console.log(place.poi?.name)} />
      );
    }

    Content Security Policy

    Add these sources to your page’s policy. The element styles itself without inline styles and never evaluates strings as code. To keep the map’s worker on your own host instead of blob:, copy node_modules/@siemens/maps/dist/maplibre-gl-worker.mjs next to your bundle, set worker-url to it and use worker-src 'self'.

    Content-Security-Policy
    script-src 'self' https://maps.siemens-cdn.com;
    worker-src blob: https://maps.siemens-cdn.com;
    connect-src 'self' https://maps.siemens-cdn.com;
    img-src 'self' https://maps.siemens-cdn.com data: blob:

    Where it works

    • The map shows on siemens.com pages, in Siemens apps on https://*.siemens.zone and on localhost. Search, geocoding, routes, isolines and satellite tiles answer Siemens apps and localhost; siemens.com pages use the iframe embed for those.
    • Every attribute, event and client call: web component reference.