2.0.0 • Published 9 months ago

react-leaflet-draft v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

React Leaflet Draft

A modern study React component of leaflet draw for react-leaflet

Version Project Size Dependencies Licence

React component of leaflet-draw for react-leaflet

React leaflet Draft

Table of contents

Main

dist/
└── index.min.js    

Getting started

Requirements

yarn add leaflet leaflet-draw react-leaflet

Installation

For React 17 with React Leaflet 3

yarn add react-leaflet-muster@ˆ1.2.1

For React 18 with React Leaflet 4

yarn add react-leaflet-muster@latest

Usage

Basic Example

<FeatureGroup>
    <DraftControl/>
</FeatureGroup>

Full Example

import { DraftControl } from "react-leaflet-draft";
import { MapContainer, TileLayer, Marker, FeatureGroup } from "react-leaflet";

function Map() {
    return(
        <MapContainer
            zoom={14}
            center={position}
        >
            <TileLayer
                url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
            />
            <FeatureGroup>
                <DraftControl />
            </FeatureGroup>
        </MapContainer>
    )
}

API

You can see the properties in Leaflet-draw Documentation

Example options

<DraftControl
    draw={{
        circle: true,
        rectangle: true
    }}
    edit={{
        edit: false
    }}
    translate={{
        toolbar: {
            buttons: {
                circle: 'Circle'
            }
        }
    }}
    limitLayers={2}
/>

Example listeners

<DraftControl
    onEdited={e => console.log(e)}
    onDeleted={e => console.log(e)}
    onCreated={e => console.log(e)}
/>

License

ISC © Giovane Santos