Many places on one map

A page that lists many places, like the siemens.com global locations page, fits on one map: one data file, clusters at world zoom, a card per place. The global offices showcase does it for about 1,400 Siemens offices, with search, filters by region and country, direction links and a link for every view.

The data file

  • /data/offices/current.json names the current file. A daily job reads the public page, geocodes new or changed addresses once with Amazon Location and writes a new file only when something changed.
  • One GeoJSON feature per office with name, kind, region, country (ISO alpha-2), area, address and url (the branch page, if any). Offices without a position have geometry: null: list them, do not draw them.
  • Positions are approximate, from the address. The file is Siemens content for this site, not open data.

Every view is a link. One office: ?office=<id>. A filter: ?region=germany, ?country=IN or ?q=plant. Dark mode: ?colorScheme=dark.

On a page of this site

The file is served to pages on this host. Clustered on your own MapLibre map:

HTML
<div id="map" style="height: 480px"></div>
<script type="module">
  // On a page of this host: MapLibre GL JS, bundled with your page.
  import { Map } from 'maplibre-gl';

  // The pointer names the current office file; offices without a position have geometry null.
  const pointer = await (await fetch('/data/offices/current.json')).json();
  const offices = await (await fetch(pointer.url)).json();
  offices.features = offices.features.filter((f) => f.geometry);

  const map = new Map({ container: 'map', style: '/your-basemap-style.json', center: [10, 30], zoom: 1.4 });
  map.on('load', () => {
    map.addSource('offices', { type: 'geojson', data: offices, cluster: true, clusterRadius: 44 });
    map.addLayer({ id: 'clusters', type: 'circle', source: 'offices', filter: ['has', 'point_count'],
      paint: { 'circle-color': '#009999', 'circle-radius': ['step', ['get', 'point_count'], 14, 10, 18, 50, 23] } });
    map.addLayer({ id: 'offices', type: 'circle', source: 'offices', filter: ['!', ['has', 'point_count']],
      paint: { 'circle-color': '#005159', 'circle-radius': 7, 'circle-stroke-color': '#fff', 'circle-stroke-width': 2 } });
  });
</script>