# Your own look on Google Maps and MapLibre

The provider's map styles, markers of your own HTML and CSS, one brand palette for areas, cluster badges and the list, or Maplace.js's styles turned off for yours.

Your map's look: the provider's own styles, and Maplace.js's parts drawn your way.

## Restyled venue map

A dark frame, pins coloured by category, a legend that filters them and a card of the venues, or of the one picked.

A map that looks nothing like Maplace.js's: a dark frame, pins of your own coloured by category, a count over the map, a legend on it whose chips show one category at a time, and beside it a card listing the venues shown, or the one picked. Each piece is one of Maplace.js's hooks; together they are one idea, the whole look the page's own.

- **Try it**: press "Markets", and the map, the count and the card's list keep the markets, the list named "Markets"; press it again, and every venue is back. Point at a pin, and it lifts; pick one, and it grows, its name beside the count and its address, year and what it is known for in the card beside the map, under it on a phone, in place of the card's list of venues; pick one from the list too, and the card's × brings the list back.
- **HTML**: a `<template data-icon>` in each `<maplace-location>`, with its `group` ([Location attributes](/element/#location-attributes)); the legend a list view of your own, [`defineListView`](/element/#list-views), at `list-position="bottom-left"`. The element puts one view of yours on the map, so the count is your own element over the map's top left, where a control would sit, taking no clicks. The card's details are each venue's own `data-` attributes, read by the page's script on the store's `selectionChange` into the card's `<template>`, added to the card while a venue is picked ([Events](/store/#events)); while none is, the card lists the venues shown, from [`listedLocations`](/store/#listed-locations), each a button calling [`select`](/store/#methods).
- **Script** and **Bundler**: an `icon` node per location ([Icons](/locations/#icons)), and the count and the legend put on the map with the adapter's [`mountControl`](/store/#adapters), the count rewritten from [`listedLocations`](/store/#listed-locations), the name beside it from the snapshot's `selectedId`, the press moved with the store's filter as the store changes, and the card written from the venue's `data` ([Location fields](/locations/)) on `selectionChange`, its markup a `<template>` in the page, and while no venue is, a button per venue shown, rewritten from `listedLocations` when they change; a chip calls [`setFilter`](/store/#methods) with its category, or with nothing to show them all.
- **React**: `markerIcon` on [`<MaplaceMap>`](/react/#maplacemap), and the count and the legend in two [`<MapControl>`](/react/#mapcontrol)s, reading the store with [`useMaplace()`](/react/#usemaplace), as the card does beside `<MaplaceMap>`, inside `<MaplaceProvider>`, its list read as the ids listed so a hover renders nothing, and `flushSync` rendering it at once so a press can move the focus into it.
- **On Google**: its map-type, Street View and camera controls are off (`map-options` in HTML, `mapOptions` elsewhere), for the clean look, as the MapLibre map shows none either.
- **In every version**: the look is one stylesheet, `whats-on.css`, in the examples' `styles/` folder, which each version's HTML links, so the page, the script, the bundled and the React versions share it, scoped by the frame's class, `.whats-on`, and the map's, `.whats-on-map`. Every venue fitted with 80px of padding, clear of the count and the legend: the store's `view`, `{ kind: "fit-all", padding: 80 }` ([The first view](/store/#the-first-view)), or in HTML, which has no attribute for it, [`fitAll`](/store/#methods) before the map opens. Maplace.js's panel around what goes on the map is made nothing with `.maplace-control { padding: 0; background: none; box-shadow: none; }`, as its rules weigh nothing ([Styling](/styling/)); each category's colour is one custom property, `--category`, which its pins and its chip take; the pins' hovered and selected looks are rules on `data-hovered` and `data-selected`, as in [HTML markers with CSS states](/examples/styling/#css-markers). A venue picked from the card's list moves the focus to the card's ×, named "Close", which takes it back to that venue in the list, so a keyboard never loses its place. The name of the venue picked is a plain element, not a live region: Maplace.js already says each selection to a screen reader ([On every map](/store/#on-every-map)). The pins differ by colour alone, so the chips, named, are how a reader picks a category out.


### HTML on MapLibre

`packages/maplace/examples/whats-on/maplibre/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- A look all your own, on OpenFreeMap's liberty style: a dark frame, pins of your markup
     coloured by category, a count over the map's top left and a legend on its bottom left whose
     chips show one category; Maplace.js's panel on the map made nothing. -->
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../../styles/whats-on.css">
<div id="whats-on-maplibre-frame" class="whats-on">
  <div id="whats-on-maplibre-status" class="event-status over-map">
    <output id="whats-on-maplibre-count" class="event-count"></output>
    <span id="whats-on-maplibre-selected" class="event-selected" hidden></span>
  </div>
  <maplace-map id="whats-on-maplibre-map" class="whats-on-map" map-style="https://tiles.openfreemap.org/styles/liberty"
    list="maplibre-whats-on-legend" list-position="bottom-left">
    <maplace-location location-id="national-theatre" lat="51.507" lng="-0.1145" title="National Theatre" group="Theatre"
      data-address="Upper Ground, London SE1 9PX" data-since="1976" data-known-for="Three stages on the South Bank">
      <template data-icon><span class="pin" data-category="Theatre"></span></template>
    </maplace-location>
    <maplace-location location-id="globe" lat="51.5081" lng="-0.0972" title="Shakespeare's Globe" group="Theatre"
      data-address="21 New Globe Walk, London SE1 9DT" data-since="1997" data-known-for="An open-air playhouse rebuilt after the 1599 original">
      <template data-icon><span class="pin" data-category="Theatre"></span></template>
    </maplace-location>
    <maplace-location location-id="donmar" lat="51.5136" lng="-0.1254" title="Donmar Warehouse" group="Theatre"
      data-address="41 Earlham Street, London WC2H 9LX" data-since="1977" data-known-for="A small studio theatre in Covent Garden">
      <template data-icon><span class="pin" data-category="Theatre"></span></template>
    </maplace-location>
    <maplace-location location-id="royal-albert-hall" lat="51.501" lng="-0.1774" title="Royal Albert Hall" group="Concerts"
      data-address="Kensington Gore, London SW7 2AP" data-since="1871" data-known-for="The BBC Proms, every summer">
      <template data-icon><span class="pin" data-category="Concerts"></span></template>
    </maplace-location>
    <maplace-location location-id="wigmore-hall" lat="51.5165" lng="-0.149" title="Wigmore Hall" group="Concerts"
      data-address="36 Wigmore Street, London W1U 2BP" data-since="1901" data-known-for="Chamber music and song recitals">
      <template data-icon><span class="pin" data-category="Concerts"></span></template>
    </maplace-location>
    <maplace-location location-id="barbican" lat="51.5202" lng="-0.0938" title="Barbican Hall" group="Concerts"
      data-address="Silk Street, London EC2Y 8DS" data-since="1982" data-known-for="Home of the London Symphony Orchestra">
      <template data-icon><span class="pin" data-category="Concerts"></span></template>
    </maplace-location>
    <maplace-location location-id="borough-market" lat="51.5055" lng="-0.091" title="Borough Market" group="Markets"
      data-address="8 Southwark Street, London SE1 1TL" data-since="1756" data-known-for="One of London's oldest food markets">
      <template data-icon><span class="pin" data-category="Markets"></span></template>
    </maplace-location>
    <maplace-location location-id="camden-market" lat="51.5413" lng="-0.146" title="Camden Market" group="Markets"
      data-address="Camden Lock Place, London NW1 8AF" data-since="1974" data-known-for="Stalls along the Regent's Canal">
      <template data-icon><span class="pin" data-category="Markets"></span></template>
    </maplace-location>
    <maplace-location location-id="spitalfields" lat="51.5197" lng="-0.0754" title="Old Spitalfields Market" group="Markets"
      data-address="16 Horner Square, London E1 6EW" data-since="1638" data-known-for="A Victorian market hall in the East End">
      <template data-icon><span class="pin" data-category="Markets"></span></template>
    </maplace-location>
    <maplace-location location-id="british-library" lat="51.5299" lng="-0.1277" title="British Library" group="Talks"
      data-address="96 Euston Road, London NW1 2DB" data-since="1973" data-known-for="The UK's national library, at St Pancras">
      <template data-icon><span class="pin" data-category="Talks"></span></template>
    </maplace-location>
    <maplace-location location-id="conway-hall" lat="51.5203" lng="-0.1188" title="Conway Hall" group="Talks"
      data-address="25 Red Lion Square, London WC1R 4RL" data-since="1929" data-known-for="Talks and debates, home of the Conway Hall Ethical Society">
      <template data-icon><span class="pin" data-category="Talks"></span></template>
    </maplace-location>
    <maplace-location location-id="royal-institution" lat="51.5098" lng="-0.1425" title="Royal Institution" group="Talks"
      data-address="21 Albemarle Street, London W1S 4BS" data-since="1799" data-known-for="The Christmas Lectures, given since 1825">
      <template data-icon><span class="pin" data-category="Talks"></span></template>
    </maplace-location>
  </maplace-map>
  <aside id="whats-on-maplibre-card" class="venue-card" aria-label="Venue">
    <div class="venue-picker">
      <p class="venue-list-category" hidden></p>
      <p class="venue-empty">Pick a venue on the map, or here.</p>
      <ul class="venue-list" aria-label="Venues"></ul>
    </div>
    <template>
      <div class="venue">
        <button type="button" class="venue-close" aria-label="Close"></button>
        <p class="venue-category"></p>
        <h3 class="venue-name">Venue</h3>
        <dl>
          <div><dt>Address</dt><dd class="venue-address"></dd></div>
          <div><dt>Since</dt><dd class="venue-since"></dd></div>
          <div><dt>Known for</dt><dd class="venue-known-for"></dd></div>
        </dl>
      </div>
    </template>
  </aside>
</div>
<script>
  // The category the map shows alone, if any: the legend presses its chip, the card names it.
  const whatsOnMaplibreShownAlone = (maplace) => {
    const groups = maplace.getSnapshot().filter?.groups;
    return groups?.length === 1 ? groups[0] : undefined;
  };

  // The legend, a list view of your own: a chip per category, in the venues' order, showing that
  // category alone, or every one again once pressed. The chips are made once, so a chip pressed
  // from the keyboard keeps its focus; a store change only moves the press.
  Maplace.defineListView('maplibre-whats-on-legend', (maplace) => {
    const legend = document.createElement('fieldset');
    legend.className = 'event-legend';
    legend.setAttribute('aria-label', 'Categories');
    const categories = new Set(maplace.getSnapshot().locations.flatMap(({ group }) => group ?? []));
    const chips = [...categories].map((category) => {
      const chip = document.createElement('button');
      chip.type = 'button';
      chip.className = 'category-chip';
      chip.dataset.category = category;
      chip.setAttribute('aria-pressed', 'false');
      chip.textContent = category;
      chip.addEventListener('click', () => maplace.setFilter(whatsOnMaplibreShownAlone(maplace) === category ? undefined : [category]));
      return chip;
    });
    legend.append(...chips);
    let pressed;
    const pressShownAlone = () => {
      const alone = whatsOnMaplibreShownAlone(maplace);
      if (alone === pressed) return;
      pressed = alone;
      for (const chip of chips) chip.setAttribute('aria-pressed', String(chip.dataset.category === alone));
    };
    pressShownAlone();
    const unsubscribe = maplace.subscribe(pressShownAlone);
    return { element: legend, destroy: () => { unsubscribe(); legend.remove(); } };
  });

  // Every venue fitted, with room at the edges for the count and the legend over the map, as the
  // map opens; then the count over the map: how many venues are shown, of all of them, said again
  // when that changes.
  {
    const maplace = document.getElementById('whats-on-maplibre-map').maplace;
    maplace.fitAll({ padding: 80 });
    const count = document.getElementById('whats-on-maplibre-count');
    const writeCount = () => {
      const snapshot = maplace.getSnapshot();
      const shown = Maplace.listedLocations(snapshot).length;
      const total = snapshot.locations.length;
      const text = shown === total ? `${total} venues` : `${shown} of ${total} venues`;
      if (count.textContent !== text) count.textContent = text;
    };
    writeCount();
    maplace.subscribe(writeCount);

    // Beside it, the name of the venue selected, marked with its category for its colour; hidden
    // while none is. Not a live region: Maplace.js says each selection to a screen reader already.
    const name = document.getElementById('whats-on-maplibre-selected');
    const writeName = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      name.hidden = selected === undefined;
      name.textContent = selected?.title ?? '';
      name.dataset.category = selected?.group ?? '';
    };
    writeName(maplace.getSnapshot().selectedId);
    maplace.on('selectionChange', ({ id }) => writeName(id));

    // The card beside the map: the venue selected, its details from its location's data-
    // attributes, its category marked for its colour, made from the card's template and in the card
    // only while a venue is selected, with a × closing it; or, while none is, the venues shown,
    // each a button selecting it, under the category shown alone, if any, written again only when
    // the venues shown change, as a hover changes the store too. Not a live region either.
    const card = document.getElementById('whats-on-maplibre-card');
    const picker = card.querySelector('.venue-picker');
    const list = card.querySelector('.venue-list');
    const categoryLine = card.querySelector('.venue-list-category');
    const venuePart = card.querySelector('template').content.firstElementChild.cloneNode(true);
    const close = venuePart.querySelector('.venue-close');
    close.addEventListener('click', () => {
      const closed = maplace.getSnapshot().selectedId ?? '';
      maplace.select(undefined);
      picker.querySelector(`.venue-pick[data-id="${CSS.escape(closed)}"]`)?.focus();
    });
    const venueEntry = ({ id, title, group }) => {
      const pick = document.createElement('button');
      pick.type = 'button';
      pick.className = 'venue-pick';
      pick.dataset.category = group ?? '';
      pick.textContent = title ?? id;
      pick.dataset.id = id;
      pick.addEventListener('click', () => {
        maplace.select(id);
        close.focus();
      });
      const entry = document.createElement('li');
      entry.append(pick);
      return entry;
    };
    let listedIds;
    const writeList = () => {
      const listed = Maplace.listedLocations(maplace.getSnapshot());
      const ids = listed.map(({ id }) => id).join();
      if (ids === listedIds) return;
      listedIds = ids;
      const alone = whatsOnMaplibreShownAlone(maplace);
      categoryLine.hidden = alone === undefined;
      categoryLine.textContent = alone ?? '';
      categoryLine.dataset.category = alone ?? '';
      list.replaceChildren(...listed.map(venueEntry));
    };
    writeList();
    maplace.subscribe(writeList);
    const write = (selector, text) => { venuePart.querySelector(selector).textContent = text; };
    const writeCard = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      picker.hidden = selected !== undefined;
      if (selected === undefined) {
        venuePart.remove();
        return;
      }
      const details = document.querySelector(`#whats-on-maplibre-map > [location-id="${CSS.escape(id)}"]`).dataset;
      venuePart.dataset.category = selected.group;
      write('.venue-category', selected.group);
      write('.venue-name', selected.title);
      write('.venue-address', details.address);
      write('.venue-since', details.since);
      write('.venue-known-for', details.knownFor);
      if (!venuePart.isConnected) card.append(venuePart);
    };
    writeCard(maplace.getSnapshot().selectedId);
    maplace.on('selectionChange', ({ id }) => writeCard(id));
  }
</script>
```

### HTML on Google

`packages/maplace/examples/whats-on/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- A look all your own, on Google's map without its map-type, Street View and camera controls:
     a dark frame, pins of your markup coloured by category, a count over the map's top left and a
     legend on its bottom left whose chips show one category; Maplace.js's panel on the map made
     nothing. -->
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../styles/whats-on.css">
<div id="whats-on-frame" class="whats-on">
  <div id="whats-on-status" class="event-status over-map">
    <output id="whats-on-count" class="event-count"></output>
    <span id="whats-on-selected" class="event-selected" hidden></span>
  </div>
  <maplace-map id="whats-on-map" class="whats-on-map" api-key="YOUR_KEY" map-options='{"mapTypeControl":false,"streetViewControl":false,"cameraControl":false}'
    list="whats-on-legend" list-position="bottom-left">
    <maplace-location location-id="national-theatre" lat="51.507" lng="-0.1145" title="National Theatre" group="Theatre"
      data-address="Upper Ground, London SE1 9PX" data-since="1976" data-known-for="Three stages on the South Bank">
      <template data-icon><span class="pin" data-category="Theatre"></span></template>
    </maplace-location>
    <maplace-location location-id="globe" lat="51.5081" lng="-0.0972" title="Shakespeare's Globe" group="Theatre"
      data-address="21 New Globe Walk, London SE1 9DT" data-since="1997" data-known-for="An open-air playhouse rebuilt after the 1599 original">
      <template data-icon><span class="pin" data-category="Theatre"></span></template>
    </maplace-location>
    <maplace-location location-id="donmar" lat="51.5136" lng="-0.1254" title="Donmar Warehouse" group="Theatre"
      data-address="41 Earlham Street, London WC2H 9LX" data-since="1977" data-known-for="A small studio theatre in Covent Garden">
      <template data-icon><span class="pin" data-category="Theatre"></span></template>
    </maplace-location>
    <maplace-location location-id="royal-albert-hall" lat="51.501" lng="-0.1774" title="Royal Albert Hall" group="Concerts"
      data-address="Kensington Gore, London SW7 2AP" data-since="1871" data-known-for="The BBC Proms, every summer">
      <template data-icon><span class="pin" data-category="Concerts"></span></template>
    </maplace-location>
    <maplace-location location-id="wigmore-hall" lat="51.5165" lng="-0.149" title="Wigmore Hall" group="Concerts"
      data-address="36 Wigmore Street, London W1U 2BP" data-since="1901" data-known-for="Chamber music and song recitals">
      <template data-icon><span class="pin" data-category="Concerts"></span></template>
    </maplace-location>
    <maplace-location location-id="barbican" lat="51.5202" lng="-0.0938" title="Barbican Hall" group="Concerts"
      data-address="Silk Street, London EC2Y 8DS" data-since="1982" data-known-for="Home of the London Symphony Orchestra">
      <template data-icon><span class="pin" data-category="Concerts"></span></template>
    </maplace-location>
    <maplace-location location-id="borough-market" lat="51.5055" lng="-0.091" title="Borough Market" group="Markets"
      data-address="8 Southwark Street, London SE1 1TL" data-since="1756" data-known-for="One of London's oldest food markets">
      <template data-icon><span class="pin" data-category="Markets"></span></template>
    </maplace-location>
    <maplace-location location-id="camden-market" lat="51.5413" lng="-0.146" title="Camden Market" group="Markets"
      data-address="Camden Lock Place, London NW1 8AF" data-since="1974" data-known-for="Stalls along the Regent's Canal">
      <template data-icon><span class="pin" data-category="Markets"></span></template>
    </maplace-location>
    <maplace-location location-id="spitalfields" lat="51.5197" lng="-0.0754" title="Old Spitalfields Market" group="Markets"
      data-address="16 Horner Square, London E1 6EW" data-since="1638" data-known-for="A Victorian market hall in the East End">
      <template data-icon><span class="pin" data-category="Markets"></span></template>
    </maplace-location>
    <maplace-location location-id="british-library" lat="51.5299" lng="-0.1277" title="British Library" group="Talks"
      data-address="96 Euston Road, London NW1 2DB" data-since="1973" data-known-for="The UK's national library, at St Pancras">
      <template data-icon><span class="pin" data-category="Talks"></span></template>
    </maplace-location>
    <maplace-location location-id="conway-hall" lat="51.5203" lng="-0.1188" title="Conway Hall" group="Talks"
      data-address="25 Red Lion Square, London WC1R 4RL" data-since="1929" data-known-for="Talks and debates, home of the Conway Hall Ethical Society">
      <template data-icon><span class="pin" data-category="Talks"></span></template>
    </maplace-location>
    <maplace-location location-id="royal-institution" lat="51.5098" lng="-0.1425" title="Royal Institution" group="Talks"
      data-address="21 Albemarle Street, London W1S 4BS" data-since="1799" data-known-for="The Christmas Lectures, given since 1825">
      <template data-icon><span class="pin" data-category="Talks"></span></template>
    </maplace-location>
  </maplace-map>
  <aside id="whats-on-card" class="venue-card" aria-label="Venue">
    <div class="venue-picker">
      <p class="venue-list-category" hidden></p>
      <p class="venue-empty">Pick a venue on the map, or here.</p>
      <ul class="venue-list" aria-label="Venues"></ul>
    </div>
    <template>
      <div class="venue">
        <button type="button" class="venue-close" aria-label="Close"></button>
        <p class="venue-category"></p>
        <h3 class="venue-name">Venue</h3>
        <dl>
          <div><dt>Address</dt><dd class="venue-address"></dd></div>
          <div><dt>Since</dt><dd class="venue-since"></dd></div>
          <div><dt>Known for</dt><dd class="venue-known-for"></dd></div>
        </dl>
      </div>
    </template>
  </aside>
</div>
<script>
  // The category the map shows alone, if any: the legend presses its chip, the card names it.
  const whatsOnShownAlone = (maplace) => {
    const groups = maplace.getSnapshot().filter?.groups;
    return groups?.length === 1 ? groups[0] : undefined;
  };

  // The legend, a list view of your own: a chip per category, in the venues' order, showing that
  // category alone, or every one again once pressed. The chips are made once, so a chip pressed
  // from the keyboard keeps its focus; a store change only moves the press.
  Maplace.defineListView('whats-on-legend', (maplace) => {
    const legend = document.createElement('fieldset');
    legend.className = 'event-legend';
    legend.setAttribute('aria-label', 'Categories');
    const categories = new Set(maplace.getSnapshot().locations.flatMap(({ group }) => group ?? []));
    const chips = [...categories].map((category) => {
      const chip = document.createElement('button');
      chip.type = 'button';
      chip.className = 'category-chip';
      chip.dataset.category = category;
      chip.setAttribute('aria-pressed', 'false');
      chip.textContent = category;
      chip.addEventListener('click', () => maplace.setFilter(whatsOnShownAlone(maplace) === category ? undefined : [category]));
      return chip;
    });
    legend.append(...chips);
    let pressed;
    const pressShownAlone = () => {
      const alone = whatsOnShownAlone(maplace);
      if (alone === pressed) return;
      pressed = alone;
      for (const chip of chips) chip.setAttribute('aria-pressed', String(chip.dataset.category === alone));
    };
    pressShownAlone();
    const unsubscribe = maplace.subscribe(pressShownAlone);
    return { element: legend, destroy: () => { unsubscribe(); legend.remove(); } };
  });

  // Every venue fitted, with room at the edges for the count and the legend over the map, as the
  // map opens; then the count over the map: how many venues are shown, of all of them, said again
  // when that changes.
  {
    const maplace = document.getElementById('whats-on-map').maplace;
    maplace.fitAll({ padding: 80 });
    const count = document.getElementById('whats-on-count');
    const writeCount = () => {
      const snapshot = maplace.getSnapshot();
      const shown = Maplace.listedLocations(snapshot).length;
      const total = snapshot.locations.length;
      const text = shown === total ? `${total} venues` : `${shown} of ${total} venues`;
      if (count.textContent !== text) count.textContent = text;
    };
    writeCount();
    maplace.subscribe(writeCount);

    // Beside it, the name of the venue selected, marked with its category for its colour; hidden
    // while none is. Not a live region: Maplace.js says each selection to a screen reader already.
    const name = document.getElementById('whats-on-selected');
    const writeName = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      name.hidden = selected === undefined;
      name.textContent = selected?.title ?? '';
      name.dataset.category = selected?.group ?? '';
    };
    writeName(maplace.getSnapshot().selectedId);
    maplace.on('selectionChange', ({ id }) => writeName(id));

    // The card beside the map: the venue selected, its details from its location's data-
    // attributes, its category marked for its colour, made from the card's template and in the card
    // only while a venue is selected, with a × closing it; or, while none is, the venues shown,
    // each a button selecting it, under the category shown alone, if any, written again only when
    // the venues shown change, as a hover changes the store too. Not a live region either.
    const card = document.getElementById('whats-on-card');
    const picker = card.querySelector('.venue-picker');
    const list = card.querySelector('.venue-list');
    const categoryLine = card.querySelector('.venue-list-category');
    const venuePart = card.querySelector('template').content.firstElementChild.cloneNode(true);
    const close = venuePart.querySelector('.venue-close');
    close.addEventListener('click', () => {
      const closed = maplace.getSnapshot().selectedId ?? '';
      maplace.select(undefined);
      picker.querySelector(`.venue-pick[data-id="${CSS.escape(closed)}"]`)?.focus();
    });
    const venueEntry = ({ id, title, group }) => {
      const pick = document.createElement('button');
      pick.type = 'button';
      pick.className = 'venue-pick';
      pick.dataset.category = group ?? '';
      pick.textContent = title ?? id;
      pick.dataset.id = id;
      pick.addEventListener('click', () => {
        maplace.select(id);
        close.focus();
      });
      const entry = document.createElement('li');
      entry.append(pick);
      return entry;
    };
    let listedIds;
    const writeList = () => {
      const listed = Maplace.listedLocations(maplace.getSnapshot());
      const ids = listed.map(({ id }) => id).join();
      if (ids === listedIds) return;
      listedIds = ids;
      const alone = whatsOnShownAlone(maplace);
      categoryLine.hidden = alone === undefined;
      categoryLine.textContent = alone ?? '';
      categoryLine.dataset.category = alone ?? '';
      list.replaceChildren(...listed.map(venueEntry));
    };
    writeList();
    maplace.subscribe(writeList);
    const write = (selector, text) => { venuePart.querySelector(selector).textContent = text; };
    const writeCard = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      picker.hidden = selected !== undefined;
      if (selected === undefined) {
        venuePart.remove();
        return;
      }
      const details = document.querySelector(`#whats-on-map > [location-id="${CSS.escape(id)}"]`).dataset;
      venuePart.dataset.category = selected.group;
      write('.venue-category', selected.group);
      write('.venue-name', selected.title);
      write('.venue-address', details.address);
      write('.venue-since', details.since);
      write('.venue-known-for', details.knownFor);
      if (!venuePart.isConnected) card.append(venuePart);
    };
    writeCard(maplace.getSnapshot().selectedId);
    maplace.on('selectionChange', ({ id }) => writeCard(id));
  }
</script>
```

### Script on MapLibre

`packages/maplace/examples/whats-on/maplibre/script.html`

```html
<!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet, what the map mounts on, and the map made with Maplace's store and adapter, on OpenFreeMap's liberty style; a count and a legend of your own on it, in Maplace.js's panel made nothing. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../../styles/whats-on.css">
<div id="whats-on-maplibre-script-frame" class="whats-on">
  <div id="whats-on-maplibre-script-map" class="whats-on-map"></div>
  <aside id="whats-on-maplibre-script-card" class="venue-card" aria-label="Venue">
    <div class="venue-picker">
      <p class="venue-list-category" hidden></p>
      <p class="venue-empty">Pick a venue on the map, or here.</p>
      <ul class="venue-list" aria-label="Venues"></ul>
    </div>
    <template>
      <div class="venue">
        <button type="button" class="venue-close" aria-label="Close"></button>
        <p class="venue-category"></p>
        <h3 class="venue-name">Venue</h3>
        <dl>
          <div><dt>Address</dt><dd class="venue-address"></dd></div>
          <div><dt>Since</dt><dd class="venue-since"></dd></div>
          <div><dt>Known for</dt><dd class="venue-known-for"></dd></div>
        </dl>
      </div>
    </template>
  </aside>
</div>
<script type="module">
  const locations = [
    venue("national-theatre", 51.507, -0.1145, "National Theatre", "Theatre", {
      address: "Upper Ground, London SE1 9PX",
      since: 1976,
      knownFor: "Three stages on the South Bank",
    }),
    venue("globe", 51.5081, -0.0972, "Shakespeare's Globe", "Theatre", {
      address: "21 New Globe Walk, London SE1 9DT",
      since: 1997,
      knownFor: "An open-air playhouse rebuilt after the 1599 original",
    }),
    venue("donmar", 51.5136, -0.1254, "Donmar Warehouse", "Theatre", {
      address: "41 Earlham Street, London WC2H 9LX",
      since: 1977,
      knownFor: "A small studio theatre in Covent Garden",
    }),
    venue("royal-albert-hall", 51.501, -0.1774, "Royal Albert Hall", "Concerts", {
      address: "Kensington Gore, London SW7 2AP",
      since: 1871,
      knownFor: "The BBC Proms, every summer",
    }),
    venue("wigmore-hall", 51.5165, -0.149, "Wigmore Hall", "Concerts", {
      address: "36 Wigmore Street, London W1U 2BP",
      since: 1901,
      knownFor: "Chamber music and song recitals",
    }),
    venue("barbican", 51.5202, -0.0938, "Barbican Hall", "Concerts", {
      address: "Silk Street, London EC2Y 8DS",
      since: 1982,
      knownFor: "Home of the London Symphony Orchestra",
    }),
    venue("borough-market", 51.5055, -0.091, "Borough Market", "Markets", {
      address: "8 Southwark Street, London SE1 1TL",
      since: 1756,
      knownFor: "One of London's oldest food markets",
    }),
    venue("camden-market", 51.5413, -0.146, "Camden Market", "Markets", {
      address: "Camden Lock Place, London NW1 8AF",
      since: 1974,
      knownFor: "Stalls along the Regent's Canal",
    }),
    venue("spitalfields", 51.5197, -0.0754, "Old Spitalfields Market", "Markets", {
      address: "16 Horner Square, London E1 6EW",
      since: 1638,
      knownFor: "A Victorian market hall in the East End",
    }),
    venue("british-library", 51.5299, -0.1277, "British Library", "Talks", {
      address: "96 Euston Road, London NW1 2DB",
      since: 1973,
      knownFor: "The UK's national library, at St Pancras",
    }),
    venue("conway-hall", 51.5203, -0.1188, "Conway Hall", "Talks", {
      address: "25 Red Lion Square, London WC1R 4RL",
      since: 1929,
      knownFor: "Talks and debates, home of the Conway Hall Ethical Society",
    }),
    venue("royal-institution", 51.5098, -0.1425, "Royal Institution", "Talks", {
      address: "21 Albemarle Street, London W1S 4BS",
      since: 1799,
      knownFor: "The Christmas Lectures, given since 1825",
    }),
  ];

  /** Every venue fitted, with room at the edges for the count and the legend over the map. */
  const maplace = Maplace.createMaplace({ locations, view: { kind: "fit-all", padding: 80 } });
  const adapter = Maplace.createMapLibreAdapter({ mapStyle: "https://tiles.openfreemap.org/styles/liberty" });
  maplace.attach(adapter, "#whats-on-maplibre-script-map");
  adapter.mountControl(eventLegend(maplace), "bottom-left");
  adapter.mountControl(eventStatus(maplace), "top-left");
  showVenueIn(document.querySelector("#whats-on-maplibre-script-card"), maplace);

  /** A venue in its category, its pin coloured by it, with what the card says of it. */
  function venue(id, lat, lng, title, group, data) {
    return { id, lat, lng, title, group, data, icon: pinFor(group) };
  }

  /** A pin of your own, its colour the category's (`--category`, by `data-category` in the CSS). */
  function pinFor(category) {
    const pin = document.createElement("span");
    pin.className = "pin";
    pin.dataset.category = category;
    return pin;
  }

  /** The count, and beside it the name of the venue selected, if any. */
  function eventStatus(maplace) {
    const status = document.createElement("div");
    status.className = "event-status";
    status.append(eventCount(maplace), selectedName(maplace));
    return status;
  }

  /** How many venues are shown, of all of them, said again when that changes. */
  function eventCount(maplace) {
    const count = document.createElement("output");
    count.className = "event-count";
    const writeCount = () => {
      const snapshot = maplace.getSnapshot();
      const shown = Maplace.listedLocations(snapshot).length;
      const total = snapshot.locations.length;
      const text = shown === total ? `${total} venues` : `${shown} of ${total} venues`;
      if (count.textContent !== text) count.textContent = text;
    };
    writeCount();
    maplace.subscribe(writeCount);
    return count;
  }

  /**
   * The name of the venue selected, marked with its category for its colour; hidden while none is.
   * Not a live region: Maplace.js says each selection to a screen reader already.
   */
  function selectedName(maplace) {
    const name = document.createElement("span");
    name.className = "event-selected";
    const writeName = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      name.hidden = selected === undefined;
      name.textContent = selected?.title ?? "";
      name.dataset.category = selected?.group ?? "";
    };
    writeName(maplace.getSnapshot().selectedId);
    maplace.on("selectionChange", ({ id }) => writeName(id));
    return name;
  }

  /**
   * The card beside the map: the venue selected, its category marked for its colour, made from the
   * card's template and in the card only while a venue is selected, with a × closing it;
   * or, while none is, the venues shown, each a button selecting it. Not a live region: Maplace.js
   * says each selection to a screen reader already.
   */
  function showVenueIn(card, maplace) {
    const picker = card.querySelector(".venue-picker");
    const venuePart = card.querySelector("template").content.firstElementChild.cloneNode(true);
    const close = venuePart.querySelector(".venue-close");
    close.addEventListener("click", () => {
      const closed = maplace.getSnapshot().selectedId ?? "";
      maplace.select(undefined);
      picker.querySelector(`.venue-pick[data-id="${CSS.escape(closed)}"]`)?.focus();
    });
    listVenuesIn(picker, maplace, () => close.focus());
    const write = (selector, text) => {
      venuePart.querySelector(selector).textContent = text;
    };
    const writeCard = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      const data = selected?.data;
      picker.hidden = data !== undefined;
      if (selected === undefined || data === undefined) {
        venuePart.remove();
        return;
      }
      venuePart.dataset.category = selected.group;
      write(".venue-category", selected.group ?? "");
      write(".venue-name", selected.title ?? "");
      write(".venue-address", data.address);
      write(".venue-since", String(data.since));
      write(".venue-known-for", data.knownFor);
      if (!venuePart.isConnected) card.append(venuePart);
    };
    writeCard(maplace.getSnapshot().selectedId);
    maplace.on("selectionChange", ({ id }) => writeCard(id));
  }

  /**
   * In the card's `picker`, a button per venue shown, selecting it and then calling `afterPick`, and
   * above them the category shown alone, if any, marked for its colour; written again only when the
   * venues shown change, as a hover changes the store too.
   */
  function listVenuesIn(picker, maplace, afterPick) {
    const categoryLine = picker.querySelector(".venue-list-category");
    const list = picker.querySelector(".venue-list");
    let listedIds;
    const writeList = () => {
      const listed = Maplace.listedLocations(maplace.getSnapshot());
      const ids = listed.map(({ id }) => id).join();
      if (ids === listedIds) return;
      listedIds = ids;
      const alone = shownAlone(maplace);
      categoryLine.hidden = alone === undefined;
      categoryLine.textContent = alone ?? "";
      categoryLine.dataset.category = alone ?? "";
      list.replaceChildren(...listed.map((location) => venueEntry(location, maplace, afterPick)));
    };
    writeList();
    maplace.subscribe(writeList);
  }

  /** A venue in the card's list: a button selecting it, marked with its category for its colour. */
  function venueEntry({ id, title, group }, maplace, afterPick) {
    const pick = document.createElement("button");
    pick.type = "button";
    pick.className = "venue-pick";
    pick.dataset.category = group ?? "";
    pick.textContent = title ?? id;
    pick.dataset.id = id;
    pick.addEventListener("click", () => {
      maplace.select(id);
      afterPick();
    });
    const entry = document.createElement("li");
    entry.append(pick);
    return entry;
  }

  /**
   * A chip per category, in the venues' order; the one shown alone is pressed. The chips are made once,
   * so a chip pressed from the keyboard keeps its focus; a store change only moves the press.
   */
  function eventLegend(maplace) {
    const legend = document.createElement("fieldset");
    legend.className = "event-legend";
    legend.setAttribute("aria-label", "Categories");
    const categories = new Set(maplace.getSnapshot().locations.flatMap(({ group }) => group ?? []));
    const chips = [...categories].map((category) => categoryChip(maplace, category));
    legend.append(...chips);
    let pressed;
    const pressShownAlone = () => {
      const alone = shownAlone(maplace);
      if (alone === pressed) return;
      pressed = alone;
      for (const chip of chips) {
        chip.setAttribute("aria-pressed", String(chip.dataset.category === alone));
      }
    };
    pressShownAlone();
    maplace.subscribe(pressShownAlone);
    return legend;
  }

  /** A toggle showing `category` alone, or every category again once pressed. */
  function categoryChip(maplace, category) {
    const chip = document.createElement("button");
    chip.type = "button";
    chip.className = "category-chip";
    chip.dataset.category = category;
    chip.setAttribute("aria-pressed", "false");
    chip.textContent = category;
    chip.addEventListener("click", () => {
      maplace.setFilter(shownAlone(maplace) === category ? undefined : [category]);
    });
    return chip;
  }

  /** The category the map shows alone, if any. */
  function shownAlone(maplace) {
    const groups = maplace.getSnapshot().filter?.groups;
    return groups?.length === 1 ? groups[0] : undefined;
  }
</script>
```

### Script on Google

`packages/maplace/examples/whats-on/script.html`

```html
<!doctype html>
<!-- A page of your own script: the CDN script, what the map mounts on, and the map made with Maplace's store and adapter, which adds Maps JS with your key, without its map-type, Street View and camera controls; a count and a legend of your own on it, in Maplace.js's panel made nothing. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../styles/whats-on.css">
<div id="whats-on-script-frame" class="whats-on">
  <div id="whats-on-script-map" class="whats-on-map"></div>
  <aside id="whats-on-script-card" class="venue-card" aria-label="Venue">
    <div class="venue-picker">
      <p class="venue-list-category" hidden></p>
      <p class="venue-empty">Pick a venue on the map, or here.</p>
      <ul class="venue-list" aria-label="Venues"></ul>
    </div>
    <template>
      <div class="venue">
        <button type="button" class="venue-close" aria-label="Close"></button>
        <p class="venue-category"></p>
        <h3 class="venue-name">Venue</h3>
        <dl>
          <div><dt>Address</dt><dd class="venue-address"></dd></div>
          <div><dt>Since</dt><dd class="venue-since"></dd></div>
          <div><dt>Known for</dt><dd class="venue-known-for"></dd></div>
        </dl>
      </div>
    </template>
  </aside>
</div>
<script type="module">
  const locations = [
    venue("national-theatre", 51.507, -0.1145, "National Theatre", "Theatre", {
      address: "Upper Ground, London SE1 9PX",
      since: 1976,
      knownFor: "Three stages on the South Bank",
    }),
    venue("globe", 51.5081, -0.0972, "Shakespeare's Globe", "Theatre", {
      address: "21 New Globe Walk, London SE1 9DT",
      since: 1997,
      knownFor: "An open-air playhouse rebuilt after the 1599 original",
    }),
    venue("donmar", 51.5136, -0.1254, "Donmar Warehouse", "Theatre", {
      address: "41 Earlham Street, London WC2H 9LX",
      since: 1977,
      knownFor: "A small studio theatre in Covent Garden",
    }),
    venue("royal-albert-hall", 51.501, -0.1774, "Royal Albert Hall", "Concerts", {
      address: "Kensington Gore, London SW7 2AP",
      since: 1871,
      knownFor: "The BBC Proms, every summer",
    }),
    venue("wigmore-hall", 51.5165, -0.149, "Wigmore Hall", "Concerts", {
      address: "36 Wigmore Street, London W1U 2BP",
      since: 1901,
      knownFor: "Chamber music and song recitals",
    }),
    venue("barbican", 51.5202, -0.0938, "Barbican Hall", "Concerts", {
      address: "Silk Street, London EC2Y 8DS",
      since: 1982,
      knownFor: "Home of the London Symphony Orchestra",
    }),
    venue("borough-market", 51.5055, -0.091, "Borough Market", "Markets", {
      address: "8 Southwark Street, London SE1 1TL",
      since: 1756,
      knownFor: "One of London's oldest food markets",
    }),
    venue("camden-market", 51.5413, -0.146, "Camden Market", "Markets", {
      address: "Camden Lock Place, London NW1 8AF",
      since: 1974,
      knownFor: "Stalls along the Regent's Canal",
    }),
    venue("spitalfields", 51.5197, -0.0754, "Old Spitalfields Market", "Markets", {
      address: "16 Horner Square, London E1 6EW",
      since: 1638,
      knownFor: "A Victorian market hall in the East End",
    }),
    venue("british-library", 51.5299, -0.1277, "British Library", "Talks", {
      address: "96 Euston Road, London NW1 2DB",
      since: 1973,
      knownFor: "The UK's national library, at St Pancras",
    }),
    venue("conway-hall", 51.5203, -0.1188, "Conway Hall", "Talks", {
      address: "25 Red Lion Square, London WC1R 4RL",
      since: 1929,
      knownFor: "Talks and debates, home of the Conway Hall Ethical Society",
    }),
    venue("royal-institution", 51.5098, -0.1425, "Royal Institution", "Talks", {
      address: "21 Albemarle Street, London W1S 4BS",
      since: 1799,
      knownFor: "The Christmas Lectures, given since 1825",
    }),
  ];

  /** Every venue fitted, with room at the edges for the count and the legend over the map. */
  const maplace = Maplace.createMaplace({ locations, view: { kind: "fit-all", padding: 80 } });
  const adapter = Maplace.createGoogleAdapter({ apiKey: "YOUR_KEY", mapOptions: { mapTypeControl: false, streetViewControl: false, cameraControl: false } });
  maplace.attach(adapter, "#whats-on-script-map");
  adapter.mountControl(eventLegend(maplace), "bottom-left");
  adapter.mountControl(eventStatus(maplace), "top-left");
  showVenueIn(document.querySelector("#whats-on-script-card"), maplace);

  /** A venue in its category, its pin coloured by it, with what the card says of it. */
  function venue(id, lat, lng, title, group, data) {
    return { id, lat, lng, title, group, data, icon: pinFor(group) };
  }

  /** A pin of your own, its colour the category's (`--category`, by `data-category` in the CSS). */
  function pinFor(category) {
    const pin = document.createElement("span");
    pin.className = "pin";
    pin.dataset.category = category;
    return pin;
  }

  /** The count, and beside it the name of the venue selected, if any. */
  function eventStatus(maplace) {
    const status = document.createElement("div");
    status.className = "event-status";
    status.append(eventCount(maplace), selectedName(maplace));
    return status;
  }

  /** How many venues are shown, of all of them, said again when that changes. */
  function eventCount(maplace) {
    const count = document.createElement("output");
    count.className = "event-count";
    const writeCount = () => {
      const snapshot = maplace.getSnapshot();
      const shown = Maplace.listedLocations(snapshot).length;
      const total = snapshot.locations.length;
      const text = shown === total ? `${total} venues` : `${shown} of ${total} venues`;
      if (count.textContent !== text) count.textContent = text;
    };
    writeCount();
    maplace.subscribe(writeCount);
    return count;
  }

  /**
   * The name of the venue selected, marked with its category for its colour; hidden while none is.
   * Not a live region: Maplace.js says each selection to a screen reader already.
   */
  function selectedName(maplace) {
    const name = document.createElement("span");
    name.className = "event-selected";
    const writeName = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      name.hidden = selected === undefined;
      name.textContent = selected?.title ?? "";
      name.dataset.category = selected?.group ?? "";
    };
    writeName(maplace.getSnapshot().selectedId);
    maplace.on("selectionChange", ({ id }) => writeName(id));
    return name;
  }

  /**
   * The card beside the map: the venue selected, its category marked for its colour, made from the
   * card's template and in the card only while a venue is selected, with a × closing it;
   * or, while none is, the venues shown, each a button selecting it. Not a live region: Maplace.js
   * says each selection to a screen reader already.
   */
  function showVenueIn(card, maplace) {
    const picker = card.querySelector(".venue-picker");
    const venuePart = card.querySelector("template").content.firstElementChild.cloneNode(true);
    const close = venuePart.querySelector(".venue-close");
    close.addEventListener("click", () => {
      const closed = maplace.getSnapshot().selectedId ?? "";
      maplace.select(undefined);
      picker.querySelector(`.venue-pick[data-id="${CSS.escape(closed)}"]`)?.focus();
    });
    listVenuesIn(picker, maplace, () => close.focus());
    const write = (selector, text) => {
      venuePart.querySelector(selector).textContent = text;
    };
    const writeCard = (id) => {
      const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
      const data = selected?.data;
      picker.hidden = data !== undefined;
      if (selected === undefined || data === undefined) {
        venuePart.remove();
        return;
      }
      venuePart.dataset.category = selected.group;
      write(".venue-category", selected.group ?? "");
      write(".venue-name", selected.title ?? "");
      write(".venue-address", data.address);
      write(".venue-since", String(data.since));
      write(".venue-known-for", data.knownFor);
      if (!venuePart.isConnected) card.append(venuePart);
    };
    writeCard(maplace.getSnapshot().selectedId);
    maplace.on("selectionChange", ({ id }) => writeCard(id));
  }

  /**
   * In the card's `picker`, a button per venue shown, selecting it and then calling `afterPick`, and
   * above them the category shown alone, if any, marked for its colour; written again only when the
   * venues shown change, as a hover changes the store too.
   */
  function listVenuesIn(picker, maplace, afterPick) {
    const categoryLine = picker.querySelector(".venue-list-category");
    const list = picker.querySelector(".venue-list");
    let listedIds;
    const writeList = () => {
      const listed = Maplace.listedLocations(maplace.getSnapshot());
      const ids = listed.map(({ id }) => id).join();
      if (ids === listedIds) return;
      listedIds = ids;
      const alone = shownAlone(maplace);
      categoryLine.hidden = alone === undefined;
      categoryLine.textContent = alone ?? "";
      categoryLine.dataset.category = alone ?? "";
      list.replaceChildren(...listed.map((location) => venueEntry(location, maplace, afterPick)));
    };
    writeList();
    maplace.subscribe(writeList);
  }

  /** A venue in the card's list: a button selecting it, marked with its category for its colour. */
  function venueEntry({ id, title, group }, maplace, afterPick) {
    const pick = document.createElement("button");
    pick.type = "button";
    pick.className = "venue-pick";
    pick.dataset.category = group ?? "";
    pick.textContent = title ?? id;
    pick.dataset.id = id;
    pick.addEventListener("click", () => {
      maplace.select(id);
      afterPick();
    });
    const entry = document.createElement("li");
    entry.append(pick);
    return entry;
  }

  /**
   * A chip per category, in the venues' order; the one shown alone is pressed. The chips are made once,
   * so a chip pressed from the keyboard keeps its focus; a store change only moves the press.
   */
  function eventLegend(maplace) {
    const legend = document.createElement("fieldset");
    legend.className = "event-legend";
    legend.setAttribute("aria-label", "Categories");
    const categories = new Set(maplace.getSnapshot().locations.flatMap(({ group }) => group ?? []));
    const chips = [...categories].map((category) => categoryChip(maplace, category));
    legend.append(...chips);
    let pressed;
    const pressShownAlone = () => {
      const alone = shownAlone(maplace);
      if (alone === pressed) return;
      pressed = alone;
      for (const chip of chips) {
        chip.setAttribute("aria-pressed", String(chip.dataset.category === alone));
      }
    };
    pressShownAlone();
    maplace.subscribe(pressShownAlone);
    return legend;
  }

  /** A toggle showing `category` alone, or every category again once pressed. */
  function categoryChip(maplace, category) {
    const chip = document.createElement("button");
    chip.type = "button";
    chip.className = "category-chip";
    chip.dataset.category = category;
    chip.setAttribute("aria-pressed", "false");
    chip.textContent = category;
    chip.addEventListener("click", () => {
      maplace.setFilter(shownAlone(maplace) === category ? undefined : [category]);
    });
    return chip;
  }

  /** The category the map shows alone, if any. */
  function shownAlone(maplace) {
    const groups = maplace.getSnapshot().filter?.groups;
    return groups?.length === 1 ? groups[0] : undefined;
  }
</script>
```

### Bundler on MapLibre

`packages/maplace/examples/whats-on/maplibre/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../../styles/whats-on.css">
<div id="whats-on-maplibre-vanilla-frame" class="whats-on">
  <div id="whats-on-maplibre-vanilla-map" class="whats-on-map"></div>
  <aside id="whats-on-maplibre-vanilla-card" class="venue-card" aria-label="Venue">
    <div class="venue-picker">
      <p class="venue-list-category" hidden></p>
      <p class="venue-empty">Pick a venue on the map, or here.</p>
      <ul class="venue-list" aria-label="Venues"></ul>
    </div>
    <template>
      <div class="venue">
        <button type="button" class="venue-close" aria-label="Close"></button>
        <p class="venue-category"></p>
        <h3 class="venue-name">Venue</h3>
        <dl>
          <div><dt>Address</dt><dd class="venue-address"></dd></div>
          <div><dt>Since</dt><dd class="venue-since"></dd></div>
          <div><dt>Known for</dt><dd class="venue-known-for"></dd></div>
        </dl>
      </div>
    </template>
  </aside>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/whats-on/maplibre/vanilla.ts`

```ts
import "maplibre-gl/dist/maplibre-gl.css";
import {
  createMaplace,
  type Location,
  type LocationGroup,
  listedLocations,
  type Maplace,
} from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";

/** What the card beside the map says of a venue, besides its name and category. */
interface VenueDetails {
  address: string;
  since: number;
  knownFor: string;
}

const locations: Location<VenueDetails>[] = [
  venue("national-theatre", 51.507, -0.1145, "National Theatre", "Theatre", {
    address: "Upper Ground, London SE1 9PX",
    since: 1976,
    knownFor: "Three stages on the South Bank",
  }),
  venue("globe", 51.5081, -0.0972, "Shakespeare's Globe", "Theatre", {
    address: "21 New Globe Walk, London SE1 9DT",
    since: 1997,
    knownFor: "An open-air playhouse rebuilt after the 1599 original",
  }),
  venue("donmar", 51.5136, -0.1254, "Donmar Warehouse", "Theatre", {
    address: "41 Earlham Street, London WC2H 9LX",
    since: 1977,
    knownFor: "A small studio theatre in Covent Garden",
  }),
  venue("royal-albert-hall", 51.501, -0.1774, "Royal Albert Hall", "Concerts", {
    address: "Kensington Gore, London SW7 2AP",
    since: 1871,
    knownFor: "The BBC Proms, every summer",
  }),
  venue("wigmore-hall", 51.5165, -0.149, "Wigmore Hall", "Concerts", {
    address: "36 Wigmore Street, London W1U 2BP",
    since: 1901,
    knownFor: "Chamber music and song recitals",
  }),
  venue("barbican", 51.5202, -0.0938, "Barbican Hall", "Concerts", {
    address: "Silk Street, London EC2Y 8DS",
    since: 1982,
    knownFor: "Home of the London Symphony Orchestra",
  }),
  venue("borough-market", 51.5055, -0.091, "Borough Market", "Markets", {
    address: "8 Southwark Street, London SE1 1TL",
    since: 1756,
    knownFor: "One of London's oldest food markets",
  }),
  venue("camden-market", 51.5413, -0.146, "Camden Market", "Markets", {
    address: "Camden Lock Place, London NW1 8AF",
    since: 1974,
    knownFor: "Stalls along the Regent's Canal",
  }),
  venue("spitalfields", 51.5197, -0.0754, "Old Spitalfields Market", "Markets", {
    address: "16 Horner Square, London E1 6EW",
    since: 1638,
    knownFor: "A Victorian market hall in the East End",
  }),
  venue("british-library", 51.5299, -0.1277, "British Library", "Talks", {
    address: "96 Euston Road, London NW1 2DB",
    since: 1973,
    knownFor: "The UK's national library, at St Pancras",
  }),
  venue("conway-hall", 51.5203, -0.1188, "Conway Hall", "Talks", {
    address: "25 Red Lion Square, London WC1R 4RL",
    since: 1929,
    knownFor: "Talks and debates, home of the Conway Hall Ethical Society",
  }),
  venue("royal-institution", 51.5098, -0.1425, "Royal Institution", "Talks", {
    address: "21 Albemarle Street, London W1S 4BS",
    since: 1799,
    knownFor: "The Christmas Lectures, given since 1825",
  }),
];

/** Every venue fitted, with room at the edges for the count and the legend over the map. */
const maplace = createMaplace({ locations, view: { kind: "fit-all", padding: 80 } });
const adapter = createMapLibreAdapter({
  mapStyle: "https://tiles.openfreemap.org/styles/liberty",
});
maplace.attach(adapter, "#whats-on-maplibre-vanilla-map");
adapter.mountControl(eventLegend(maplace), "bottom-left");
adapter.mountControl(eventStatus(maplace), "top-left");
showVenueIn(document.querySelector("#whats-on-maplibre-vanilla-card") as HTMLElement, maplace);

/** A venue in its category, its pin coloured by it, with what the card says of it. */
function venue(
  id: string,
  lat: number,
  lng: number,
  title: string,
  group: string,
  data: VenueDetails,
): Location<VenueDetails> {
  return { id, lat, lng, title, group, data, icon: pinFor(group) };
}

/** A pin of your own, its colour the category's (`--category`, by `data-category` in the CSS). */
function pinFor(category: string): HTMLElement {
  const pin = document.createElement("span");
  pin.className = "pin";
  pin.dataset.category = category;
  return pin;
}

/** The count, and beside it the name of the venue selected, if any. */
function eventStatus(maplace: Maplace): HTMLElement {
  const status = document.createElement("div");
  status.className = "event-status";
  status.append(eventCount(maplace), selectedName(maplace));
  return status;
}

/** How many venues are shown, of all of them, said again when that changes. */
function eventCount(maplace: Maplace): HTMLOutputElement {
  const count = document.createElement("output");
  count.className = "event-count";
  const writeCount = () => {
    const snapshot = maplace.getSnapshot();
    const shown = listedLocations(snapshot).length;
    const total = snapshot.locations.length;
    const text = shown === total ? `${total} venues` : `${shown} of ${total} venues`;
    if (count.textContent !== text) count.textContent = text;
  };
  writeCount();
  maplace.subscribe(writeCount);
  return count;
}

/**
 * The name of the venue selected, marked with its category for its colour; hidden while none is.
 * Not a live region: Maplace.js says each selection to a screen reader already.
 */
function selectedName(maplace: Maplace): HTMLElement {
  const name = document.createElement("span");
  name.className = "event-selected";
  const writeName = (id: string | undefined) => {
    const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
    name.hidden = selected === undefined;
    name.textContent = selected?.title ?? "";
    name.dataset.category = categoryOf(selected?.group);
  };
  writeName(maplace.getSnapshot().selectedId);
  maplace.on("selectionChange", ({ id }) => writeName(id));
  return name;
}

/**
 * The card beside the map: the venue selected, its category marked for its colour, made from the
 * card's template and in the card only while a venue is selected, with a × closing it; or,
 * while none is, the venues shown, each a button selecting it. Not a live region: Maplace.js says each
 * selection to a screen reader already.
 */
function showVenueIn(card: HTMLElement, maplace: Maplace<VenueDetails>): void {
  const picker = card.querySelector(".venue-picker") as HTMLElement;
  const template = card.querySelector("template") as HTMLTemplateElement;
  const venuePart = template.content.firstElementChild?.cloneNode(true) as HTMLElement;
  const close = venuePart.querySelector(".venue-close") as HTMLButtonElement;
  close.addEventListener("click", () => {
    const closed = maplace.getSnapshot().selectedId ?? "";
    maplace.select(undefined);
    picker.querySelector<HTMLElement>(`.venue-pick[data-id="${CSS.escape(closed)}"]`)?.focus();
  });
  listVenuesIn(picker, maplace, () => close.focus());
  const write = (selector: string, text: string) => {
    (venuePart.querySelector(selector) as HTMLElement).textContent = text;
  };
  const writeCard = (id: string | undefined) => {
    const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
    const data = selected?.data;
    picker.hidden = data !== undefined;
    if (selected === undefined || data === undefined) {
      venuePart.remove();
      return;
    }
    venuePart.dataset.category = categoryOf(selected.group);
    write(".venue-category", categoryOf(selected.group));
    write(".venue-name", selected.title ?? "");
    write(".venue-address", data.address);
    write(".venue-since", String(data.since));
    write(".venue-known-for", data.knownFor);
    if (!venuePart.isConnected) card.append(venuePart);
  };
  writeCard(maplace.getSnapshot().selectedId);
  maplace.on("selectionChange", ({ id }) => writeCard(id));
}

/**
 * In the card's `picker`, a button per venue shown, selecting it and then calling `afterPick`, and
 * above them the category shown alone, if any, marked for its colour; written again only when the
 * venues shown change, as a hover changes the store too.
 */
function listVenuesIn(picker: HTMLElement, maplace: Maplace, afterPick: () => void): void {
  const categoryLine = picker.querySelector(".venue-list-category") as HTMLElement;
  const list = picker.querySelector(".venue-list") as HTMLElement;
  let listedIds: string | undefined;
  const writeList = () => {
    const listed = listedLocations(maplace.getSnapshot());
    const ids = listed.map(({ id }) => id).join();
    if (ids === listedIds) return;
    listedIds = ids;
    const alone = shownAlone(maplace);
    categoryLine.hidden = alone === undefined;
    categoryLine.textContent = alone ?? "";
    categoryLine.dataset.category = alone ?? "";
    list.replaceChildren(...listed.map((location) => venueEntry(location, maplace, afterPick)));
  };
  writeList();
  maplace.subscribe(writeList);
}

/** A venue in the card's list: a button selecting it, marked with its category for its colour. */
function venueEntry({ id, title, group }: Location, maplace: Maplace, afterPick: () => void) {
  const pick = document.createElement("button");
  pick.type = "button";
  pick.className = "venue-pick";
  pick.dataset.category = categoryOf(group);
  pick.textContent = title ?? id;
  pick.dataset.id = id;
  pick.addEventListener("click", () => {
    maplace.select(id);
    afterPick();
  });
  const entry = document.createElement("li");
  entry.append(pick);
  return entry;
}

/**
 * A chip per category, in the venues' order; the one shown alone is pressed. The chips are made
 * once, so a chip pressed from the keyboard keeps its focus; a store change only moves the press.
 */
function eventLegend(maplace: Maplace): HTMLElement {
  const legend = document.createElement("fieldset");
  legend.className = "event-legend";
  legend.setAttribute("aria-label", "Categories");
  const categories = new Set(maplace.getSnapshot().locations.flatMap(({ group }) => group ?? []));
  const chips = [...categories].map((category) => categoryChip(maplace, category));
  legend.append(...chips);
  let pressed: string | undefined;
  const pressShownAlone = () => {
    const alone = shownAlone(maplace);
    if (alone === pressed) return;
    pressed = alone;
    for (const chip of chips) {
      chip.setAttribute("aria-pressed", String(chip.dataset.category === alone));
    }
  };
  pressShownAlone();
  maplace.subscribe(pressShownAlone);
  return legend;
}

/** A toggle showing `category` alone, or every category again once pressed. */
function categoryChip(maplace: Maplace, category: string): HTMLButtonElement {
  const chip = document.createElement("button");
  chip.type = "button";
  chip.className = "category-chip";
  chip.dataset.category = category;
  chip.setAttribute("aria-pressed", "false");
  chip.textContent = category;
  chip.addEventListener("click", () => {
    maplace.setFilter(shownAlone(maplace) === category ? undefined : [category]);
  });
  return chip;
}

/** The category the map shows alone, if any. */
function shownAlone(maplace: Maplace): string | undefined {
  const groups = maplace.getSnapshot().filter?.groups;
  return groups?.length === 1 ? categoryOf(groups[0]) || undefined : undefined;
}

/** A venue's category: its group, a plain name on this map. */
function categoryOf(group: LocationGroup | undefined): string {
  return typeof group === "string" ? group : "";
}
```

### Bundler on Google

`packages/maplace/examples/whats-on/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../styles/whats-on.css">
<div id="whats-on-vanilla-frame" class="whats-on">
  <div id="whats-on-vanilla-map" class="whats-on-map"></div>
  <aside id="whats-on-vanilla-card" class="venue-card" aria-label="Venue">
    <div class="venue-picker">
      <p class="venue-list-category" hidden></p>
      <p class="venue-empty">Pick a venue on the map, or here.</p>
      <ul class="venue-list" aria-label="Venues"></ul>
    </div>
    <template>
      <div class="venue">
        <button type="button" class="venue-close" aria-label="Close"></button>
        <p class="venue-category"></p>
        <h3 class="venue-name">Venue</h3>
        <dl>
          <div><dt>Address</dt><dd class="venue-address"></dd></div>
          <div><dt>Since</dt><dd class="venue-since"></dd></div>
          <div><dt>Known for</dt><dd class="venue-known-for"></dd></div>
        </dl>
      </div>
    </template>
  </aside>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/whats-on/vanilla.ts`

```ts
import {
  createMaplace,
  type Location,
  type LocationGroup,
  listedLocations,
  type Maplace,
} from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";

/** What the card beside the map says of a venue, besides its name and category. */
interface VenueDetails {
  address: string;
  since: number;
  knownFor: string;
}

const locations: Location<VenueDetails>[] = [
  venue("national-theatre", 51.507, -0.1145, "National Theatre", "Theatre", {
    address: "Upper Ground, London SE1 9PX",
    since: 1976,
    knownFor: "Three stages on the South Bank",
  }),
  venue("globe", 51.5081, -0.0972, "Shakespeare's Globe", "Theatre", {
    address: "21 New Globe Walk, London SE1 9DT",
    since: 1997,
    knownFor: "An open-air playhouse rebuilt after the 1599 original",
  }),
  venue("donmar", 51.5136, -0.1254, "Donmar Warehouse", "Theatre", {
    address: "41 Earlham Street, London WC2H 9LX",
    since: 1977,
    knownFor: "A small studio theatre in Covent Garden",
  }),
  venue("royal-albert-hall", 51.501, -0.1774, "Royal Albert Hall", "Concerts", {
    address: "Kensington Gore, London SW7 2AP",
    since: 1871,
    knownFor: "The BBC Proms, every summer",
  }),
  venue("wigmore-hall", 51.5165, -0.149, "Wigmore Hall", "Concerts", {
    address: "36 Wigmore Street, London W1U 2BP",
    since: 1901,
    knownFor: "Chamber music and song recitals",
  }),
  venue("barbican", 51.5202, -0.0938, "Barbican Hall", "Concerts", {
    address: "Silk Street, London EC2Y 8DS",
    since: 1982,
    knownFor: "Home of the London Symphony Orchestra",
  }),
  venue("borough-market", 51.5055, -0.091, "Borough Market", "Markets", {
    address: "8 Southwark Street, London SE1 1TL",
    since: 1756,
    knownFor: "One of London's oldest food markets",
  }),
  venue("camden-market", 51.5413, -0.146, "Camden Market", "Markets", {
    address: "Camden Lock Place, London NW1 8AF",
    since: 1974,
    knownFor: "Stalls along the Regent's Canal",
  }),
  venue("spitalfields", 51.5197, -0.0754, "Old Spitalfields Market", "Markets", {
    address: "16 Horner Square, London E1 6EW",
    since: 1638,
    knownFor: "A Victorian market hall in the East End",
  }),
  venue("british-library", 51.5299, -0.1277, "British Library", "Talks", {
    address: "96 Euston Road, London NW1 2DB",
    since: 1973,
    knownFor: "The UK's national library, at St Pancras",
  }),
  venue("conway-hall", 51.5203, -0.1188, "Conway Hall", "Talks", {
    address: "25 Red Lion Square, London WC1R 4RL",
    since: 1929,
    knownFor: "Talks and debates, home of the Conway Hall Ethical Society",
  }),
  venue("royal-institution", 51.5098, -0.1425, "Royal Institution", "Talks", {
    address: "21 Albemarle Street, London W1S 4BS",
    since: 1799,
    knownFor: "The Christmas Lectures, given since 1825",
  }),
];

/** Every venue fitted, with room at the edges for the count and the legend over the map. */
const maplace = createMaplace({ locations, view: { kind: "fit-all", padding: 80 } });
const adapter = createGoogleAdapter({
  mapOptions: { mapTypeControl: false, streetViewControl: false, cameraControl: false },
});
maplace.attach(adapter, "#whats-on-vanilla-map");
adapter.mountControl(eventLegend(maplace), "bottom-left");
adapter.mountControl(eventStatus(maplace), "top-left");
showVenueIn(document.querySelector("#whats-on-vanilla-card") as HTMLElement, maplace);

/** A venue in its category, its pin coloured by it, with what the card says of it. */
function venue(
  id: string,
  lat: number,
  lng: number,
  title: string,
  group: string,
  data: VenueDetails,
): Location<VenueDetails> {
  return { id, lat, lng, title, group, data, icon: pinFor(group) };
}

/** A pin of your own, its colour the category's (`--category`, by `data-category` in the CSS). */
function pinFor(category: string): HTMLElement {
  const pin = document.createElement("span");
  pin.className = "pin";
  pin.dataset.category = category;
  return pin;
}

/** The count, and beside it the name of the venue selected, if any. */
function eventStatus(maplace: Maplace): HTMLElement {
  const status = document.createElement("div");
  status.className = "event-status";
  status.append(eventCount(maplace), selectedName(maplace));
  return status;
}

/** How many venues are shown, of all of them, said again when that changes. */
function eventCount(maplace: Maplace): HTMLOutputElement {
  const count = document.createElement("output");
  count.className = "event-count";
  const writeCount = () => {
    const snapshot = maplace.getSnapshot();
    const shown = listedLocations(snapshot).length;
    const total = snapshot.locations.length;
    const text = shown === total ? `${total} venues` : `${shown} of ${total} venues`;
    if (count.textContent !== text) count.textContent = text;
  };
  writeCount();
  maplace.subscribe(writeCount);
  return count;
}

/**
 * The name of the venue selected, marked with its category for its colour; hidden while none is.
 * Not a live region: Maplace.js says each selection to a screen reader already.
 */
function selectedName(maplace: Maplace): HTMLElement {
  const name = document.createElement("span");
  name.className = "event-selected";
  const writeName = (id: string | undefined) => {
    const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
    name.hidden = selected === undefined;
    name.textContent = selected?.title ?? "";
    name.dataset.category = categoryOf(selected?.group);
  };
  writeName(maplace.getSnapshot().selectedId);
  maplace.on("selectionChange", ({ id }) => writeName(id));
  return name;
}

/**
 * The card beside the map: the venue selected, its category marked for its colour, made from the
 * card's template and in the card only while a venue is selected, with a × closing it; or,
 * while none is, the venues shown, each a button selecting it. Not a live region: Maplace.js says each
 * selection to a screen reader already.
 */
function showVenueIn(card: HTMLElement, maplace: Maplace<VenueDetails>): void {
  const picker = card.querySelector(".venue-picker") as HTMLElement;
  const template = card.querySelector("template") as HTMLTemplateElement;
  const venuePart = template.content.firstElementChild?.cloneNode(true) as HTMLElement;
  const close = venuePart.querySelector(".venue-close") as HTMLButtonElement;
  close.addEventListener("click", () => {
    const closed = maplace.getSnapshot().selectedId ?? "";
    maplace.select(undefined);
    picker.querySelector<HTMLElement>(`.venue-pick[data-id="${CSS.escape(closed)}"]`)?.focus();
  });
  listVenuesIn(picker, maplace, () => close.focus());
  const write = (selector: string, text: string) => {
    (venuePart.querySelector(selector) as HTMLElement).textContent = text;
  };
  const writeCard = (id: string | undefined) => {
    const selected = maplace.getSnapshot().locations.find((location) => location.id === id);
    const data = selected?.data;
    picker.hidden = data !== undefined;
    if (selected === undefined || data === undefined) {
      venuePart.remove();
      return;
    }
    venuePart.dataset.category = categoryOf(selected.group);
    write(".venue-category", categoryOf(selected.group));
    write(".venue-name", selected.title ?? "");
    write(".venue-address", data.address);
    write(".venue-since", String(data.since));
    write(".venue-known-for", data.knownFor);
    if (!venuePart.isConnected) card.append(venuePart);
  };
  writeCard(maplace.getSnapshot().selectedId);
  maplace.on("selectionChange", ({ id }) => writeCard(id));
}

/**
 * In the card's `picker`, a button per venue shown, selecting it and then calling `afterPick`, and
 * above them the category shown alone, if any, marked for its colour; written again only when the
 * venues shown change, as a hover changes the store too.
 */
function listVenuesIn(picker: HTMLElement, maplace: Maplace, afterPick: () => void): void {
  const categoryLine = picker.querySelector(".venue-list-category") as HTMLElement;
  const list = picker.querySelector(".venue-list") as HTMLElement;
  let listedIds: string | undefined;
  const writeList = () => {
    const listed = listedLocations(maplace.getSnapshot());
    const ids = listed.map(({ id }) => id).join();
    if (ids === listedIds) return;
    listedIds = ids;
    const alone = shownAlone(maplace);
    categoryLine.hidden = alone === undefined;
    categoryLine.textContent = alone ?? "";
    categoryLine.dataset.category = alone ?? "";
    list.replaceChildren(...listed.map((location) => venueEntry(location, maplace, afterPick)));
  };
  writeList();
  maplace.subscribe(writeList);
}

/** A venue in the card's list: a button selecting it, marked with its category for its colour. */
function venueEntry({ id, title, group }: Location, maplace: Maplace, afterPick: () => void) {
  const pick = document.createElement("button");
  pick.type = "button";
  pick.className = "venue-pick";
  pick.dataset.category = categoryOf(group);
  pick.textContent = title ?? id;
  pick.dataset.id = id;
  pick.addEventListener("click", () => {
    maplace.select(id);
    afterPick();
  });
  const entry = document.createElement("li");
  entry.append(pick);
  return entry;
}

/**
 * A chip per category, in the venues' order; the one shown alone is pressed. The chips are made
 * once, so a chip pressed from the keyboard keeps its focus; a store change only moves the press.
 */
function eventLegend(maplace: Maplace): HTMLElement {
  const legend = document.createElement("fieldset");
  legend.className = "event-legend";
  legend.setAttribute("aria-label", "Categories");
  const categories = new Set(maplace.getSnapshot().locations.flatMap(({ group }) => group ?? []));
  const chips = [...categories].map((category) => categoryChip(maplace, category));
  legend.append(...chips);
  let pressed: string | undefined;
  const pressShownAlone = () => {
    const alone = shownAlone(maplace);
    if (alone === pressed) return;
    pressed = alone;
    for (const chip of chips) {
      chip.setAttribute("aria-pressed", String(chip.dataset.category === alone));
    }
  };
  pressShownAlone();
  maplace.subscribe(pressShownAlone);
  return legend;
}

/** A toggle showing `category` alone, or every category again once pressed. */
function categoryChip(maplace: Maplace, category: string): HTMLButtonElement {
  const chip = document.createElement("button");
  chip.type = "button";
  chip.className = "category-chip";
  chip.dataset.category = category;
  chip.setAttribute("aria-pressed", "false");
  chip.textContent = category;
  chip.addEventListener("click", () => {
    maplace.setFilter(shownAlone(maplace) === category ? undefined : [category]);
  });
  return chip;
}

/** The category the map shows alone, if any. */
function shownAlone(maplace: Maplace): string | undefined {
  const groups = maplace.getSnapshot().filter?.groups;
  return groups?.length === 1 ? categoryOf(groups[0]) || undefined : undefined;
}

/** A venue's category: its group, a plain name on this map. */
function categoryOf(group: LocationGroup | undefined): string {
  return typeof group === "string" ? group : "";
}
```

### React on MapLibre

`packages/maplace/examples/whats-on/maplibre/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../../styles/whats-on.css">
<div id="whats-on-maplibre-react-root" class="whats-on"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/whats-on/maplibre/react.tsx`

```tsx
import "maplibre-gl/dist/maplibre-gl.css";
import { type Location, listedLocations, type Snapshot, type View } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { MapControl, MaplaceMap, MaplaceProvider, useMaplace } from "@maplacejs/maplace/react";
import { StrictMode, useRef, useSyncExternalStore } from "react";
import { flushSync } from "react-dom";
import { createRoot } from "react-dom/client";

/** What the card beside the map says of a venue, besides its name and category. */
interface VenueDetails {
  address: string;
  since: number;
  knownFor: string;
}

const venues: Location<VenueDetails>[] = [
  venue("national-theatre", 51.507, -0.1145, "National Theatre", "Theatre", {
    address: "Upper Ground, London SE1 9PX",
    since: 1976,
    knownFor: "Three stages on the South Bank",
  }),
  venue("globe", 51.5081, -0.0972, "Shakespeare's Globe", "Theatre", {
    address: "21 New Globe Walk, London SE1 9DT",
    since: 1997,
    knownFor: "An open-air playhouse rebuilt after the 1599 original",
  }),
  venue("donmar", 51.5136, -0.1254, "Donmar Warehouse", "Theatre", {
    address: "41 Earlham Street, London WC2H 9LX",
    since: 1977,
    knownFor: "A small studio theatre in Covent Garden",
  }),
  venue("royal-albert-hall", 51.501, -0.1774, "Royal Albert Hall", "Concerts", {
    address: "Kensington Gore, London SW7 2AP",
    since: 1871,
    knownFor: "The BBC Proms, every summer",
  }),
  venue("wigmore-hall", 51.5165, -0.149, "Wigmore Hall", "Concerts", {
    address: "36 Wigmore Street, London W1U 2BP",
    since: 1901,
    knownFor: "Chamber music and song recitals",
  }),
  venue("barbican", 51.5202, -0.0938, "Barbican Hall", "Concerts", {
    address: "Silk Street, London EC2Y 8DS",
    since: 1982,
    knownFor: "Home of the London Symphony Orchestra",
  }),
  venue("borough-market", 51.5055, -0.091, "Borough Market", "Markets", {
    address: "8 Southwark Street, London SE1 1TL",
    since: 1756,
    knownFor: "One of London's oldest food markets",
  }),
  venue("camden-market", 51.5413, -0.146, "Camden Market", "Markets", {
    address: "Camden Lock Place, London NW1 8AF",
    since: 1974,
    knownFor: "Stalls along the Regent's Canal",
  }),
  venue("spitalfields", 51.5197, -0.0754, "Old Spitalfields Market", "Markets", {
    address: "16 Horner Square, London E1 6EW",
    since: 1638,
    knownFor: "A Victorian market hall in the East End",
  }),
  venue("british-library", 51.5299, -0.1277, "British Library", "Talks", {
    address: "96 Euston Road, London NW1 2DB",
    since: 1973,
    knownFor: "The UK's national library, at St Pancras",
  }),
  venue("conway-hall", 51.5203, -0.1188, "Conway Hall", "Talks", {
    address: "25 Red Lion Square, London WC1R 4RL",
    since: 1929,
    knownFor: "Talks and debates, home of the Conway Hall Ethical Society",
  }),
  venue("royal-institution", 51.5098, -0.1425, "Royal Institution", "Talks", {
    address: "21 Albemarle Street, London W1S 4BS",
    since: 1799,
    knownFor: "The Christmas Lectures, given since 1825",
  }),
];

/** A venue in its category, with what the card says of it. */
function venue(
  id: string,
  lat: number,
  lng: number,
  title: string,
  group: string,
  data: VenueDetails,
): Location<VenueDetails> {
  return { id, lat, lng, title, group, data };
}

/** A map on OpenFreeMap's liberty style. */
const createAdapter = () =>
  createMapLibreAdapter({ mapStyle: "https://tiles.openfreemap.org/styles/liberty" });

/** Every venue fitted, with room at the edges for the count and the legend over the map. */
const firstView: View = { kind: "fit-all", padding: 80 };

/**
 * A pin of your own, its colour the category's (`--category`, by `data-category` in the CSS), in a
 * node Maplace.js keeps for each marker and marks `data-hovered` and `data-selected`.
 */
const markerIcon = ({ group }: Location) => <span className="pin" data-category={group} />;

/** The count, and beside it the name of the venue selected, if any. */
function EventStatus() {
  return (
    <div className="event-status">
      <EventCount />
      <SelectedName />
    </div>
  );
}

/** How many venues are shown, of all of them; read as text, so a hover renders nothing. */
function EventCount() {
  const maplace = useMaplace();
  const text = useSyncExternalStore(maplace.subscribe, () => countText(maplace.getSnapshot()));
  return <output className="event-count">{text}</output>;
}

function countText(snapshot: Snapshot): string {
  const shown = listedLocations(snapshot).length;
  const total = snapshot.locations.length;
  return shown === total ? `${total} venues` : `${shown} of ${total} venues`;
}

/**
 * The name of the venue selected, marked with its category for its colour; hidden while none is.
 * Not a live region: Maplace.js says each selection to a screen reader already.
 */
function SelectedName() {
  const maplace = useMaplace<VenueDetails>();
  const selected = useSyncExternalStore(maplace.subscribe, () => selectedIn(maplace.getSnapshot()));
  return (
    <span
      className="event-selected"
      data-category={selected?.group}
      hidden={selected === undefined}
    >
      {selected?.title}
    </span>
  );
}

function selectedIn({
  locations,
  selectedId,
}: Snapshot<VenueDetails>): Location<VenueDetails> | undefined {
  return locations.find(({ id }) => id === selectedId);
}

/**
 * The card beside the map: the venue selected, its category marked for its colour, with a × closing
 * it; or, while none is, the venues shown, each a button selecting it, under the category shown
 * alone, if any. A press moves the focus to what takes the button's place, the card rendered at
 * once for it. Not a live region: Maplace.js says each selection to a screen reader already.
 */
function VenueCard() {
  const maplace = useMaplace<VenueDetails>();
  const selected = useSyncExternalStore(maplace.subscribe, () => selectedIn(maplace.getSnapshot()));
  const listed = useListedVenues();
  const shownAlone = useSyncExternalStore(maplace.subscribe, () =>
    shownAloneIn(maplace.getSnapshot()),
  );
  const card = useRef<HTMLElement>(null);
  const selectAndFocus = (id: string | undefined, toFocus: string) => {
    flushSync(() => maplace.select(id));
    card.current?.querySelector<HTMLElement>(toFocus)?.focus();
  };
  return (
    <aside className="venue-card" aria-label="Venue" ref={card}>
      {selected?.data === undefined ? (
        <div className="venue-picker">
          <p
            className="venue-list-category"
            data-category={shownAlone}
            hidden={shownAlone === undefined}
          >
            {shownAlone}
          </p>
          <p className="venue-empty">Pick a venue on the map, or here.</p>
          <ul className="venue-list" aria-label="Venues">
            {listed.map(({ id, title, group }) => (
              <li key={id}>
                <button
                  type="button"
                  className="venue-pick"
                  data-category={group}
                  data-id={id}
                  onClick={() => selectAndFocus(id, ".venue-close")}
                >
                  {title ?? id}
                </button>
              </li>
            ))}
          </ul>
        </div>
      ) : (
        <div className="venue" data-category={selected.group}>
          <button
            type="button"
            className="venue-close"
            aria-label="Close"
            onClick={() =>
              selectAndFocus(undefined, `.venue-pick[data-id="${CSS.escape(selected.id)}"]`)
            }
          />
          <p className="venue-category">{selected.group}</p>
          <h3 className="venue-name">{selected.title}</h3>
          <dl>
            <div>
              <dt>Address</dt>
              <dd className="venue-address">{selected.data.address}</dd>
            </div>
            <div>
              <dt>Since</dt>
              <dd className="venue-since">{selected.data.since}</dd>
            </div>
            <div>
              <dt>Known for</dt>
              <dd className="venue-known-for">{selected.data.knownFor}</dd>
            </div>
          </dl>
        </div>
      )}
    </aside>
  );
}

/** The venues shown, rendered again when they change; read as their ids, so a hover renders none. */
function useListedVenues(): readonly Location[] {
  const maplace = useMaplace();
  useSyncExternalStore(maplace.subscribe, () =>
    listedLocations(maplace.getSnapshot())
      .map(({ id }) => id)
      .join(),
  );
  return listedLocations(maplace.getSnapshot());
}

/**
 * A chip per category, in the venues' order, showing it alone, or every one again once pressed;
 * read from the locations and the category shown alone, so a hover renders nothing.
 */
function EventLegend() {
  const maplace = useMaplace();
  const locations = useSyncExternalStore(maplace.subscribe, () => maplace.getSnapshot().locations);
  const shownAlone = useSyncExternalStore(maplace.subscribe, () =>
    shownAloneIn(maplace.getSnapshot()),
  );
  const categories = new Set(locations.flatMap(({ group }) => group ?? []));
  return (
    <fieldset className="event-legend" aria-label="Categories">
      {[...categories].map((category) => (
        <button
          key={category}
          type="button"
          className="category-chip"
          data-category={category}
          aria-pressed={category === shownAlone}
          onClick={() => maplace.setFilter(category === shownAlone ? undefined : [category])}
        >
          {category}
        </button>
      ))}
    </fieldset>
  );
}

/** The category the map shows alone, if any. */
function shownAloneIn({ filter }: Snapshot): string | undefined {
  const alone = filter?.groups?.length === 1 ? filter.groups[0] : undefined;
  return typeof alone === "string" ? alone : undefined;
}

function WhatsOn() {
  return (
    <MaplaceProvider locations={venues} view={firstView}>
      <MaplaceMap createAdapter={createAdapter} className="whats-on-map" markerIcon={markerIcon}>
        <MapControl position="bottom-left">
          <EventLegend />
        </MapControl>
        <MapControl position="top-left">
          <EventStatus />
        </MapControl>
      </MaplaceMap>
      <VenueCard />
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("whats-on-maplibre-react-root") as HTMLElement).render(
  <StrictMode>
    <WhatsOn />
  </StrictMode>,
);
```

### React on Google

`packages/maplace/examples/whats-on/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<!-- This example's look lives in the examples' styles/whats-on.css, which every version links. -->
<link rel="stylesheet" href="../styles/whats-on.css">
<div id="whats-on-react-root" class="whats-on"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/whats-on/react.tsx`

```tsx
import { type Location, listedLocations, type Snapshot, type View } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { MapControl, MaplaceMap, MaplaceProvider, useMaplace } from "@maplacejs/maplace/react";
import { StrictMode, useRef, useSyncExternalStore } from "react";
import { flushSync } from "react-dom";
import { createRoot } from "react-dom/client";

/** What the card beside the map says of a venue, besides its name and category. */
interface VenueDetails {
  address: string;
  since: number;
  knownFor: string;
}

const venues: Location<VenueDetails>[] = [
  venue("national-theatre", 51.507, -0.1145, "National Theatre", "Theatre", {
    address: "Upper Ground, London SE1 9PX",
    since: 1976,
    knownFor: "Three stages on the South Bank",
  }),
  venue("globe", 51.5081, -0.0972, "Shakespeare's Globe", "Theatre", {
    address: "21 New Globe Walk, London SE1 9DT",
    since: 1997,
    knownFor: "An open-air playhouse rebuilt after the 1599 original",
  }),
  venue("donmar", 51.5136, -0.1254, "Donmar Warehouse", "Theatre", {
    address: "41 Earlham Street, London WC2H 9LX",
    since: 1977,
    knownFor: "A small studio theatre in Covent Garden",
  }),
  venue("royal-albert-hall", 51.501, -0.1774, "Royal Albert Hall", "Concerts", {
    address: "Kensington Gore, London SW7 2AP",
    since: 1871,
    knownFor: "The BBC Proms, every summer",
  }),
  venue("wigmore-hall", 51.5165, -0.149, "Wigmore Hall", "Concerts", {
    address: "36 Wigmore Street, London W1U 2BP",
    since: 1901,
    knownFor: "Chamber music and song recitals",
  }),
  venue("barbican", 51.5202, -0.0938, "Barbican Hall", "Concerts", {
    address: "Silk Street, London EC2Y 8DS",
    since: 1982,
    knownFor: "Home of the London Symphony Orchestra",
  }),
  venue("borough-market", 51.5055, -0.091, "Borough Market", "Markets", {
    address: "8 Southwark Street, London SE1 1TL",
    since: 1756,
    knownFor: "One of London's oldest food markets",
  }),
  venue("camden-market", 51.5413, -0.146, "Camden Market", "Markets", {
    address: "Camden Lock Place, London NW1 8AF",
    since: 1974,
    knownFor: "Stalls along the Regent's Canal",
  }),
  venue("spitalfields", 51.5197, -0.0754, "Old Spitalfields Market", "Markets", {
    address: "16 Horner Square, London E1 6EW",
    since: 1638,
    knownFor: "A Victorian market hall in the East End",
  }),
  venue("british-library", 51.5299, -0.1277, "British Library", "Talks", {
    address: "96 Euston Road, London NW1 2DB",
    since: 1973,
    knownFor: "The UK's national library, at St Pancras",
  }),
  venue("conway-hall", 51.5203, -0.1188, "Conway Hall", "Talks", {
    address: "25 Red Lion Square, London WC1R 4RL",
    since: 1929,
    knownFor: "Talks and debates, home of the Conway Hall Ethical Society",
  }),
  venue("royal-institution", 51.5098, -0.1425, "Royal Institution", "Talks", {
    address: "21 Albemarle Street, London W1S 4BS",
    since: 1799,
    knownFor: "The Christmas Lectures, given since 1825",
  }),
];

/** A venue in its category, with what the card says of it. */
function venue(
  id: string,
  lat: number,
  lng: number,
  title: string,
  group: string,
  data: VenueDetails,
): Location<VenueDetails> {
  return { id, lat, lng, title, group, data };
}

/**
 * Google's map without its map-type, camera and Street View controls: the count and the legend take
 * their place.
 */
const createAdapter = () =>
  createGoogleAdapter({
    mapOptions: { mapTypeControl: false, streetViewControl: false, cameraControl: false },
  });

/** Every venue fitted, with room at the edges for the count and the legend over the map. */
const firstView: View = { kind: "fit-all", padding: 80 };

/**
 * A pin of your own, its colour the category's (`--category`, by `data-category` in the CSS), in a
 * node Maplace.js keeps for each marker and marks `data-hovered` and `data-selected`.
 */
const markerIcon = ({ group }: Location) => <span className="pin" data-category={group} />;

/** The count, and beside it the name of the venue selected, if any. */
function EventStatus() {
  return (
    <div className="event-status">
      <EventCount />
      <SelectedName />
    </div>
  );
}

/** How many venues are shown, of all of them; read as text, so a hover renders nothing. */
function EventCount() {
  const maplace = useMaplace();
  const text = useSyncExternalStore(maplace.subscribe, () => countText(maplace.getSnapshot()));
  return <output className="event-count">{text}</output>;
}

function countText(snapshot: Snapshot): string {
  const shown = listedLocations(snapshot).length;
  const total = snapshot.locations.length;
  return shown === total ? `${total} venues` : `${shown} of ${total} venues`;
}

/**
 * The name of the venue selected, marked with its category for its colour; hidden while none is.
 * Not a live region: Maplace.js says each selection to a screen reader already.
 */
function SelectedName() {
  const maplace = useMaplace<VenueDetails>();
  const selected = useSyncExternalStore(maplace.subscribe, () => selectedIn(maplace.getSnapshot()));
  return (
    <span
      className="event-selected"
      data-category={selected?.group}
      hidden={selected === undefined}
    >
      {selected?.title}
    </span>
  );
}

function selectedIn({
  locations,
  selectedId,
}: Snapshot<VenueDetails>): Location<VenueDetails> | undefined {
  return locations.find(({ id }) => id === selectedId);
}

/**
 * The card beside the map: the venue selected, its category marked for its colour, with a × closing
 * it; or, while none is, the venues shown, each a button selecting it, under the category shown
 * alone, if any. A press moves the focus to what takes the button's place, the card rendered at
 * once for it. Not a live region: Maplace.js says each selection to a screen reader already.
 */
function VenueCard() {
  const maplace = useMaplace<VenueDetails>();
  const selected = useSyncExternalStore(maplace.subscribe, () => selectedIn(maplace.getSnapshot()));
  const listed = useListedVenues();
  const shownAlone = useSyncExternalStore(maplace.subscribe, () =>
    shownAloneIn(maplace.getSnapshot()),
  );
  const card = useRef<HTMLElement>(null);
  const selectAndFocus = (id: string | undefined, toFocus: string) => {
    flushSync(() => maplace.select(id));
    card.current?.querySelector<HTMLElement>(toFocus)?.focus();
  };
  return (
    <aside className="venue-card" aria-label="Venue" ref={card}>
      {selected?.data === undefined ? (
        <div className="venue-picker">
          <p
            className="venue-list-category"
            data-category={shownAlone}
            hidden={shownAlone === undefined}
          >
            {shownAlone}
          </p>
          <p className="venue-empty">Pick a venue on the map, or here.</p>
          <ul className="venue-list" aria-label="Venues">
            {listed.map(({ id, title, group }) => (
              <li key={id}>
                <button
                  type="button"
                  className="venue-pick"
                  data-category={group}
                  data-id={id}
                  onClick={() => selectAndFocus(id, ".venue-close")}
                >
                  {title ?? id}
                </button>
              </li>
            ))}
          </ul>
        </div>
      ) : (
        <div className="venue" data-category={selected.group}>
          <button
            type="button"
            className="venue-close"
            aria-label="Close"
            onClick={() =>
              selectAndFocus(undefined, `.venue-pick[data-id="${CSS.escape(selected.id)}"]`)
            }
          />
          <p className="venue-category">{selected.group}</p>
          <h3 className="venue-name">{selected.title}</h3>
          <dl>
            <div>
              <dt>Address</dt>
              <dd className="venue-address">{selected.data.address}</dd>
            </div>
            <div>
              <dt>Since</dt>
              <dd className="venue-since">{selected.data.since}</dd>
            </div>
            <div>
              <dt>Known for</dt>
              <dd className="venue-known-for">{selected.data.knownFor}</dd>
            </div>
          </dl>
        </div>
      )}
    </aside>
  );
}

/** The venues shown, rendered again when they change; read as their ids, so a hover renders none. */
function useListedVenues(): readonly Location[] {
  const maplace = useMaplace();
  useSyncExternalStore(maplace.subscribe, () =>
    listedLocations(maplace.getSnapshot())
      .map(({ id }) => id)
      .join(),
  );
  return listedLocations(maplace.getSnapshot());
}

/**
 * A chip per category, in the venues' order, showing it alone, or every one again once pressed;
 * read from the locations and the category shown alone, so a hover renders nothing.
 */
function EventLegend() {
  const maplace = useMaplace();
  const locations = useSyncExternalStore(maplace.subscribe, () => maplace.getSnapshot().locations);
  const shownAlone = useSyncExternalStore(maplace.subscribe, () =>
    shownAloneIn(maplace.getSnapshot()),
  );
  const categories = new Set(locations.flatMap(({ group }) => group ?? []));
  return (
    <fieldset className="event-legend" aria-label="Categories">
      {[...categories].map((category) => (
        <button
          key={category}
          type="button"
          className="category-chip"
          data-category={category}
          aria-pressed={category === shownAlone}
          onClick={() => maplace.setFilter(category === shownAlone ? undefined : [category])}
        >
          {category}
        </button>
      ))}
    </fieldset>
  );
}

/** The category the map shows alone, if any. */
function shownAloneIn({ filter }: Snapshot): string | undefined {
  const alone = filter?.groups?.length === 1 ? filter.groups[0] : undefined;
  return typeof alone === "string" ? alone : undefined;
}

function WhatsOn() {
  return (
    <MaplaceProvider locations={venues} view={firstView}>
      <MaplaceMap createAdapter={createAdapter} className="whats-on-map" markerIcon={markerIcon}>
        <MapControl position="bottom-left">
          <EventLegend />
        </MapControl>
        <MapControl position="top-left">
          <EventStatus />
        </MapControl>
      </MaplaceMap>
      <VenueCard />
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("whats-on-react-root") as HTMLElement).render(
  <StrictMode>
    <WhatsOn />
  </StrictMode>,
);
```

### The stylesheet every version links

`packages/maplace/examples/styles/whats-on.css`

```css
/* The whats-on example's look, which every version links: page, script, vanilla and React, on
   either map. */
/* The frame: a dark page of its own around a rounded map and, beside it, a card. */
.whats-on {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
  padding: 12px;
  border-radius: 16px;
  background: #1c1d21;
}
.whats-on-map {
  flex: 3 1 22rem;
  min-width: 0;
  height: 26rem;
  border-radius: 12px;
  overflow: hidden;
}
/* Each category's colour, which its pins and its chip take. */
.whats-on [data-category="Theatre"] {
  --category: #e4572e;
}
.whats-on [data-category="Concerts"] {
  --category: #8e44ad;
}
.whats-on [data-category="Markets"] {
  --category: #2a9d8f;
}
.whats-on [data-category="Talks"] {
  --category: #c48a00;
}
.whats-on .pin {
  display: block;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--category);
  box-shadow: 0 1px 4px rgb(0 0 0 / 40%);
  cursor: pointer;
}
/* React marks the node Maplace.js keeps for each marker, the pin inside it. */
.whats-on .pin[data-hovered],
.whats-on [data-hovered] > .pin {
  transform: translateY(-2px);
}
.whats-on .pin[data-selected],
.whats-on [data-selected] > .pin {
  transform: scale(1.25);
  box-shadow:
    0 0 0 2px var(--category),
    0 2px 6px rgb(0 0 0 / 45%);
}
/* The category's dot beside its name: on the venue picked, a chip, a venue in the list, the card. */
.whats-on .event-selected::before,
.whats-on .category-chip::before,
.whats-on .venue-pick::before,
.whats-on .venue-category::before,
.whats-on .venue-list-category::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--category);
}
/* Maplace.js's panel on the map, made nothing, so the count and the legend are the page's own. */
.whats-on .maplace-control {
  padding: 0;
  background: none;
  box-shadow: none;
}
.whats-on .event-count,
.whats-on .event-selected,
.whats-on .event-legend {
  background: rgb(28 29 33 / 88%);
  color: #f2f2f3;
  font:
    500 13px / 1.2 system-ui,
    sans-serif;
}
.whats-on .event-count,
.whats-on .event-selected {
  padding: 8px 14px;
  border-radius: 999px;
}
.whats-on .event-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.whats-on .event-selected {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.whats-on .event-selected[hidden] {
  display: none;
}
.whats-on .event-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 18px;
}
/* On a phone, the four chips two by two rather than three and one. */
@media (width < 30rem) {
  .whats-on .event-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
.whats-on .category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
/* Under the legend too, to weigh more than MapLibre's hover on a control's buttons. */
.whats-on .event-legend .category-chip:hover {
  background: rgb(255 255 255 / 12%);
}
.whats-on .event-legend .category-chip[aria-pressed="true"] {
  background: #f2f2f3;
  color: #1c1d21;
}
/* The page's count, marked over-map, over the map's top left where a control would sit: the element
   places one view of yours on the map, the legend. It takes no clicks, so the map under it does. */
.whats-on .over-map {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 1;
  pointer-events: none;
}
/* Shown with the map only, not over its load or failure panel. */
.whats-on:has(.whats-on-map:not(:state(ready))) .over-map {
  display: none;
}
/* The card beside the map, under it where there is no room: the venue selected, or the
   venues shown, each picked with a press. */
.whats-on .venue-card {
  flex: 1 1 14rem;
  box-sizing: border-box;
  padding: 16px 18px;
  border-radius: 12px;
  background: #26272c;
  color: #f2f2f3;
  font:
    400 14px / 1.4 system-ui,
    sans-serif;
}
.whats-on .venue-empty {
  margin: 0;
  color: #a5a6ad;
}
.whats-on .venue-list {
  display: grid;
  margin: 8px -8px 0;
  padding: 0;
  list-style: none;
}
.whats-on .venue-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.whats-on .venue-close {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #c9cad0;
  cursor: pointer;
}
/* The × drawn as two bars crossing at the button's centre, which a glyph's metrics never are. */
.whats-on .venue-close::before,
.whats-on .venue-close::after {
  content: "";
  grid-area: 1 / 1;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(45deg);
}
.whats-on .venue-close::after {
  transform: rotate(-45deg);
}
.whats-on .venue-pick:hover,
.whats-on .venue-close:hover {
  background: rgb(255 255 255 / 8%);
}
.whats-on .category-chip:focus-visible,
.whats-on .venue-pick:focus-visible,
.whats-on .venue-close:focus-visible {
  outline: 2px solid #f2f2f3;
  outline-offset: 2px;
}
.whats-on .venue {
  position: relative;
  padding-left: 12px;
  border-left: 3px solid var(--category);
}
.whats-on .venue-category,
.whats-on .venue-list-category {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: #c9cad0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* The category shown alone, a tag over the list rather than another of its venues. */
.whats-on .venue-list-category {
  width: fit-content;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--category) 30%, transparent);
  color: #f2f2f3;
}
.whats-on .venue-list-category[hidden] {
  display: none;
}
.whats-on .venue-name {
  margin: 6px 0 14px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}
.whats-on .venue dl {
  display: grid;
  gap: 12px;
  margin: 0;
}
.whats-on .venue dt {
  color: #a5a6ad;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.whats-on .venue dd {
  margin: 2px 0 0;
}
```

## A team around the world

Faces for markers, list entries of your own with each person's local time, filtered by team.

Each person is a face on the map, their initials on their team's colour, and the list beside it is the page's own: their name, role and city, and the time where they are next to how far that is from yours, turning as each minute begins.

- **Try it**: find someone by name, city or role, or untick teams in the group filter to see one; pick a face on the map and the list follows. On MapLibre the earth opens as a globe, faces on its far side faded: turn it, or flatten it with the toggle.
- **HTML**: a `<template data-icon>` in each `<maplace-location>` draws the face, and the person's role, city and time zone are the page's own `data-` attributes there, which Maplace.js leaves alone; the template makes the location's `icon` a function ([Templates](/element/#templates)). The list is a view of the page's own, `Maplace.defineListView` around `Maplace.createListView` with `render`, which reads those attributes from the person's `<maplace-location>` and draws the face with the location's own `icon` ([List views](/element/#list-views)); `group-filter`, `group-counts` and `search` on the map still reach it as its `options`.
- **Script** and **Bundler**: the people from `team.json`, each given an `icon` that draws the face from its `data` ([Icons](/locations/#icons)), and `list.render` building each entry ([List view options](/store/#list-view-options)). The times are written into each entry's own span, and a timeout set to the next minute writes them again, so no location changes for the clock.
- **React**: `markerIcon` on `<MaplaceMap>` and the entry as `<LocationList>`'s children ([`<LocationList>`](/react/#locationlist)); each entry's `<LocalTime>` keeps the minute in its state, so only the times render again as each minute begins.
- **Styling**: each team's colour, and the rings a face takes while pointed at or picked (`[data-hovered]`, `[data-selected]`), in the examples' `styles/team.css` ([Styling](/styling/)).
- **On MapLibre, a globe**: `globe` on the map (`globe: true` in the options; in React, `createAdapter={() => createMapLibreAdapter({ globe: true })}`) ([Globe](/maplibre/#globe)). Google's map has no globe.


### HTML on MapLibre

`packages/maplace/examples/team/maplibre/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- A team around the world: each person's face on the map, their initials on their team's colour,
     and the list beside it, each entry their role and city and the time where they are, which
     turns as each minute begins; filtered by team, or searched by name, city or role. On
     MapLibre, the earth as a globe, with a toggle on the map to flatten it. -->
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../../styles/team.css">
<style>
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-maplibre-map { height: 36rem; }
    #team-maplibre-map > .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<maplace-map id="team-maplibre-map" list="maplibre-team-members" list-heading="The team" group-counts
  group-filter search search-label="Find someone" globe>
  <maplace-location location-id="ana-maria-ruiz" lat="19.4326" lng="-99.1332" title="Ana María Ruiz" group="Design"
    search-text="Mexico City Product designer" data-role="Product designer" data-city="Mexico City" data-time-zone="America/Mexico_City">
    <template data-icon><span class="team-avatar" data-team="Design">AR</span></template>
  </maplace-location>
  <maplace-location location-id="kofi-mensah" lat="5.6037" lng="-0.187" title="Kofi Mensah" group="Engineering"
    search-text="Accra Backend engineer" data-role="Backend engineer" data-city="Accra" data-time-zone="Africa/Accra">
    <template data-icon><span class="team-avatar" data-team="Engineering">KM</span></template>
  </maplace-location>
  <maplace-location location-id="priya-raman" lat="12.9716" lng="77.5946" title="Priya Raman" group="Engineering"
    search-text="Bengaluru Frontend engineer" data-role="Frontend engineer" data-city="Bengaluru" data-time-zone="Asia/Kolkata">
    <template data-icon><span class="team-avatar" data-team="Engineering">PR</span></template>
  </maplace-location>
  <maplace-location location-id="sven-lindqvist" lat="59.3293" lng="18.0686" title="Sven Lindqvist" group="Engineering"
    search-text="Stockholm Engineering lead" data-role="Engineering lead" data-city="Stockholm" data-time-zone="Europe/Stockholm">
    <template data-icon><span class="team-avatar" data-team="Engineering">SL</span></template>
  </maplace-location>
  <maplace-location location-id="hana-sato" lat="34.6937" lng="135.5023" title="Hana Sato" group="Support"
    search-text="Osaka Support lead" data-role="Support lead" data-city="Osaka" data-time-zone="Asia/Tokyo">
    <template data-icon><span class="team-avatar" data-team="Support">HS</span></template>
  </maplace-location>
  <maplace-location location-id="lucas-ferreira" lat="-23.5505" lng="-46.6333" title="Lucas Ferreira" group="Support"
    search-text="São Paulo Support engineer" data-role="Support engineer" data-city="São Paulo" data-time-zone="America/Sao_Paulo">
    <template data-icon><span class="team-avatar" data-team="Support">LF</span></template>
  </maplace-location>
  <maplace-location location-id="amara-okafor" lat="6.5244" lng="3.3792" title="Amara Okafor" group="Design"
    search-text="Lagos Interaction designer" data-role="Interaction designer" data-city="Lagos" data-time-zone="Africa/Lagos">
    <template data-icon><span class="team-avatar" data-team="Design">AO</span></template>
  </maplace-location>
  <maplace-location location-id="tom-gallagher" lat="53.3498" lng="-6.2603" title="Tom Gallagher" group="Growth"
    search-text="Dublin Account manager" data-role="Account manager" data-city="Dublin" data-time-zone="Europe/Dublin">
    <template data-icon><span class="team-avatar" data-team="Growth">TG</span></template>
  </maplace-location>
  <maplace-location location-id="mei-lin" lat="25.033" lng="121.5654" title="Mei Lin" group="Engineering"
    search-text="Taipei Data engineer" data-role="Data engineer" data-city="Taipei" data-time-zone="Asia/Taipei">
    <template data-icon><span class="team-avatar" data-team="Engineering">ML</span></template>
  </maplace-location>
  <maplace-location location-id="rajesh-thapa" lat="27.7172" lng="85.324" title="Rajesh Thapa" group="Engineering"
    search-text="Kathmandu QA engineer" data-role="QA engineer" data-city="Kathmandu" data-time-zone="Asia/Kathmandu">
    <template data-icon><span class="team-avatar" data-team="Engineering">RT</span></template>
  </maplace-location>
  <maplace-location location-id="chloe-martin" lat="45.764" lng="4.8357" title="Chloé Martin" group="Design"
    search-text="Lyon Product manager" data-role="Product manager" data-city="Lyon" data-time-zone="Europe/Paris">
    <template data-icon><span class="team-avatar" data-team="Design">CM</span></template>
  </maplace-location>
  <maplace-location location-id="jack-wilson" lat="-37.8136" lng="144.9631" title="Jack Wilson" group="Growth"
    search-text="Melbourne Growth lead" data-role="Growth lead" data-city="Melbourne" data-time-zone="Australia/Melbourne">
    <template data-icon><span class="team-avatar" data-team="Growth">JW</span></template>
  </maplace-location>
  <maplace-location location-id="aroha-ngata" lat="-41.2865" lng="174.7762" title="Aroha Ngata" group="Support"
    search-text="Wellington Support engineer" data-role="Support engineer" data-city="Wellington" data-time-zone="Pacific/Auckland">
    <template data-icon><span class="team-avatar" data-team="Support">AN</span></template>
  </maplace-location>
  <maplace-location location-id="daniel-cohen" lat="32.0853" lng="34.7818" title="Daniel Cohen" group="Engineering"
    search-text="Tel Aviv Platform engineer" data-role="Platform engineer" data-city="Tel Aviv" data-time-zone="Asia/Jerusalem">
    <template data-icon><span class="team-avatar" data-team="Engineering">DC</span></template>
  </maplace-location>
  <maplace-location location-id="sofia-rossi" lat="45.4642" lng="9.19" title="Sofia Rossi" group="Design"
    search-text="Milan Content designer" data-role="Content designer" data-city="Milan" data-time-zone="Europe/Rome">
    <template data-icon><span class="team-avatar" data-team="Design">SR</span></template>
  </maplace-location>
  <maplace-location location-id="marcus-johnson" lat="33.749" lng="-84.388" title="Marcus Johnson" group="Growth"
    search-text="Atlanta Partnerships" data-role="Partnerships" data-city="Atlanta" data-time-zone="America/New_York">
    <template data-icon><span class="team-avatar" data-team="Growth">MJ</span></template>
  </maplace-location>
  <maplace-location location-id="emily-tremblay" lat="45.5017" lng="-73.5673" title="Emily Tremblay" group="Support"
    search-text="Montréal Support engineer" data-role="Support engineer" data-city="Montréal" data-time-zone="America/Toronto">
    <template data-icon><span class="team-avatar" data-team="Support">ET</span></template>
  </maplace-location>
  <maplace-location location-id="diego-alvarez" lat="-34.6037" lng="-58.3816" title="Diego Alvarez" group="Engineering"
    search-text="Buenos Aires Mobile engineer" data-role="Mobile engineer" data-city="Buenos Aires" data-time-zone="America/Argentina/Buenos_Aires">
    <template data-icon><span class="team-avatar" data-team="Engineering">DA</span></template>
  </maplace-location>
  <maplace-location location-id="leah-park" lat="47.6062" lng="-122.3321" title="Leah Park" group="Design"
    search-text="Seattle User researcher" data-role="User researcher" data-city="Seattle" data-time-zone="America/Los_Angeles">
    <template data-icon><span class="team-avatar" data-team="Design">LP</span></template>
  </maplace-location>
  <maplace-location location-id="yusuf-demir" lat="41.0082" lng="28.9784" title="Yusuf Demir" group="Growth"
    search-text="Istanbul Growth marketer" data-role="Growth marketer" data-city="Istanbul" data-time-zone="Europe/Istanbul">
    <template data-icon><span class="team-avatar" data-team="Growth">YD</span></template>
  </maplace-location>
</maplace-map>
<script>
  {
    const map = document.getElementById("team-maplibre-map");
    const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
    // How long until the next minute begins, and a little past it, so the clock reads the new one.
    const untilNextMinute = () => 60_050 - (Date.now() % 60_000);

    // The time on a zone's clock: "17:30".
    const localTimeOf = (timeZone, now) =>
      new Intl.DateTimeFormat("en-GB", { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(now);
    // How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0).
    const minutesFromUtc = (timeZone, now) => {
      const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
        .formatToParts(now).find(({ type }) => type === "timeZoneName")?.value ?? "";
      const [, sign = "+", hours = "0", minutes = "0"] = /GMT([+\-−])(\d\d):(\d\d)/.exec(name) ?? [];
      return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
    };
    // "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind.
    const offsetFromYou = (timeZone, now) => {
      const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
      if (minutes === 0) return "same time";
      const sign = minutes > 0 ? "+" : "−";
      const hours = Math.floor(Math.abs(minutes) / 60);
      const rest = Math.abs(minutes) % 60;
      return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
    };
    const writeLocalTime = (time) => {
      const now = new Date();
      time.textContent = `${localTimeOf(time.dataset.timeZone, now)} · ${offsetFromYou(time.dataset.timeZone, now)}`;
    };
    // A span showing the time on a zone's clock beside how far it is from yours.
    const localTime = (timeZone) => {
      const time = document.createElement("span");
      time.className = "team-member-time";
      time.dataset.timeZone = timeZone;
      writeLocalTime(time);
      return time;
    };
    const span = (className, ...children) => {
      const element = document.createElement("span");
      element.className = className;
      element.append(...children);
      return element;
    };

    // A person's entry in the list, the page's own: their face (their location's own icon), name,
    // role and city from their <maplace-location>'s data- attributes, and the time where they are.
    const memberItem = ({ location }) => {
      const person = map.querySelector(`maplace-location[location-id="${CSS.escape(location.id)}"]`).dataset;
      const face = location.icon(location, { selected: false, hovered: false });
      face.setAttribute("aria-hidden", "true");
      return span("team-member", face, span("team-member-text",
        span("team-member-name", location.title),
        span("team-member-detail", `${person.role} · ${person.city}`),
        localTime(person.timeZone)));
    };
    Maplace.defineListView("maplibre-team-members", (maplace, { options }) =>
      Maplace.createListView(maplace, { ...options, render: memberItem }));

    // Every time shown turns as each minute begins.
    const showLocalTimes = () => {
      for (const time of map.querySelectorAll(".team-member-time")) writeLocalTime(time);
      setTimeout(showLocalTimes, untilNextMinute());
    };
    setTimeout(showLocalTimes, untilNextMinute());
  }
</script>
```

### HTML on Google

`packages/maplace/examples/team/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- A team around the world: each person's face on the map, their initials on their team's colour,
     and the list beside it, each entry their role and city and the time where they are, which
     turns as each minute begins; filtered by team, or searched by name, city or role. -->
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../styles/team.css">
<style>
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-map { height: 36rem; }
    #team-map > .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<maplace-map id="team-map" api-key="YOUR_KEY" list="team-members" list-heading="The team" group-counts
  group-filter search search-label="Find someone">
  <maplace-location location-id="ana-maria-ruiz" lat="19.4326" lng="-99.1332" title="Ana María Ruiz" group="Design"
    search-text="Mexico City Product designer" data-role="Product designer" data-city="Mexico City" data-time-zone="America/Mexico_City">
    <template data-icon><span class="team-avatar" data-team="Design">AR</span></template>
  </maplace-location>
  <maplace-location location-id="kofi-mensah" lat="5.6037" lng="-0.187" title="Kofi Mensah" group="Engineering"
    search-text="Accra Backend engineer" data-role="Backend engineer" data-city="Accra" data-time-zone="Africa/Accra">
    <template data-icon><span class="team-avatar" data-team="Engineering">KM</span></template>
  </maplace-location>
  <maplace-location location-id="priya-raman" lat="12.9716" lng="77.5946" title="Priya Raman" group="Engineering"
    search-text="Bengaluru Frontend engineer" data-role="Frontend engineer" data-city="Bengaluru" data-time-zone="Asia/Kolkata">
    <template data-icon><span class="team-avatar" data-team="Engineering">PR</span></template>
  </maplace-location>
  <maplace-location location-id="sven-lindqvist" lat="59.3293" lng="18.0686" title="Sven Lindqvist" group="Engineering"
    search-text="Stockholm Engineering lead" data-role="Engineering lead" data-city="Stockholm" data-time-zone="Europe/Stockholm">
    <template data-icon><span class="team-avatar" data-team="Engineering">SL</span></template>
  </maplace-location>
  <maplace-location location-id="hana-sato" lat="34.6937" lng="135.5023" title="Hana Sato" group="Support"
    search-text="Osaka Support lead" data-role="Support lead" data-city="Osaka" data-time-zone="Asia/Tokyo">
    <template data-icon><span class="team-avatar" data-team="Support">HS</span></template>
  </maplace-location>
  <maplace-location location-id="lucas-ferreira" lat="-23.5505" lng="-46.6333" title="Lucas Ferreira" group="Support"
    search-text="São Paulo Support engineer" data-role="Support engineer" data-city="São Paulo" data-time-zone="America/Sao_Paulo">
    <template data-icon><span class="team-avatar" data-team="Support">LF</span></template>
  </maplace-location>
  <maplace-location location-id="amara-okafor" lat="6.5244" lng="3.3792" title="Amara Okafor" group="Design"
    search-text="Lagos Interaction designer" data-role="Interaction designer" data-city="Lagos" data-time-zone="Africa/Lagos">
    <template data-icon><span class="team-avatar" data-team="Design">AO</span></template>
  </maplace-location>
  <maplace-location location-id="tom-gallagher" lat="53.3498" lng="-6.2603" title="Tom Gallagher" group="Growth"
    search-text="Dublin Account manager" data-role="Account manager" data-city="Dublin" data-time-zone="Europe/Dublin">
    <template data-icon><span class="team-avatar" data-team="Growth">TG</span></template>
  </maplace-location>
  <maplace-location location-id="mei-lin" lat="25.033" lng="121.5654" title="Mei Lin" group="Engineering"
    search-text="Taipei Data engineer" data-role="Data engineer" data-city="Taipei" data-time-zone="Asia/Taipei">
    <template data-icon><span class="team-avatar" data-team="Engineering">ML</span></template>
  </maplace-location>
  <maplace-location location-id="rajesh-thapa" lat="27.7172" lng="85.324" title="Rajesh Thapa" group="Engineering"
    search-text="Kathmandu QA engineer" data-role="QA engineer" data-city="Kathmandu" data-time-zone="Asia/Kathmandu">
    <template data-icon><span class="team-avatar" data-team="Engineering">RT</span></template>
  </maplace-location>
  <maplace-location location-id="chloe-martin" lat="45.764" lng="4.8357" title="Chloé Martin" group="Design"
    search-text="Lyon Product manager" data-role="Product manager" data-city="Lyon" data-time-zone="Europe/Paris">
    <template data-icon><span class="team-avatar" data-team="Design">CM</span></template>
  </maplace-location>
  <maplace-location location-id="jack-wilson" lat="-37.8136" lng="144.9631" title="Jack Wilson" group="Growth"
    search-text="Melbourne Growth lead" data-role="Growth lead" data-city="Melbourne" data-time-zone="Australia/Melbourne">
    <template data-icon><span class="team-avatar" data-team="Growth">JW</span></template>
  </maplace-location>
  <maplace-location location-id="aroha-ngata" lat="-41.2865" lng="174.7762" title="Aroha Ngata" group="Support"
    search-text="Wellington Support engineer" data-role="Support engineer" data-city="Wellington" data-time-zone="Pacific/Auckland">
    <template data-icon><span class="team-avatar" data-team="Support">AN</span></template>
  </maplace-location>
  <maplace-location location-id="daniel-cohen" lat="32.0853" lng="34.7818" title="Daniel Cohen" group="Engineering"
    search-text="Tel Aviv Platform engineer" data-role="Platform engineer" data-city="Tel Aviv" data-time-zone="Asia/Jerusalem">
    <template data-icon><span class="team-avatar" data-team="Engineering">DC</span></template>
  </maplace-location>
  <maplace-location location-id="sofia-rossi" lat="45.4642" lng="9.19" title="Sofia Rossi" group="Design"
    search-text="Milan Content designer" data-role="Content designer" data-city="Milan" data-time-zone="Europe/Rome">
    <template data-icon><span class="team-avatar" data-team="Design">SR</span></template>
  </maplace-location>
  <maplace-location location-id="marcus-johnson" lat="33.749" lng="-84.388" title="Marcus Johnson" group="Growth"
    search-text="Atlanta Partnerships" data-role="Partnerships" data-city="Atlanta" data-time-zone="America/New_York">
    <template data-icon><span class="team-avatar" data-team="Growth">MJ</span></template>
  </maplace-location>
  <maplace-location location-id="emily-tremblay" lat="45.5017" lng="-73.5673" title="Emily Tremblay" group="Support"
    search-text="Montréal Support engineer" data-role="Support engineer" data-city="Montréal" data-time-zone="America/Toronto">
    <template data-icon><span class="team-avatar" data-team="Support">ET</span></template>
  </maplace-location>
  <maplace-location location-id="diego-alvarez" lat="-34.6037" lng="-58.3816" title="Diego Alvarez" group="Engineering"
    search-text="Buenos Aires Mobile engineer" data-role="Mobile engineer" data-city="Buenos Aires" data-time-zone="America/Argentina/Buenos_Aires">
    <template data-icon><span class="team-avatar" data-team="Engineering">DA</span></template>
  </maplace-location>
  <maplace-location location-id="leah-park" lat="47.6062" lng="-122.3321" title="Leah Park" group="Design"
    search-text="Seattle User researcher" data-role="User researcher" data-city="Seattle" data-time-zone="America/Los_Angeles">
    <template data-icon><span class="team-avatar" data-team="Design">LP</span></template>
  </maplace-location>
  <maplace-location location-id="yusuf-demir" lat="41.0082" lng="28.9784" title="Yusuf Demir" group="Growth"
    search-text="Istanbul Growth marketer" data-role="Growth marketer" data-city="Istanbul" data-time-zone="Europe/Istanbul">
    <template data-icon><span class="team-avatar" data-team="Growth">YD</span></template>
  </maplace-location>
</maplace-map>
<script>
  {
    const map = document.getElementById("team-map");
    const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
    // How long until the next minute begins, and a little past it, so the clock reads the new one.
    const untilNextMinute = () => 60_050 - (Date.now() % 60_000);

    // The time on a zone's clock: "17:30".
    const localTimeOf = (timeZone, now) =>
      new Intl.DateTimeFormat("en-GB", { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(now);
    // How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0).
    const minutesFromUtc = (timeZone, now) => {
      const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
        .formatToParts(now).find(({ type }) => type === "timeZoneName")?.value ?? "";
      const [, sign = "+", hours = "0", minutes = "0"] = /GMT([+\-−])(\d\d):(\d\d)/.exec(name) ?? [];
      return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
    };
    // "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind.
    const offsetFromYou = (timeZone, now) => {
      const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
      if (minutes === 0) return "same time";
      const sign = minutes > 0 ? "+" : "−";
      const hours = Math.floor(Math.abs(minutes) / 60);
      const rest = Math.abs(minutes) % 60;
      return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
    };
    const writeLocalTime = (time) => {
      const now = new Date();
      time.textContent = `${localTimeOf(time.dataset.timeZone, now)} · ${offsetFromYou(time.dataset.timeZone, now)}`;
    };
    // A span showing the time on a zone's clock beside how far it is from yours.
    const localTime = (timeZone) => {
      const time = document.createElement("span");
      time.className = "team-member-time";
      time.dataset.timeZone = timeZone;
      writeLocalTime(time);
      return time;
    };
    const span = (className, ...children) => {
      const element = document.createElement("span");
      element.className = className;
      element.append(...children);
      return element;
    };

    // A person's entry in the list, the page's own: their face (their location's own icon), name,
    // role and city from their <maplace-location>'s data- attributes, and the time where they are.
    const memberItem = ({ location }) => {
      const person = map.querySelector(`maplace-location[location-id="${CSS.escape(location.id)}"]`).dataset;
      const face = location.icon(location, { selected: false, hovered: false });
      face.setAttribute("aria-hidden", "true");
      return span("team-member", face, span("team-member-text",
        span("team-member-name", location.title),
        span("team-member-detail", `${person.role} · ${person.city}`),
        localTime(person.timeZone)));
    };
    Maplace.defineListView("team-members", (maplace, { options }) =>
      Maplace.createListView(maplace, { ...options, render: memberItem }));

    // Every time shown turns as each minute begins.
    const showLocalTimes = () => {
      for (const time of map.querySelectorAll(".team-member-time")) writeLocalTime(time);
      setTimeout(showLocalTimes, untilNextMinute());
    };
    setTimeout(showLocalTimes, untilNextMinute());
  }
</script>
```

### Script on MapLibre

`packages/maplace/examples/team/maplibre/script.html`

```html
<!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet, what the map and its list mount on, and the map made with Maplace; each person's face on the map, and the list with the time where each one is. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../../styles/team.css">
<style>
  #team-maplibre-script-map-and-list { display: flex; height: 24rem; }
  #team-maplibre-script-map { flex: 1 1 auto; min-width: 0; }
  #team-maplibre-script-list { display: contents; }
  #team-maplibre-script-list .maplace-list { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-maplibre-script-map-and-list { flex-direction: column; height: 36rem; }
    #team-maplibre-script-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<div id="team-maplibre-script-map-and-list">
  <div id="team-maplibre-script-map"></div>
  <div id="team-maplibre-script-list"></div>
</div>
<script type="module">
  // Each person, in their team's group: their role, city, clock and initials in their data.
  const team = await fetch("/examples/data/team.json").then((response) => response.json());
  const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  // How long until the next minute begins, and a little past it, so the clock reads the new one.
  const untilNextMinute = () => 60_050 - (Date.now() % 60_000);

  // The time on a zone's clock: "17:30".
  const localTimeOf = (timeZone, now) =>
    new Intl.DateTimeFormat("en-GB", { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(now);
  // How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0).
  const minutesFromUtc = (timeZone, now) => {
    const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
      .formatToParts(now).find(({ type }) => type === "timeZoneName")?.value ?? "";
    const [, sign = "+", hours = "0", minutes = "0"] = /GMT([+\-−])(\d\d):(\d\d)/.exec(name) ?? [];
    return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
  };
  // "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind.
  const offsetFromYou = (timeZone, now) => {
    const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
    if (minutes === 0) return "same time";
    const sign = minutes > 0 ? "+" : "−";
    const hours = Math.floor(Math.abs(minutes) / 60);
    const rest = Math.abs(minutes) % 60;
    return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
  };
  const writeLocalTime = (time) => {
    const now = new Date();
    time.textContent = `${localTimeOf(time.dataset.timeZone, now)} · ${offsetFromYou(time.dataset.timeZone, now)}`;
  };
  // A span showing the time on a zone's clock beside how far it is from yours.
  const localTime = (timeZone) => {
    const time = document.createElement("span");
    time.className = "team-member-time";
    time.dataset.timeZone = timeZone;
    writeLocalTime(time);
    return time;
  };
  const span = (className, ...children) => {
    const element = document.createElement("span");
    element.className = className;
    element.append(...children);
    return element;
  };

  // A face: the person's initials on their team's colour, the marker and the entry's lead.
  const avatar = ({ group, data }) => {
    const face = span("team-avatar", data.initials);
    face.dataset.team = group;
    return face;
  };
  // A person's entry in the list, the page's own: their face, name, role and city, and the time
  // where they are.
  const memberItem = ({ location }) => {
    const face = avatar(location);
    face.setAttribute("aria-hidden", "true");
    return span("team-member", face, span("team-member-text",
      span("team-member-name", location.title),
      span("team-member-detail", `${location.data.role} · ${location.data.city}`),
      localTime(location.data.timeZone)));
  };

  Maplace.createMapLibreMap("#team-maplibre-script-map", {
    // The earth as a globe, with a toggle on the map to flatten it.
    globe: true,
    locations: team.map((person) => ({ ...person, icon: avatar })),
    list: {
      container: "#team-maplibre-script-list",
      heading: "The team",
      render: memberItem,
      groupCounts: true,
      groupFilter: true,
      search: true,
      searchLabel: "Find someone",
    },
  });

  // Every time shown turns as each minute begins.
  const list = document.getElementById("team-maplibre-script-list");
  const showLocalTimes = () => {
    for (const time of list.querySelectorAll(".team-member-time")) writeLocalTime(time);
    setTimeout(showLocalTimes, untilNextMinute());
  };
  setTimeout(showLocalTimes, untilNextMinute());
</script>
```

### Script on Google

`packages/maplace/examples/team/script.html`

```html
<!doctype html>
<!-- A page of your own script: the CDN script, what the map and its list mount on, and the map made with Maplace, which adds Maps JS with your key; each person's face on the map, and the list with the time where each one is. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../styles/team.css">
<style>
  #team-script-map-and-list { display: flex; height: 24rem; }
  #team-script-map { flex: 1 1 auto; min-width: 0; }
  #team-script-list { display: contents; }
  #team-script-list .maplace-list { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-script-map-and-list { flex-direction: column; height: 36rem; }
    #team-script-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<div id="team-script-map-and-list">
  <div id="team-script-map"></div>
  <div id="team-script-list"></div>
</div>
<script type="module">
  // Each person, in their team's group: their role, city, clock and initials in their data.
  const team = await fetch("/examples/data/team.json").then((response) => response.json());
  const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  // How long until the next minute begins, and a little past it, so the clock reads the new one.
  const untilNextMinute = () => 60_050 - (Date.now() % 60_000);

  // The time on a zone's clock: "17:30".
  const localTimeOf = (timeZone, now) =>
    new Intl.DateTimeFormat("en-GB", { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(now);
  // How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0).
  const minutesFromUtc = (timeZone, now) => {
    const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
      .formatToParts(now).find(({ type }) => type === "timeZoneName")?.value ?? "";
    const [, sign = "+", hours = "0", minutes = "0"] = /GMT([+\-−])(\d\d):(\d\d)/.exec(name) ?? [];
    return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
  };
  // "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind.
  const offsetFromYou = (timeZone, now) => {
    const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
    if (minutes === 0) return "same time";
    const sign = minutes > 0 ? "+" : "−";
    const hours = Math.floor(Math.abs(minutes) / 60);
    const rest = Math.abs(minutes) % 60;
    return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
  };
  const writeLocalTime = (time) => {
    const now = new Date();
    time.textContent = `${localTimeOf(time.dataset.timeZone, now)} · ${offsetFromYou(time.dataset.timeZone, now)}`;
  };
  // A span showing the time on a zone's clock beside how far it is from yours.
  const localTime = (timeZone) => {
    const time = document.createElement("span");
    time.className = "team-member-time";
    time.dataset.timeZone = timeZone;
    writeLocalTime(time);
    return time;
  };
  const span = (className, ...children) => {
    const element = document.createElement("span");
    element.className = className;
    element.append(...children);
    return element;
  };

  // A face: the person's initials on their team's colour, the marker and the entry's lead.
  const avatar = ({ group, data }) => {
    const face = span("team-avatar", data.initials);
    face.dataset.team = group;
    return face;
  };
  // A person's entry in the list, the page's own: their face, name, role and city, and the time
  // where they are.
  const memberItem = ({ location }) => {
    const face = avatar(location);
    face.setAttribute("aria-hidden", "true");
    return span("team-member", face, span("team-member-text",
      span("team-member-name", location.title),
      span("team-member-detail", `${location.data.role} · ${location.data.city}`),
      localTime(location.data.timeZone)));
  };

  Maplace.createGoogleMap("#team-script-map", {
    apiKey: "YOUR_KEY",
    locations: team.map((person) => ({ ...person, icon: avatar })),
    list: {
      container: "#team-script-list",
      heading: "The team",
      render: memberItem,
      groupCounts: true,
      groupFilter: true,
      search: true,
      searchLabel: "Find someone",
    },
  });

  // Every time shown turns as each minute begins.
  const list = document.getElementById("team-script-list");
  const showLocalTimes = () => {
    for (const time of list.querySelectorAll(".team-member-time")) writeLocalTime(time);
    setTimeout(showLocalTimes, untilNextMinute());
  };
  setTimeout(showLocalTimes, untilNextMinute());
</script>
```

### Bundler on MapLibre

`packages/maplace/examples/team/maplibre/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../../styles/team.css">
<style>
  #team-maplibre-vanilla-map-and-list { display: flex; height: 24rem; }
  #team-maplibre-vanilla-map { flex: 1 1 auto; min-width: 0; }
  #team-maplibre-vanilla-list { display: contents; }
  #team-maplibre-vanilla-list .maplace-list { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-maplibre-vanilla-map-and-list { flex-direction: column; height: 36rem; }
    #team-maplibre-vanilla-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<div id="team-maplibre-vanilla-map-and-list">
  <div id="team-maplibre-vanilla-map"></div>
  <div id="team-maplibre-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/team/maplibre/vanilla.ts`

```ts
import "maplibre-gl/dist/maplibre-gl.css";
import type { ListEntry, Location } from "@maplacejs/maplace";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";

/** What each person's location carries: their role, city, clock and initials. */
interface Member {
  readonly role: string;
  readonly city: string;
  readonly timeZone: string;
  readonly initials: string;
}

// Each person, in their team's group.
const team: Location<Member>[] = await (await fetch("/examples/data/team.json")).json();
const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

/** How long until the next minute begins, and a little past it, so the clock reads the new one. */
const untilNextMinute = () => 60_050 - (Date.now() % 60_000);

/** The time on a zone's clock: "17:30". */
function localTimeOf(timeZone: string, now: Date): string {
  const clock = { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" } as const;
  return new Intl.DateTimeFormat("en-GB", clock).format(now);
}

/** How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0). */
function minutesFromUtc(timeZone: string, now: Date): number {
  const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
    .formatToParts(now)
    .find(({ type }) => type === "timeZoneName")?.value;
  const [, sign = "+", hours = "0", minutes = "0"] =
    /GMT([+\-−])(\d\d):(\d\d)/.exec(name ?? "") ?? [];
  return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
}

/** "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind. */
function offsetFromYou(timeZone: string, now: Date): string {
  const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
  if (minutes === 0) return "same time";
  const sign = minutes > 0 ? "+" : "−";
  const hours = Math.floor(Math.abs(minutes) / 60);
  const rest = Math.abs(minutes) % 60;
  return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
}

function writeLocalTime(time: HTMLElement): void {
  const now = new Date();
  const zone = time.dataset.timeZone ?? viewerZone;
  time.textContent = `${localTimeOf(zone, now)} · ${offsetFromYou(zone, now)}`;
}

/** A span showing the time on a zone's clock beside how far it is from yours. */
function localTime(timeZone: string): HTMLElement {
  const time = document.createElement("span");
  time.className = "team-member-time";
  time.dataset.timeZone = timeZone;
  writeLocalTime(time);
  return time;
}

function span(className: string, ...children: (Node | string)[]): HTMLSpanElement {
  const element = document.createElement("span");
  element.className = className;
  element.append(...children);
  return element;
}

/** A face: the person's initials on their team's colour, the marker and the entry's lead. */
function avatar({ group, data }: Location<Member>): HTMLElement {
  const face = span("team-avatar", data?.initials ?? "");
  face.dataset.team = String(group);
  return face;
}

/** A person's entry in the list: their face, name, role and city, and the time where they are. */
function memberItem({ location }: ListEntry<Member>): Node {
  const face = avatar(location);
  face.setAttribute("aria-hidden", "true");
  return span(
    "team-member",
    face,
    span(
      "team-member-text",
      span("team-member-name", location.title ?? ""),
      span("team-member-detail", `${location.data?.role} · ${location.data?.city}`),
      localTime(location.data?.timeZone ?? viewerZone),
    ),
  );
}

createMapLibreMap<Member>("#team-maplibre-vanilla-map", {
  // The earth as a globe, with a toggle on the map to flatten it.
  globe: true,
  locations: team.map((person) => ({ ...person, icon: avatar })),
  list: {
    container: "#team-maplibre-vanilla-list",
    heading: "The team",
    render: memberItem,
    groupCounts: true,
    groupFilter: true,
    search: true,
    searchLabel: "Find someone",
  },
});

/** Every time shown turns as each minute begins. */
function showLocalTimes(): void {
  for (const time of document.querySelectorAll<HTMLElement>(
    "#team-maplibre-vanilla-list .team-member-time",
  )) {
    writeLocalTime(time);
  }
  setTimeout(showLocalTimes, untilNextMinute());
}
setTimeout(showLocalTimes, untilNextMinute());
```

### Bundler on Google

`packages/maplace/examples/team/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../styles/team.css">
<style>
  #team-vanilla-map-and-list { display: flex; height: 24rem; }
  #team-vanilla-map { flex: 1 1 auto; min-width: 0; }
  #team-vanilla-list { display: contents; }
  #team-vanilla-list .maplace-list { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-vanilla-map-and-list { flex-direction: column; height: 36rem; }
    #team-vanilla-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<div id="team-vanilla-map-and-list">
  <div id="team-vanilla-map"></div>
  <div id="team-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/team/vanilla.ts`

```ts
import type { ListEntry, Location } from "@maplacejs/maplace";
import { createGoogleMap } from "@maplacejs/maplace/google";

/** What each person's location carries: their role, city, clock and initials. */
interface Member {
  readonly role: string;
  readonly city: string;
  readonly timeZone: string;
  readonly initials: string;
}

// Each person, in their team's group.
const team: Location<Member>[] = await (await fetch("/examples/data/team.json")).json();
const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

/** How long until the next minute begins, and a little past it, so the clock reads the new one. */
const untilNextMinute = () => 60_050 - (Date.now() % 60_000);

/** The time on a zone's clock: "17:30". */
function localTimeOf(timeZone: string, now: Date): string {
  const clock = { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" } as const;
  return new Intl.DateTimeFormat("en-GB", clock).format(now);
}

/** How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0). */
function minutesFromUtc(timeZone: string, now: Date): number {
  const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
    .formatToParts(now)
    .find(({ type }) => type === "timeZoneName")?.value;
  const [, sign = "+", hours = "0", minutes = "0"] =
    /GMT([+\-−])(\d\d):(\d\d)/.exec(name ?? "") ?? [];
  return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
}

/** "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind. */
function offsetFromYou(timeZone: string, now: Date): string {
  const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
  if (minutes === 0) return "same time";
  const sign = minutes > 0 ? "+" : "−";
  const hours = Math.floor(Math.abs(minutes) / 60);
  const rest = Math.abs(minutes) % 60;
  return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
}

function writeLocalTime(time: HTMLElement): void {
  const now = new Date();
  const zone = time.dataset.timeZone ?? viewerZone;
  time.textContent = `${localTimeOf(zone, now)} · ${offsetFromYou(zone, now)}`;
}

/** A span showing the time on a zone's clock beside how far it is from yours. */
function localTime(timeZone: string): HTMLElement {
  const time = document.createElement("span");
  time.className = "team-member-time";
  time.dataset.timeZone = timeZone;
  writeLocalTime(time);
  return time;
}

function span(className: string, ...children: (Node | string)[]): HTMLSpanElement {
  const element = document.createElement("span");
  element.className = className;
  element.append(...children);
  return element;
}

/** A face: the person's initials on their team's colour, the marker and the entry's lead. */
function avatar({ group, data }: Location<Member>): HTMLElement {
  const face = span("team-avatar", data?.initials ?? "");
  face.dataset.team = String(group);
  return face;
}

/** A person's entry in the list: their face, name, role and city, and the time where they are. */
function memberItem({ location }: ListEntry<Member>): Node {
  const face = avatar(location);
  face.setAttribute("aria-hidden", "true");
  return span(
    "team-member",
    face,
    span(
      "team-member-text",
      span("team-member-name", location.title ?? ""),
      span("team-member-detail", `${location.data?.role} · ${location.data?.city}`),
      localTime(location.data?.timeZone ?? viewerZone),
    ),
  );
}

createGoogleMap<Member>("#team-vanilla-map", {
  locations: team.map((person) => ({ ...person, icon: avatar })),
  list: {
    container: "#team-vanilla-list",
    heading: "The team",
    render: memberItem,
    groupCounts: true,
    groupFilter: true,
    search: true,
    searchLabel: "Find someone",
  },
});

/** Every time shown turns as each minute begins. */
function showLocalTimes(): void {
  for (const time of document.querySelectorAll<HTMLElement>(
    "#team-vanilla-list .team-member-time",
  )) {
    writeLocalTime(time);
  }
  setTimeout(showLocalTimes, untilNextMinute());
}
setTimeout(showLocalTimes, untilNextMinute());
```

### React on MapLibre

`packages/maplace/examples/team/maplibre/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../../styles/team.css">
<style>
  #team-maplibre-react-root .map-and-list { display: flex; height: 24rem; }
  #team-maplibre-react-root .map { flex: 1 1 auto; min-width: 0; }
  #team-maplibre-react-root .maplace-list { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-maplibre-react-root .map-and-list { flex-direction: column; height: 36rem; }
    #team-maplibre-react-root .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<div id="team-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/team/maplibre/react.tsx`

```tsx
import "maplibre-gl/dist/maplibre-gl.css";
import type { ListEntry, Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode, useEffect, useState } from "react";
import { createRoot } from "react-dom/client";

/** What each person's location carries: their role, city, clock and initials. */
interface Member {
  readonly role: string;
  readonly city: string;
  readonly timeZone: string;
  readonly initials: string;
}

const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

/** The time on a zone's clock: "17:30". */
function localTimeOf(timeZone: string, now: Date): string {
  const clock = { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" } as const;
  return new Intl.DateTimeFormat("en-GB", clock).format(now);
}

/** How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0). */
function minutesFromUtc(timeZone: string, now: Date): number {
  const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
    .formatToParts(now)
    .find(({ type }) => type === "timeZoneName")?.value;
  const [, sign = "+", hours = "0", minutes = "0"] =
    /GMT([+\-−])(\d\d):(\d\d)/.exec(name ?? "") ?? [];
  return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
}

/** "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind. */
function offsetFromYou(timeZone: string, now: Date): string {
  const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
  if (minutes === 0) return "same time";
  const sign = minutes > 0 ? "+" : "−";
  const hours = Math.floor(Math.abs(minutes) / 60);
  const rest = Math.abs(minutes) % 60;
  return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
}

/** The time now, turning as each minute begins (a little past it, so the clock reads the new one). */
function useMinute(): Date {
  const [now, setNow] = useState(() => new Date());
  useEffect(() => {
    const turn = setTimeout(() => setNow(new Date()), 60_050 - (now.getTime() % 60_000));
    return () => clearTimeout(turn);
  }, [now]);
  return now;
}

/** The time on a zone's clock beside how far it is from yours, turning as each minute begins. */
function LocalTime({ timeZone }: { readonly timeZone: string }) {
  const now = useMinute();
  return (
    <span className="team-member-time">
      {localTimeOf(timeZone, now)} · {offsetFromYou(timeZone, now)}
    </span>
  );
}

/** A face: the person's initials on their team's colour, the marker and the entry's lead. */
function Avatar({ location: { group, data } }: { readonly location: Location<Member> }) {
  return (
    <span className="team-avatar" data-team={String(group)}>
      {data?.initials}
    </span>
  );
}

// The earth as a globe, with a toggle on the map to flatten it.
const onTheGlobe = () => createMapLibreAdapter({ globe: true });

const markerIcon = (location: Location<Member>) => <Avatar location={location} />;

/** A person's entry in the list: their face, name, role and city, and the time where they are. */
const memberItem = ({ location }: ListEntry<Member>) => (
  <span className="team-member">
    <span aria-hidden="true">
      <Avatar location={location} />
    </span>
    <span className="team-member-text">
      <span className="team-member-name">{location.title}</span>
      <span className="team-member-detail">
        {location.data?.role} · {location.data?.city}
      </span>
      <LocalTime timeZone={location.data?.timeZone ?? viewerZone} />
    </span>
  </span>
);

function Team() {
  // Each person, in their team's group.
  const [team, setTeam] = useState<readonly Location<Member>[]>([]);
  useEffect(() => {
    fetch("/examples/data/team.json")
      .then((response) => response.json())
      .then(setTeam);
  }, []);
  return (
    <MaplaceProvider locations={team}>
      <div className="map-and-list">
        <MaplaceMap createAdapter={onTheGlobe} className="map" markerIcon={markerIcon} />
        <LocationList heading="The team" groupCounts groupFilter search searchLabel="Find someone">
          {memberItem}
        </LocationList>
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("team-maplibre-react-root") as HTMLElement).render(
  <StrictMode>
    <Team />
  </StrictMode>,
);
```

### React on Google

`packages/maplace/examples/team/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<!-- This example's look lives in the examples' styles/team.css, which every version links. -->
<link rel="stylesheet" href="../styles/team.css">
<style>
  #team-react-root .map-and-list { display: flex; height: 24rem; }
  #team-react-root .map { flex: 1 1 auto; min-width: 0; }
  #team-react-root .maplace-list { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, its half staying that size. */
  @media (width < 40rem) {
    #team-react-root .map-and-list { flex-direction: column; height: 36rem; }
    #team-react-root .maplace-list { flex: 0 0 50%; max-height: 50%; }
  }
</style>
<div id="team-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/team/react.tsx`

```tsx
import type { ListEntry, Location } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode, useEffect, useState } from "react";
import { createRoot } from "react-dom/client";

/** What each person's location carries: their role, city, clock and initials. */
interface Member {
  readonly role: string;
  readonly city: string;
  readonly timeZone: string;
  readonly initials: string;
}

const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

/** The time on a zone's clock: "17:30". */
function localTimeOf(timeZone: string, now: Date): string {
  const clock = { timeZone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" } as const;
  return new Intl.DateTimeFormat("en-GB", clock).format(now);
}

/** How far a zone's clock is ahead of UTC, in minutes: Kolkata's 330 ("GMT" alone is 0). */
function minutesFromUtc(timeZone: string, now: Date): number {
  const name = new Intl.DateTimeFormat("en-GB", { timeZone, timeZoneName: "longOffset" })
    .formatToParts(now)
    .find(({ type }) => type === "timeZoneName")?.value;
  const [, sign = "+", hours = "0", minutes = "0"] =
    /GMT([+\-−])(\d\d):(\d\d)/.exec(name ?? "") ?? [];
  return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes));
}

/** "+5h30", "−8h" or "same time": how far a zone's clock is ahead of yours, or behind. */
function offsetFromYou(timeZone: string, now: Date): string {
  const minutes = minutesFromUtc(timeZone, now) - minutesFromUtc(viewerZone, now);
  if (minutes === 0) return "same time";
  const sign = minutes > 0 ? "+" : "−";
  const hours = Math.floor(Math.abs(minutes) / 60);
  const rest = Math.abs(minutes) % 60;
  return `${sign}${hours}h${rest ? String(rest).padStart(2, "0") : ""}`;
}

/** The time now, turning as each minute begins (a little past it, so the clock reads the new one). */
function useMinute(): Date {
  const [now, setNow] = useState(() => new Date());
  useEffect(() => {
    const turn = setTimeout(() => setNow(new Date()), 60_050 - (now.getTime() % 60_000));
    return () => clearTimeout(turn);
  }, [now]);
  return now;
}

/** The time on a zone's clock beside how far it is from yours, turning as each minute begins. */
function LocalTime({ timeZone }: { readonly timeZone: string }) {
  const now = useMinute();
  return (
    <span className="team-member-time">
      {localTimeOf(timeZone, now)} · {offsetFromYou(timeZone, now)}
    </span>
  );
}

/** A face: the person's initials on their team's colour, the marker and the entry's lead. */
function Avatar({ location: { group, data } }: { readonly location: Location<Member> }) {
  return (
    <span className="team-avatar" data-team={String(group)}>
      {data?.initials}
    </span>
  );
}

const markerIcon = (location: Location<Member>) => <Avatar location={location} />;

/** A person's entry in the list: their face, name, role and city, and the time where they are. */
const memberItem = ({ location }: ListEntry<Member>) => (
  <span className="team-member">
    <span aria-hidden="true">
      <Avatar location={location} />
    </span>
    <span className="team-member-text">
      <span className="team-member-name">{location.title}</span>
      <span className="team-member-detail">
        {location.data?.role} · {location.data?.city}
      </span>
      <LocalTime timeZone={location.data?.timeZone ?? viewerZone} />
    </span>
  </span>
);

function Team() {
  // Each person, in their team's group.
  const [team, setTeam] = useState<readonly Location<Member>[]>([]);
  useEffect(() => {
    fetch("/examples/data/team.json")
      .then((response) => response.json())
      .then(setTeam);
  }, []);
  return (
    <MaplaceProvider locations={team}>
      <div className="map-and-list">
        <MaplaceMap createAdapter={createGoogleAdapter} className="map" markerIcon={markerIcon} />
        <LocationList heading="The team" groupCounts groupFilter search searchLabel="Find someone">
          {memberItem}
        </LocationList>
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("team-react-root") as HTMLElement).render(
  <StrictMode>
    <Team />
  </StrictMode>,
);
```

### The stylesheet every version links

`packages/maplace/examples/styles/team.css`

```css
/* The team example's look, which every version links: page, script, vanilla and React, on either
   map. */
/* Each team's colour, which its people's avatars take: white initials read on each at 5.4:1 or
   more. */
[data-team="Design"] {
  --team: #7b2cbf;
}
[data-team="Engineering"] {
  --team: #1d4ed8;
}
[data-team="Growth"] {
  --team: #b42318;
}
[data-team="Support"] {
  --team: #047857;
}
/* A face: the person's initials on their team's colour, the marker on the map and the lead of
   their entry in the list. */
.team-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--team, #111);
  color: #fff;
  font:
    700 0.75rem / 1 system-ui,
    sans-serif;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
}
/* A marker pointed at, or picked: ringed, the picked one in red. The marks are on the avatar, or on
   the node around it when the map wraps it. */
.team-avatar[data-hovered],
[data-hovered] > .team-avatar {
  outline: 2px solid #111;
}
.team-avatar[data-selected],
[data-selected] > .team-avatar {
  outline: 3px solid #e4322b;
}
/* A person in the list: their face, then their name, role and city, and the time where they are. */
.team-member {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.team-member-text {
  display: grid;
  gap: 0.125rem;
}
.team-member-name {
  font-weight: 600;
}
.team-member-detail,
.team-member-time {
  font-size: 0.875em;
}
.team-member-detail {
  color: #55554f;
}
```

## Map styles

The provider's own looks: a choice of styles, and on Google the map-type control.

The provider's own looks: on Google a light or dark map, or the visitor's system setting, with Google's map options; on MapLibre a choice of OpenFreeMap's styles, or any style's URL.

- **Try it**: choose from **Map style**: the map opens again in that look, where it was, keeping its state.
- **HTML**: on Google `color-scheme`, `map-id` and `map-options`, a change of `color-scheme` or `map-options` opening the map again ([Provider attributes](/google/#provider-attributes)); on MapLibre `map-style` and `map-options` ([Provider attributes](/maplibre/#provider-attributes)).
- **Script** and **Bundler**: `createGoogleAdapter({ mapId, colorScheme, mapOptions })` ([Map ID and styling](/google/#map-id-and-styling)) or `createMapLibreAdapter({ mapStyle, mapOptions })` ([Styles and tiles](/maplibre/#styles-and-tiles)), and `attach`; a new look is a new adapter, attached where the last one was ([Methods](/store/#methods)).
- **React**: the same adapters through `createAdapter`, and a `key` on `<MaplaceMap>` that changes with the look, so a new one opens ([`<MaplaceMap>`](/react/#maplacemap)).


### HTML on MapLibre

`packages/maplace/examples/styled/maplibre/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- MapLibre's own look: a style, here one of OpenFreeMap's, and MapLibre's map options (here a
     compact attribution). Choosing a style opens the map again in it, where it was. Any style URL
     works in map-style: MapTiler's, Stadia's, your own. -->
<p><label for="styled-maplibre-style">Map style</label> <select id="styled-maplibre-style" autocomplete="off">
  <option value="https://tiles.openfreemap.org/styles/bright">Bright</option>
  <option value="https://tiles.openfreemap.org/styles/liberty">Liberty</option>
  <option value="https://tiles.openfreemap.org/styles/positron">Positron</option>
  <option value="https://tiles.openfreemap.org/styles/dark">Dark</option>
</select></p>
<maplace-map id="styled-maplibre-map" map-style="https://tiles.openfreemap.org/styles/bright"
  map-options='{"attributionControl":{"compact":true}}'>
  <maplace-location location-id="lisbon" lat="38.7223" lng="-9.1393" title="Lisbon"></maplace-location>
  <maplace-location location-id="porto" lat="41.1579" lng="-8.6291" title="Porto"></maplace-location>
  <maplace-location location-id="coimbra" lat="40.2033" lng="-8.4103" title="Coimbra"></maplace-location>
  <maplace-location location-id="faro" lat="37.0194" lng="-7.9304" title="Faro"></maplace-location>
</maplace-map>
<script>
  document.getElementById('styled-maplibre-style').addEventListener('change', (event) => {
    document.getElementById('styled-maplibre-map').setAttribute('map-style', event.currentTarget.value);
  });
</script>
```

### HTML on Google

`packages/maplace/examples/styled/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- Google's own look: a light or dark map, or the reader's system scheme, and Google's map options
     (here the map-type control). Choosing a scheme opens the map again in it, where it was.
     A map's Cloud styling hangs on its map ID: put your own in map-id. -->
<p><label for="styled-scheme">Map style</label> <select id="styled-scheme" autocomplete="off">
  <option value="light">Light</option>
  <option value="dark">Dark</option>
  <option value="follow-system">Follow the system</option>
</select></p>
<maplace-map id="styled-map" api-key="YOUR_KEY" map-id="DEMO_MAP_ID" color-scheme="light"
  map-options='{"mapTypeControl":true}'>
  <maplace-location location-id="lisbon" lat="38.7223" lng="-9.1393" title="Lisbon"></maplace-location>
  <maplace-location location-id="porto" lat="41.1579" lng="-8.6291" title="Porto"></maplace-location>
  <maplace-location location-id="coimbra" lat="40.2033" lng="-8.4103" title="Coimbra"></maplace-location>
  <maplace-location location-id="faro" lat="37.0194" lng="-7.9304" title="Faro"></maplace-location>
</maplace-map>
<script>
  document.getElementById('styled-scheme').addEventListener('change', (event) => {
    document.getElementById('styled-map').setAttribute('color-scheme', event.currentTarget.value);
  });
</script>
```

### Script on MapLibre

`packages/maplace/examples/styled/maplibre/script.html`

```html
<!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet, the style select and what the map mounts on, and the map made with Maplace's store and MapLibre adapter. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
  #styled-maplibre-script-map { height: 24rem; }
</style>
<p><label for="styled-maplibre-script-style">Map style</label> <select id="styled-maplibre-script-style" autocomplete="off">
  <option value="https://tiles.openfreemap.org/styles/bright">Bright</option>
  <option value="https://tiles.openfreemap.org/styles/liberty">Liberty</option>
  <option value="https://tiles.openfreemap.org/styles/positron">Positron</option>
  <option value="https://tiles.openfreemap.org/styles/dark">Dark</option>
</select></p>
<div id="styled-maplibre-script-map"></div>
<script type="module">
  const locations = [
    { id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
    { id: "porto", lat: 41.1579, lng: -8.6291, title: "Porto" },
    { id: "coimbra", lat: 40.2033, lng: -8.4103, title: "Coimbra" },
    { id: "faro", lat: 37.0194, lng: -7.9304, title: "Faro" },
  ];

  /**
   * MapLibre's own look: a style, here one of OpenFreeMap's the page offers (any style URL works:
   * MapTiler's, Stadia's, your own), with a compact attribution.
   */
  const adapterIn = (mapStyle) =>
    Maplace.createMapLibreAdapter({
      mapStyle,
      mapOptions: { attributionControl: { compact: true } },
    });

  const maplace = Maplace.createMaplace({ locations });
  const styleSelect = document.querySelector("#styled-maplibre-script-style");
  let detach = maplace.attach(adapterIn(styleSelect.value), "#styled-maplibre-script-map");

  // A map's style is set when it opens: choosing one opens a new map where this one was.
  styleSelect.addEventListener("change", () => {
    const { viewport } = maplace.getSnapshot();
    detach();
    if (viewport) maplace.setView(viewport.center, viewport.zoom);
    detach = maplace.attach(adapterIn(styleSelect.value), "#styled-maplibre-script-map");
  });
</script>
```

### Script on Google

`packages/maplace/examples/styled/script.html`

```html
<!doctype html>
<!-- A page of your own script: the CDN script, the scheme select and what the map mounts on, and the map made with Maplace's store and Google adapter, which adds Maps JS with your key. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<style>
  #styled-script-map { height: 24rem; }
</style>
<p><label for="styled-script-scheme">Map style</label> <select id="styled-script-scheme" autocomplete="off">
  <option value="light">Light</option>
  <option value="dark">Dark</option>
  <option value="follow-system">Follow the system</option>
</select></p>
<div id="styled-script-map"></div>
<script type="module">
  const locations = [
    { id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
    { id: "porto", lat: 41.1579, lng: -8.6291, title: "Porto" },
    { id: "coimbra", lat: 40.2033, lng: -8.4103, title: "Coimbra" },
    { id: "faro", lat: 37.0194, lng: -7.9304, title: "Faro" },
  ];

  /**
   * Google's own look: a light or dark map, or the reader's system scheme, with the map-type
   * control. A map's Cloud styling hangs on its map ID: put your own in `mapId`.
   */
  const adapterIn = (colorScheme) =>
    Maplace.createGoogleAdapter({
      apiKey: "YOUR_KEY",
      mapId: "DEMO_MAP_ID",
      colorScheme,
      mapOptions: { mapTypeControl: true },
    });

  const maplace = Maplace.createMaplace({ locations });
  const schemeSelect = document.querySelector("#styled-script-scheme");
  let detach = maplace.attach(adapterIn(schemeSelect.value), "#styled-script-map");

  // A map's colour scheme is set when it opens: choosing one opens a new map where this one was.
  schemeSelect.addEventListener("change", () => {
    const { viewport } = maplace.getSnapshot();
    detach();
    if (viewport) maplace.setView(viewport.center, viewport.zoom);
    detach = maplace.attach(adapterIn(schemeSelect.value), "#styled-script-map");
  });
</script>
```

### Bundler on MapLibre

`packages/maplace/examples/styled/maplibre/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  #styled-maplibre-vanilla-map { height: 24rem; }
</style>
<p><label for="styled-maplibre-vanilla-style">Map style</label> <select id="styled-maplibre-vanilla-style" autocomplete="off">
  <option value="https://tiles.openfreemap.org/styles/bright">Bright</option>
  <option value="https://tiles.openfreemap.org/styles/liberty">Liberty</option>
  <option value="https://tiles.openfreemap.org/styles/positron">Positron</option>
  <option value="https://tiles.openfreemap.org/styles/dark">Dark</option>
</select></p>
<div id="styled-maplibre-vanilla-map"></div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/styled/maplibre/vanilla.ts`

```ts
import "maplibre-gl/dist/maplibre-gl.css";
import { createMaplace, type Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";

const locations: Location[] = [
  { id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
  { id: "porto", lat: 41.1579, lng: -8.6291, title: "Porto" },
  { id: "coimbra", lat: 40.2033, lng: -8.4103, title: "Coimbra" },
  { id: "faro", lat: 37.0194, lng: -7.9304, title: "Faro" },
];

/**
 * MapLibre's own look: a style, here one of OpenFreeMap's the page offers (any style URL works:
 * MapTiler's, Stadia's, your own), with a compact attribution.
 */
const adapterIn = (mapStyle: string) =>
  createMapLibreAdapter({
    mapStyle,
    mapOptions: { attributionControl: { compact: true } },
  });

const maplace = createMaplace({ locations });
const styleSelect = document.querySelector("#styled-maplibre-vanilla-style") as HTMLSelectElement;
let detach = maplace.attach(adapterIn(styleSelect.value), "#styled-maplibre-vanilla-map");

// A map's style is set when it opens: choosing one opens a new map where this one was.
styleSelect.addEventListener("change", () => {
  const { viewport } = maplace.getSnapshot();
  detach();
  if (viewport) maplace.setView(viewport.center, viewport.zoom);
  detach = maplace.attach(adapterIn(styleSelect.value), "#styled-maplibre-vanilla-map");
});
```

### Bundler on Google

`packages/maplace/examples/styled/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  #styled-vanilla-map { height: 24rem; }
</style>
<p><label for="styled-vanilla-scheme">Map style</label> <select id="styled-vanilla-scheme" autocomplete="off">
  <option value="light">Light</option>
  <option value="dark">Dark</option>
  <option value="follow-system">Follow the system</option>
</select></p>
<div id="styled-vanilla-map"></div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/styled/vanilla.ts`

```ts
import { createMaplace, type Location } from "@maplacejs/maplace";
import { createGoogleAdapter, type GoogleAdapterOptions } from "@maplacejs/maplace/google";

type ColorScheme = NonNullable<GoogleAdapterOptions["colorScheme"]>;

const locations: Location[] = [
  { id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
  { id: "porto", lat: 41.1579, lng: -8.6291, title: "Porto" },
  { id: "coimbra", lat: 40.2033, lng: -8.4103, title: "Coimbra" },
  { id: "faro", lat: 37.0194, lng: -7.9304, title: "Faro" },
];

/**
 * Google's own look: a light or dark map, or the reader's system scheme, with the map-type
 * control. A map's Cloud styling hangs on its map ID: put your own in `mapId`.
 */
const adapterIn = (colorScheme: ColorScheme) =>
  createGoogleAdapter({ mapId: "DEMO_MAP_ID", colorScheme, mapOptions: { mapTypeControl: true } });

const maplace = createMaplace({ locations });
const schemeSelect = document.querySelector("#styled-vanilla-scheme") as HTMLSelectElement;
const chosenScheme = () => schemeSelect.value as ColorScheme;
let detach = maplace.attach(adapterIn(chosenScheme()), "#styled-vanilla-map");

// A map's colour scheme is set when it opens: choosing one opens a new map where this one was.
schemeSelect.addEventListener("change", () => {
  const { viewport } = maplace.getSnapshot();
  detach();
  if (viewport) maplace.setView(viewport.center, viewport.zoom);
  detach = maplace.attach(adapterIn(chosenScheme()), "#styled-vanilla-map");
});
```

### React on MapLibre

`packages/maplace/examples/styled/maplibre/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  #styled-maplibre-react-root .map { height: 24rem; }
</style>
<div id="styled-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/styled/maplibre/react.tsx`

```tsx
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { MaplaceMap, MaplaceProvider, useMaplace } from "@maplacejs/maplace/react";
import { type ChangeEvent, StrictMode, useState } from "react";
import { createRoot } from "react-dom/client";

/** OpenFreeMap's styles, by name; any style URL works: MapTiler's, Stadia's, your own. */
const STYLES = {
  Bright: "https://tiles.openfreemap.org/styles/bright",
  Liberty: "https://tiles.openfreemap.org/styles/liberty",
  Positron: "https://tiles.openfreemap.org/styles/positron",
  Dark: "https://tiles.openfreemap.org/styles/dark",
} as const;

const places: Location[] = [
  { id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
  { id: "porto", lat: 41.1579, lng: -8.6291, title: "Porto" },
  { id: "coimbra", lat: 40.2033, lng: -8.4103, title: "Coimbra" },
  { id: "faro", lat: 37.0194, lng: -7.9304, title: "Faro" },
];

/** MapLibre's own look: a style, with a compact attribution. */
const adapterIn = (mapStyle: string) => () =>
  createMapLibreAdapter({
    mapStyle,
    mapOptions: { attributionControl: { compact: true } },
  });

/** The style's select: the store keeps where the map is, for the map opened in the new style. */
function StyleSelect({
  mapStyle,
  onChoose,
}: {
  readonly mapStyle: string;
  readonly onChoose: (mapStyle: string) => void;
}) {
  const maplace = useMaplace();
  const choose = (event: ChangeEvent<HTMLSelectElement>) => {
    const { viewport } = maplace.getSnapshot();
    if (viewport) maplace.setView(viewport.center, viewport.zoom);
    onChoose(event.currentTarget.value);
  };
  return (
    <p>
      <label htmlFor="styled-maplibre-react-style">Map style</label>{" "}
      <select
        id="styled-maplibre-react-style"
        autoComplete="off"
        value={mapStyle}
        onChange={choose}
      >
        {Object.entries(STYLES).map(([name, url]) => (
          <option key={url} value={url}>
            {name}
          </option>
        ))}
      </select>
    </p>
  );
}

function Styled() {
  const [mapStyle, setMapStyle] = useState<string>(STYLES.Bright);
  return (
    <MaplaceProvider locations={places}>
      <StyleSelect mapStyle={mapStyle} onChoose={setMapStyle} />
      {/* A map's style is set when it opens: a new key opens a new one. */}
      <MaplaceMap key={mapStyle} createAdapter={adapterIn(mapStyle)} className="map" />
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("styled-maplibre-react-root") as HTMLElement).render(
  <StrictMode>
    <Styled />
  </StrictMode>,
);
```

### React on Google

`packages/maplace/examples/styled/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  #styled-react-root .map { height: 24rem; }
</style>
<div id="styled-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/styled/react.tsx`

```tsx
import type { Location } from "@maplacejs/maplace";
import { createGoogleAdapter, type GoogleAdapterOptions } from "@maplacejs/maplace/google";
import { MaplaceMap, MaplaceProvider, useMaplace } from "@maplacejs/maplace/react";
import { type ChangeEvent, StrictMode, useState } from "react";
import { createRoot } from "react-dom/client";

type ColorScheme = NonNullable<GoogleAdapterOptions["colorScheme"]>;

const SCHEMES = {
  light: "Light",
  dark: "Dark",
  "follow-system": "Follow the system",
} satisfies Record<ColorScheme, string>;

const places: Location[] = [
  { id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
  { id: "porto", lat: 41.1579, lng: -8.6291, title: "Porto" },
  { id: "coimbra", lat: 40.2033, lng: -8.4103, title: "Coimbra" },
  { id: "faro", lat: 37.0194, lng: -7.9304, title: "Faro" },
];

/**
 * Google's own look: a light or dark map, or the reader's system scheme, with the map-type
 * control. A map's Cloud styling hangs on its map ID: put your own in `mapId`.
 */
const adapterIn = (colorScheme: ColorScheme) => () =>
  createGoogleAdapter({ mapId: "DEMO_MAP_ID", colorScheme, mapOptions: { mapTypeControl: true } });

/** The scheme's select: the store keeps where the map is, for the map opened in the new scheme. */
function SchemeSelect({
  scheme,
  onChoose,
}: {
  readonly scheme: ColorScheme;
  readonly onChoose: (scheme: ColorScheme) => void;
}) {
  const maplace = useMaplace();
  const choose = (event: ChangeEvent<HTMLSelectElement>) => {
    const { viewport } = maplace.getSnapshot();
    if (viewport) maplace.setView(viewport.center, viewport.zoom);
    onChoose(event.currentTarget.value as ColorScheme);
  };
  return (
    <p>
      <label htmlFor="styled-react-scheme">Map style</label>{" "}
      <select id="styled-react-scheme" autoComplete="off" value={scheme} onChange={choose}>
        {Object.entries(SCHEMES).map(([value, label]) => (
          <option key={value} value={value}>
            {label}
          </option>
        ))}
      </select>
    </p>
  );
}

function Styled() {
  const [scheme, setScheme] = useState<ColorScheme>("light");
  return (
    <MaplaceProvider locations={places}>
      <SchemeSelect scheme={scheme} onChoose={setScheme} />
      {/* A map's colour scheme is set when it opens: a new key opens a new one. */}
      <MaplaceMap key={scheme} createAdapter={adapterIn(scheme)} className="map" />
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("styled-react-root") as HTMLElement).render(
  <StrictMode>
    <Styled />
  </StrictMode>,
);
```

## HTML markers with CSS states

Pins of your own markup, their hovered and selected looks in your CSS.

Each pin is a node of yours, styled by the page's CSS: Maplace.js marks it `data-hovered` while the reader points at it and `data-selected` once they pick it, so a rule on each attribute gives that state its look.

- **Try it**: point at a pin, and it lifts; pick one, and it turns red with a pop. Pick another, and the first goes back.
- **HTML**: a `<template data-icon>` inside each `<maplace-location>` ([Location attributes](/element/#location-attributes)). The template is drawn anew for each state, so the pop is a CSS animation, which starts on a new node, rather than a transition; pointing at a selected pin plays it again.
- **Script** and **Bundler**: an `icon` that is a node, the same node in every state ([Icons](/locations/#icons)).
- **React**: `markerIcon` on `<MaplaceMap>`, whose output sits in a node Maplace.js keeps for each marker; that node carries the marks, so the rules read `[data-selected] > .pin` where the others read `.pin[data-selected]` ([`<MaplaceMap>`](/react/#maplacemap)).
- **Styling**: every class and attribute Maplace.js's markup carries, in [Styling](/styling/).


### HTML on MapLibre

`packages/maplace/examples/css-markers/maplibre/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- Markers drawn by your CSS: each pin is your own markup (a <template data-icon>), which Maplace.js
     marks data-hovered while the reader points at it and data-selected once they pick it, so your
     CSS gives each state its look. The pin is drawn anew for each state, so the pop is an animation,
     which starts on a new node, not a transition. -->
<style>
  #css-markers-maplibre-map .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-maplibre-map .pin[data-hovered] { transform: translateY(-3px); }
  #css-markers-maplibre-map .pin[data-selected] {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-maplibre-map .pin[data-selected] { animation: css-markers-maplibre-pop 0.3s ease-out; }
  }
  @keyframes css-markers-maplibre-pop { from { transform: scale(0.85); } }
</style>
<maplace-map id="css-markers-maplibre-map">
  <maplace-location location-id="rijks" lat="52.36" lng="4.8852" title="Rijksmuseum">
    <template data-icon><span class="pin">Rijks</span></template>
  </maplace-location>
  <maplace-location location-id="anne-frank" lat="52.3752" lng="4.884" title="Anne Frank House">
    <template data-icon><span class="pin">Anne Frank</span></template>
  </maplace-location>
  <maplace-location location-id="hermitage" lat="52.3654" lng="4.9025" title="Hermitage">
    <template data-icon><span class="pin">Hermitage</span></template>
  </maplace-location>
  <maplace-location location-id="nemo" lat="52.3738" lng="4.9123" title="NEMO Science Museum">
    <template data-icon><span class="pin">NEMO</span></template>
  </maplace-location>
  <maplace-location location-id="eye" lat="52.3843" lng="4.9008" title="Eye Filmmuseum">
    <template data-icon><span class="pin">Eye</span></template>
  </maplace-location>
</maplace-map>
```

### HTML on Google

`packages/maplace/examples/css-markers/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- Markers drawn by your CSS: each pin is your own markup (a <template data-icon>), which Maplace.js
     marks data-hovered while the reader points at it and data-selected once they pick it, so your
     CSS gives each state its look. The pin is drawn anew for each state, so the pop is an animation,
     which starts on a new node, not a transition. -->
<style>
  #css-markers-map .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-map .pin[data-hovered] { transform: translateY(-3px); }
  #css-markers-map .pin[data-selected] {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-map .pin[data-selected] { animation: css-markers-pop 0.3s ease-out; }
  }
  @keyframes css-markers-pop { from { transform: scale(0.85); } }
</style>
<maplace-map id="css-markers-map" api-key="YOUR_KEY">
  <maplace-location location-id="rijks" lat="52.36" lng="4.8852" title="Rijksmuseum">
    <template data-icon><span class="pin">Rijks</span></template>
  </maplace-location>
  <maplace-location location-id="anne-frank" lat="52.3752" lng="4.884" title="Anne Frank House">
    <template data-icon><span class="pin">Anne Frank</span></template>
  </maplace-location>
  <maplace-location location-id="hermitage" lat="52.3654" lng="4.9025" title="Hermitage">
    <template data-icon><span class="pin">Hermitage</span></template>
  </maplace-location>
  <maplace-location location-id="nemo" lat="52.3738" lng="4.9123" title="NEMO Science Museum">
    <template data-icon><span class="pin">NEMO</span></template>
  </maplace-location>
  <maplace-location location-id="eye" lat="52.3843" lng="4.9008" title="Eye Filmmuseum">
    <template data-icon><span class="pin">Eye</span></template>
  </maplace-location>
</maplace-map>
```

### Script on MapLibre

`packages/maplace/examples/css-markers/maplibre/script.html`

```html
<!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet, what the map mounts on, and the map made with Maplace; each pin is a node of yours, styled by the page's CSS. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
  #css-markers-maplibre-script-map { height: 24rem; }
  #css-markers-maplibre-script-map .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-maplibre-script-map .pin[data-hovered] { transform: translateY(-3px); }
  #css-markers-maplibre-script-map .pin[data-selected] {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-maplibre-script-map .pin[data-selected] { animation: css-markers-maplibre-script-pop 0.3s ease-out; }
  }
  @keyframes css-markers-maplibre-script-pop { from { transform: scale(0.85); } }
</style>
<div id="css-markers-maplibre-script-map"></div>
<script type="module">
  const locations = [
    { id: "rijks", lat: 52.36, lng: 4.8852, title: "Rijksmuseum", icon: pinFor("Rijks") },
    { id: "anne-frank", lat: 52.3752, lng: 4.884, title: "Anne Frank House", icon: pinFor("Anne Frank") },
    { id: "hermitage", lat: 52.3654, lng: 4.9025, title: "Hermitage", icon: pinFor("Hermitage") },
    { id: "nemo", lat: 52.3738, lng: 4.9123, title: "NEMO Science Museum", icon: pinFor("NEMO") },
    { id: "eye", lat: 52.3843, lng: 4.9008, title: "Eye Filmmuseum", icon: pinFor("Eye") },
  ];

  Maplace.createMapLibreMap("#css-markers-maplibre-script-map", { locations });

  /**
   * A pin of your own: one node for every state, which Maplace.js marks `data-hovered` and
   * `data-selected`, so the page's CSS gives each state its look.
   */
  function pinFor(label) {
    const pin = document.createElement("span");
    pin.className = "pin";
    pin.textContent = label;
    return pin;
  }
</script>
```

### Script on Google

`packages/maplace/examples/css-markers/script.html`

```html
<!doctype html>
<!-- A page of your own script: the CDN script, what the map mounts on, and the map made with Maplace, which adds Maps JS with your key; each pin is a node of yours, styled by the page's CSS. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<style>
  #css-markers-script-map { height: 24rem; }
  #css-markers-script-map .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-script-map .pin[data-hovered] { transform: translateY(-3px); }
  #css-markers-script-map .pin[data-selected] {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-script-map .pin[data-selected] { animation: css-markers-script-pop 0.3s ease-out; }
  }
  @keyframes css-markers-script-pop { from { transform: scale(0.85); } }
</style>
<div id="css-markers-script-map"></div>
<script type="module">
  const locations = [
    { id: "rijks", lat: 52.36, lng: 4.8852, title: "Rijksmuseum", icon: pinFor("Rijks") },
    { id: "anne-frank", lat: 52.3752, lng: 4.884, title: "Anne Frank House", icon: pinFor("Anne Frank") },
    { id: "hermitage", lat: 52.3654, lng: 4.9025, title: "Hermitage", icon: pinFor("Hermitage") },
    { id: "nemo", lat: 52.3738, lng: 4.9123, title: "NEMO Science Museum", icon: pinFor("NEMO") },
    { id: "eye", lat: 52.3843, lng: 4.9008, title: "Eye Filmmuseum", icon: pinFor("Eye") },
  ];

  Maplace.createGoogleMap("#css-markers-script-map", { apiKey: "YOUR_KEY", locations });

  /**
   * A pin of your own: one node for every state, which Maplace.js marks `data-hovered` and
   * `data-selected`, so the page's CSS gives each state its look.
   */
  function pinFor(label) {
    const pin = document.createElement("span");
    pin.className = "pin";
    pin.textContent = label;
    return pin;
  }
</script>
```

### Bundler on MapLibre

`packages/maplace/examples/css-markers/maplibre/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  #css-markers-maplibre-vanilla-map { height: 24rem; }
  #css-markers-maplibre-vanilla-map .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-maplibre-vanilla-map .pin[data-hovered] { transform: translateY(-3px); }
  #css-markers-maplibre-vanilla-map .pin[data-selected] {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-maplibre-vanilla-map .pin[data-selected] { animation: css-markers-maplibre-vanilla-pop 0.3s ease-out; }
  }
  @keyframes css-markers-maplibre-vanilla-pop { from { transform: scale(0.85); } }
</style>
<div id="css-markers-maplibre-vanilla-map"></div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/css-markers/maplibre/vanilla.ts`

```ts
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";

const locations: Location[] = [
  { id: "rijks", lat: 52.36, lng: 4.8852, title: "Rijksmuseum", icon: pinFor("Rijks") },
  {
    id: "anne-frank",
    lat: 52.3752,
    lng: 4.884,
    title: "Anne Frank House",
    icon: pinFor("Anne Frank"),
  },
  { id: "hermitage", lat: 52.3654, lng: 4.9025, title: "Hermitage", icon: pinFor("Hermitage") },
  { id: "nemo", lat: 52.3738, lng: 4.9123, title: "NEMO Science Museum", icon: pinFor("NEMO") },
  { id: "eye", lat: 52.3843, lng: 4.9008, title: "Eye Filmmuseum", icon: pinFor("Eye") },
];

createMapLibreMap("#css-markers-maplibre-vanilla-map", { locations });

/**
 * A pin of your own: one node for every state, which Maplace.js marks `data-hovered` and
 * `data-selected`, so the page's CSS gives each state its look.
 */
function pinFor(label: string): HTMLElement {
  const pin = document.createElement("span");
  pin.className = "pin";
  pin.textContent = label;
  return pin;
}
```

### Bundler on Google

`packages/maplace/examples/css-markers/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  #css-markers-vanilla-map { height: 24rem; }
  #css-markers-vanilla-map .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-vanilla-map .pin[data-hovered] { transform: translateY(-3px); }
  #css-markers-vanilla-map .pin[data-selected] {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-vanilla-map .pin[data-selected] { animation: css-markers-vanilla-pop 0.3s ease-out; }
  }
  @keyframes css-markers-vanilla-pop { from { transform: scale(0.85); } }
</style>
<div id="css-markers-vanilla-map"></div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/css-markers/vanilla.ts`

```ts
import type { Location } from "@maplacejs/maplace";
import { createGoogleMap } from "@maplacejs/maplace/google";

const locations: Location[] = [
  { id: "rijks", lat: 52.36, lng: 4.8852, title: "Rijksmuseum", icon: pinFor("Rijks") },
  {
    id: "anne-frank",
    lat: 52.3752,
    lng: 4.884,
    title: "Anne Frank House",
    icon: pinFor("Anne Frank"),
  },
  { id: "hermitage", lat: 52.3654, lng: 4.9025, title: "Hermitage", icon: pinFor("Hermitage") },
  { id: "nemo", lat: 52.3738, lng: 4.9123, title: "NEMO Science Museum", icon: pinFor("NEMO") },
  { id: "eye", lat: 52.3843, lng: 4.9008, title: "Eye Filmmuseum", icon: pinFor("Eye") },
];

createGoogleMap("#css-markers-vanilla-map", { locations });

/**
 * A pin of your own: one node for every state, which Maplace.js marks `data-hovered` and
 * `data-selected`, so the page's CSS gives each state its look.
 */
function pinFor(label: string): HTMLElement {
  const pin = document.createElement("span");
  pin.className = "pin";
  pin.textContent = label;
  return pin;
}
```

### React on MapLibre

`packages/maplace/examples/css-markers/maplibre/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  #css-markers-maplibre-react-root .map { height: 24rem; }
  #css-markers-maplibre-react-root .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-maplibre-react-root [data-hovered] > .pin { transform: translateY(-3px); }
  #css-markers-maplibre-react-root [data-selected] > .pin {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-maplibre-react-root [data-selected] > .pin { animation: css-markers-maplibre-react-pop 0.3s ease-out; }
  }
  @keyframes css-markers-maplibre-react-pop { from { transform: scale(0.85); } }
</style>
<div id="css-markers-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/css-markers/maplibre/react.tsx`

```tsx
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/** Your own field, in each location's `data`: its pin's label. */
interface Museum {
  readonly pin: string;
}

const museums: Location<Museum>[] = [
  { id: "rijks", lat: 52.36, lng: 4.8852, title: "Rijksmuseum", data: { pin: "Rijks" } },
  {
    id: "anne-frank",
    lat: 52.3752,
    lng: 4.884,
    title: "Anne Frank House",
    data: { pin: "Anne Frank" },
  },
  { id: "hermitage", lat: 52.3654, lng: 4.9025, title: "Hermitage", data: { pin: "Hermitage" } },
  { id: "nemo", lat: 52.3738, lng: 4.9123, title: "NEMO Science Museum", data: { pin: "NEMO" } },
  { id: "eye", lat: 52.3843, lng: 4.9008, title: "Eye Filmmuseum", data: { pin: "Eye" } },
];

/**
 * A pin of your own, in a node Maplace.js keeps for each marker and marks `data-hovered` and
 * `data-selected`, so the page's CSS gives each state its look (`[data-selected] > .pin`).
 */
const markerIcon = ({ data }: Location<Museum>) => <span className="pin">{data?.pin}</span>;

function CssMarkers() {
  return (
    <MaplaceProvider locations={museums}>
      <MaplaceMap createAdapter={createMapLibreAdapter} className="map" markerIcon={markerIcon} />
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("css-markers-maplibre-react-root") as HTMLElement).render(
  <StrictMode>
    <CssMarkers />
  </StrictMode>,
);
```

### React on Google

`packages/maplace/examples/css-markers/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  #css-markers-react-root .map { height: 24rem; }
  #css-markers-react-root .pin {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border: 2px solid #1d1d1b;
    border-radius: 999px;
    background: #fff;
    color: #1d1d1b;
    font: 600 0.8125rem/1.2 system-ui, sans-serif;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 30%);
    cursor: pointer;
  }
  #css-markers-react-root [data-hovered] > .pin { transform: translateY(-3px); }
  #css-markers-react-root [data-selected] > .pin {
    border-color: #c62828;
    background: #c62828;
    color: #fff;
    transform: scale(1.15);
  }
  @media (prefers-reduced-motion: no-preference) {
    #css-markers-react-root [data-selected] > .pin { animation: css-markers-react-pop 0.3s ease-out; }
  }
  @keyframes css-markers-react-pop { from { transform: scale(0.85); } }
</style>
<div id="css-markers-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/css-markers/react.tsx`

```tsx
import type { Location } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/** Your own field, in each location's `data`: its pin's label. */
interface Museum {
  readonly pin: string;
}

const museums: Location<Museum>[] = [
  { id: "rijks", lat: 52.36, lng: 4.8852, title: "Rijksmuseum", data: { pin: "Rijks" } },
  {
    id: "anne-frank",
    lat: 52.3752,
    lng: 4.884,
    title: "Anne Frank House",
    data: { pin: "Anne Frank" },
  },
  { id: "hermitage", lat: 52.3654, lng: 4.9025, title: "Hermitage", data: { pin: "Hermitage" } },
  { id: "nemo", lat: 52.3738, lng: 4.9123, title: "NEMO Science Museum", data: { pin: "NEMO" } },
  { id: "eye", lat: 52.3843, lng: 4.9008, title: "Eye Filmmuseum", data: { pin: "Eye" } },
];

/**
 * A pin of your own, in a node Maplace.js keeps for each marker and marks `data-hovered` and
 * `data-selected`, so the page's CSS gives each state its look (`[data-selected] > .pin`).
 */
const markerIcon = ({ data }: Location<Museum>) => <span className="pin">{data?.pin}</span>;

function CssMarkers() {
  return (
    <MaplaceProvider locations={museums}>
      <MaplaceMap createAdapter={createGoogleAdapter} className="map" markerIcon={markerIcon} />
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("css-markers-react-root") as HTMLElement).render(
  <StrictMode>
    <CssMarkers />
  </StrictMode>,
);
```

## Brand colours

One palette across the delivery areas, the cluster badges and the list.

One palette across the map: the delivery areas, the cluster badge and the list, each through its own hook.

- **Try it**: point at a delivery area, and its edge turns green; pick one, here or in the list, and it fills green, its entry too. Zoom in, and the brown badges, the old town's shops and Christianshavn's, split into single shops.
- **HTML**: the areas' fields in a `<script type="application/json">` inside `<maplace-map>`, as a polygon's path takes more than an attribute ([Data](/element/#data)); a circle written as a `<maplace-location>` takes them as `shape-style`, `hovered-style` and `selected-style`. `cluster` on the map, on `maplace-element-cluster.iife.js` on Google.
- **Script** and **Bundler**: `style`, `hoveredStyle` and `selectedStyle` on each location, in hex, as every provider reads them ([Styles](/locations/#styles)), with `cluster: true` in the options, on the cluster script for the Script version on Google.
- **React**: the same locations, and the `cluster` prop of [`<MaplaceProvider>`](/react/#maplaceprovider).
- **In every version**: the badge takes `--maplace-cluster-background` and `--maplace-cluster-color` on the map or any element around it ([Cluster badges](/styling/#cluster-badges)), and the list the page's rules on `.maplace-option[data-hovered]` and `.maplace-option[data-selected]`; Maplace.js's own rules are in `:where()`, so any of yours wins ([Styling](/styling/)). The single shops keep Maplace.js's default pin; for pins in the brand's colours, an `icon` of your own, as in [HTML markers with CSS states](/examples/styling/#css-markers).


### HTML on MapLibre

`packages/maplace/examples/brand/maplibre/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- One palette across the map: the delivery areas' colours at rest, hovered and selected, the
     cluster badge's (--maplace-cluster-background, --maplace-cluster-color), and the list's,
     through the classes Maplace.js's markup carries. -->
<style>
  #brand-maplibre-map { --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-maplibre-map .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-maplibre-map .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<maplace-map id="brand-maplibre-map" cluster list>
  <script type="application/json">
    [
      {"id": "north", "type": "polygon", "title": "North delivery area", "path": [{"lat": 55.697, "lng": 12.548}, {"lat": 55.697, "lng": 12.598}, {"lat": 55.684, "lng": 12.598}, {"lat": 55.684, "lng": 12.548}], "style": {"stroke": "#3b2416", "strokeWidth": 2, "fill": "#c8a27a", "fillOpacity": 0.3}, "hoveredStyle": {"stroke": "#23735a", "strokeWidth": 3}, "selectedStyle": {"stroke": "#23735a", "strokeWidth": 3, "fill": "#23735a", "fillOpacity": 0.4}},
      {"id": "south", "type": "polygon", "title": "South delivery area", "path": [{"lat": 55.677, "lng": 12.548}, {"lat": 55.677, "lng": 12.6}, {"lat": 55.658, "lng": 12.6}, {"lat": 55.658, "lng": 12.548}], "style": {"stroke": "#3b2416", "strokeWidth": 2, "fill": "#c8a27a", "fillOpacity": 0.3}, "hoveredStyle": {"stroke": "#23735a", "strokeWidth": 3}, "selectedStyle": {"stroke": "#23735a", "strokeWidth": 3, "fill": "#23735a", "fillOpacity": 0.4}},
      {"id": "stroget", "lat": 55.6784, "lng": 12.5755, "title": "Kaffa Strøget"},
      {"id": "amagertorv", "lat": 55.6786, "lng": 12.579, "title": "Kaffa Amagertorv"},
      {"id": "kobmagergade", "lat": 55.6807, "lng": 12.5773, "title": "Kaffa Købmagergade"},
      {"id": "gammeltorv", "lat": 55.6775, "lng": 12.5725, "title": "Kaffa Gammeltorv"},
      {"id": "nikolaj", "lat": 55.6789, "lng": 12.5822, "title": "Kaffa Nikolaj"},
      {"id": "christianshavn", "lat": 55.6729, "lng": 12.5935, "title": "Kaffa Christianshavn"},
      {"id": "torvegade", "lat": 55.672, "lng": 12.591, "title": "Kaffa Torvegade"},
      {"id": "overgaden", "lat": 55.6735, "lng": 12.596, "title": "Kaffa Overgaden"},
      {"id": "vesterbro", "lat": 55.6704, "lng": 12.556, "title": "Kaffa Vesterbro"},
      {"id": "norrebro", "lat": 55.692, "lng": 12.556, "title": "Kaffa Nørrebro"}
    ]
  </script>
</maplace-map>
```

### HTML on Google

`packages/maplace/examples/brand/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-cluster.iife.js"></script>
<!-- One palette across the map: the delivery areas' colours at rest, hovered and selected, the
     cluster badge's (--maplace-cluster-background, --maplace-cluster-color), and the list's,
     through the classes Maplace.js's markup carries. -->
<style>
  #brand-map { --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-map .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-map .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<maplace-map id="brand-map" api-key="YOUR_KEY" cluster list>
  <script type="application/json">
    [
      {"id": "north", "type": "polygon", "title": "North delivery area", "path": [{"lat": 55.697, "lng": 12.548}, {"lat": 55.697, "lng": 12.598}, {"lat": 55.684, "lng": 12.598}, {"lat": 55.684, "lng": 12.548}], "style": {"stroke": "#3b2416", "strokeWidth": 2, "fill": "#c8a27a", "fillOpacity": 0.3}, "hoveredStyle": {"stroke": "#23735a", "strokeWidth": 3}, "selectedStyle": {"stroke": "#23735a", "strokeWidth": 3, "fill": "#23735a", "fillOpacity": 0.4}},
      {"id": "south", "type": "polygon", "title": "South delivery area", "path": [{"lat": 55.677, "lng": 12.548}, {"lat": 55.677, "lng": 12.6}, {"lat": 55.658, "lng": 12.6}, {"lat": 55.658, "lng": 12.548}], "style": {"stroke": "#3b2416", "strokeWidth": 2, "fill": "#c8a27a", "fillOpacity": 0.3}, "hoveredStyle": {"stroke": "#23735a", "strokeWidth": 3}, "selectedStyle": {"stroke": "#23735a", "strokeWidth": 3, "fill": "#23735a", "fillOpacity": 0.4}},
      {"id": "stroget", "lat": 55.6784, "lng": 12.5755, "title": "Kaffa Strøget"},
      {"id": "amagertorv", "lat": 55.6786, "lng": 12.579, "title": "Kaffa Amagertorv"},
      {"id": "kobmagergade", "lat": 55.6807, "lng": 12.5773, "title": "Kaffa Købmagergade"},
      {"id": "gammeltorv", "lat": 55.6775, "lng": 12.5725, "title": "Kaffa Gammeltorv"},
      {"id": "nikolaj", "lat": 55.6789, "lng": 12.5822, "title": "Kaffa Nikolaj"},
      {"id": "christianshavn", "lat": 55.6729, "lng": 12.5935, "title": "Kaffa Christianshavn"},
      {"id": "torvegade", "lat": 55.672, "lng": 12.591, "title": "Kaffa Torvegade"},
      {"id": "overgaden", "lat": 55.6735, "lng": 12.596, "title": "Kaffa Overgaden"},
      {"id": "vesterbro", "lat": 55.6704, "lng": 12.556, "title": "Kaffa Vesterbro"},
      {"id": "norrebro", "lat": 55.692, "lng": 12.556, "title": "Kaffa Nørrebro"}
    ]
  </script>
</maplace-map>
```

### Script on MapLibre

`packages/maplace/examples/brand/maplibre/script.html`

```html
<!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl, its stylesheet and its clustering, what the map and its list mount on, and the map made with Maplace; one palette across the areas, the cluster badge and the list. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
  #brand-maplibre-script-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-maplibre-script-map { flex: 1 1 auto; min-width: 0; }
  #brand-maplibre-script-list { display: contents; }
  #brand-maplibre-script-list [role="listbox"] { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, as the element's does. */
  @media (width < 40rem) {
    #brand-maplibre-script-map-and-list { flex-direction: column; }
    #brand-maplibre-script-list [role="listbox"] { flex: none; max-height: 40%; }
  }
  #brand-maplibre-script-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-maplibre-script-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-maplibre-script-map-and-list">
  <div id="brand-maplibre-script-map"></div>
  <div id="brand-maplibre-script-list"></div>
</div>
<script type="module">
  /**
   * The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
   * provider reads (a CSS variable is the page's, not the map's).
   */
  const AREA = {
    style: { stroke: "#3b2416", strokeWidth: 2, fill: "#c8a27a", fillOpacity: 0.3 },
    hoveredStyle: { stroke: "#23735a", strokeWidth: 3 },
    selectedStyle: { stroke: "#23735a", strokeWidth: 3, fill: "#23735a", fillOpacity: 0.4 },
  };

  const locations = [
    { id: "north", type: "polygon", title: "North delivery area", path: [{ lat: 55.697, lng: 12.548 }, { lat: 55.697, lng: 12.598 }, { lat: 55.684, lng: 12.598 }, { lat: 55.684, lng: 12.548 }], ...AREA },
    { id: "south", type: "polygon", title: "South delivery area", path: [{ lat: 55.677, lng: 12.548 }, { lat: 55.677, lng: 12.6 }, { lat: 55.658, lng: 12.6 }, { lat: 55.658, lng: 12.548 }], ...AREA },
    { id: "stroget", lat: 55.6784, lng: 12.5755, title: "Kaffa Strøget" },
    { id: "amagertorv", lat: 55.6786, lng: 12.579, title: "Kaffa Amagertorv" },
    { id: "kobmagergade", lat: 55.6807, lng: 12.5773, title: "Kaffa Købmagergade" },
    { id: "gammeltorv", lat: 55.6775, lng: 12.5725, title: "Kaffa Gammeltorv" },
    { id: "nikolaj", lat: 55.6789, lng: 12.5822, title: "Kaffa Nikolaj" },
    { id: "christianshavn", lat: 55.6729, lng: 12.5935, title: "Kaffa Christianshavn" },
    { id: "torvegade", lat: 55.672, lng: 12.591, title: "Kaffa Torvegade" },
    { id: "overgaden", lat: 55.6735, lng: 12.596, title: "Kaffa Overgaden" },
    { id: "vesterbro", lat: 55.6704, lng: 12.556, title: "Kaffa Vesterbro" },
    { id: "norrebro", lat: 55.692, lng: 12.556, title: "Kaffa Nørrebro" },
  ];

  Maplace.createMapLibreMap("#brand-maplibre-script-map", {
    locations,
    cluster: true,
    list: { container: "#brand-maplibre-script-list" },
  });
</script>
```

### Script on Google

`packages/maplace/examples/brand/script.html`

```html
<!doctype html>
<!-- A page of your own script: the cluster CDN script, which bundles @googlemaps/markerclusterer, what the map and its list mount on, and the map made with Maplace, which adds Maps JS with your key; one palette across the areas, the cluster badge and the list. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-cluster.iife.js"></script>
<style>
  #brand-script-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-script-map { flex: 1 1 auto; min-width: 0; }
  #brand-script-list { display: contents; }
  #brand-script-list [role="listbox"] { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, as the element's does. */
  @media (width < 40rem) {
    #brand-script-map-and-list { flex-direction: column; }
    #brand-script-list [role="listbox"] { flex: none; max-height: 40%; }
  }
  #brand-script-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-script-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-script-map-and-list">
  <div id="brand-script-map"></div>
  <div id="brand-script-list"></div>
</div>
<script type="module">
  /**
   * The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
   * provider reads (a CSS variable is the page's, not the map's).
   */
  const AREA = {
    style: { stroke: "#3b2416", strokeWidth: 2, fill: "#c8a27a", fillOpacity: 0.3 },
    hoveredStyle: { stroke: "#23735a", strokeWidth: 3 },
    selectedStyle: { stroke: "#23735a", strokeWidth: 3, fill: "#23735a", fillOpacity: 0.4 },
  };

  const locations = [
    { id: "north", type: "polygon", title: "North delivery area", path: [{ lat: 55.697, lng: 12.548 }, { lat: 55.697, lng: 12.598 }, { lat: 55.684, lng: 12.598 }, { lat: 55.684, lng: 12.548 }], ...AREA },
    { id: "south", type: "polygon", title: "South delivery area", path: [{ lat: 55.677, lng: 12.548 }, { lat: 55.677, lng: 12.6 }, { lat: 55.658, lng: 12.6 }, { lat: 55.658, lng: 12.548 }], ...AREA },
    { id: "stroget", lat: 55.6784, lng: 12.5755, title: "Kaffa Strøget" },
    { id: "amagertorv", lat: 55.6786, lng: 12.579, title: "Kaffa Amagertorv" },
    { id: "kobmagergade", lat: 55.6807, lng: 12.5773, title: "Kaffa Købmagergade" },
    { id: "gammeltorv", lat: 55.6775, lng: 12.5725, title: "Kaffa Gammeltorv" },
    { id: "nikolaj", lat: 55.6789, lng: 12.5822, title: "Kaffa Nikolaj" },
    { id: "christianshavn", lat: 55.6729, lng: 12.5935, title: "Kaffa Christianshavn" },
    { id: "torvegade", lat: 55.672, lng: 12.591, title: "Kaffa Torvegade" },
    { id: "overgaden", lat: 55.6735, lng: 12.596, title: "Kaffa Overgaden" },
    { id: "vesterbro", lat: 55.6704, lng: 12.556, title: "Kaffa Vesterbro" },
    { id: "norrebro", lat: 55.692, lng: 12.556, title: "Kaffa Nørrebro" },
  ];

  Maplace.createGoogleMap("#brand-script-map", {
    apiKey: "YOUR_KEY",
    locations,
    cluster: true,
    list: { container: "#brand-script-list" },
  });
</script>
```

### Bundler on MapLibre

`packages/maplace/examples/brand/maplibre/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  #brand-maplibre-vanilla-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-maplibre-vanilla-map { flex: 1 1 auto; min-width: 0; }
  #brand-maplibre-vanilla-list { display: contents; }
  #brand-maplibre-vanilla-list [role="listbox"] { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, as the element's does. */
  @media (width < 40rem) {
    #brand-maplibre-vanilla-map-and-list { flex-direction: column; }
    #brand-maplibre-vanilla-list [role="listbox"] { flex: none; max-height: 40%; }
  }
  #brand-maplibre-vanilla-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-maplibre-vanilla-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-maplibre-vanilla-map-and-list">
  <div id="brand-maplibre-vanilla-map"></div>
  <div id="brand-maplibre-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/brand/maplibre/vanilla.ts`

```ts
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";

/**
 * The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
 * provider reads (a CSS variable is the page's, not the map's).
 */
const AREA = {
  style: { stroke: "#3b2416", strokeWidth: 2, fill: "#c8a27a", fillOpacity: 0.3 },
  hoveredStyle: { stroke: "#23735a", strokeWidth: 3 },
  selectedStyle: { stroke: "#23735a", strokeWidth: 3, fill: "#23735a", fillOpacity: 0.4 },
};

const locations: Location[] = [
  {
    id: "north",
    type: "polygon",
    title: "North delivery area",
    path: [
      { lat: 55.697, lng: 12.548 },
      { lat: 55.697, lng: 12.598 },
      { lat: 55.684, lng: 12.598 },
      { lat: 55.684, lng: 12.548 },
    ],
    ...AREA,
  },
  {
    id: "south",
    type: "polygon",
    title: "South delivery area",
    path: [
      { lat: 55.677, lng: 12.548 },
      { lat: 55.677, lng: 12.6 },
      { lat: 55.658, lng: 12.6 },
      { lat: 55.658, lng: 12.548 },
    ],
    ...AREA,
  },
  { id: "stroget", lat: 55.6784, lng: 12.5755, title: "Kaffa Strøget" },
  { id: "amagertorv", lat: 55.6786, lng: 12.579, title: "Kaffa Amagertorv" },
  { id: "kobmagergade", lat: 55.6807, lng: 12.5773, title: "Kaffa Købmagergade" },
  { id: "gammeltorv", lat: 55.6775, lng: 12.5725, title: "Kaffa Gammeltorv" },
  { id: "nikolaj", lat: 55.6789, lng: 12.5822, title: "Kaffa Nikolaj" },
  { id: "christianshavn", lat: 55.6729, lng: 12.5935, title: "Kaffa Christianshavn" },
  { id: "torvegade", lat: 55.672, lng: 12.591, title: "Kaffa Torvegade" },
  { id: "overgaden", lat: 55.6735, lng: 12.596, title: "Kaffa Overgaden" },
  { id: "vesterbro", lat: 55.6704, lng: 12.556, title: "Kaffa Vesterbro" },
  { id: "norrebro", lat: 55.692, lng: 12.556, title: "Kaffa Nørrebro" },
];

createMapLibreMap("#brand-maplibre-vanilla-map", {
  locations,
  cluster: true,
  list: { container: "#brand-maplibre-vanilla-list" },
});
```

### Bundler on Google

`packages/maplace/examples/brand/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  #brand-vanilla-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-vanilla-map { flex: 1 1 auto; min-width: 0; }
  #brand-vanilla-list { display: contents; }
  #brand-vanilla-list [role="listbox"] { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, as the element's does. */
  @media (width < 40rem) {
    #brand-vanilla-map-and-list { flex-direction: column; }
    #brand-vanilla-list [role="listbox"] { flex: none; max-height: 40%; }
  }
  #brand-vanilla-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-vanilla-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-vanilla-map-and-list">
  <div id="brand-vanilla-map"></div>
  <div id="brand-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/brand/vanilla.ts`

```ts
import type { Location } from "@maplacejs/maplace";
import { createGoogleMap } from "@maplacejs/maplace/google";

/**
 * The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
 * provider reads (a CSS variable is the page's, not the map's).
 */
const AREA = {
  style: { stroke: "#3b2416", strokeWidth: 2, fill: "#c8a27a", fillOpacity: 0.3 },
  hoveredStyle: { stroke: "#23735a", strokeWidth: 3 },
  selectedStyle: { stroke: "#23735a", strokeWidth: 3, fill: "#23735a", fillOpacity: 0.4 },
};

const locations: Location[] = [
  {
    id: "north",
    type: "polygon",
    title: "North delivery area",
    path: [
      { lat: 55.697, lng: 12.548 },
      { lat: 55.697, lng: 12.598 },
      { lat: 55.684, lng: 12.598 },
      { lat: 55.684, lng: 12.548 },
    ],
    ...AREA,
  },
  {
    id: "south",
    type: "polygon",
    title: "South delivery area",
    path: [
      { lat: 55.677, lng: 12.548 },
      { lat: 55.677, lng: 12.6 },
      { lat: 55.658, lng: 12.6 },
      { lat: 55.658, lng: 12.548 },
    ],
    ...AREA,
  },
  { id: "stroget", lat: 55.6784, lng: 12.5755, title: "Kaffa Strøget" },
  { id: "amagertorv", lat: 55.6786, lng: 12.579, title: "Kaffa Amagertorv" },
  { id: "kobmagergade", lat: 55.6807, lng: 12.5773, title: "Kaffa Købmagergade" },
  { id: "gammeltorv", lat: 55.6775, lng: 12.5725, title: "Kaffa Gammeltorv" },
  { id: "nikolaj", lat: 55.6789, lng: 12.5822, title: "Kaffa Nikolaj" },
  { id: "christianshavn", lat: 55.6729, lng: 12.5935, title: "Kaffa Christianshavn" },
  { id: "torvegade", lat: 55.672, lng: 12.591, title: "Kaffa Torvegade" },
  { id: "overgaden", lat: 55.6735, lng: 12.596, title: "Kaffa Overgaden" },
  { id: "vesterbro", lat: 55.6704, lng: 12.556, title: "Kaffa Vesterbro" },
  { id: "norrebro", lat: 55.692, lng: 12.556, title: "Kaffa Nørrebro" },
];

createGoogleMap("#brand-vanilla-map", {
  locations,
  cluster: true,
  list: { container: "#brand-vanilla-list" },
});
```

### React on MapLibre

`packages/maplace/examples/brand/maplibre/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  #brand-maplibre-react-root .map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-maplibre-react-root .map { flex: 1 1 auto; min-width: 0; }
  #brand-maplibre-react-root [role="listbox"] { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, as the element's does. */
  @media (width < 40rem) {
    #brand-maplibre-react-root .map-and-list { flex-direction: column; }
    #brand-maplibre-react-root [role="listbox"] { flex: none; max-height: 40%; }
  }
  #brand-maplibre-react-root .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-maplibre-react-root .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/brand/maplibre/react.tsx`

```tsx
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/**
 * The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
 * provider reads (a CSS variable is the page's, not the map's).
 */
const AREA = {
  style: { stroke: "#3b2416", strokeWidth: 2, fill: "#c8a27a", fillOpacity: 0.3 },
  hoveredStyle: { stroke: "#23735a", strokeWidth: 3 },
  selectedStyle: { stroke: "#23735a", strokeWidth: 3, fill: "#23735a", fillOpacity: 0.4 },
};

const locations: Location[] = [
  {
    id: "north",
    type: "polygon",
    title: "North delivery area",
    path: [
      { lat: 55.697, lng: 12.548 },
      { lat: 55.697, lng: 12.598 },
      { lat: 55.684, lng: 12.598 },
      { lat: 55.684, lng: 12.548 },
    ],
    ...AREA,
  },
  {
    id: "south",
    type: "polygon",
    title: "South delivery area",
    path: [
      { lat: 55.677, lng: 12.548 },
      { lat: 55.677, lng: 12.6 },
      { lat: 55.658, lng: 12.6 },
      { lat: 55.658, lng: 12.548 },
    ],
    ...AREA,
  },
  { id: "stroget", lat: 55.6784, lng: 12.5755, title: "Kaffa Strøget" },
  { id: "amagertorv", lat: 55.6786, lng: 12.579, title: "Kaffa Amagertorv" },
  { id: "kobmagergade", lat: 55.6807, lng: 12.5773, title: "Kaffa Købmagergade" },
  { id: "gammeltorv", lat: 55.6775, lng: 12.5725, title: "Kaffa Gammeltorv" },
  { id: "nikolaj", lat: 55.6789, lng: 12.5822, title: "Kaffa Nikolaj" },
  { id: "christianshavn", lat: 55.6729, lng: 12.5935, title: "Kaffa Christianshavn" },
  { id: "torvegade", lat: 55.672, lng: 12.591, title: "Kaffa Torvegade" },
  { id: "overgaden", lat: 55.6735, lng: 12.596, title: "Kaffa Overgaden" },
  { id: "vesterbro", lat: 55.6704, lng: 12.556, title: "Kaffa Vesterbro" },
  { id: "norrebro", lat: 55.692, lng: 12.556, title: "Kaffa Nørrebro" },
];

function Brand() {
  return (
    <MaplaceProvider locations={locations} cluster>
      <div className="map-and-list">
        <MaplaceMap createAdapter={createMapLibreAdapter} className="map" />
        <LocationList />
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("brand-maplibre-react-root") as HTMLElement).render(
  <StrictMode>
    <Brand />
  </StrictMode>,
);
```

### React on Google

`packages/maplace/examples/brand/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  #brand-react-root .map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-react-root .map { flex: 1 1 auto; min-width: 0; }
  #brand-react-root [role="listbox"] { flex: 0 1 16rem; }
  /* On a phone the list goes under the map, as the element's does. */
  @media (width < 40rem) {
    #brand-react-root .map-and-list { flex-direction: column; }
    #brand-react-root [role="listbox"] { flex: none; max-height: 40%; }
  }
  #brand-react-root .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-react-root .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/brand/react.tsx`

```tsx
import type { Location } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/**
 * The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
 * provider reads (a CSS variable is the page's, not the map's).
 */
const AREA = {
  style: { stroke: "#3b2416", strokeWidth: 2, fill: "#c8a27a", fillOpacity: 0.3 },
  hoveredStyle: { stroke: "#23735a", strokeWidth: 3 },
  selectedStyle: { stroke: "#23735a", strokeWidth: 3, fill: "#23735a", fillOpacity: 0.4 },
};

const locations: Location[] = [
  {
    id: "north",
    type: "polygon",
    title: "North delivery area",
    path: [
      { lat: 55.697, lng: 12.548 },
      { lat: 55.697, lng: 12.598 },
      { lat: 55.684, lng: 12.598 },
      { lat: 55.684, lng: 12.548 },
    ],
    ...AREA,
  },
  {
    id: "south",
    type: "polygon",
    title: "South delivery area",
    path: [
      { lat: 55.677, lng: 12.548 },
      { lat: 55.677, lng: 12.6 },
      { lat: 55.658, lng: 12.6 },
      { lat: 55.658, lng: 12.548 },
    ],
    ...AREA,
  },
  { id: "stroget", lat: 55.6784, lng: 12.5755, title: "Kaffa Strøget" },
  { id: "amagertorv", lat: 55.6786, lng: 12.579, title: "Kaffa Amagertorv" },
  { id: "kobmagergade", lat: 55.6807, lng: 12.5773, title: "Kaffa Købmagergade" },
  { id: "gammeltorv", lat: 55.6775, lng: 12.5725, title: "Kaffa Gammeltorv" },
  { id: "nikolaj", lat: 55.6789, lng: 12.5822, title: "Kaffa Nikolaj" },
  { id: "christianshavn", lat: 55.6729, lng: 12.5935, title: "Kaffa Christianshavn" },
  { id: "torvegade", lat: 55.672, lng: 12.591, title: "Kaffa Torvegade" },
  { id: "overgaden", lat: 55.6735, lng: 12.596, title: "Kaffa Overgaden" },
  { id: "vesterbro", lat: 55.6704, lng: 12.556, title: "Kaffa Vesterbro" },
  { id: "norrebro", lat: 55.692, lng: 12.556, title: "Kaffa Nørrebro" },
];

function Brand() {
  return (
    <MaplaceProvider locations={locations} cluster>
      <div className="map-and-list">
        <MaplaceMap createAdapter={createGoogleAdapter} className="map" />
        <LocationList />
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("brand-react-root") as HTMLElement).render(
  <StrictMode>
    <Brand />
  </StrictMode>,
);
```

## Default styles off

Maplace.js's styles off and nothing in their place: the map and its list as your page shows them, with no CSS but a height.

Maplace.js's own styles switched off and nothing put in their place: the map and its list exactly as your page shows them with no CSS of yours but the one rule a map can't do without, its height.

- **Try it**: the list is plain lines in the page's font, under the map; pick one and its popup opens, with nothing in the list marking it. It's the starting point for a look of your own.
- **Off with the defaults**: the map's height, the list beside it, the list's spacing, its hover and selected looks and its scrolling, and the popups' dark text and inset, and on MapLibre their heading's weight and its room beside the close button. On a dark page, give `.maplace-popup` and `.maplace-popup-heading` a dark colour: their text takes the page's on the white bubble ([Turning them off](/styling/#turning-them-off)).
- **HTML**: `data-maplace-unstyled` on `<maplace-map>`, and a height on its `.maplace-map-pane`: the map fills it, and the list goes under it.
- **Script** and **Bundler**: `data-maplace-unstyled` on the element holding the map and its list, and a height on the map's container.
- **React**: the same attribute on the element around `<MaplaceMap>` and `<LocationList>`, and a height on the map's class.
- **On this site**: the site's own styles stay out of anything inside `data-maplace-unstyled`, its keyboard focus ring apart, so what shows here is what your page shows: the list takes the site's font and text colour as it would take yours. To draw a look of your own, style the classes Maplace.js's markup carries ([Classes](/styling/#classes)).


### HTML on MapLibre

`packages/maplace/examples/unstyled/maplibre/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- No default styles: data-maplace-unstyled turns Maplace.js's own off inside the map (its height,
     the list's layout and looks, the popups' text), and nothing takes their place: the map and its
     list as your page shows them, with no CSS of yours but the map's height. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-map .maplace-map-pane { height: 24rem; }
</style>
<maplace-map id="unstyled-maplibre-map" list data-maplace-unstyled>
  <maplace-location location-id="rome" lat="41.9028" lng="12.4964" title="Rome">
    <template><p>Capital of Italy.</p></template>
  </maplace-location>
  <maplace-location location-id="milan" lat="45.4642" lng="9.19" title="Milan">
    <template><p>Finance and fashion.</p></template>
  </maplace-location>
  <maplace-location location-id="naples" lat="40.8518" lng="14.2681" title="Naples">
    <template><p>Pizza's home town.</p></template>
  </maplace-location>
  <maplace-location location-id="venice" lat="45.4408" lng="12.3155" title="Venice">
    <template><p>Built on water.</p></template>
  </maplace-location>
</maplace-map>
```

### HTML on Google

`packages/maplace/examples/unstyled/page.html`

```html
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- No default styles: data-maplace-unstyled turns Maplace.js's own off inside the map (its height,
     the list's layout and looks, the popups' text), and nothing takes their place: the map and its
     list as your page shows them, with no CSS of yours but the map's height. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-map .maplace-map-pane { height: 24rem; }
</style>
<maplace-map id="unstyled-map" api-key="YOUR_KEY" list data-maplace-unstyled>
  <maplace-location location-id="rome" lat="41.9028" lng="12.4964" title="Rome">
    <template><p>Capital of Italy.</p></template>
  </maplace-location>
  <maplace-location location-id="milan" lat="45.4642" lng="9.19" title="Milan">
    <template><p>Finance and fashion.</p></template>
  </maplace-location>
  <maplace-location location-id="naples" lat="40.8518" lng="14.2681" title="Naples">
    <template><p>Pizza's home town.</p></template>
  </maplace-location>
  <maplace-location location-id="venice" lat="45.4408" lng="12.3155" title="Venice">
    <template><p>Built on water.</p></template>
  </maplace-location>
</maplace-map>
```

### Script on MapLibre

`packages/maplace/examples/unstyled/maplibre/script.html`

```html
<!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet, what the map and its list mount on, inside data-maplace-unstyled, and the map made with Maplace; no CSS of yours but the map's height. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-script-map { height: 24rem; }
</style>
<div id="unstyled-maplibre-script-map-and-list" data-maplace-unstyled>
  <div id="unstyled-maplibre-script-map"></div>
  <div id="unstyled-maplibre-script-list"></div>
</div>
<script type="module">
  const locations = [
    { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", content: () => popupOf("Capital of Italy.") },
    { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", content: () => popupOf("Finance and fashion.") },
    { id: "naples", lat: 40.8518, lng: 14.2681, title: "Naples", content: () => popupOf("Pizza's home town.") },
    { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", content: () => popupOf("Built on water.") },
  ];

  Maplace.createMapLibreMap("#unstyled-maplibre-script-map", {
    locations,
    list: { container: "#unstyled-maplibre-script-list" },
  });

  /** A popup's content: a line about the place, under its title (the popup's heading). */
  function popupOf(about) {
    const text = document.createElement("p");
    text.textContent = about;
    return text;
  }
</script>
```

### Script on Google

`packages/maplace/examples/unstyled/script.html`

```html
<!doctype html>
<!-- A page of your own script: the CDN script, what the map and its list mount on, inside data-maplace-unstyled, and the map made with Maplace, which adds Maps JS with your key; no CSS of yours but the map's height. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-script-map { height: 24rem; }
</style>
<div id="unstyled-script-map-and-list" data-maplace-unstyled>
  <div id="unstyled-script-map"></div>
  <div id="unstyled-script-list"></div>
</div>
<script type="module">
  const locations = [
    { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", content: () => popupOf("Capital of Italy.") },
    { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", content: () => popupOf("Finance and fashion.") },
    { id: "naples", lat: 40.8518, lng: 14.2681, title: "Naples", content: () => popupOf("Pizza's home town.") },
    { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", content: () => popupOf("Built on water.") },
  ];

  Maplace.createGoogleMap("#unstyled-script-map", {
    apiKey: "YOUR_KEY",
    locations,
    list: { container: "#unstyled-script-list" },
  });

  /** A popup's content: a line about the place, under its title (the popup's heading). */
  function popupOf(about) {
    const text = document.createElement("p");
    text.textContent = about;
    return text;
  }
</script>
```

### Bundler on MapLibre

`packages/maplace/examples/unstyled/maplibre/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-vanilla-map { height: 24rem; }
</style>
<div id="unstyled-maplibre-vanilla-map-and-list" data-maplace-unstyled>
  <div id="unstyled-maplibre-vanilla-map"></div>
  <div id="unstyled-maplibre-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/unstyled/maplibre/vanilla.ts`

```ts
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";

const locations: Location[] = [
  {
    id: "rome",
    lat: 41.9028,
    lng: 12.4964,
    title: "Rome",
    content: () => popupOf("Capital of Italy."),
  },
  {
    id: "milan",
    lat: 45.4642,
    lng: 9.19,
    title: "Milan",
    content: () => popupOf("Finance and fashion."),
  },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    content: () => popupOf("Pizza's home town."),
  },
  {
    id: "venice",
    lat: 45.4408,
    lng: 12.3155,
    title: "Venice",
    content: () => popupOf("Built on water."),
  },
];

createMapLibreMap("#unstyled-maplibre-vanilla-map", {
  locations,
  list: { container: "#unstyled-maplibre-vanilla-list" },
});

/** A popup's content: a line about the place, under its title (the popup's heading). */
function popupOf(about: string): HTMLParagraphElement {
  const text = document.createElement("p");
  text.textContent = about;
  return text;
}
```

### Bundler on Google

`packages/maplace/examples/unstyled/vanilla.html`

```html
<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-vanilla-map { height: 24rem; }
</style>
<div id="unstyled-vanilla-map-and-list" data-maplace-unstyled>
  <div id="unstyled-vanilla-map"></div>
  <div id="unstyled-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>
```

`packages/maplace/examples/unstyled/vanilla.ts`

```ts
import type { Location } from "@maplacejs/maplace";
import { createGoogleMap } from "@maplacejs/maplace/google";

const locations: Location[] = [
  {
    id: "rome",
    lat: 41.9028,
    lng: 12.4964,
    title: "Rome",
    content: () => popupOf("Capital of Italy."),
  },
  {
    id: "milan",
    lat: 45.4642,
    lng: 9.19,
    title: "Milan",
    content: () => popupOf("Finance and fashion."),
  },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    content: () => popupOf("Pizza's home town."),
  },
  {
    id: "venice",
    lat: 45.4408,
    lng: 12.3155,
    title: "Venice",
    content: () => popupOf("Built on water."),
  },
];

createGoogleMap("#unstyled-vanilla-map", {
  locations,
  list: { container: "#unstyled-vanilla-list" },
});

/** A popup's content: a line about the place, under its title (the popup's heading). */
function popupOf(about: string): HTMLParagraphElement {
  const text = document.createElement("p");
  text.textContent = about;
  return text;
}
```

### React on MapLibre

`packages/maplace/examples/unstyled/maplibre/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-maplibre-react-root .map { height: 24rem; }
</style>
<div id="unstyled-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/unstyled/maplibre/react.tsx`

```tsx
import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/** Your own field, in each location's `data`: a line about the place. */
interface City {
  readonly about: string;
}

const cities: Location<City>[] = [
  { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", data: { about: "Capital of Italy." } },
  { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", data: { about: "Finance and fashion." } },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    data: { about: "Pizza's home town." },
  },
  { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", data: { about: "Built on water." } },
];

// Outside the component, so a render of the page around it doesn't render every popup again.
const popupContent = ({ data }: Location<City>) => <p>{data?.about}</p>;

function Unstyled() {
  return (
    <MaplaceProvider locations={cities}>
      {/* Maplace.js's own styles are off inside, and nothing takes their place: no CSS but the map's height. */}
      <div className="map-and-list" data-maplace-unstyled="">
        <MaplaceMap
          createAdapter={createMapLibreAdapter}
          className="map"
          popupContent={popupContent}
        />
        <LocationList />
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("unstyled-maplibre-react-root") as HTMLElement).render(
  <StrictMode>
    <Unstyled />
  </StrictMode>,
);
```

### React on Google

`packages/maplace/examples/unstyled/react.html`

```html
<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->
<script>
  (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
    key: "YOUR_KEY",
    v: "weekly",
  });
</script>
<style>
  /* The one rule the map needs: with Maplace.js's defaults off, it has no height of its own. */
  #unstyled-react-root .map { height: 24rem; }
</style>
<div id="unstyled-react-root"></div>
<script type="module" src="./react.tsx"></script>
```

`packages/maplace/examples/unstyled/react.tsx`

```tsx
import type { Location } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

/** Your own field, in each location's `data`: a line about the place. */
interface City {
  readonly about: string;
}

const cities: Location<City>[] = [
  { id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome", data: { about: "Capital of Italy." } },
  { id: "milan", lat: 45.4642, lng: 9.19, title: "Milan", data: { about: "Finance and fashion." } },
  {
    id: "naples",
    lat: 40.8518,
    lng: 14.2681,
    title: "Naples",
    data: { about: "Pizza's home town." },
  },
  { id: "venice", lat: 45.4408, lng: 12.3155, title: "Venice", data: { about: "Built on water." } },
];

// Outside the component, so a render of the page around it doesn't render every popup again.
const popupContent = ({ data }: Location<City>) => <p>{data?.about}</p>;

function Unstyled() {
  return (
    <MaplaceProvider locations={cities}>
      {/* Maplace.js's own styles are off inside, and nothing takes their place: no CSS but the map's height. */}
      <div className="map-and-list" data-maplace-unstyled="">
        <MaplaceMap
          createAdapter={createGoogleAdapter}
          className="map"
          popupContent={popupContent}
        />
        <LocationList />
      </div>
    </MaplaceProvider>
  );
}

createRoot(document.getElementById("unstyled-react-root") as HTMLElement).render(
  <StrictMode>
    <Unstyled />
  </StrictMode>,
);
```
