# @luomus/leaflet-measure-path

> Show measurements on Leaflet paths

Latest version **1.5.0** (published 2023-11-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install @luomus/leaflet-measure-path
pnpm add @luomus/leaflet-measure-path
yarn add @luomus/leaflet-measure-path
bun add @luomus/leaflet-measure-path
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2023-11-03 |
| First published | 2023-11-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 32 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 104 |
| Author | Per Liedman |
| Maintainers | olzraiti, luomus-admin |
| Keywords | leaflet, measurement, path |

## Links

- npm: https://www.npmjs.com/package/@luomus/leaflet-measure-path
- Repository: https://github.com/perliedman/leaflet-measure-path
- Issues: https://github.com/perliedman/leaflet-measure-path/issues
- npm.io page: https://npm.io/package/@luomus/leaflet-measure-path

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.5.0 (latest) — 2023-11-03

## README

# Leaflet Measure Path

![Leaflet 1.0 compatible!](https://img.shields.io/badge/Leaflet%201.0.0-%E2%9C%93-1EB300.svg?style=flat)

A plugin to show measurements on paths (polylines, polygons and circles currently supported).

[Leaflet Measure Path demo](http://prominentedge.com/leaflet-measure-path/)

## Usage

Load `leaflet-measure-path.js` and `leaflet-measure-path.css`. Then, to enable measurements on a path:

```js
var polygon = L.polygon([ ... ])
    .addTo(map)
    .showMeasurements();
```

To later hide measurements:

```js
var polygon = L.polygon([ ... ])
    .addTo(map)
    .hideMeasurements();
```

## API

The simplest way to enable measurements for a path is to pass the option `showMeasurements: true` when
creating the path. To control the measurement options, you can also pass `measurementOptions`, see [options](#options) below.

The plugin also adds the methods listed below to Leaflet's `L.Polyline`, `L.Polygon` and `L.Circle` classes.

### showMeasurements(options)

Enables measurements. You can also overide the defaults by passing an options object.

#### Options

* `showOnHover: Boolean` (default `false`): if `true`, the measurements will only show when the user hovers the cursor over the path
* `showTotalDistance: Boolean` (default `true`): if `false`, the total length of polyline will not be shown
* `minDistance: Number` (default `30`): the minimum length a line segment in the feature must have for a measurement to be added
* `formatDistance: Function`: allows to override the built-in function that formats a distance in meters to the string shown in the map
* `formatArea: Function`: allows to override the built-in function that formats an area in square meters to the string shown in the map

### hideMeasurements()

Disables measurements.

### updateMeasurements()

Updates the measurements displayed. Normally, this method is called automatically if the path's geometry is changed using `setLatLngs`, `spliceLatLngs` or when the map is zoomed. If the geometry is somehow changed by other means, this method can be called to force the measurements to update.

---
_Source: https://npm.io/package/@luomus/leaflet-measure-path · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
