Map
<Map /><clover-map>20 kB loaded by a page with it alone to first view, gzipped65 kB loaded by a page with it alone to first view, styles included, gzipped
Where a IIIF resource is, on a map: its places, and its georeferenced images laid over the ground.
import { Map } from "@nulib/clover/map";
import "@nulib/clover/styles.css";
import "maplibre-gl/dist/maplibre-gl.css";
<Map
iiifContent="https://clover.iiif.library.northwestern.edu/mocks/navplace/manifest.json"
scrollZoom={}
style={{ "--clover-map-height": "px" }}
/>;<script type="module">
import "@nulib/clover/web-components";
</script>
<clover-map
iiif-content="https://clover.iiif.library.northwestern.edu/mocks/navplace/manifest.json"
scroll-zoom=""
style="--clover-map-height: px">
</clover-map>API reference
Draws a resource’s navPlace places and its
georeferenced images on a
MapLibre GL map, and lists them under it. MapLibre loads when a
map is first shown. Inside a Root<clover-root>, it maps the Root’s resource and follows the view; its
other props, and its ref, go to its element.
<clover-map>
A map: inside a clover-root, its places (navPlace) and the view's georeferenced images; alone, those of the iiif-content it is given. Its places are listed under it as buttons, for the keyboard.
Examples
Georeferenced images
A Georeference Extension annotation lays its image over the map by an affine fit of its control points, clipped to its mask. The image server must allow CORS.
<Map iiifContent="https://clover.iiif.library.northwestern.edu/mocks/georeference/manifest.json" /><clover-map
iiif-content="https://clover.iiif.library.northwestern.edu/mocks/georeference/manifest.json"></clover-map>In a Viewer
The Viewer adds a Map section to its Panel by itself, where the resource has places or a georeference.
<Viewer iiifContent="https://clover.iiif.library.northwestern.edu/mocks/georeference/manifest.json" /><clover-viewer
iiif-content="https://clover.iiif.library.northwestern.edu/mocks/georeference/manifest.json"></clover-viewer>In a layout of your own
Inside a Root<clover-root>, it lays the view’s georeferenced images over the map, and choosing a
place goes to its Canvas.
import * as Clover from "@nulib/clover";
import { Map } from "@nulib/clover/map";
<Clover.Root iiifContent={url}>
<Clover.Body />
<Map />
</Clover.Root>;<script type="module">
import "@nulib/clover/web-components";
</script>
<clover-root
iiif-content="https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json">
<clover-body></clover-body>
<clover-map></clover-map>
</clover-root>Size
Size the map with --clover-map-height (default 24rem), never height: style goes
to the box around the map and its list.
<Map iiifContent={url} style={{ "--clover-map-height": "420px" }} /><clover-map
iiif-content="https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json"
style="--clover-map-height: 420px"></clover-map>MapLibre’s worker
Clover brings MapLibre’s worker, bundled, and starts it from a blob: URL, so a map draws
its places in any bundler with no setup. A page whose Content Security Policy refuses
blob: workers (worker-src) serves the worker itself, and tells Clover where, once,
for every map.
import { setMapWorkerUrl } from "@nulib/clover";
// maplibre-gl-worker.mjs and maplibre-gl-shared.mjs, copied together from
// node_modules/maplibre-gl/dist/ to a folder you serve.
setMapWorkerUrl("/static/maplibre-gl-worker.mjs");The worker is the one built for the MapLibre Clover depends on. A page that brings another MapLibre serves that one’s worker the same way; Clover says so in the console.
Previous versions
Map<clover-map>is a named export of@nulib/clover/map.- A Viewer shows it in its Panel by itself: no
options.map. georefAnnotationisgeoreferences.georeferences, and overlays draw by default.- MapLibre’s worker comes with Clover: no
workerUrlto set.