Code Monkey home page Code Monkey logo

leaflet-plot's Introduction

leaflet-plot

NPM Version

Installation

Install via npm

npm i leaflet-plot

Install Manually

Download leaflet-plot.css and leaflet-plot.min.js and include them in your project.

Include via CDN

CSS

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet-plot.css" />

JS

<script src="https://unpkg.com/[email protected]/dist/leaflet-plot.min.js"></script>

Include as ES6 Module

import 'leaflet-plot';
import 'leaflet-plot/dist/leaflet-plot.css';

Getting Started

Currently available shapes are StraightArrow, RightAngleArrow, TailedArrow, DoubleArrow.

Create function

Use Create function on a map like this

// StraightArrow create function
const arrowLayer = window.L.SL.Create.StraightArrow(latlngs, options)
See the available options.

latlngs: Array<Array>

options: leaflet path options

Drawing Mode

Use Drawing Mode on a map like this

// enable StraightArrow drawing mode
map.sl.enableDraw('StraightArrow', options);

// disable drawing mode
map.sl.disableDraw();
See the available options.

options: leaflet path options

You can listen to map events to hook into the drawing procedure like this:
map.on('sl:create', e => {
  console.log(e);
});
Event Params Description
sl:create e Called when a shape is drawn/finished. Payload includes shape type and the drawn layer

Edit Mode

Let's you edit vertices of layers. Use it like this:

// enable edit mode
layer.sl.enable();
You can listen to map events to hook into the drawing procedure like this:
map.on('sl:edit', e => {
  console.log(e);
});
Event Params Description
sl:edit e Fired when a layer is edited.

leaflet-plot's People

Contributors

shenglinl 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.