Giter VIP home page Giter VIP logo

react-leaflet-draw's Introduction

React-Leaflet-Draw

React component build on top of React-Leaflet that integrate leaflet-draw feature.

Install

npm install react-leaflet-draw

Getting started

First, include leaflet-draw styles in your project

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.3/leaflet.draw.css"/>

or by including

node_modules/leaflet-draw/dist/leaflet.draw.css

You might need to add one more rule missing in the current css:

  .sr-only {
    display: none;
  }

It's important to wrap EditControl component into FeatureGroup component from react-leaflet. The elements you draw will be added to this FeatureGroup layer, when you hit edit button only items in this layer will be edited.

import { Map, TileLayer, FeatureGroup, Circle } from 'react-leaflet';
import { EditControl } from "react-leaflet-draw"

const Component = () => (
  <FeatureGroup>
    <EditControl
      position='topright'
      onEdited={this._onEditPath}
      onCreated={this._onCreate}
      onDeleted={this._onDeleted}
      draw={{
        rectangle: false
      }}
    />
    <Circle center={[51.51, -0.06]} radius={200} />
  </FeatureGroup>
);

For more details on how to use this plugin check the example.

You can pass more options on draw object, this informations can be found here

EditControl API

Props

name type description
position string control group position
draw object enable/disable draw controls
edit object enable/disable edit controls
onEdited function hook to leaflet-draw's draw:edited event
onCreated function hook to leaflet-draw's draw:created event
onDeleted function hook to leaflet-draw's draw:deleted event
onMounted function hook to leaflet-draw's draw:mounted event
onEditStart function hook to leaflet-draw's draw:editstart event
onEditStop function hook to leaflet-draw's draw:editstop event
onDeleteStart function hook to leaflet-draw's draw:deletestart event
onDeleteStop function hook to leaflet-draw's draw:deletestop event
onDrawStart function hook to leaflet-draw's draw:drawstart event
onDrawStop function hook to leaflet-draw's draw:drawstop event
onDrawVertex function hook to leaflet-draw's draw:drawvertex event
onEditMove function hook to leaflet-draw's draw:editmove event
onEditResize function hook to leaflet-draw's draw:editresize event
onEditVertex function hook to leaflet-draw's draw:editvertex event

Links to docs

react-leaflet-draw's People

Contributors

aaronfriel avatar alex3165 avatar anajavi avatar andrewlipscomb avatar aparij avatar cbmasri avatar gpbmike avatar markhepburn avatar nhusher avatar nygardk avatar rexmondo avatar rotoglup avatar srghma avatar tigleym avatar timhollies 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.