react-leaflet
Advanced tools
Comparing version 3.2.4 to 3.2.5
@@ -59,7 +59,8 @@ "use strict"; | ||
} | ||
}, [map, whenCreated]); | ||
(0, _react.useEffect)(() => { | ||
return () => { | ||
map == null ? void 0 : map.remove(); | ||
}; | ||
}, [map, whenCreated]); | ||
}, [map]); | ||
const [props] = (0, _react.useState)({ | ||
@@ -66,0 +67,0 @@ className, |
@@ -45,7 +45,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
} | ||
}, [map, whenCreated]); | ||
useEffect(() => { | ||
return () => { | ||
map == null ? void 0 : map.remove(); | ||
}; | ||
}, [map, whenCreated]); | ||
}, [map]); | ||
const [props] = useState({ | ||
@@ -52,0 +53,0 @@ className, |
{ | ||
"name": "react-leaflet", | ||
"version": "3.2.4", | ||
"version": "3.2.5", | ||
"description": "React components for Leaflet maps", | ||
@@ -5,0 +5,0 @@ "main": "cjs/index.js", |
@@ -572,7 +572,8 @@ (function (global, factory) { | ||
} | ||
}, [map, whenCreated]); | ||
React.useEffect(() => { | ||
return () => { | ||
map == null ? void 0 : map.remove(); | ||
}; | ||
}, [map, whenCreated]); | ||
}, [map]); | ||
const [props] = React.useState({ | ||
@@ -579,0 +580,0 @@ className, |
@@ -1,1 +0,1 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("leaflet"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","leaflet","react-dom"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).ReactLeaflet={},n.React,n.L,n.ReactDOM)}(this,(function(n,e,t,o){"use strict";function r(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=r(e);function c(n,t){const o=e.useRef(t);e.useEffect((function(){t!==o.current&&null!=n.attributionControl&&(null!=o.current&&n.attributionControl.removeAttribution(o.current),null!=t&&n.attributionControl.addAttribution(t)),o.current=t}),[n,t])}function a(n,e,t){e.center!==t.center&&n.setLatLng(e.center),null!=e.radius&&e.radius!==t.radius&&n.setRadius(e.radius)}const l=e.createContext(null),i=l.Provider;function s(){const n=e.useContext(l);if(null==n)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return n}function f(n){function t(t,o){const{instance:r,context:c}=n(t).current;return e.useImperativeHandle(o,(()=>r)),null==t.children?null:u.default.createElement(i,{value:c},t.children)}return e.forwardRef(t)}function p(n){function t(t,o){const{instance:r}=n(t).current;return e.useImperativeHandle(o,(()=>r)),null}return e.forwardRef(t)}function d(n){return function(t){const o=s(),r=n(t,o),{instance:u}=r.current,c=e.useRef(t.position),{position:a}=t;return e.useEffect((function(){return u.addTo(o.map),function(){u.remove()}}),[o.map,u]),e.useEffect((function(){null!=a&&a!==c.current&&(u.setPosition(a),c.current=a)}),[u,a]),r}}function y(n,t){const o=e.useRef();e.useEffect((function(){return null!=t&&n.instance.on(t),o.current=t,function(){null!=o.current&&n.instance.off(o.current),o.current=null}}),[n,t])}function m(n,e){const t=n.pane??e.pane;return t?{...n,pane:t}:n}function v(n,e){(function(n){return n.split(" ").filter(Boolean)})(e).forEach((e=>{t.DomUtil.addClass(n,e)}))}function C(n,t){return null==t?function(t,o){return e.useRef(n(t,o))}:function(o,r){const u=e.useRef(n(o,r)),c=e.useRef(o),{instance:a}=u.current;return e.useEffect((function(){c.current!==o&&(t(a,o,c.current),c.current=o)}),[a,o,r]),u}}function h(n,t){e.useEffect((function(){return(t.layerContainer??t.map).addLayer(n.instance),function(){var e;null==(e=t.layerContainer)||e.removeLayer(n.instance),t.map.removeLayer(n.instance)}}),[t,n])}function b(n){return function(e){const t=s(),o=n(m(e,t),t);return c(t.map,e.attribution),y(o.current,e.eventHandlers),h(o.current,t),o}}function w(n){return function(t){const o=s(),r=n(m(t,o),o);return y(r.current,t.eventHandlers),h(r.current,o),function(n,t){const o=e.useRef();e.useEffect((function(){if(t.pathOptions!==o.current){const e=t.pathOptions??{};n.instance.setStyle(e),o.current=e}}),[n,t])}(r.current,t),r}}function g(n){return p(d(C((function(e,t){return{instance:n(e),context:t}}))))}function x(n,e){return f(b(C(n,e)))}function L(n,t){const r=function(n,e){return function(t,o){const r=s(),u=n(m(t,r),r);return c(r.map,t.attribution),y(u.current,t.eventHandlers),e(u.current,r,t,o),u}}(C(n),t);return function(n){function t(t,r){const[u,c]=e.useState(!1),{instance:a}=n(t,c).current;e.useImperativeHandle(r,(()=>a)),e.useEffect((function(){u&&a.update()}),[a,u,t.children]);const l=a._contentNode;return l?o.createPortal(t.children,l):null}return e.forwardRef(t)}(r)}function E(n,e){return f(w(C(n,e)))}function O(n,e){return p(b(C(n,e)))}function P(n,e,t){const{opacity:o,zIndex:r}=e;null!=o&&o!==t.opacity&&n.setOpacity(o),null!=r&&r!==t.zIndex&&n.setZIndex(r)}function R(n,e,o){e.bounds instanceof t.LatLngBounds&&e.bounds!==o.bounds&&n.setBounds(e.bounds),null!=e.opacity&&e.opacity!==o.opacity&&n.setOpacity(e.opacity),null!=e.zIndex&&e.zIndex!==o.zIndex&&n.setZIndex(e.zIndex)}function I(){return s().map}const M=g((function(n){return new t.Control.Attribution(n)})),S=E((function(n,e){let{center:o,children:r,...u}=n;const c=new t.Circle(o,u);return{instance:c,context:{...e,overlayContainer:c}}}),a),k=E((function(n,e){let{center:o,children:r,...u}=n;const c=new t.CircleMarker(o,u);return{instance:c,context:{...e,overlayContainer:c}}}),a),z=E((function(n,e){let{children:o,...r}=n;const u=new t.FeatureGroup([],r);return{instance:u,context:{...e,layerContainer:u,overlayContainer:u}}})),T=E((function(n,e){let{data:o,...r}=n;const u=new t.GeoJSON(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.style!==t.style&&(null==e.style?n.resetStyle():n.setStyle(e.style))})),_=x((function(n,e){let{bounds:o,url:r,...u}=n;const c=new t.ImageOverlay(r,o,u);return{instance:c,context:{...e,overlayContainer:c}}}),(function(n,e,t){R(n,e,t),e.url!==t.url&&n.setUrl(e.url)})),N=x((function(n,e){let{children:o,...r}=n;const u=new t.LayerGroup([],r);return{instance:u,context:{...e,layerContainer:u}}})),G=f(d(C((function(n,e){let{children:o,...r}=n;const u=new t.Control.Layers(void 0,void 0,r);return{instance:u,context:{...e,layersControl:u}}}),(function(n,e,t){e.collapsed!==t.collapsed&&(!0===e.collapsed?n.collapse():n.expand())}))));function j(n){return function(t){const o=s(),r=e.useRef(t),[c,a]=e.useState(null),{layersControl:l,map:f}=o,p=e.useCallback((e=>{null!=l&&(r.current.checked&&f.addLayer(e),n(l,e,r.current.name),a(e))}),[l,f]),d=e.useCallback((n=>{null==l||l.removeLayer(n),a(null)}),[l]),y=e.useMemo((()=>({...o,layerContainer:{addLayer:p,removeLayer:d}})),[o,p,d]);return e.useEffect((()=>{null!==c&&r.current!==t&&(!0!==t.checked||null!=r.current.checked&&!1!==r.current.checked?!0!==r.current.checked||null!=t.checked&&!1!==t.checked||f.removeLayer(c):f.addLayer(c),r.current=t)})),t.children?u.default.createElement(i,{value:y},t.children):null}}function A(){return A=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},A.apply(this,arguments)}G.BaseLayer=j((function(n,e,t){n.addBaseLayer(e,t)})),G.Overlay=j((function(n,e,t){n.addOverlay(e,t)}));const B=x((function(n,e){let{position:o,...r}=n;const u=new t.Marker(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.position!==t.position&&n.setLatLng(e.position),null!=e.icon&&e.icon!==t.icon&&n.setIcon(e.icon),null!=e.zIndexOffset&&e.zIndexOffset!==t.zIndexOffset&&n.setZIndexOffset(e.zIndexOffset),null!=e.opacity&&e.opacity!==t.opacity&&n.setOpacity(e.opacity),null!=n.dragging&&e.draggable!==t.draggable&&(!0===e.draggable?n.dragging.enable():n.dragging.disable())})),H=["mapPane","markerPane","overlayPane","popupPane","shadowPane","tilePane","tooltipPane"];function V(n,e){const{[e]:t,...o}=n;return o}const Z=E((function(n,e){let{positions:o,...r}=n;const u=new t.Polygon(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),q=E((function(n,e){let{positions:o,...r}=n;const u=new t.Polyline(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),U=L((function(n,e){return{instance:new t.Popup(n,e.overlayContainer),context:e}}),(function(n,t,o,r){const{onClose:u,onOpen:c,position:a}=o;e.useEffect((function(){const{instance:e}=n;function o(n){n.popup===e&&(e.update(),r(!0),null==c||c())}function l(n){n.popup===e&&(r(!1),null==u||u())}return t.map.on({popupopen:o,popupclose:l}),null==t.overlayContainer?(null!=a&&e.setLatLng(a),e.openOn(t.map)):t.overlayContainer.bindPopup(e),function(){var n;t.map.off({popupopen:o,popupclose:l}),null==(n=t.overlayContainer)||n.unbindPopup(),t.map.removeLayer(e)}}),[n,t,r,u,c,a])})),D=E((function(n,e){let{bounds:o,...r}=n;const u=new t.Rectangle(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.bounds!==t.bounds&&n.setBounds(e.bounds)})),F=g((function(n){return new t.Control.Scale(n)})),J=b(C((function(n,e){const{attributes:o,bounds:r,...u}=n,c=document.createElementNS("http://www.w3.org/2000/svg","svg");return c.setAttribute("xmlns","http://www.w3.org/2000/svg"),null!=o&&Object.keys(o).forEach((n=>{c.setAttribute(n,o[n])})),{instance:new t.SVGOverlay(c,r,u),container:c,context:e}}),R));function W(n,t){let{children:r,...u}=n;const{instance:c,container:a}=J(u).current;return e.useImperativeHandle(t,(()=>c)),null==a||null==r?null:o.createPortal(r,a)}const $=e.forwardRef(W),Y=O((function(n,e){let{url:o,...r}=n;return{instance:new t.TileLayer(o,m(r,e)),context:e}}),P),K=L((function(n,e){return{instance:new t.Tooltip(n,e.overlayContainer),context:e}}),(function(n,t,o,r){const{onClose:u,onOpen:c,position:a}=o;e.useEffect((function(){const e=t.overlayContainer;if(null==e)return;const{instance:o}=n,l=n=>{n.tooltip===o&&(a&&o.setLatLng(a),o.update(),r(!0),null==c||c())},i=n=>{n.tooltip===o&&(r(!1),null==u||u())};return e.on({tooltipopen:l,tooltipclose:i}),e.bindTooltip(o),function(){e.off({tooltipopen:l,tooltipclose:i}),null!=e._map&&e.unbindTooltip()}}),[n,t,r,u,c,a])})),Q=x((function(n,e){let{bounds:o,url:r,...u}=n;const c=new t.VideoOverlay(r,o,u);var a;!0===u.play&&(null==(a=c.getElement())||a.play());return{instance:c,context:{...e,overlayContainer:c}}}),(function(n,e,t){R(n,e,t),"string"==typeof e.url&&e.url!==t.url&&n.setUrl(e.url);const o=n.getElement();null!=o&&(!0!==e.play||t.play?e.play||!0!==t.play||o.pause():o.play())})),X=O((function(n,e){let{params:o={},url:r,...u}=n;return{instance:new t.TileLayer.WMS(r,{...o,...m(u,e)}),context:e}}),(function(n,e,t){P(n,e,t),null!=e.params&&e.params!==t.params&&n.setParams(e.params)})),nn=g((function(n){return new t.Control.Zoom(n)}));n.AttributionControl=M,n.Circle=S,n.CircleMarker=k,n.FeatureGroup=z,n.GeoJSON=T,n.ImageOverlay=_,n.LayerGroup=N,n.LayersControl=G,n.MapConsumer=function(n){let{children:e}=n;return e(I())},n.MapContainer=function(n){let{children:o,className:r,id:c,placeholder:a,style:l,whenCreated:s,...f}=n;const p=e.useRef(null),d=function(n,o){const[r,u]=e.useState(null);return e.useEffect((()=>{if(null!==n.current&&null===r){const e=new t.Map(n.current,o);null!=o.center&&null!=o.zoom?e.setView(o.center,o.zoom):null!=o.bounds&&e.fitBounds(o.bounds,o.boundsOptions),null!=o.whenReady&&e.whenReady(o.whenReady),u(e)}}),[n,r,o]),r}(p,f),y=e.useRef(!1);e.useEffect((()=>(null!=d&&!1===y.current&&null!=s&&(y.current=!0,s(d)),()=>{null==d||d.remove()})),[d,s]);const[m]=e.useState({className:r,id:c,style:l}),v=e.useMemo((()=>d?{__version:1,map:d}:null),[d]),C=v?u.default.createElement(i,{value:v},o):a??null;return u.default.createElement("div",A({},m,{ref:p}),C)},n.Marker=B,n.Pane=function(n){const[t,r]=e.useState(),c=s(),a=e.useMemo((()=>({...c,pane:n.name})),[c]);return e.useEffect((()=>(r(function(n,e){const t=n.name;if(-1!==H.indexOf(t))throw new Error(`You must use a unique name for a pane that is not a default Leaflet pane: ${t}`);if(null!=e.map.getPane(t))throw new Error(`A pane with this name already exists: ${t}`);const o=n.pane??e.pane,r=o?e.map.getPane(o):void 0,u=e.map.createPane(t,r);return null!=n.className&&v(u,n.className),null!=n.style&&Object.keys(n.style).forEach((e=>{u.style[e]=n.style[e]})),u}(n,c)),function(){const e=c.map.getPane(n.name);null==e||null==e.remove||e.remove(),null!=c.map._panes&&(c.map._panes=V(c.map._panes,n.name),c.map._paneRenderers=V(c.map._paneRenderers,n.name))})),[]),null!=n.children&&null!=t?o.createPortal(u.default.createElement(i,{value:a},n.children),t):null},n.Polygon=Z,n.Polyline=q,n.Popup=U,n.Rectangle=D,n.SVGOverlay=$,n.ScaleControl=F,n.TileLayer=Y,n.Tooltip=K,n.VideoOverlay=Q,n.WMSTileLayer=X,n.ZoomControl=nn,n.useMap=I,n.useMapEvent=function(n,t){const o=I();return e.useEffect((function(){return o.on(n,t),function(){o.off(n,t)}}),[o,n,t]),o},n.useMapEvents=function(n){const t=I();return e.useEffect((function(){return t.on(n),function(){t.off(n)}}),[t,n]),t},Object.defineProperty(n,"__esModule",{value:!0})})); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("leaflet"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","leaflet","react-dom"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).ReactLeaflet={},n.React,n.L,n.ReactDOM)}(this,(function(n,e,t,o){"use strict";function r(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=r(e);function c(n,t){const o=e.useRef(t);e.useEffect((function(){t!==o.current&&null!=n.attributionControl&&(null!=o.current&&n.attributionControl.removeAttribution(o.current),null!=t&&n.attributionControl.addAttribution(t)),o.current=t}),[n,t])}function a(n,e,t){e.center!==t.center&&n.setLatLng(e.center),null!=e.radius&&e.radius!==t.radius&&n.setRadius(e.radius)}const l=e.createContext(null),i=l.Provider;function s(){const n=e.useContext(l);if(null==n)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return n}function f(n){function t(t,o){const{instance:r,context:c}=n(t).current;return e.useImperativeHandle(o,(()=>r)),null==t.children?null:u.default.createElement(i,{value:c},t.children)}return e.forwardRef(t)}function p(n){function t(t,o){const{instance:r}=n(t).current;return e.useImperativeHandle(o,(()=>r)),null}return e.forwardRef(t)}function d(n){return function(t){const o=s(),r=n(t,o),{instance:u}=r.current,c=e.useRef(t.position),{position:a}=t;return e.useEffect((function(){return u.addTo(o.map),function(){u.remove()}}),[o.map,u]),e.useEffect((function(){null!=a&&a!==c.current&&(u.setPosition(a),c.current=a)}),[u,a]),r}}function y(n,t){const o=e.useRef();e.useEffect((function(){return null!=t&&n.instance.on(t),o.current=t,function(){null!=o.current&&n.instance.off(o.current),o.current=null}}),[n,t])}function m(n,e){const t=n.pane??e.pane;return t?{...n,pane:t}:n}function v(n,e){(function(n){return n.split(" ").filter(Boolean)})(e).forEach((e=>{t.DomUtil.addClass(n,e)}))}function C(n,t){return null==t?function(t,o){return e.useRef(n(t,o))}:function(o,r){const u=e.useRef(n(o,r)),c=e.useRef(o),{instance:a}=u.current;return e.useEffect((function(){c.current!==o&&(t(a,o,c.current),c.current=o)}),[a,o,r]),u}}function h(n,t){e.useEffect((function(){return(t.layerContainer??t.map).addLayer(n.instance),function(){var e;null==(e=t.layerContainer)||e.removeLayer(n.instance),t.map.removeLayer(n.instance)}}),[t,n])}function b(n){return function(e){const t=s(),o=n(m(e,t),t);return c(t.map,e.attribution),y(o.current,e.eventHandlers),h(o.current,t),o}}function w(n){return function(t){const o=s(),r=n(m(t,o),o);return y(r.current,t.eventHandlers),h(r.current,o),function(n,t){const o=e.useRef();e.useEffect((function(){if(t.pathOptions!==o.current){const e=t.pathOptions??{};n.instance.setStyle(e),o.current=e}}),[n,t])}(r.current,t),r}}function g(n){return p(d(C((function(e,t){return{instance:n(e),context:t}}))))}function x(n,e){return f(b(C(n,e)))}function L(n,t){const r=function(n,e){return function(t,o){const r=s(),u=n(m(t,r),r);return c(r.map,t.attribution),y(u.current,t.eventHandlers),e(u.current,r,t,o),u}}(C(n),t);return function(n){function t(t,r){const[u,c]=e.useState(!1),{instance:a}=n(t,c).current;e.useImperativeHandle(r,(()=>a)),e.useEffect((function(){u&&a.update()}),[a,u,t.children]);const l=a._contentNode;return l?o.createPortal(t.children,l):null}return e.forwardRef(t)}(r)}function E(n,e){return f(w(C(n,e)))}function O(n,e){return p(b(C(n,e)))}function P(n,e,t){const{opacity:o,zIndex:r}=e;null!=o&&o!==t.opacity&&n.setOpacity(o),null!=r&&r!==t.zIndex&&n.setZIndex(r)}function R(n,e,o){e.bounds instanceof t.LatLngBounds&&e.bounds!==o.bounds&&n.setBounds(e.bounds),null!=e.opacity&&e.opacity!==o.opacity&&n.setOpacity(e.opacity),null!=e.zIndex&&e.zIndex!==o.zIndex&&n.setZIndex(e.zIndex)}function I(){return s().map}const M=g((function(n){return new t.Control.Attribution(n)})),S=E((function(n,e){let{center:o,children:r,...u}=n;const c=new t.Circle(o,u);return{instance:c,context:{...e,overlayContainer:c}}}),a),k=E((function(n,e){let{center:o,children:r,...u}=n;const c=new t.CircleMarker(o,u);return{instance:c,context:{...e,overlayContainer:c}}}),a),z=E((function(n,e){let{children:o,...r}=n;const u=new t.FeatureGroup([],r);return{instance:u,context:{...e,layerContainer:u,overlayContainer:u}}})),T=E((function(n,e){let{data:o,...r}=n;const u=new t.GeoJSON(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.style!==t.style&&(null==e.style?n.resetStyle():n.setStyle(e.style))})),_=x((function(n,e){let{bounds:o,url:r,...u}=n;const c=new t.ImageOverlay(r,o,u);return{instance:c,context:{...e,overlayContainer:c}}}),(function(n,e,t){R(n,e,t),e.url!==t.url&&n.setUrl(e.url)})),N=x((function(n,e){let{children:o,...r}=n;const u=new t.LayerGroup([],r);return{instance:u,context:{...e,layerContainer:u}}})),G=f(d(C((function(n,e){let{children:o,...r}=n;const u=new t.Control.Layers(void 0,void 0,r);return{instance:u,context:{...e,layersControl:u}}}),(function(n,e,t){e.collapsed!==t.collapsed&&(!0===e.collapsed?n.collapse():n.expand())}))));function j(n){return function(t){const o=s(),r=e.useRef(t),[c,a]=e.useState(null),{layersControl:l,map:f}=o,p=e.useCallback((e=>{null!=l&&(r.current.checked&&f.addLayer(e),n(l,e,r.current.name),a(e))}),[l,f]),d=e.useCallback((n=>{null==l||l.removeLayer(n),a(null)}),[l]),y=e.useMemo((()=>({...o,layerContainer:{addLayer:p,removeLayer:d}})),[o,p,d]);return e.useEffect((()=>{null!==c&&r.current!==t&&(!0!==t.checked||null!=r.current.checked&&!1!==r.current.checked?!0!==r.current.checked||null!=t.checked&&!1!==t.checked||f.removeLayer(c):f.addLayer(c),r.current=t)})),t.children?u.default.createElement(i,{value:y},t.children):null}}function A(){return A=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n},A.apply(this,arguments)}G.BaseLayer=j((function(n,e,t){n.addBaseLayer(e,t)})),G.Overlay=j((function(n,e,t){n.addOverlay(e,t)}));const B=x((function(n,e){let{position:o,...r}=n;const u=new t.Marker(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.position!==t.position&&n.setLatLng(e.position),null!=e.icon&&e.icon!==t.icon&&n.setIcon(e.icon),null!=e.zIndexOffset&&e.zIndexOffset!==t.zIndexOffset&&n.setZIndexOffset(e.zIndexOffset),null!=e.opacity&&e.opacity!==t.opacity&&n.setOpacity(e.opacity),null!=n.dragging&&e.draggable!==t.draggable&&(!0===e.draggable?n.dragging.enable():n.dragging.disable())})),H=["mapPane","markerPane","overlayPane","popupPane","shadowPane","tilePane","tooltipPane"];function V(n,e){const{[e]:t,...o}=n;return o}const Z=E((function(n,e){let{positions:o,...r}=n;const u=new t.Polygon(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),q=E((function(n,e){let{positions:o,...r}=n;const u=new t.Polyline(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),U=L((function(n,e){return{instance:new t.Popup(n,e.overlayContainer),context:e}}),(function(n,t,o,r){const{onClose:u,onOpen:c,position:a}=o;e.useEffect((function(){const{instance:e}=n;function o(n){n.popup===e&&(e.update(),r(!0),null==c||c())}function l(n){n.popup===e&&(r(!1),null==u||u())}return t.map.on({popupopen:o,popupclose:l}),null==t.overlayContainer?(null!=a&&e.setLatLng(a),e.openOn(t.map)):t.overlayContainer.bindPopup(e),function(){var n;t.map.off({popupopen:o,popupclose:l}),null==(n=t.overlayContainer)||n.unbindPopup(),t.map.removeLayer(e)}}),[n,t,r,u,c,a])})),D=E((function(n,e){let{bounds:o,...r}=n;const u=new t.Rectangle(o,r);return{instance:u,context:{...e,overlayContainer:u}}}),(function(n,e,t){e.bounds!==t.bounds&&n.setBounds(e.bounds)})),F=g((function(n){return new t.Control.Scale(n)})),J=b(C((function(n,e){const{attributes:o,bounds:r,...u}=n,c=document.createElementNS("http://www.w3.org/2000/svg","svg");return c.setAttribute("xmlns","http://www.w3.org/2000/svg"),null!=o&&Object.keys(o).forEach((n=>{c.setAttribute(n,o[n])})),{instance:new t.SVGOverlay(c,r,u),container:c,context:e}}),R));function W(n,t){let{children:r,...u}=n;const{instance:c,container:a}=J(u).current;return e.useImperativeHandle(t,(()=>c)),null==a||null==r?null:o.createPortal(r,a)}const $=e.forwardRef(W),Y=O((function(n,e){let{url:o,...r}=n;return{instance:new t.TileLayer(o,m(r,e)),context:e}}),P),K=L((function(n,e){return{instance:new t.Tooltip(n,e.overlayContainer),context:e}}),(function(n,t,o,r){const{onClose:u,onOpen:c,position:a}=o;e.useEffect((function(){const e=t.overlayContainer;if(null==e)return;const{instance:o}=n,l=n=>{n.tooltip===o&&(a&&o.setLatLng(a),o.update(),r(!0),null==c||c())},i=n=>{n.tooltip===o&&(r(!1),null==u||u())};return e.on({tooltipopen:l,tooltipclose:i}),e.bindTooltip(o),function(){e.off({tooltipopen:l,tooltipclose:i}),null!=e._map&&e.unbindTooltip()}}),[n,t,r,u,c,a])})),Q=x((function(n,e){let{bounds:o,url:r,...u}=n;const c=new t.VideoOverlay(r,o,u);var a;!0===u.play&&(null==(a=c.getElement())||a.play());return{instance:c,context:{...e,overlayContainer:c}}}),(function(n,e,t){R(n,e,t),"string"==typeof e.url&&e.url!==t.url&&n.setUrl(e.url);const o=n.getElement();null!=o&&(!0!==e.play||t.play?e.play||!0!==t.play||o.pause():o.play())})),X=O((function(n,e){let{params:o={},url:r,...u}=n;return{instance:new t.TileLayer.WMS(r,{...o,...m(u,e)}),context:e}}),(function(n,e,t){P(n,e,t),null!=e.params&&e.params!==t.params&&n.setParams(e.params)})),nn=g((function(n){return new t.Control.Zoom(n)}));n.AttributionControl=M,n.Circle=S,n.CircleMarker=k,n.FeatureGroup=z,n.GeoJSON=T,n.ImageOverlay=_,n.LayerGroup=N,n.LayersControl=G,n.MapConsumer=function(n){let{children:e}=n;return e(I())},n.MapContainer=function(n){let{children:o,className:r,id:c,placeholder:a,style:l,whenCreated:s,...f}=n;const p=e.useRef(null),d=function(n,o){const[r,u]=e.useState(null);return e.useEffect((()=>{if(null!==n.current&&null===r){const e=new t.Map(n.current,o);null!=o.center&&null!=o.zoom?e.setView(o.center,o.zoom):null!=o.bounds&&e.fitBounds(o.bounds,o.boundsOptions),null!=o.whenReady&&e.whenReady(o.whenReady),u(e)}}),[n,r,o]),r}(p,f),y=e.useRef(!1);e.useEffect((()=>{null!=d&&!1===y.current&&null!=s&&(y.current=!0,s(d))}),[d,s]),e.useEffect((()=>()=>{null==d||d.remove()}),[d]);const[m]=e.useState({className:r,id:c,style:l}),v=e.useMemo((()=>d?{__version:1,map:d}:null),[d]),C=v?u.default.createElement(i,{value:v},o):a??null;return u.default.createElement("div",A({},m,{ref:p}),C)},n.Marker=B,n.Pane=function(n){const[t,r]=e.useState(),c=s(),a=e.useMemo((()=>({...c,pane:n.name})),[c]);return e.useEffect((()=>(r(function(n,e){const t=n.name;if(-1!==H.indexOf(t))throw new Error(`You must use a unique name for a pane that is not a default Leaflet pane: ${t}`);if(null!=e.map.getPane(t))throw new Error(`A pane with this name already exists: ${t}`);const o=n.pane??e.pane,r=o?e.map.getPane(o):void 0,u=e.map.createPane(t,r);return null!=n.className&&v(u,n.className),null!=n.style&&Object.keys(n.style).forEach((e=>{u.style[e]=n.style[e]})),u}(n,c)),function(){const e=c.map.getPane(n.name);null==e||null==e.remove||e.remove(),null!=c.map._panes&&(c.map._panes=V(c.map._panes,n.name),c.map._paneRenderers=V(c.map._paneRenderers,n.name))})),[]),null!=n.children&&null!=t?o.createPortal(u.default.createElement(i,{value:a},n.children),t):null},n.Polygon=Z,n.Polyline=q,n.Popup=U,n.Rectangle=D,n.SVGOverlay=$,n.ScaleControl=F,n.TileLayer=Y,n.Tooltip=K,n.VideoOverlay=Q,n.WMSTileLayer=X,n.ZoomControl=nn,n.useMap=I,n.useMapEvent=function(n,t){const o=I();return e.useEffect((function(){return o.on(n,t),function(){o.off(n,t)}}),[o,n,t]),o},n.useMapEvents=function(n){const t=I();return e.useEffect((function(){return t.on(n),function(){t.off(n)}}),[t,n]),t},Object.defineProperty(n,"__esModule",{value:!0})})); |
118676
2644