Skip to main content

ScaleBar

A scale bar drawn straight on the map: a thin line with end ticks and a haloed label, re-computed whenever the view changes.

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

Signature​

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

function ScaleBar(input: ScaleBarProps): JSX.Element | null;

Parameters​

  • { units }
  • input (ScaleBarProps)

Returns​

JSX.Element | null

Remarks​

It is an image named with the spoken scale ("Scale: 200 metres"). It fades about two seconds after the zoom last changed and comes back on the next zoom, but never while the map has keyboard focus or the user asked for reduced motion. Its width changes through a CSS custom property and a transform, set with CSSOM so no style attribute is rendered. Reads the map with useMap(), so it must sit inside the map context.

See also​

Source: packages/map/src/chrome/MapReadout/MapReadout.tsx:100