A modern study React component of leaflet draw for react-leaflet
React component of leaflet-draw for react-leaflet
dist/
└── index.min.js
yarn add leaflet leaflet-draw react-leaflet
yarn add react-leaflet-draft@ˆ1.2.1
yarn add react-leaflet-draft@latest
<FeatureGroup>
<DraftControl/>
</FeatureGroup>
import "leaflet/dist/leaflet.css";
import { DraftControl } from "react-leaflet-draft";
import { MapContainer, TileLayer, FeatureGroup } from "react-leaflet";
function Map() {
return(
<MapContainer
zoom={14}
center={[-22.2108112, -49.6771926]}
>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<FeatureGroup>
<DraftControl />
</FeatureGroup>
</MapContainer>
)
}
You can see the properties in Leaflet-draw Documentation
<DraftControl
draw={{
circle: true,
rectangle: true
}}
edit={{
edit: {}
}}
translate={{
toolbar: {
buttons: {
circle: 'Circle'
}
}
}}
limitLayers={2}
/>
<DraftControl
onEdited={e => console.log(e)}
onDeleted={e => console.log(e)}
onCreated={e => console.log(e)}
/>