Skip to main content

defineMapCairnElement

Registers the <mapcairn-map> element, or one under another name. The element draws nothing until its services is set, to the whole of Services. Asking twice is safe: a name that is taken by this definition is left as it is. Nothing is registered by importing the package, and where there is no browser this does nothing.

This is a function exported by @mapcairn/map, checked against version 0.2.0.

Signature​

import { defineMapCairnElement } from "@mapcairn/map";

function defineMapCairnElement(name?: string, defaults?: MapDefaults): MapCairnMapElementClass | undefined;

Description​

defineMapElement of @mapcairn/sdk/browser is the other definition of the element, which brings defaults of its own. A page uses one of the two.

Parameters​

  • name? (string): The tag name, with a hyphen in it. "mapcairn-map" when left out. The element needs display: block and a height in the page's CSS.
  • defaults? (MapDefaults): Internal, for @mapcairn/sdk/browser, which has defaults of its own for the ports, and not supported outside it. Leave it out.

Returns​

MapCairnMapElementClass | undefined: The element's class, or undefined where there is no browser.

Throws​

  • MountMapError when name cannot name an element, or another element or another definition has it.

Examples​

defineMapCairnElement();
const map = document.createElement("mapcairn-map") as MapCairnMapElement;
map.services = services;
document.body.append(map);

See also​

Source: packages/map/src/element/defineMapCairnElement.ts:34