react-leaflet
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -15,3 +15,3 @@ "use strict"; | ||
return { | ||
instance: new _leaflet.TileLayer(url, options), | ||
instance: new _leaflet.TileLayer(url, (0, _core.withPane)(options, context)), | ||
context | ||
@@ -18,0 +18,0 @@ }; |
@@ -17,3 +17,3 @@ "use strict"; | ||
instance: new _leaflet.TileLayer.WMS(url, { ...params, | ||
...options | ||
...(0, _core.withPane)(options, context) | ||
}), | ||
@@ -20,0 +20,0 @@ context |
@@ -1,2 +0,2 @@ | ||
import { createTileLayerComponent, updateGridLayer } from '@react-leaflet/core'; | ||
import { createTileLayerComponent, updateGridLayer, withPane } from '@react-leaflet/core'; | ||
import { TileLayer as LeafletTileLayer } from 'leaflet'; | ||
@@ -8,5 +8,5 @@ export const TileLayer = createTileLayerComponent(function createTileLayer({ | ||
return { | ||
instance: new LeafletTileLayer(url, options), | ||
instance: new LeafletTileLayer(url, withPane(options, context)), | ||
context | ||
}; | ||
}, updateGridLayer); |
@@ -1,2 +0,2 @@ | ||
import { createTileLayerComponent, updateGridLayer } from '@react-leaflet/core'; | ||
import { createTileLayerComponent, updateGridLayer, withPane } from '@react-leaflet/core'; | ||
import { TileLayer } from 'leaflet'; | ||
@@ -10,3 +10,3 @@ export const WMSTileLayer = createTileLayerComponent(function createWMSTileLayer({ | ||
instance: new TileLayer.WMS(url, { ...params, | ||
...options | ||
...withPane(options, context) | ||
}), | ||
@@ -13,0 +13,0 @@ context |
{ | ||
"name": "react-leaflet", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "React components for Leaflet maps", | ||
@@ -34,7 +34,7 @@ "main": "cjs/index.js", | ||
"author": "Paul Le Cam <paul@ulem.net>", | ||
"license": "SEE LICENSE IN LICENSE.md", | ||
"license": "Hippocratic-2.1", | ||
"bugs": { | ||
"url": "https://github.com/PaulLeCam/react-leaflet/issues" | ||
}, | ||
"homepage": "https://github.com/PaulLeCam/react-leaflet", | ||
"homepage": "https://react-leaflet.js.org", | ||
"files": [ | ||
@@ -41,0 +41,0 @@ "cjs/*", |
/// <reference types="react" /> | ||
import { EventedProps } from '@react-leaflet/core'; | ||
import { LayerProps } from '@react-leaflet/core'; | ||
import { TileLayer as LeafletTileLayer, TileLayerOptions } from 'leaflet'; | ||
export interface TileLayerProps extends TileLayerOptions, EventedProps { | ||
export interface TileLayerProps extends TileLayerOptions, LayerProps { | ||
url: string; | ||
} | ||
export declare const TileLayer: import("react").ForwardRefExoticComponent<TileLayerProps & import("react").RefAttributes<LeafletTileLayer>>; |
/// <reference types="react" /> | ||
import { EventedProps } from '@react-leaflet/core'; | ||
import { LayerProps } from '@react-leaflet/core'; | ||
import { TileLayer, WMSOptions, WMSParams } from 'leaflet'; | ||
export interface WMSTileLayerProps extends WMSOptions, EventedProps { | ||
export interface WMSTileLayerProps extends WMSOptions, LayerProps { | ||
params?: WMSParams; | ||
@@ -6,0 +6,0 @@ url: string; |
@@ -11,2 +11,19 @@ (function (global, factory) { | ||
function useAttribution(map, attribution) { | ||
const attributionRef = React.useRef(attribution); | ||
React.useEffect(function updateAttribution() { | ||
if (attribution !== attributionRef.current && map.attributionControl != null) { | ||
if (attributionRef.current != null) { | ||
map.attributionControl.removeAttribution(attributionRef.current); | ||
} | ||
if (attribution != null) { | ||
map.attributionControl.addAttribution(attribution); | ||
} | ||
} | ||
attributionRef.current = attribution; | ||
}, [map, attribution]); | ||
} | ||
function updateCircle(layer, props, prevProps) { | ||
@@ -125,6 +142,16 @@ if (props.center !== prevProps.center) { | ||
function withPane(props, context) { | ||
var _props$pane; | ||
const pane = (_props$pane = props.pane) != null ? _props$pane : context.pane; | ||
return pane ? { ...props, | ||
pane | ||
} : props; | ||
} | ||
function createDivOverlayHook(useElement, useLifecycle) { | ||
return function useDivOverlay(props, setOpen) { | ||
const context = useLeafletContext(); | ||
const elementRef = useElement(props, context); | ||
const elementRef = useElement(withPane(props, context), context); | ||
useAttribution(context.map, props.attribution); | ||
useEventHandlers(elementRef.current, props.eventHandlers); | ||
@@ -174,18 +201,2 @@ useLifecycle(elementRef.current, context, props, setOpen); | ||
function useAttribution(map, attribution) { | ||
const attributionRef = React.useRef(attribution); | ||
React.useEffect(function updateAttribution() { | ||
if (attribution !== attributionRef.current && map.attributionControl != null) { | ||
if (attributionRef.current != null) { | ||
map.attributionControl.removeAttribution(attributionRef.current); | ||
} | ||
if (attribution != null) { | ||
map.attributionControl.addAttribution(attribution); | ||
} | ||
} | ||
attributionRef.current = attribution; | ||
}, [map, attribution]); | ||
} | ||
function useLayerLifecycle(element, context) { | ||
@@ -205,3 +216,3 @@ React.useEffect(function addLayer() { | ||
const context = useLeafletContext(); | ||
const elementRef = useElement(props, context); | ||
const elementRef = useElement(withPane(props, context), context); | ||
useAttribution(context.map, props.attribution); | ||
@@ -848,3 +859,3 @@ useEventHandlers(elementRef.current, props.eventHandlers); | ||
return { | ||
instance: new leaflet.TileLayer(url, options), | ||
instance: new leaflet.TileLayer(url, withPane(options, context)), | ||
context | ||
@@ -949,3 +960,3 @@ }; | ||
instance: new leaflet.TileLayer.WMS(url, { ...params, | ||
...options | ||
...withPane(options, context) | ||
}), | ||
@@ -952,0 +963,0 @@ context |
@@ -1,1 +0,1 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react-dom"),require("leaflet")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","leaflet"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).ReactLeaflet={},n.React,n.ReactDOM,n.L)}(this,(function(n,e,t,r){"use strict";function o(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=o(e);function c(n,e,t){e.center!==t.center&&n.setLatLng(e.center),null!=e.radius&&e.radius!==t.radius&&n.setRadius(e.radius)}const a=e.createContext(null),l=a.Provider;function i(){const n=e.useContext(a);if(null==n)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return n}function s(n){function t(t,r){const{instance:o,context:c}=n(t).current;return e.useImperativeHandle(r,(()=>o)),null==t.children?null:u.default.createElement(l,{value:c},t.children)}return e.forwardRef(t)}function f(n){function t(t,r){const{instance:o}=n(t).current;return e.useImperativeHandle(r,(()=>o)),null}return e.forwardRef(t)}function p(n){return function(t){const r=i(),o=n(t,r),{instance:u}=o.current,c=e.useRef(t.position),{position:a}=t;return e.useEffect((function(){return u.addTo(r.map),function(){u.remove()}}),[r.map,u]),e.useEffect((function(){null!=a&&a!==c.current&&(u.setPosition(a),c.current=a)}),[u,a]),o}}function d(n,t){const r=e.useRef();e.useEffect((function(){return null!=t&&n.instance.on(t),r.current=t,function(){null!=r.current&&n.instance.off(r.current),r.current=null}}),[n,t])}function y(n){return n.split(" ").filter(Boolean)}function m(n,t){return null==t?function(t,r){return e.useRef(n(t,r))}:function(r,o){const u=e.useRef(n(r,o)),c=e.useRef(r),{instance:a}=u.current;return e.useEffect((function(){c.current!==r&&(t(a,r,c.current),c.current=r)}),[a,r,o]),u}}function v(n,t){e.useEffect((function(){var e;const r=null!=(e=t.layerContainer)?e:t.map;return r.addLayer(n.instance),function(){r.removeLayer(n.instance)}}),[t,n])}function C(n){return function(t){const r=i(),o=n(t,r);return function(n,t){const r=e.useRef(t);e.useEffect((function(){t!==r.current&&null!=n.attributionControl&&(null!=r.current&&n.attributionControl.removeAttribution(r.current),null!=t&&n.attributionControl.addAttribution(t)),r.current=t}),[n,t])}(r.map,t.attribution),d(o.current,t.eventHandlers),v(o.current,r),o}}function h(n){return function(t){const r=i(),o=n(t,r);return d(o.current,t.eventHandlers),v(o.current,r),function(n,t){const r=e.useRef();e.useEffect((function(){if(t.pathOptions!==r.current){var e;const o=null!=(e=t.pathOptions)?e:{};n.instance.setStyle(o),r.current=o}}),[n,t])}(o.current,t),o}}function b(n){return f(p(m((function(e,t){return{instance:n(e),context:t}}))))}function w(n,e){return s(C(m(n,e)))}function x(n,r){return function(n){function r(r,o){const[u,c]=e.useState(!1),{instance:a}=n(r,c).current;e.useImperativeHandle(o,(()=>a)),e.useEffect((function(){u&&a.update()}),[a,u,r.children]);const l=a._contentNode;return l?t.createPortal(r.children,l):null}return e.forwardRef(r)}(function(n,e){return function(t,r){const o=i(),u=n(t,o);return d(u.current,t.eventHandlers),e(u.current,o,t,r),u}}(m(n),r))}function g(n,e){return s(h(m(n,e)))}function L(n,e){return f(C(m(n,e)))}function E(n,e,t){const{opacity:r,zIndex:o}=e;null!=r&&r!==t.opacity&&n.setOpacity(r),null!=o&&o!==t.zIndex&&n.setZIndex(o)}function O(n,e,t){e.bounds instanceof r.LatLngBounds&&e.bounds!==t.bounds&&n.setBounds(e.bounds),null!=e.opacity&&e.opacity!==t.opacity&&n.setOpacity(e.opacity),null!=e.zIndex&&e.zIndex!==t.zIndex&&n.setZIndex(e.zIndex)}function R(){return i().map}const P=b((function(n){return new r.Control.Attribution(n)})),I=g((function({center:n,children:e,...t},o){const u=new r.Circle(n,t);return{instance:u,context:{...o,overlayContainer:u}}}),c),M=g((function({center:n,children:e,...t},o){const u=new r.CircleMarker(n,t);return{instance:u,context:{...o,overlayContainer:u}}}),c),k=g((function({children:n,...e},t){const o=new r.FeatureGroup([],e);return{instance:o,context:{...t,layerContainer:o,overlayContainer:o}}})),N=g((function({data:n,...e},t){const o=new r.GeoJSON(n,e);return{instance:o,context:{...t,overlayContainer:o}}})),S=w((function({bounds:n,url:e,...t},o){const u=new r.ImageOverlay(e,n,t);return{instance:u,context:{...o,overlayContainer:u}}}),(function(n,e,t){O(n,e,t),e.url!==t.url&&n.setUrl(e.url)})),z=w((function({children:n,...e},t){const o=new r.LayerGroup([],e);return{instance:o,context:{...t,layerContainer:o}}})),T=s(p(m((function({children:n,...e},t){const o=new r.Control.Layers(void 0,void 0,e);return{instance:o,context:{...t,layersControl:o}}}),(function(n,e,t){e.collapsed!==t.collapsed&&(!0===e.collapsed?n.collapse():n.expand())}))));function _(n){return function(t){const r=i(),o=e.useRef(t),[c,a]=e.useState(null),{layersControl:s,map:f}=r,p=e.useCallback((e=>{null!=s&&(o.current.checked&&f.addLayer(e),n(s,e,o.current.name),a(e))}),[s,f]),d=e.useCallback((n=>{null==s||s.removeLayer(n),a(null)}),[s]),y=e.useMemo((()=>({...r,layerContainer:{addLayer:p,removeLayer:d}})),[r,p,d]);return e.useEffect((()=>{null!==c&&o.current!==t&&(!0!==t.checked||null!=o.current.checked&&!1!==o.current.checked?!0!==o.current.checked||null!=t.checked&&!1!==t.checked||f.removeLayer(c):f.addLayer(c),o.current=t)})),t.children?u.default.createElement(l,{value:y},t.children):null}}T.BaseLayer=_((function(n,e,t){n.addBaseLayer(e,t)})),T.Overlay=_((function(n,e,t){n.addOverlay(e,t)}));const G=w((function({position:n,...e},t){const o=new r.Marker(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(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())})),A=["mapPane","markerPane","overlayPane","popupPane","shadowPane","tilePane","tooltipPane"],B={position:"absolute",top:0,right:0,bottom:0,left:0};function H(n,e){const{[e]:t,...r}=n;return r}const j=g((function({positions:n,...e},t){const o=new r.Polygon(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),V=g((function({positions:n,...e},t){const o=new r.Polyline(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),Z=x((function(n,e){return{instance:new r.Popup(n,e.overlayContainer),context:e}}),(function(n,t,r,o){const{onClose:u,onOpen:c,position:a}=r;e.useEffect((function(){const{instance:e}=n;function r(n){n.popup===e&&(e.update(),o(!0),null==c||c())}function l(n){n.popup===e&&(o(!1),null==u||u())}return t.map.on({popupopen:r,popupclose:l}),null==t.overlayContainer?(null!=a&&e.setLatLng(a),e.openOn(t.map)):t.overlayContainer.bindPopup(e),function(){t.map.off({popupopen:r,popupclose:l}),null==t.overlayContainer?t.map.removeLayer(e):t.overlayContainer.unbindPopup()}}),[n,t,o,u,c,a])})),q=g((function({bounds:n,...e},t){const o=new r.Rectangle(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(function(n,e,t){e.bounds!==t.bounds&&n.setBounds(e.bounds)})),U=b((function(n){return new r.Control.Scale(n)})),D=C(m((function(n,e){const{attributes:t,bounds:o,...u}=n,c=document.createElementNS("http://www.w3.org/2000/svg","svg");return c.setAttribute("xmlns","http://www.w3.org/2000/svg"),null!=t&&Object.keys(t).forEach((n=>{c.setAttribute(n,t[n])})),{instance:new r.SVGOverlay(c,o,u),container:c,context:e}}),O));function F({children:n,...r},o){const{instance:u,container:c}=D(r).current;return e.useImperativeHandle(o,(()=>u)),null==c||null==n?null:t.createPortal(n,c)}const J=e.forwardRef(F),W=L((function({url:n,...e},t){return{instance:new r.TileLayer(n,e),context:t}}),E),Y=x((function(n,e){return{instance:new r.Tooltip(n,e.overlayContainer),context:e}}),(function(n,t,r,o){const{onClose:u,onOpen:c}=r;e.useEffect((function(){const e=t.overlayContainer;if(null==e)return;const{instance:r}=n,a=n=>{n.tooltip===r&&(r.update(),o(!0),null==c||c())},l=n=>{n.tooltip===r&&(o(!1),null==u||u())};return e.on({tooltipopen:a,tooltipclose:l}),e.bindTooltip(r),function(){e.off({tooltipopen:a,tooltipclose:l}),e.unbindTooltip()}}),[n,t,o,u,c])})),K=w((function({bounds:n,url:e,...t},o){const u=new r.VideoOverlay(e,n,t);var c;!0===t.play&&(null==(c=u.getElement())||c.play());return{instance:u,context:{...o,overlayContainer:u}}}),(function(n,e,t){O(n,e,t),"string"==typeof e.url&&e.url!==t.url&&n.setUrl(e.url);const r=n.getElement();null!=r&&(!0!==e.play||t.play?e.play||!0!==t.play||r.pause():r.play())})),Q=L((function({params:n={},url:e,...t},o){return{instance:new r.TileLayer.WMS(e,{...n,...t}),context:o}}),(function(n,e,t){E(n,e,t),null!=e.params&&e.params!==t.params&&n.setParams(e.params)})),X=b((function(n){return new r.Control.Zoom(n)}));n.AttributionControl=P,n.Circle=I,n.CircleMarker=M,n.FeatureGroup=k,n.GeoJSON=N,n.ImageOverlay=S,n.LayerGroup=z,n.LayersControl=T,n.MapConsumer=function({children:n}){return n(R())},n.MapContainer=function({children:n,className:t,id:o,placeholder:c,style:a,whenCreated:i,...s}){const f=e.useRef(null),p=function(n,t){const[o,u]=e.useState(null);return e.useEffect((()=>{if(null!==n.current&&null===o){const e=new r.Map(n.current,t);null!=t.center&&null!=t.zoom?e.setView(t.center,t.zoom):null!=t.bounds&&e.fitBounds(t.bounds,t.boundsOptions),null!=t.whenReady&&e.whenReady(t.whenReady),u(e)}}),[n,o,t]),o}(f,s),d=e.useRef(!1);e.useEffect((()=>{null!=p&&!1===d.current&&null!=i&&(d.current=!0,i(p))}),[p,i]);const y=e.useMemo((()=>p?{__version:1,map:p}:null),[p]),m=y?u.default.createElement(l,{value:y},n):null!=c?c:null;return u.default.createElement("div",{ref:f,className:t,id:o,style:a},m)},n.Marker=G,n.Pane=function(n){const t=i(),o=e.useRef(null),c=e.useRef(n);function a(e){var t;null!=n.className&&(t=e,y(n.className).forEach((n=>{r.DomUtil.addClass(t,n)}))),null!=n.style&&Object.keys(n.style).forEach((t=>{e.style[t]=n.style[t]}))}function s(){const e=n.name;if(-1!==A.indexOf(e))throw new Error("You must use a unique name for a pane that is not a default Leaflet pane: "+e);if(null!=t.map.getPane(e))throw new Error("A pane with this name already exists: "+e);const r=t.pane?t.map.getPane(t.pane):void 0;o.current=t.map.createPane(e,r),a(o.current)}function f(n){const e=t.map.getPane(n);null==e||null==e.remove||e.remove(),null!=t.map._panes&&(t.map._panes=H(t.map._panes,n),t.map._paneRenderers=H(t.map._paneRenderers,n))}e.useEffect((function(){var e;return null===o.current?s():n!==c.current&&(n.name===c.current.name?(c.current.className&&n.className!==c.current.className&&(e=o.current,y(c.current.className).forEach((n=>{r.DomUtil.removeClass(e,n)}))),a(o.current)):(f(c.current.name),s())),function(){f(n.name)}}));const p=e.useMemo((()=>({...t,pane:n.name})),[t,n.name]);return n.children?u.default.createElement(l,{value:p},u.default.createElement("div",{style:B},n.children)):null},n.Polygon=j,n.Polyline=V,n.Popup=Z,n.Rectangle=q,n.SVGOverlay=J,n.ScaleControl=U,n.TileLayer=W,n.Tooltip=Y,n.VideoOverlay=K,n.WMSTileLayer=Q,n.ZoomControl=X,n.useMap=R,n.useMapEvent=function(n,t){const r=R();return e.useEffect((function(){return r.on(n,t),function(){r.off(n,t)}}),[r,n,t]),r},n.useMapEvents=function(n){const t=R();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("react-dom"),require("leaflet")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","leaflet"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).ReactLeaflet={},n.React,n.ReactDOM,n.L)}(this,(function(n,e,t,r){"use strict";function o(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var u=o(e);function c(n,t){const r=e.useRef(t);e.useEffect((function(){t!==r.current&&null!=n.attributionControl&&(null!=r.current&&n.attributionControl.removeAttribution(r.current),null!=t&&n.attributionControl.addAttribution(t)),r.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,r){const{instance:o,context:c}=n(t).current;return e.useImperativeHandle(r,(()=>o)),null==t.children?null:u.default.createElement(i,{value:c},t.children)}return e.forwardRef(t)}function p(n){function t(t,r){const{instance:o}=n(t).current;return e.useImperativeHandle(r,(()=>o)),null}return e.forwardRef(t)}function d(n){return function(t){const r=s(),o=n(t,r),{instance:u}=o.current,c=e.useRef(t.position),{position:a}=t;return e.useEffect((function(){return u.addTo(r.map),function(){u.remove()}}),[r.map,u]),e.useEffect((function(){null!=a&&a!==c.current&&(u.setPosition(a),c.current=a)}),[u,a]),o}}function y(n,t){const r=e.useRef();e.useEffect((function(){return null!=t&&n.instance.on(t),r.current=t,function(){null!=r.current&&n.instance.off(r.current),r.current=null}}),[n,t])}function m(n,e){var t;const r=null!=(t=n.pane)?t:e.pane;return r?{...n,pane:r}:n}function v(n){return n.split(" ").filter(Boolean)}function C(n,t){return null==t?function(t,r){return e.useRef(n(t,r))}:function(r,o){const u=e.useRef(n(r,o)),c=e.useRef(r),{instance:a}=u.current;return e.useEffect((function(){c.current!==r&&(t(a,r,c.current),c.current=r)}),[a,r,o]),u}}function b(n,t){e.useEffect((function(){var e;const r=null!=(e=t.layerContainer)?e:t.map;return r.addLayer(n.instance),function(){r.removeLayer(n.instance)}}),[t,n])}function h(n){return function(e){const t=s(),r=n(m(e,t),t);return c(t.map,e.attribution),y(r.current,e.eventHandlers),b(r.current,t),r}}function w(n){return function(t){const r=s(),o=n(t,r);return y(o.current,t.eventHandlers),b(o.current,r),function(n,t){const r=e.useRef();e.useEffect((function(){if(t.pathOptions!==r.current){var e;const o=null!=(e=t.pathOptions)?e:{};n.instance.setStyle(o),r.current=o}}),[n,t])}(o.current,t),o}}function x(n){return p(d(C((function(e,t){return{instance:n(e),context:t}}))))}function g(n,e){return f(h(C(n,e)))}function L(n,r){return function(n){function r(r,o){const[u,c]=e.useState(!1),{instance:a}=n(r,c).current;e.useImperativeHandle(o,(()=>a)),e.useEffect((function(){u&&a.update()}),[a,u,r.children]);const l=a._contentNode;return l?t.createPortal(r.children,l):null}return e.forwardRef(r)}(function(n,e){return function(t,r){const o=s(),u=n(m(t,o),o);return c(o.map,t.attribution),y(u.current,t.eventHandlers),e(u.current,o,t,r),u}}(C(n),r))}function E(n,e){return f(w(C(n,e)))}function O(n,e){return p(h(C(n,e)))}function R(n,e,t){const{opacity:r,zIndex:o}=e;null!=r&&r!==t.opacity&&n.setOpacity(r),null!=o&&o!==t.zIndex&&n.setZIndex(o)}function P(n,e,t){e.bounds instanceof r.LatLngBounds&&e.bounds!==t.bounds&&n.setBounds(e.bounds),null!=e.opacity&&e.opacity!==t.opacity&&n.setOpacity(e.opacity),null!=e.zIndex&&e.zIndex!==t.zIndex&&n.setZIndex(e.zIndex)}function I(){return s().map}const M=x((function(n){return new r.Control.Attribution(n)})),k=E((function({center:n,children:e,...t},o){const u=new r.Circle(n,t);return{instance:u,context:{...o,overlayContainer:u}}}),a),N=E((function({center:n,children:e,...t},o){const u=new r.CircleMarker(n,t);return{instance:u,context:{...o,overlayContainer:u}}}),a),S=E((function({children:n,...e},t){const o=new r.FeatureGroup([],e);return{instance:o,context:{...t,layerContainer:o,overlayContainer:o}}})),z=E((function({data:n,...e},t){const o=new r.GeoJSON(n,e);return{instance:o,context:{...t,overlayContainer:o}}})),T=g((function({bounds:n,url:e,...t},o){const u=new r.ImageOverlay(e,n,t);return{instance:u,context:{...o,overlayContainer:u}}}),(function(n,e,t){P(n,e,t),e.url!==t.url&&n.setUrl(e.url)})),_=g((function({children:n,...e},t){const o=new r.LayerGroup([],e);return{instance:o,context:{...t,layerContainer:o}}})),G=f(d(C((function({children:n,...e},t){const o=new r.Control.Layers(void 0,void 0,e);return{instance:o,context:{...t,layersControl:o}}}),(function(n,e,t){e.collapsed!==t.collapsed&&(!0===e.collapsed?n.collapse():n.expand())}))));function A(n){return function(t){const r=s(),o=e.useRef(t),[c,a]=e.useState(null),{layersControl:l,map:f}=r,p=e.useCallback((e=>{null!=l&&(o.current.checked&&f.addLayer(e),n(l,e,o.current.name),a(e))}),[l,f]),d=e.useCallback((n=>{null==l||l.removeLayer(n),a(null)}),[l]),y=e.useMemo((()=>({...r,layerContainer:{addLayer:p,removeLayer:d}})),[r,p,d]);return e.useEffect((()=>{null!==c&&o.current!==t&&(!0!==t.checked||null!=o.current.checked&&!1!==o.current.checked?!0!==o.current.checked||null!=t.checked&&!1!==t.checked||f.removeLayer(c):f.addLayer(c),o.current=t)})),t.children?u.default.createElement(i,{value:y},t.children):null}}G.BaseLayer=A((function(n,e,t){n.addBaseLayer(e,t)})),G.Overlay=A((function(n,e,t){n.addOverlay(e,t)}));const B=g((function({position:n,...e},t){const o=new r.Marker(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(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"],j={position:"absolute",top:0,right:0,bottom:0,left:0};function V(n,e){const{[e]:t,...r}=n;return r}const Z=E((function({positions:n,...e},t){const o=new r.Polygon(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),q=E((function({positions:n,...e},t){const o=new r.Polyline(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(function(n,e,t){e.positions!==t.positions&&n.setLatLngs(e.positions)})),U=L((function(n,e){return{instance:new r.Popup(n,e.overlayContainer),context:e}}),(function(n,t,r,o){const{onClose:u,onOpen:c,position:a}=r;e.useEffect((function(){const{instance:e}=n;function r(n){n.popup===e&&(e.update(),o(!0),null==c||c())}function l(n){n.popup===e&&(o(!1),null==u||u())}return t.map.on({popupopen:r,popupclose:l}),null==t.overlayContainer?(null!=a&&e.setLatLng(a),e.openOn(t.map)):t.overlayContainer.bindPopup(e),function(){t.map.off({popupopen:r,popupclose:l}),null==t.overlayContainer?t.map.removeLayer(e):t.overlayContainer.unbindPopup()}}),[n,t,o,u,c,a])})),D=E((function({bounds:n,...e},t){const o=new r.Rectangle(n,e);return{instance:o,context:{...t,overlayContainer:o}}}),(function(n,e,t){e.bounds!==t.bounds&&n.setBounds(e.bounds)})),F=x((function(n){return new r.Control.Scale(n)})),J=h(C((function(n,e){const{attributes:t,bounds:o,...u}=n,c=document.createElementNS("http://www.w3.org/2000/svg","svg");return c.setAttribute("xmlns","http://www.w3.org/2000/svg"),null!=t&&Object.keys(t).forEach((n=>{c.setAttribute(n,t[n])})),{instance:new r.SVGOverlay(c,o,u),container:c,context:e}}),P));function W({children:n,...r},o){const{instance:u,container:c}=J(r).current;return e.useImperativeHandle(o,(()=>u)),null==c||null==n?null:t.createPortal(n,c)}const Y=e.forwardRef(W),K=O((function({url:n,...e},t){return{instance:new r.TileLayer(n,m(e,t)),context:t}}),R),Q=L((function(n,e){return{instance:new r.Tooltip(n,e.overlayContainer),context:e}}),(function(n,t,r,o){const{onClose:u,onOpen:c}=r;e.useEffect((function(){const e=t.overlayContainer;if(null==e)return;const{instance:r}=n,a=n=>{n.tooltip===r&&(r.update(),o(!0),null==c||c())},l=n=>{n.tooltip===r&&(o(!1),null==u||u())};return e.on({tooltipopen:a,tooltipclose:l}),e.bindTooltip(r),function(){e.off({tooltipopen:a,tooltipclose:l}),e.unbindTooltip()}}),[n,t,o,u,c])})),X=g((function({bounds:n,url:e,...t},o){const u=new r.VideoOverlay(e,n,t);var c;!0===t.play&&(null==(c=u.getElement())||c.play());return{instance:u,context:{...o,overlayContainer:u}}}),(function(n,e,t){P(n,e,t),"string"==typeof e.url&&e.url!==t.url&&n.setUrl(e.url);const r=n.getElement();null!=r&&(!0!==e.play||t.play?e.play||!0!==t.play||r.pause():r.play())})),$=O((function({params:n={},url:e,...t},o){return{instance:new r.TileLayer.WMS(e,{...n,...m(t,o)}),context:o}}),(function(n,e,t){R(n,e,t),null!=e.params&&e.params!==t.params&&n.setParams(e.params)})),nn=x((function(n){return new r.Control.Zoom(n)}));n.AttributionControl=M,n.Circle=k,n.CircleMarker=N,n.FeatureGroup=S,n.GeoJSON=z,n.ImageOverlay=T,n.LayerGroup=_,n.LayersControl=G,n.MapConsumer=function({children:n}){return n(I())},n.MapContainer=function({children:n,className:t,id:o,placeholder:c,style:a,whenCreated:l,...s}){const f=e.useRef(null),p=function(n,t){const[o,u]=e.useState(null);return e.useEffect((()=>{if(null!==n.current&&null===o){const e=new r.Map(n.current,t);null!=t.center&&null!=t.zoom?e.setView(t.center,t.zoom):null!=t.bounds&&e.fitBounds(t.bounds,t.boundsOptions),null!=t.whenReady&&e.whenReady(t.whenReady),u(e)}}),[n,o,t]),o}(f,s),d=e.useRef(!1);e.useEffect((()=>{null!=p&&!1===d.current&&null!=l&&(d.current=!0,l(p))}),[p,l]);const y=e.useMemo((()=>p?{__version:1,map:p}:null),[p]),m=y?u.default.createElement(i,{value:y},n):null!=c?c:null;return u.default.createElement("div",{ref:f,className:t,id:o,style:a},m)},n.Marker=B,n.Pane=function(n){const t=s(),o=e.useRef(null),c=e.useRef(n);function a(e){var t;null!=n.className&&(t=e,v(n.className).forEach((n=>{r.DomUtil.addClass(t,n)}))),null!=n.style&&Object.keys(n.style).forEach((t=>{e.style[t]=n.style[t]}))}function l(){const e=n.name;if(-1!==H.indexOf(e))throw new Error("You must use a unique name for a pane that is not a default Leaflet pane: "+e);if(null!=t.map.getPane(e))throw new Error("A pane with this name already exists: "+e);const r=t.pane?t.map.getPane(t.pane):void 0;o.current=t.map.createPane(e,r),a(o.current)}function f(n){const e=t.map.getPane(n);null==e||null==e.remove||e.remove(),null!=t.map._panes&&(t.map._panes=V(t.map._panes,n),t.map._paneRenderers=V(t.map._paneRenderers,n))}e.useEffect((function(){var e;return null===o.current?l():n!==c.current&&(n.name===c.current.name?(c.current.className&&n.className!==c.current.className&&(e=o.current,v(c.current.className).forEach((n=>{r.DomUtil.removeClass(e,n)}))),a(o.current)):(f(c.current.name),l())),function(){f(n.name)}}));const p=e.useMemo((()=>({...t,pane:n.name})),[t,n.name]);return n.children?u.default.createElement(i,{value:p},u.default.createElement("div",{style:j},n.children)):null},n.Polygon=Z,n.Polyline=q,n.Popup=U,n.Rectangle=D,n.SVGOverlay=Y,n.ScaleControl=F,n.TileLayer=K,n.Tooltip=Q,n.VideoOverlay=X,n.WMSTileLayer=$,n.ZoomControl=nn,n.useMap=I,n.useMapEvent=function(n,t){const r=I();return e.useEffect((function(){return r.on(n,t),function(){r.off(n,t)}}),[r,n,t]),r},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})})); |
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
116626
0
2603