Maplace.js

Styling

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.

Markdown

Map and code

Run the examples on

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

These maps come from Google Maps and OpenFreeMap, which see your IP address. They stay off until you say so, once for the whole site. What loading the maps sends

<!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>

How it works

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.

  • 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).
  • 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).