Git Product home page Git Product logo

leaflet.boxselector's Introduction

License: AL2 GitHub issues

What is this?

This is a simple leaflet control that allows you to draw a box to select a number of markers. It then allows you to perform an action on those markers (e.g. export to file). This control is heavily influenced by the built-in box-zoom (shift + click and drag draws a box and then zooms to it) so the selection area looks very similar.

Requires leaflet 1.6.0 to work with touch devices.

How can I try it?

Live demo

Live demo with selectable clusters

How to use it

A built in action that just displays the markers in an 'alert' popup is registered for testing purposes, so to get started all you need to do is add the control:

(new L.Control.BoxSelector()).addTo(map);

If you want to register any additional actions, add them to options.actions like this:

var options = {
	actions: {
		alert: {
			display: "Display selected coords",
			action:	L.Control.BoxSelector.Actions.alert()
		},
		GPX: {
			display: "Export to GPX",
			action: L.Control.BoxSelector.Actions.gpx('points.gpx')
		}
	}
};
(new L.Control.BoxSelector(options)).addTo(map);

Note that the alert and gpx actions are created via factory functions which return the action functions.

Adding custom actions

Actions are simply functions which take a single argument which is an array of L.Marker objects. Passing a function as the value of options.[action_name].action will register it as an action and it will be available in the drop down to select when you have selected markers. If you create an action which you think may be useful to others, please consider submitting a pull request to have it included in this repository.

Contributing

PRs are very welcome, but for any big changes or new features please open an issue to discuss first.

leaflet.boxselector's People

Contributors

tstibbs avatar

Watchers

 avatar  avatar

Forkers

zhuzhe1983

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.