2.2.13 • Published 7 months ago

leaflet-lasso v2.2.13

Weekly downloads
1,233
License
MIT
Repository
github
Last release
7 months ago

leaflet-lasso

npm.io npm.io npm.io

Lasso selection plugin for Leaflet

Demo

Supports all Leaflet vector layers:

  • Marker
  • CircleMarker
  • Circle
  • Polyline
  • Polyline with multiple segments
  • Rectangle
  • Polygon
  • Polygon with hole
  • Polygon with multiple segments
  • Polygon with multiple segments and holes
  • Custom layers can be supported if they inherit from the above layers, and have getBounds and toGeoJSON methods

Selection modes:

  • contain - entire shape must be in lasso polygon (default)
  • intersect - any part of shape can be in lasso polygon

Install

npm install leaflet-lasso

or

<script src="https://unpkg.com/leaflet-lasso@2.2.13/dist/leaflet-lasso.umd.min.js"></script>

Usage

import "leaflet-lasso";

For detailed API, please see exported TypeScript typings.

Handler

Use for custom activation.

interface LassoHandlerOptions {
    polygon?: L.PolylineOptions,
    intersect?: boolean;
}
const lasso = L.lasso(map, options);
yourCustomButton.addEventListener('click', () => {
    lasso.enable();
});

Control

Use for default control.

interface LassoControlOptionsData  {
    title?: string;
}

type LassoControlOptions = L.ControlOptions & LassoControlOptionsData & LassoHandlerOptions;
L.control.lasso(options).addTo(map);

Finished event

Listen for this event to receive matching Leaflet layers.

interface LassoHandlerFinishedEventData {
    originalEvent: MouseEvent;
    latLngs: L.LatLng[];
    layers: L.Layer[];
}

type LassoHandlerFinishedEvent = L.LeafletEvent & LassoHandlerFinishedEventData;
map.on('lasso.finished', (event: LassoHandlerFinishedEvent) => {
    console.log(event.layers);
});

Thanks

Icon by @Falke-Design

2.2.13

7 months ago

2.2.11

2 years ago

2.2.12

2 years ago

2.2.10

2 years ago

2.2.9

2 years ago

2.2.8

2 years ago

2.2.7

2 years ago

2.2.6

3 years ago

2.2.5

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

2.0.0-alpha5

5 years ago

2.0.0-alpha4

5 years ago

2.0.0-alpha3

5 years ago

2.0.0-alpha2

5 years ago

2.0.0-alpha1

5 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago