1 | import { createElementObject, createLayerComponent, extendContext, updateMediaOverlay } from '@react-leaflet/core';
|
2 | import { LatLngBounds, ImageOverlay as LeafletImageOverlay } from 'leaflet';
|
3 | export const ImageOverlay = createLayerComponent(function createImageOveraly({ bounds , url , ...options }, ctx) {
|
4 | const overlay = new LeafletImageOverlay(url, bounds, options);
|
5 | return createElementObject(overlay, extendContext(ctx, {
|
6 | overlayContainer: overlay
|
7 | }));
|
8 | }, function updateImageOverlay(overlay, props, prevProps) {
|
9 | updateMediaOverlay(overlay, props, prevProps);
|
10 | if (props.bounds !== prevProps.bounds) {
|
11 | const bounds = props.bounds instanceof LatLngBounds ? props.bounds : new LatLngBounds(props.bounds);
|
12 | overlay.setBounds(bounds);
|
13 | }
|
14 | if (props.url !== prevProps.url) {
|
15 | overlay.setUrl(props.url);
|
16 | }
|
17 | });
|