JSPM

leaflet-selectareafeature

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 442
  • Score
    100M100P100Q93437F
  • License GPL-3.0

Plugin that selects feature(s) by drawing an area on the map

Package Exports

  • leaflet-selectareafeature

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (leaflet-selectareafeature) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Leaflet.SelectAreaFeature

Plugin that selects feature(s) by drawing an area on the map

This plugin let the user draw an area on the map. As a developer you can get the layers that are within the bounding box of that area. Once you have the instances of the layers you can manupulate them separately.

Example

Here you can find an example

Usage

Include Leaflet.SelectFeature in your JavaScript project using npm install leaflet-selectareafeature.

You can then include Leaflet.SelectFeature in your web application by adding the following HTML tags (paths below are relative to your project's root):

<script src="./lib/js/Leaflet.SelectAreaFeature.js"></script>

Put it after leaflet is loaded. Once your page is loaded you can easily use it by enable it like:

var selectfeature = map.selectAreaFeature.enable();

After the plugin is enabled the user can draw an area by holding the left mouse button and start drawing. You can disable the plugin by:

selectfeature.disable();

Than the mouse events for drawing stop working with the map.

Options

The following options are available with SelectFeature (showing you here with the default settings):

options{
color : "green",
weight : 2,
dashArray : ' 5, 5, 1, 5',
selCursor : 'crosshair',
normCursor: ''
}

You may modify the options once the plugin is enabled, for example;

  selectfeature.options.color = '#663399' ;
  selectfeature.options.weight = 1 ;

Methods

The following methods are supported by the plugin:

  • getBoundsAreaLatLon
  • gets all LatLngs for the area that was last drawn on the map
  • doRemoveAllSelection
  • removes all area's drawn on the map
  • doRemoveLastSelection
  • removes the las area drawn on the map
  • getFeaturesSelected('layertype')
  • returns an array of the layers wich are in the bounding box of the area drawn layertype can be: 'polygon'/'polyline'/'circle'/'rectangle'