1 | import { createElementObject, createPathComponent, extendContext } from '@react-leaflet/core';
|
2 | import { Rectangle as LeafletRectangle } from 'leaflet';
|
3 | export const Rectangle = createPathComponent(function createRectangle({ bounds , ...options }, ctx) {
|
4 | const rectangle = new LeafletRectangle(bounds, options);
|
5 | return createElementObject(rectangle, extendContext(ctx, {
|
6 | overlayContainer: rectangle
|
7 | }));
|
8 | }, function updateRectangle(layer, props, prevProps) {
|
9 | if (props.bounds !== prevProps.bounds) {
|
10 | layer.setBounds(props.bounds);
|
11 | }
|
12 | });
|