Giter VIP home page Giter VIP logo

leaflet-lasso's Introduction

leaflet-lasso

Lasso selection plugin for Leaflet

Demo

Screenshot

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

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/[email protected]/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.

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

Finished event

Listen for this event to receive matching Leaflet layers.

interface LassoHandlerFinishedEventData {
    latLngs: L.LatLng[];
    layers: L.Layer[];
}
map.on('lasso.finished', (event: LassoHandlerFinishedEventData) => {
    console.log(event.layers);
});

Thanks

Icon by @Falke-Design

leaflet-lasso's People

Contributors

dependabot[bot] avatar ebradshaw avatar zakjan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.