Preview the map on a live page

See the Siemens map exactly where the Google map sits on a page today, before anyone changes code. The snippet rewrites the page’s own Google Maps iframes in place, in your browser only: same element, same size and layout, every parameter kept except key. Nothing on the server changes and nothing is sent anywhere.

Bookmarklet

  1. Drag this button to your bookmarks bar: Siemens map preview (clicking it here does nothing; it acts on the page you click it on)
  2. Open your page with a Google map and scroll to the map.
  3. Click the bookmark. The Google map turns into the Siemens map in the same box. Reload the page to undo.

No bookmarks bar, or a browser that blocks dragging? Copy the bookmark URL and paste it as the URL of a new bookmark:

Bookmark URL
javascript:(()%20%3D%3E%20%7B%0Aif%20(window.__siemensMapsSwap)%20%7B%0Aconsole.info('%5Bsiemens%20maps%5D%20already%20active')%3B%0Areturn%3B%0A%7D%0Aconst%20GOOGLE%20%3D%20%2F%5Ehttps%3A%5C%2F%5C%2Fwww%5C.google%5C.com%5C%2Fmaps%5C%2Fembed%5C%2Fv1%5C%2F(place%7Cview%7Csearch)%5C%2F%3F(%3F%3D%5C%3F%7C%23%7C%24)%2F%3B%0Aconst%20swap%20%3D%20(el)%20%3D%3E%20%7B%0Afor%20(const%20attr%20of%20%5B'src'%2C%20'data-src'%5D)%20%7B%0Aconst%20value%20%3D%20el.getAttribute(attr)%3B%0Aconst%20match%20%3D%20value%20%26%26%20GOOGLE.exec(value)%3B%0Aif%20(!match)%20continue%3B%0Aconst%20url%20%3D%20new%20URL(value)%3B%0Aurl.searchParams.delete('key')%3B%0Ael.setAttribute(attr%2C%20%60https%3A%2F%2Fmaps.siemens-cdn.com%2Fmaps%2Fembed%2Fv1%2F%24%7Bmatch%5B1%5D%7D%24%7Burl.search%7D%24%7Burl.hash%7D%60)%3B%0Aconsole.info('%5Bsiemens%20maps%5D%20swapped'%2C%20el)%3B%0A%7D%0A%7D%3B%0Aconst%20scan%20%3D%20(node)%20%3D%3E%20%7B%0Aif%20(node.nodeType%20!%3D%3D%201)%20return%3B%0Aif%20(node.tagName%20%3D%3D%3D%20'IFRAME')%20swap(node)%3B%0Anode.querySelectorAll('iframe').forEach(swap)%3B%0A%7D%3B%0Ascan(document.documentElement)%3B%0Aconst%20observer%20%3D%20new%20MutationObserver((records)%20%3D%3E%20%7B%0Afor%20(const%20r%20of%20records)%20%7B%0Aif%20(r.type%20%3D%3D%3D%20'attributes')%20%7B%0Aif%20(r.target.tagName%20%3D%3D%3D%20'IFRAME')%20swap(r.target)%3B%0A%7D%20else%20r.addedNodes.forEach(scan)%3B%0A%7D%0A%7D)%3B%0Aobserver.observe(document.documentElement%2C%20%7B%0Asubtree%3A%20true%2C%0AchildList%3A%20true%2C%0Aattributes%3A%20true%2C%0AattributeFilter%3A%20%5B'src'%2C%20'data-src'%5D%2C%0A%7D)%3B%0Awindow.__siemensMapsSwap%20%3D%20observer%3B%0A%7D)()%3B

Console snippet

The same code, readable. Open the browser’s developer tools on the page (F12 or Cmd+Option+I), go to the Console, paste it and press Enter. Some browsers ask you to type “allow pasting” first.

Console snippet
// Preview the self-hosted map on a live siemens.com page: paste into the browser console.
// Rewrites every Google Maps Embed iframe (place, view, search) in place to maps.siemens-cdn.com,
// keeping the element, its size, classes and wrapper, and every query parameter except `key`.
// Iframes added or changed later (lazy load, consent placeholder, client navigation) are caught
// by a MutationObserver. Pasting it twice does nothing the second time. It sends nothing anywhere.
/* global window, document, MutationObserver */
(() => {
  if (window.__siemensMapsSwap) {
    console.info('[siemens maps] already active');
    return;
  }
  const GOOGLE = /^https:\/\/www\.google\.com\/maps\/embed\/v1\/(place|view|search)\/?(?=\?|#|$)/;
  const swap = (el) => {
    for (const attr of ['src', 'data-src']) {
      const value = el.getAttribute(attr);
      const match = value && GOOGLE.exec(value);
      if (!match) continue;
      const url = new URL(value);
      url.searchParams.delete('key');
      el.setAttribute(attr, `https://maps.siemens-cdn.com/maps/embed/v1/${match[1]}${url.search}${url.hash}`);
      console.info('[siemens maps] swapped', el);
    }
  };
  const scan = (node) => {
    if (node.nodeType !== 1) return;
    if (node.tagName === 'IFRAME') swap(node);
    node.querySelectorAll('iframe').forEach(swap);
  };
  scan(document.documentElement);
  const observer = new MutationObserver((records) => {
    for (const r of records) {
      if (r.type === 'attributes') {
        if (r.target.tagName === 'IFRAME') swap(r.target);
      } else r.addedNodes.forEach(scan);
    }
  });
  observer.observe(document.documentElement, {
    subtree: true,
    childList: true,
    attributes: true,
    attributeFilter: ['src', 'data-src'],
  });
  window.__siemensMapsSwap = observer;
})();

What to expect

  • Maps that load later (lazy loading, a consent placeholder, client-side navigation) are swapped as they appear. Running the snippet twice does nothing the second time; the console says “[siemens maps] already active”.
  • Only Google Maps Embed iframes (place, view, search) change. Street View and every other iframe stay as they are.
  • It works on siemens.com and *.siemens.com pages only: elsewhere the map’s frame-ancestors policy leaves the frame empty (see where the map can be embedded).
  • If your page sends a report-only CSP without our host, the console shows a “[Report Only] Refused to load https://maps.siemens-cdn.com/…” message. Report-only blocks nothing; the map shows. A page whose enforced CSP lacks our host blocks the map: that is the CSP change the page needs anyway.