Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@evergis/react

Package Overview
Dependencies
Maintainers
6
Versions
357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/react - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

dist/components/Layers/EvergisDynamicLayer.d.ts

10

dist/components/index.d.ts
export * from './Measurer/Measurer';
export { MeasureTool } from './Measurer/MeasureTool';
export { Map } from './Map/Map';
export { EvergisDynamicLayer } from './Map/EvergisDynamicLayer';
export { EvergisTileLayer } from './Map/EvergisTileLayer';
export { FeatureLayer } from './Map/FeatureLayer';
export { TileLayer } from './Map/TileLayer';
export * from './Map/Map';
export { EvergisDynamicLayer } from './Layers/EvergisDynamicLayer';
export { EvergisTileLayer, AVAILABLE_BASE_MAPS, } from './Layers/EvergisTileLayer';
export { FeatureLayer } from './Layers/FeatureLayer';
export { TileLayer } from './Layers/TileLayer';

@@ -1,5 +0,5 @@

import React, { CSSProperties } from 'react';
import { CSSProperties, PropsWithChildren } from 'react';
import { MapState } from '../../hooks';
import { Coordinates } from '@evergis/sgis/es/baseTypes';
import { MapState } from '../../hooks/useMapBboxChange';
declare type MapProps = {
export declare type MapProps = {
className?: string;

@@ -13,3 +13,2 @@ position?: Coordinates;

};
export declare const Map: React.FC<MapProps>;
export {};
export declare const Map: ({ className, position, resolution, minScale, maxScale, children, onBboxChange, style, }: PropsWithChildren<MapProps>) => JSX.Element;

@@ -9,4 +9,3 @@ import React from 'react';

import { renderLabelSymbolType } from './Measurer';
import { BaseMeasureToolCreator } from '../../controls/BaseMeasureToolCreator';
import { BaseMeasureToolEditor } from '../../controls/BaseMeasureToolEditor';
import { BaseMeasureToolCreator, BaseMeasureToolEditor } from '../../controls';
declare type Props = {

@@ -13,0 +12,0 @@ map: SMap;

@@ -1,2 +0,2 @@

import * as React from 'react';
import React from 'react';
import { Api } from '@evergis/api';

@@ -3,0 +3,0 @@ declare type EvergisProviderProps = {

@@ -1,2 +0,2 @@

import * as React from 'react';
import React from 'react';
import { Map } from '@evergis/sgis/es/Map';

@@ -3,0 +3,0 @@ import { DomPainter } from '@evergis/sgis/es/painters/DomPainter/DomPainter';

@@ -18,2 +18,2 @@ export * from './LayerProps';

export { useUpdate } from './useUpdate';
export { useUpdateMapView } from './useUpdateMapView';
export { useUpdateMapView, shouldUpdateMapState } from './useUpdateMapView';

@@ -5,4 +5,6 @@ import { Coordinates } from '@evergis/sgis/es/baseTypes';

zoomTo: (k: number) => void;
zoomIn: () => void;
zoomOut: () => void;
zoomAround: (event: sGisClickEvent) => void;
animateTo: ({ position, resolution, extent }: AnimateToParams) => void;
zoomAround: (event: sGisClickEvent) => void;
};

@@ -9,0 +11,0 @@ declare type AnimateToParams = {

@@ -9,2 +9,3 @@ 'use strict';

var React__default = _interopDefault(React);
var api = require('@evergis/api');
var _Map = require('@evergis/sgis/es/Map');

@@ -15,8 +16,10 @@ var DomPainter = require('@evergis/sgis/es/painters/DomPainter/DomPainter');

var Polygon = require('@evergis/sgis/es/features/Polygon');
var ReactDOM = _interopDefault(require('react-dom'));
var _Symbol = require('@evergis/sgis/es/symbols/Symbol');
var Arc = require('@evergis/sgis/es/renders/Arc');
var Point = require('@evergis/sgis/es/symbols/point/Point');
var PointFeature = require('@evergis/sgis/es/features/PointFeature');
var PolylineSymbol = require('@evergis/sgis/es/symbols/PolylineSymbol');
var Poly = require('@evergis/sgis/es/features/Poly');
var Poly$1 = require('@evergis/sgis/es/renders/Poly');
var Arc = require('@evergis/sgis/es/renders/Arc');
var Point = require('@evergis/sgis/es/symbols/point/Point');
var PointFeature = require('@evergis/sgis/es/features/PointFeature');
var PolylineControl = require('@evergis/sgis/es/controls/PolylineControl');

@@ -27,12 +30,28 @@ var Label = require('@evergis/sgis/es/features/Label');

var Control = require('@evergis/sgis/es/controls/Control');
var ReactDOM = _interopDefault(require('react-dom'));
var _Symbol = require('@evergis/sgis/es/symbols/Symbol');
var math = require('@evergis/sgis/es/utils/math');
var PolyEditor = require('@evergis/sgis/es/controls/PolyEditor');
var sgis = require('@evergis/sgis');
var commonEvents = require('@evergis/sgis/es/commonEvents');
var Bbox = require('@evergis/sgis/es/Bbox');
var api = require('@evergis/api');
var sgis = require('@evergis/sgis');
var TileLayer$1 = require('@evergis/sgis/es/layers/TileLayer');
var commonEvents = require('@evergis/sgis/es/commonEvents');
var BASE_URL = '/';
var defaultApi = /*#__PURE__*/new api.Api({
url: BASE_URL
});
var evergisContext = /*#__PURE__*/React.createContext(defaultApi);
var EvergisProvider = function EvergisProvider(_ref) {
var api = _ref.api,
children = _ref.children;
var value = React.useMemo(function () {
return api || defaultApi;
}, [api]);
return React__default.createElement(evergisContext.Provider, {
value: value
}, children);
};
var useEvergisContext = function useEvergisContext() {
return React.useContext(evergisContext);
};
var defaultMap = /*#__PURE__*/new _Map.Map();

@@ -53,3 +72,3 @@ var defaultPainter = /*#__PURE__*/new DomPainter.DomPainter(defaultMap);

}, [map]);
return React.createElement(mapContext.Provider, {
return React__default.createElement(mapContext.Provider, {
value: value

@@ -253,2 +272,82 @@ }, children);

var LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
_inherits(LabelSymbol, _DynamicPointSymbol);
var _super = /*#__PURE__*/_createSuper(LabelSymbol);
function LabelSymbol(_temp) {
var _this;
var _ref = _temp === void 0 ? {} : _temp,
component = _ref.component,
offset = _ref.offset;
_classCallCheck(this, LabelSymbol);
_this = _super.call(this, {
offset: offset
});
_this.component = component;
return _this;
}
_createClass(LabelSymbol, [{
key: "_getFeatureNode",
value: function _getFeatureNode(feature) {
var node = document.createElement('div');
this.renderDom(feature.content, node);
return node;
}
}, {
key: "_updateFeatureNode",
value: function _updateFeatureNode(feature) {
this.renderDom(feature.content, this.getNode(feature));
}
}, {
key: "renderDom",
value: function renderDom(content, node) {
if (!node) {
return;
}
var Component = this.component;
if (Component) {
ReactDOM.render(React__default.createElement(Component, {
content: content
}), node);
} else {
node.innerText = content;
}
}
}]);
return LabelSymbol;
}(_Symbol.DynamicPointSymbol);
var defaultOffset = [8, -16];
var createLabelSymbol = function createLabelSymbol(props) {
var _ref = props || {},
_ref$offset = _ref.offset,
offset = _ref$offset === void 0 ? defaultOffset : _ref$offset,
_ref$renderLabel = _ref.renderLabel,
renderLabel = _ref$renderLabel === void 0 ? function (_ref2) {
var content = _ref2.content;
return React__default.createElement("div", null, content);
} : _ref$renderLabel,
_ref$onClose = _ref.onClose,
onClose = _ref$onClose === void 0 ? undefined : _ref$onClose;
return new LabelSymbol({
offset: offset,
component: function component(_ref3) {
var content = _ref3.content;
return renderLabel({
content: content,
onClose: onClose
});
}
});
};
function createShadowRender(position, _ref) {

@@ -484,82 +583,2 @@ var _ref$strokeWidth = _ref.strokeWidth,

var LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
_inherits(LabelSymbol, _DynamicPointSymbol);
var _super = /*#__PURE__*/_createSuper(LabelSymbol);
function LabelSymbol(_temp) {
var _this;
var _ref = _temp === void 0 ? {} : _temp,
component = _ref.component,
offset = _ref.offset;
_classCallCheck(this, LabelSymbol);
_this = _super.call(this, {
offset: offset
});
_this.component = component;
return _this;
}
_createClass(LabelSymbol, [{
key: "_getFeatureNode",
value: function _getFeatureNode(feature) {
var node = document.createElement('div');
this.renderDom(feature.content, node);
return node;
}
}, {
key: "_updateFeatureNode",
value: function _updateFeatureNode(feature) {
this.renderDom(feature.content, this.getNode(feature));
}
}, {
key: "renderDom",
value: function renderDom(content, node) {
if (!node) {
return;
}
var Component = this.component;
if (Component) {
ReactDOM.render(React__default.createElement(Component, {
content: content
}), node);
} else {
node.innerText = content;
}
}
}]);
return LabelSymbol;
}(_Symbol.DynamicPointSymbol);
var defaultOffset = [8, -16];
var createLabelSymbol = function createLabelSymbol(props) {
var _ref = props || {},
_ref$offset = _ref.offset,
offset = _ref$offset === void 0 ? defaultOffset : _ref$offset,
_ref$renderLabel = _ref.renderLabel,
renderLabel = _ref$renderLabel === void 0 ? function (_ref2) {
var content = _ref2.content;
return React__default.createElement("div", null, content);
} : _ref$renderLabel,
_ref$onClose = _ref.onClose,
onClose = _ref$onClose === void 0 ? undefined : _ref$onClose;
return new LabelSymbol({
offset: offset,
component: function component(_ref3) {
var content = _ref3.content;
return renderLabel({
content: content,
onClose: onClose
});
}
});
};
function polylineLikePolygon(rings, resolution) {

@@ -701,7 +720,7 @@ if (rings[0].length <= 3) {

lat = _projection[0],
_long = _projection[1];
long = _projection[1];
this.removeTempLabel();
this.addMeasureResultLabel();
this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + _long.toFixed(COORD_FRACTION), point);
this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
} else {

@@ -1100,124 +1119,2 @@ this.removeCoordLabel();

var byScale = function byScale(scale) {
return function (_ref) {
var zIndex = _ref.zIndex;
return zIndex === scale;
};
};
var useMaxMinScale = function useMaxMinScale(minScale, maxScale, currentPosition, currentResolution) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
React.useEffect(function () {
var levels = map.tileScheme.levels;
if (maxScale !== undefined) {
var _ref2 = levels.find(byScale(maxScale)) || {
resolution: -1
},
resolution = _ref2.resolution;
map.minResolution = resolution;
}
if (minScale !== undefined) {
var _ref3 = levels.find(byScale(minScale)) || {
resolution: -1
},
_resolution = _ref3.resolution;
map.maxResolution = _resolution;
}
if (minScale !== undefined || maxScale !== undefined) {
updateMapResolution(map, currentPosition, currentResolution);
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, minScale, maxScale]);
};
var updateMapResolution = function updateMapResolution(map, currentPosition, currentResolution) {
if (currentPosition && currentResolution) {
var newResolution = Math.min(Math.max(currentResolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE);
map.animateTo(currentPosition, newResolution);
}
};
function useMapViewActions() {
var _useMapContext = useMapContext(),
map = _useMapContext.map,
painter = _useMapContext.painter;
var zoomTo = React.useCallback(function (k) {
map.zoom(k, map.position);
}, [map]);
var animateTo = React.useCallback(function (_ref) {
var position = _ref.position,
resolution = _ref.resolution,
extent = _ref.extent;
if (position || resolution) {
var nextPosition = position ? position.slice(0) : map.position;
map.animateTo(nextPosition, resolution || map.resolution);
}
if (extent) {
var xMax = extent.xMax,
xMin = extent.xMin,
yMax = extent.yMax,
yMin = extent.yMin;
var bbox = new Bbox.Bbox([xMin, yMax], [xMax, yMin], map.crs);
painter && painter.show(bbox, true);
}
}, [map, painter]);
var zoomAround = React.useCallback(function (event) {
var _event$sourceObject;
map.zoom(1, event === null || event === void 0 ? void 0 : (_event$sourceObject = event.sourceObject) === null || _event$sourceObject === void 0 ? void 0 : _event$sourceObject.point);
}, [map]);
return {
zoomTo: zoomTo,
animateTo: animateTo,
zoomAround: zoomAround
};
}
function useUpdateMapView(_ref, force) {
var position = _ref.position,
resolution = _ref.resolution;
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var _useMapViewActions = useMapViewActions(),
animateTo = _useMapViewActions.animateTo;
React.useEffect(function () {
if (shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
animateTo({
position: position,
resolution: resolution
});
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [position, resolution, force]);
}
function shouldUpdatePosition(map, position) {
return position && (!math.softEquals(map.position[0], position[0]) || !math.softEquals(map.position[1], position[1]));
}
function shouldUpdateResolution(map, resolution) {
return resolution && !math.softEquals(map.resolution, resolution);
}
function shouldUpdateMapState(map, _ref2) {
var position = _ref2.position,
resolution = _ref2.resolution;
return shouldUpdatePosition(map, position) || shouldUpdateResolution(map, resolution);
}
function useMount(_ref) {

@@ -1232,75 +1129,2 @@ var onMount = _ref.onMount,

function useMapWrapper() {
var _useMapContext = useMapContext(),
painter = _useMapContext.painter;
var wrapperRef = React.useRef(null);
useMount({
onMount: function onMount() {
return painter.wrapper = wrapperRef.current;
},
onUnmount: function onUnmount() {
return painter.wrapper = null;
}
});
return wrapperRef;
}
function useMapBboxChange(onBboxChange, force) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var event = force ? _Map.BboxChangeEvent : _Map.BboxChangeEndEvent;
var handleBboxChange = React.useCallback(function () {
onBboxChange && onBboxChange(getMapState(map)); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onBboxChange, map, event]);
React.useEffect(function () {
map.on(event.type, handleBboxChange);
return function () {
map.off(event.type, handleBboxChange);
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleBboxChange, event]);
}
function getMapState(map) {
return {
position: map.position.slice(0),
resolution: map.resolution
};
}
var Map = function Map(_ref) {
var className = _ref.className,
position = _ref.position,
resolution = _ref.resolution,
minScale = _ref.minScale,
maxScale = _ref.maxScale,
children = _ref.children,
onBboxChange = _ref.onBboxChange,
style = _ref.style;
var wrapperRef = useMapWrapper();
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var handleBboxChange = React.useCallback(function (state) {
if (onBboxChange && shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
onBboxChange(state);
}
}, [map, onBboxChange, position, resolution]);
useUpdateMapView({
position: position,
resolution: resolution
});
useMaxMinScale(minScale, maxScale, position, resolution);
useMapBboxChange(handleBboxChange);
return React__default.createElement("div", {
className: className,
ref: wrapperRef,
style: style
}, children);
};
function useProperty(_ref, deps) {

@@ -1344,20 +1168,2 @@ var factory = _ref.factory,

var defaultApi = /*#__PURE__*/new api.Api({
url: '/'
});
var evergisContext = /*#__PURE__*/React.createContext(defaultApi);
var EvergisProvider = function EvergisProvider(_ref) {
var api = _ref.api,
children = _ref.children;
var value = React.useMemo(function () {
return api || defaultApi;
}, [api]);
return React.createElement(evergisContext.Provider, {
value: value
}, children);
};
var useEvergisContext = function useEvergisContext() {
return React.useContext(evergisContext);
};
function useUpdate(_ref) {

@@ -1437,7 +1243,2 @@ var onUpdate = _ref.onUpdate,

var EvergisDynamicLayer = function EvergisDynamicLayer(props) {
useEvergisDynamicLayer(props);
return null;
};
function useEvergisTileLayer(_ref) {

@@ -1477,7 +1278,2 @@ var name = _ref.name,

var EvergisTileLayer = function EvergisTileLayer(props) {
useEvergisTileLayer(props);
return null;
};
function useFeatureLayer(_ref) {

@@ -1511,33 +1307,24 @@ var zIndex = _ref.zIndex,

var FeatureLayer = function FeatureLayer(props) {
useFeatureLayer(props);
return null;
};
function useTileLayer(_ref) {
var maskUrl = _ref.maskUrl,
zIndex = _ref.zIndex,
isDisplayed = _ref.isDisplayed;
function useMapBboxChange(onBboxChange, force) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var layer = useProperty({
factory: function factory() {
return new TileLayer$1.TileLayer(maskUrl);
},
destructor: function destructor(layer) {
return map.indexOf(layer) !== -1 && map.removeLayer(layer);
}
}, [maskUrl]);
useLayerOrder(layer, zIndex);
useLayerVisibility(layer, isDisplayed);
return layer;
var event = force ? _Map.BboxChangeEvent : _Map.BboxChangeEndEvent;
var handleBboxChange = React.useCallback(function () {
onBboxChange && onBboxChange(getMapState(map)); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onBboxChange, map, event]);
React.useEffect(function () {
map.on(event.type, handleBboxChange);
return function () {
map.off(event.type, handleBboxChange);
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleBboxChange, event]);
}
function getMapState(map) {
return {
position: map.position.slice(0),
resolution: map.resolution
};
}
var TileLayer = function TileLayer(props) {
useTileLayer(props);
return null;
};
var useMapPick = function useMapPick() {

@@ -1665,2 +1452,110 @@ var _useMapContext = useMapContext(),

function useMapViewActions() {
var _useMapContext = useMapContext(),
map = _useMapContext.map,
painter = _useMapContext.painter;
var zoomTo = React.useCallback(function (k) {
map.zoom(k, map.position);
}, [map]);
var zoomIn = React.useCallback(function () {
return zoomTo(1);
}, [zoomTo]);
var zoomOut = React.useCallback(function () {
return zoomTo(-1);
}, [zoomTo]);
var animateTo = React.useCallback(function (_ref) {
var position = _ref.position,
resolution = _ref.resolution,
extent = _ref.extent;
if (position || resolution) {
var nextPosition = position ? position.slice(0) : map.position;
map.animateTo(nextPosition, resolution || map.resolution);
}
if (extent) {
var xMax = extent.xMax,
xMin = extent.xMin,
yMax = extent.yMax,
yMin = extent.yMin;
var bbox = new Bbox.Bbox([xMin, yMax], [xMax, yMin], map.crs);
painter && painter.show(bbox, true);
}
}, [map, painter]);
var zoomAround = React.useCallback(function (event) {
var _event$sourceObject;
map.zoom(1, event === null || event === void 0 ? void 0 : (_event$sourceObject = event.sourceObject) === null || _event$sourceObject === void 0 ? void 0 : _event$sourceObject.point);
}, [map]);
return {
zoomTo: zoomTo,
zoomIn: zoomIn,
zoomOut: zoomOut,
zoomAround: zoomAround,
animateTo: animateTo
};
}
function useMapWrapper() {
var _useMapContext = useMapContext(),
painter = _useMapContext.painter;
var wrapperRef = React.useRef(null);
useMount({
onMount: function onMount() {
return painter.wrapper = wrapperRef.current;
},
onUnmount: function onUnmount() {
return painter.wrapper = null;
}
});
return wrapperRef;
}
var byScale = function byScale(scale) {
return function (_ref) {
var zIndex = _ref.zIndex;
return zIndex === scale;
};
};
var useMaxMinScale = function useMaxMinScale(minScale, maxScale, currentPosition, currentResolution) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
React.useEffect(function () {
var levels = map.tileScheme.levels;
if (maxScale !== undefined) {
var _ref2 = levels.find(byScale(maxScale)) || {
resolution: -1
},
resolution = _ref2.resolution;
map.minResolution = resolution;
}
if (minScale !== undefined) {
var _ref3 = levels.find(byScale(minScale)) || {
resolution: -1
},
_resolution = _ref3.resolution;
map.maxResolution = _resolution;
}
if (minScale !== undefined || maxScale !== undefined) {
updateMapResolution(map, currentPosition, currentResolution);
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, minScale, maxScale]);
};
var updateMapResolution = function updateMapResolution(map, currentPosition, currentResolution) {
if (currentPosition && currentResolution) {
var newResolution = Math.min(Math.max(currentResolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE);
map.animateTo(currentPosition, newResolution);
}
};
function getScale(scale) {

@@ -1712,2 +1607,118 @@ var pow10 = Math.pow(10, (Math.floor(scale) + '').length - 1);

function useUpdateMapView(_ref, force) {
var position = _ref.position,
resolution = _ref.resolution;
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var _useMapViewActions = useMapViewActions(),
animateTo = _useMapViewActions.animateTo;
React.useEffect(function () {
if (shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
animateTo({
position: position,
resolution: resolution
});
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [position, resolution, force]);
}
function shouldUpdatePosition(map, position) {
return position && (!math.softEquals(map.position[0], position[0]) || !math.softEquals(map.position[1], position[1]));
}
function shouldUpdateResolution(map, resolution) {
return resolution && !math.softEquals(map.resolution, resolution);
}
function shouldUpdateMapState(map, _ref2) {
var position = _ref2.position,
resolution = _ref2.resolution;
return shouldUpdatePosition(map, position) || shouldUpdateResolution(map, resolution);
}
var Map = function Map(_ref) {
var className = _ref.className,
position = _ref.position,
resolution = _ref.resolution,
minScale = _ref.minScale,
maxScale = _ref.maxScale,
children = _ref.children,
onBboxChange = _ref.onBboxChange,
style = _ref.style;
var wrapperRef = useMapWrapper();
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var handleBboxChange = React.useCallback(function (state) {
if (onBboxChange && shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
onBboxChange(state);
}
}, [map, onBboxChange, position, resolution]);
useUpdateMapView({
position: position,
resolution: resolution
});
useMaxMinScale(minScale, maxScale, position, resolution);
useMapBboxChange(handleBboxChange);
return React__default.createElement("div", {
className: className,
ref: wrapperRef,
style: style
}, children);
};
var EvergisDynamicLayer = function EvergisDynamicLayer(props) {
useEvergisDynamicLayer(props);
return null;
};
var AVAILABLE_BASE_MAPS = ['2gis', 'osm_mono', 'carto_dm', 'sputnik', 'stamen_terrain', 'stamen_toner', 'stamen_watercolor'];
var EvergisTileLayer = function EvergisTileLayer(props) {
useEvergisTileLayer(props);
return null;
};
var FeatureLayer = function FeatureLayer(props) {
useFeatureLayer(props);
return null;
};
function useTileLayer(_ref) {
var maskUrl = _ref.maskUrl,
zIndex = _ref.zIndex,
isDisplayed = _ref.isDisplayed;
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var layer = useProperty({
factory: function factory() {
return new TileLayer$1.TileLayer(maskUrl);
},
destructor: function destructor(layer) {
return map.indexOf(layer) !== -1 && map.removeLayer(layer);
}
}, [maskUrl]);
useLayerOrder(layer, zIndex);
useLayerVisibility(layer, isDisplayed);
return layer;
}
var TileLayer = function TileLayer(props) {
useTileLayer(props);
return null;
};
exports.AVAILABLE_BASE_MAPS = AVAILABLE_BASE_MAPS;
exports.BaseMeasureToolCreator = BaseMeasureToolCreator;

@@ -1737,2 +1748,3 @@ exports.BaseMeasureToolEditor = BaseMeasureToolEditor;

exports.measurePolygonSnapSymbol = measurePolygonSnapSymbol;
exports.shouldUpdateMapState = shouldUpdateMapState;
exports.useEvergisContext = useEvergisContext;

@@ -1739,0 +1751,0 @@ exports.useEvergisDynamicLayer = useEvergisDynamicLayer;

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),o=require("@evergis/sgis/es/Map"),n=require("@evergis/sgis/es/painters/DomPainter/DomPainter"),i=require("@evergis/sgis/es/features/Polyline"),s=require("@evergis/sgis/es/layers/FeatureLayer"),a=require("@evergis/sgis/es/features/Polygon"),u=require("@evergis/sgis/es/symbols/PolylineSymbol"),l=require("@evergis/sgis/es/features/Poly"),c=require("@evergis/sgis/es/renders/Poly"),f=require("@evergis/sgis/es/renders/Arc"),d=require("@evergis/sgis/es/symbols/point/Point"),h=require("@evergis/sgis/es/features/PointFeature"),p=require("@evergis/sgis/es/controls/PolylineControl"),v=require("@evergis/sgis/es/features/Label"),m=require("@evergis/sgis/es/geotools"),y=require("@evergis/sgis/es/Crs"),b=require("@evergis/sgis/es/controls/Control"),g=e(require("react-dom")),L=require("@evergis/sgis/es/symbols/Symbol"),w=require("@evergis/sgis/es/utils/math"),x=require("@evergis/sgis/es/controls/PolyEditor"),C=require("@evergis/sgis/es/Bbox"),k=require("@evergis/api"),P=require("@evergis/sgis"),S=require("@evergis/sgis/es/layers/TileLayer"),M=require("@evergis/sgis/es/commonEvents"),R=new o.Map,E=new n.DomPainter(R),F=t.createContext({map:R,painter:E}),_=function(){return t.useContext(F)};function A(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function q(e,t,r){return t&&D(e.prototype,t),r&&D(e,r),e}function z(){return(z=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function T(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=O(e);if(t){var n=O(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return j(this,r)}}function U(e,t,r){return(U="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=O(e)););return e}(e,t);if(o){var n=Object.getOwnPropertyDescriptor(o,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function V(e,t){var r=t.strokeWidth,o=t.shadowSize,n=t.size;return new f.Arc(e,{fillColor:"transparent",strokeColor:t.shadowColor,strokeWidth:o,radius:((void 0===n?6:n)+(void 0===r?2:r)+o)/2})}function B(e,t){var r=t.strokeColor,o=t.strokeWidth,n=t.fillColor,i=t.size,s=void 0===i?0:i,a=s/2;return[V(e,{strokeWidth:o,strokeColor:r,shadowSize:t.shadowSize,shadowColor:t.shadowColor,size:s}),new f.Arc(e,{fillColor:n,strokeColor:r,strokeWidth:o,radius:a})]}var N=function(e){T(r,d.PointSymbol);var t=W(r);function r(e){return A(this,r),t.call(this,e)}return q(r,[{key:"renderFunction",value:function(e,t,r){if(!(e instanceof h.PointFeature))return[];var o=e.projectTo(r).position,n=[o[0]/t+(this.offset[0]||0),-o[1]/t+(this.offset[1]||0)],i=this.getShadow(n),s=this.getPoint(n);return i?[i,s]:[s]}},{key:"getShadow",value:function(e){return r.getShadowArc(e,this)}},{key:"getPoint",value:function(e){return r.getPointArc(e,this)}}],[{key:"getShadowArc",value:function(e,t){var r=t.strokeWidth,o=t.shadowSize,n=t.size;return new f.Arc(e,{fillColor:"transparent",strokeColor:t.shadowColor,strokeWidth:o,radius:((void 0===n?6:n)+(void 0===r?2:r)+o)/2})}},{key:"getPointArc",value:function(e,t){var r=t.size;return new f.Arc(e,{fillColor:t.fillColor,strokeColor:t.strokeColor,strokeWidth:t.strokeWidth,radius:(void 0===r?6:r)/2})}},{key:"getArcs",value:function(e,t){var o=r.getShadowArc(e,t),n=r.getPointArc(e,t);return o?[o,n]:[n]}}]),r}(),G=function(e){T(r,u.PolylineSymbol);var t=W(r);function r(e){return A(this,r),t.call(this,e)}return q(r,[{key:"renderFunction",value:function(e,t,r){if(!(e instanceof l.Poly))return[];var o=u.PolylineSymbol.getRenderedCoordinates(e,t,r),n=this.getPolyRender(o),i=this.getShadow(o),s=this.getVertexRenders(o),a=[n];return i&&(a=[i,n]),s&&(a=a.concat(s)),a}},{key:"getShadow",value:function(e){return new c.PolyRender(e,{fillStyle:c.FillStyle.None,enclosed:this.enclose,strokeColor:this.shadowColor,strokeWidth:this.shadowSize,lineDash:this.lineDash})}},{key:"getPolyRender",value:function(e){return new c.PolyRender(e,{fillStyle:this.enclose?c.FillStyle.Color:c.FillStyle.None,enclosed:this.enclose,fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,lineDash:this.lineDash})}},{key:"getVertexRenders",value:function(e){var t=this;if(this.showVertex)return e.reduce((function(e,t){return e.concat(t)}),[]).map((function(e){return B(e,{size:6,strokeWidth:2,shadowColor:t.shadowColor,strokeColor:t.strokeColor,shadowSize:void 0!==t.vertexShadowSize?t.vertexShadowSize:2,fillColor:"#ffffff"})})).reduce((function(e,t){return e.concat(t)}),[])}}]),r}(),X={strokeWidth:2,strokeColor:"#e33600",shadowSize:8,shadowColor:"rgba(227, 54, 0, 0.3)"},$={strokeColor:"#ff6933",shadowSize:0,vertexShadowSize:0},H=new G(z({},X,$,{enclose:!1,showVertex:!0})),J=new G(z({},X,$,{fillColor:"rgba(255, 105, 51, 0.25)",enclose:!0,showVertex:!0})),K=new N(z({},{size:10,strokeWidth:2,strokeColor:"#e33600",fillColor:"#ffffff",shadowColor:"rgba(227, 54, 0, 0.3)",shadowSize:3},{strokeColor:"#ff6933",shadowSize:0})),Q=function(e){T(o,L.DynamicPointSymbol);var t=W(o);function o(e){var r,n=void 0===e?{}:e,i=n.component,s=n.offset;return A(this,o),(r=t.call(this,{offset:s})).component=i,r}return q(o,[{key:"_getFeatureNode",value:function(e){var t=document.createElement("div");return this.renderDom(e.content,t),t}},{key:"_updateFeatureNode",value:function(e){this.renderDom(e.content,this.getNode(e))}},{key:"renderDom",value:function(e,t){if(t){var o=this.component;o?g.render(r.createElement(o,{content:e}),t):t.innerText=e}}}]),o}(),Y=[8,-16],Z=function(e){var t=e||{},o=t.offset,n=t.renderLabel,i=void 0===n?function(e){return r.createElement("div",null,e.content)}:n,s=t.onClose,a=void 0===s?void 0:s;return new Q({offset:void 0===o?Y:o,component:function(e){return i({content:e.content,onClose:a})}})};function ee(e,t){if(e[0].length<=3)return!1;var r=e[0],o=r[0],n=r[r.length-1],i=2*t;return w.softEquals(o[0],n[0],i)&&w.softEquals(o[1],n[1],i)}function te(e,t,r){void 0===t&&(t=2),void 0===r&&(r=",");var o=e.toFixed(t).split("."),n=o[1];return[o[0].replace(/\B(?=(\d{3})+(?!\d))/g," "),n].join(r)}function re(e){var t=e,r="м²";return e>=1e7?(t=e/1e6,r="км²"):e>=1e4&&(t=e/1e4,r="га"),te(t)+" "+r}function oe(e){var t=e,r="м";return e>1e4&&(t=e/1e3,r="км"),te(t)+" "+r}function ne(e,t){return"S : "+re(e)+" P : "+oe(t)}var ie=[Infinity,Infinity],se=function(e){T(r,p.PolylineControl);var t=W(r);function r(e,o,n){var i;return A(this,r),(i=t.call(this,e,n)).cancel=function(){i.fire("cancel")},i.painter=o,i.renderLabelSymbol=n.renderLabelSymbol,i.on("pointAdd",i.handlePointAdd),i.on("change",i.updateDistance),i}return q(r,[{key:"_handleMousemove",value:function(e){U(O(r.prototype),"_handleMousemove",this).call(this,e),this.drawPointOnMouseMove(e)}},{key:"_activate",value:function(){U(O(r.prototype),"_activate",this).call(this),this.addTempLabel(),this.setCursor("pointer")}},{key:"_deactivate",value:function(){U(O(r.prototype),"_deactivate",this).call(this),this.removeCoordLabel(),this.removeTempLabel(),this.removeMeasureLabel(),this.removeTempPolygon(),this.setCursor("default")}},{key:"handlePointAdd",value:function(){var e=this.activeFeature;if(e){var t=e.rings,r=e.crs;if(ee(t,this.map.resolution))return this.finishDrawing(),void this.fire(new b.DrawingFinishEvent(e,new MouseEvent("mouseup")));if(2===t[0].length){var o=r.projectionTo(y.geo),n=t[0][0];if(!o)return;var i=o(n),s=i[0],a=i[1];this.removeTempLabel(),this.addMeasureResultLabel(),this.addCoordLabel(s.toFixed(6)+", "+a.toFixed(6),n)}else this.removeCoordLabel()}}},{key:"polygonPreview",value:function(){this.tempPolygon&&this._tempLayer&&this._tempLayer.remove(this.tempPolygon);var e=this.activeFeature;if(e){var t=e.crs,r=[].concat(e.rings[0]);r.shift(),this.tempPolygon=new a.Polygon(r,{crs:t}),this.tempPolygon.symbol=J,this.activeFeature&&this.activeFeature.hide(),this._tempLayer&&this._tempLayer.add(this.tempPolygon)}}},{key:"removeTempPolygon",value:function(){this.tempPolygon&&(this._tempLayer&&this._tempLayer.remove(this.tempPolygon),delete this.tempPolygon)}},{key:"updateDistance",value:function(e){var t=this.activeFeature,r=e.ringIndex,o=e.pointIndex;if(t&&null!==r&&null!==o){var n=t.rings,i=t.crs,s=n[r][o],a=m.length(n,i),u=oe(a);ee(n,this.map.resolution)?(this.polygonPreview(),u=ne(m.area(n,i),a)):this.tempPolygon&&(t.show(),this.removeTempPolygon()),this.measureResultLabel&&(this.measureResultLabel.position=s,this.measureResultLabel.content=u)}}},{key:"addTempLabel",value:function(){this.tempLabel=new v.LabelFeature(ie,{content:"Нажмите на карту, чтобы начать измерение",crs:this.map.crs,symbol:Z({renderLabel:this.renderLabelSymbol})}),this._tempLayer&&this._tempLayer.add(this.tempLabel)}},{key:"addCoordLabel",value:function(e,t){this.coordLabel=new v.LabelFeature(t,{content:e,crs:this.map.crs,symbol:Z({renderLabel:this.renderLabelSymbol,onClose:this.cancel})}),this._tempLayer&&this.coordLabel&&this._tempLayer.add(this.coordLabel)}},{key:"addMeasureResultLabel",value:function(){this.measureResultLabel=new v.LabelFeature(ie,{crs:this.map.crs,symbol:Z({renderLabel:this.renderLabelSymbol})}),this._tempLayer&&this.measureResultLabel&&this._tempLayer.add(this.measureResultLabel)}},{key:"removeTempLabel",value:function(){this.tempLabel&&(this._tempLayer&&this._tempLayer.remove(this.tempLabel),delete this.tempLabel)}},{key:"removeCoordLabel",value:function(){this.coordLabel&&(this._tempLayer&&this._tempLayer.remove(this.coordLabel),delete this.coordLabel)}},{key:"removeMeasureLabel",value:function(){this.measureResultLabel&&(this._tempLayer&&this._tempLayer.remove(this.measureResultLabel),delete this.measureResultLabel)}},{key:"drawPointOnMouseMove",value:function(e){this.tempLabel&&(this.tempLabel.position=e.point.position)}},{key:"setCursor",value:function(e){var t=this.painter.wrapper;t&&"string"!=typeof t&&(t.style.cursor=e)}}]),r}(),ae=function(e){T(r,x.PolyEditor);var t=W(r);function r(e,o,n){var i;return A(this,r),(i=t.call(this,e,n)).measureResult=function(){var e=i.activeFeature;if(!e)return null;var t=e.rings,r=e.isEnclosed,o=e.crs,n=t[0][t[0].length-1],s=m.area(t,o),a=m.length(t,o,r);return{content:r?ne(s,a):oe(a),position:n}},i.removeFeature=function(){i.fire("remove")},i.painter=o,i.renderLabelSymbol=n.renderLabelSymbol,i.on("change",i.updateMeasureResult),i.on("edit",i.updateMeasureResult),i}return q(r,[{key:"_activate",value:function(){U(O(r.prototype),"_activate",this).call(this),this.addMeasureResultLabel()}},{key:"addMeasureResultLabel",value:function(){var e=this.measureResult();null!==e&&(this.measureResultLabel=new v.LabelFeature(e.position,{content:e.content,crs:this.map.crs,symbol:Z({onClose:this.removeFeature,renderLabel:this.renderLabelSymbol})}),this._tempLayer&&this._tempLayer.add(this.measureResultLabel))}},{key:"updateMeasureResult",value:function(){if(this.measureResultLabel){var e=this.measureResult();if(null===e)return;var t=e.position;this.measureResultLabel.content=e.content,this.measureResultLabel.position=t}}}]),r}(),ue=function(e){T(o,r.Component);var t=W(o);function o(){var e;return A(this,o),(e=t.apply(this,arguments)).createFeature=function(t){var r=e.getFeature([].concat(t.feature.rings));e.layer&&e.layer.add(r),e.editorControl&&(e.editorControl.activeFeature=r),e.switchMode(!1,!0)},e.removeFeature=function(){e.editorControl&&e.editorControl.activeFeature&&e.layer&&e.layer.remove(e.editorControl.activeFeature),e.switchMode(!0,!1)},e.cancelFeatureCreation=function(){setTimeout((function(){e.switchMode(!1,!1),e.switchMode(!0,!1)}),10)},e}return q(o,[{key:"componentDidMount",value:function(){var e=this.props,t=e.map,r=e.painter,o=e.renderLabelSymbol;this.layer=new s.FeatureLayer,this.initCreateMode(t,r,o),this.initEditMode(t,r,o),this.props.map.addLayer(this.layer),this.switchMode(!0,!1)}},{key:"componentWillUnmount",value:function(){this.layer&&this.props.map.removeLayer(this.layer),this.switchMode(!1,!1),this.offEvents(),this.clearProperties()}},{key:"initCreateMode",value:function(e,t,r){this.createControl=new se(e,t,{isActive:!1,useTempLayer:!0,symbol:H,dblClickMinTime:300,renderLabelSymbol:r}),this.createControl.on("drawingFinish",this.createFeature),this.createControl.on("cancel",this.cancelFeatureCreation)}},{key:"initEditMode",value:function(e,t,r){this.editorControl=new ae(e,t,{isActive:!1,activeLayer:this.layer,snappingSymbol:K,symbol:H,renderLabelSymbol:r}),this.editorControl.featureDragAllowed=!1,this.editorControl.on("remove",this.removeFeature)}},{key:"offEvents",value:function(){this.createControl&&this.createControl.off("drawingFinish",this.createFeature),this.editorControl&&this.editorControl.off("remove",this.removeFeature),this.createControl&&this.createControl.off("cancel",this.cancelFeatureCreation)}},{key:"clearProperties",value:function(){delete this.createControl,delete this.editorControl,delete this.layer}},{key:"switchMode",value:function(e,t){this.createControl&&(this.createControl.isActive=e),this.editorControl&&(this.editorControl.isActive=t)}},{key:"getFeature",value:function(e){var t;return ee(e,this.props.map.resolution)?(e[0].shift(),(t=new a.Polygon(e,{crs:this.props.map.crs})).symbol=J):(t=new i.Polyline(e,{crs:this.props.map.crs})).symbol=H,t}},{key:"render",value:function(){return r.createElement("div",{style:{display:"none"}})}}]),o}(),le=function(e){return function(t){return t.zIndex===e}},ce=function(e,r,o,n){var i=_().map;t.useEffect((function(){var t=i.tileScheme.levels;if(void 0!==r){var s=t.find(le(r))||{resolution:-1};i.minResolution=s.resolution}if(void 0!==e){var a=t.find(le(e))||{resolution:-1};i.maxResolution=a.resolution}void 0===e&&void 0===r||fe(i,o,n)}),[i,e,r])},fe=function(e,t,r){if(t&&r){var o=Math.min(Math.max(r,e.minResolution||0),e.maxResolution||Number.MAX_VALUE);e.animateTo(t,o)}};function de(){var e=_(),r=e.map,o=e.painter;return{zoomTo:t.useCallback((function(e){r.zoom(e,r.position)}),[r]),animateTo:t.useCallback((function(e){var t=e.position,n=e.resolution,i=e.extent;if(t||n){var s=t?t.slice(0):r.position;r.animateTo(s,n||r.resolution)}if(i){var a=new C.Bbox([i.xMin,i.yMax],[i.xMax,i.yMin],r.crs);o&&o.show(a,!0)}}),[r,o]),zoomAround:t.useCallback((function(e){var t;r.zoom(1,null==e||null===(t=e.sourceObject)||void 0===t?void 0:t.point)}),[r])}}function he(e,r){var o=e.position,n=e.resolution,i=_().map,s=de().animateTo;t.useEffect((function(){pe(i,{position:o,resolution:n})&&s({position:o,resolution:n})}),[o,n,r])}function pe(e,t){var r=t.resolution;return function(e,t){return t&&(!w.softEquals(e.position[0],t[0])||!w.softEquals(e.position[1],t[1]))}(e,t.position)||function(e,t){return t&&!w.softEquals(e.resolution,t)}(e,r)}function ve(e){var r=e.onMount,o=e.onUnmount;t.useEffect((function(){return r&&r(),o}),[])}function me(){var e=_().painter,r=t.useRef(null);return ve({onMount:function(){return e.wrapper=r.current},onUnmount:function(){return e.wrapper=null}}),r}function ye(e,r){var n=_().map,i=r?o.BboxChangeEvent:o.BboxChangeEndEvent,s=t.useCallback((function(){e&&e(be(n))}),[e,n,i]);t.useEffect((function(){return n.on(i.type,s),function(){n.off(i.type,s)}}),[s,i])}function be(e){return{position:e.position.slice(0),resolution:e.resolution}}function ge(e,r){var o=e.factory,n=e.destructor,i=e.update;void 0===r&&(r=[]);var s=t.useRef();return ve({onUnmount:function(){s.current&&n&&n(s.current)}}),t.useMemo((function(){if(s.current)if(i){var e=i(s.current,r,{factory:o,destructor:n});e&&(s.current=e)}else n&&n(s.current);else i&&s.current||(s.current=o(r));return s.current}),r)}var Le=new k.Api({url:"/"}),we=t.createContext(Le),xe=function(){return t.useContext(we)};function Ce(e){var r=e.onUpdate,o=e.shouldUpdate;t.useEffect((function(){o&&!o()||r()}),e.deps)}function ke(e,t){var r=_().map;Ce({onUpdate:function(){return r.insertLayer(e,t)},deps:[t,e]})}function Pe(e,t){void 0===t&&(t=!0),Ce({shouldUpdate:function(){return e.isDisplayed!==t},onUpdate:function(){return e.isDisplayed=t},deps:[t,e]})}function Se(e){var t=e.name,r=e.zIndex,o=e.style,n=e.condition,i=e.isDisplayed,s=xe(),a=_().map,u=ge({factory:function(){return new k.EvergisDynamicLayer({name:t},s)},destructor:function(e){return-1!==a.indexOf(e)&&a.removeLayer(e)},update:function(e,t){var r=t[1],o=t[2];e.name=t[0],e.style=r,e.condition=o}},[t,o,n]);return ke(u,r),Pe(u,i),u}function Me(e){var t=e.name,r=e.subDomains,o=e.zIndex,n=e.isDisplayed,i=xe(),s=_().map,a=ge({factory:function(){return new k.EvergisTileLayer({name:t,subDomains:r},i)},update:function(e,t){var r=t[1];e.name=t[0],e.subDomains=r,"function"==typeof e.clearCache&&e.clearCache(),"function"==typeof e.redraw&&e.redraw()},destructor:function(e){return-1!==s.indexOf(e)&&s.removeLayer(e)}},[t,r]);return ke(a,o),Pe(a,n),a}function Re(e){var t=e.zIndex,r=e.isDisplayed,o=void 0===r||r,n=e.features,i=_().map,s=ge({factory:function(){return new P.FeatureLayer({features:n})},destructor:function(e){return-1!==i.indexOf(e)&&i.removeLayer(e)},update:function(e,t){e.features=t[0]}},[n]);return ke(s,t),Pe(s,o),s}function Ee(e){return e._currentRender&&e._currentRender.bbox&&e._currentRender.bbox.coordinates}function Fe(e){for(var t,r={},o=function(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return I(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,void 0):void 0}}(e))){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}(e);!(t=o()).done;){var n=t.value;k.isEvergisDynamicLayer(n)&&(r[n.name]=Ee(n))}return r}function _e(e){var r=_().map,o=t.useReducer(Ae,void 0,(function(){return be(r)}));return ye(t.useCallback(o[1],[]),e),be(r)}function Ae(e,t){return t}function De(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),r=e/t;return t*(r>=10?10:r>=5?5:r>=3?3:r>=2?2:1)}exports.BaseMeasureToolCreator=se,exports.BaseMeasureToolEditor=ae,exports.EvergisDynamicLayer=function(e){return Se(e),null},exports.EvergisProvider=function(e){var r=e.api,o=e.children,n=t.useMemo((function(){return r||Le}),[r]);return t.createElement(we.Provider,{value:n},o)},exports.EvergisTileLayer=function(e){return Me(e),null},exports.FeatureLayer=function(e){return Re(e),null},exports.LabelSymbol=Q,exports.Map=function(e){var o=e.className,n=e.position,i=e.resolution,s=e.minScale,a=e.maxScale,u=e.children,l=e.onBboxChange,c=e.style,f=me(),d=_().map,h=t.useCallback((function(e){l&&pe(d,{position:n,resolution:i})&&l(e)}),[d,l,n,i]);return he({position:n,resolution:i}),ce(s,a,n,i),ye(h),r.createElement("div",{className:o,ref:f,style:c},u)},exports.MapProvider=function(e){var r=e.map,o=e.children,i=t.useMemo((function(){return{map:r||R,painter:r?new n.DomPainter(r):E}}),[r]);return t.createElement(F.Provider,{value:i},o)},exports.MeasureTool=ue,exports.Measurer=function(e){var t=e.isActive,o=e.renderLabelSymbol,n=_();return t?r.createElement(ue,{map:n.map,painter:n.painter,renderLabelSymbol:o}):null},exports.ShadowedPointSymbol=N,exports.ShadowedPolySymbol=G,exports.TileLayer=function(e){var t,r,o,n,i,s;return r=(t=e).maskUrl,o=t.zIndex,n=t.isDisplayed,i=_().map,ke(s=ge({factory:function(){return new S.TileLayer(r)},destructor:function(e){return-1!==i.indexOf(e)&&i.removeLayer(e)}},[r]),o),Pe(s,n),null},exports.createLabelSymbol=Z,exports.createShadowRender=V,exports.defaultOffset=Y,exports.formatArea=re,exports.formatLength=oe,exports.getEditorPointRenderer=B,exports.getMapState=be,exports.measureAreaSymbol=J,exports.measureLengthSymbol=H,exports.measurePolygonSnapSymbol=K,exports.useEvergisContext=xe,exports.useEvergisDynamicLayer=Se,exports.useEvergisTileLayer=Me,exports.useFeatureLayer=Re,exports.useLayerOrder=ke,exports.useLayerVisibility=Pe,exports.useMapBboxChange=ye,exports.useMapContext=_,exports.useMapLevel=function(){var e=_().map,r=_e(!0).resolution;return t.useMemo((function(){var t=e.tileScheme.getLevel(r);if(void 0!==t||null!==t)return e.tileScheme.levels[t].zIndex}),[r])},exports.useMapPick=function(){var e=_(),r=e.map,o=e.painter,n=t.useState(),i=n[0],s=n[1],a=t.useMemo((function(){return r.layers}),[r.layers]),u=t.useCallback((function(e){if(e instanceof M.sGisClickEvent){var t=[0,0,o.width,o.height],r=o.getPxPosition(e.point.position),n=r[1];s({clickPoint:[Math.round(r[0]),Math.round(n)],envelopes:Fe(a),imageRectangle:t})}}),[r]);return ve({onMount:function(){return r.on("click",u)},onUnmount:function(){return r.off("click",u)}}),i},exports.useMapState=_e,exports.useMapView=function(){var e=_(),r=e.map,o=e.painter,n=_e(),i=n.position,s=n.resolution,a=t.useMemo((function(){var e=r.tileScheme.getLevel(s);if(void 0!==e||null!==e)return r.tileScheme.levels[e].zIndex}),[s]),u=t.useMemo((function(){return o.bbox}),[i,s]);return{position:i,resolution:s,level:a,bbox:u}},exports.useMapViewActions=de,exports.useMapWrapper=me,exports.useMaxMinScale=ce,exports.useMount=ve,exports.useProperty=ge,exports.useScale=function(e){var r,o,n,i,s,a=e.minLength,u=void 0===a?50:a,l=(r=e.resolution,o=_().painter,t.useMemo((function(){if(0===i)return r;var e=i/10,t=o.getPointFromPxPosition(0,n/2),s=o.getPointFromPxPosition(e,n/2);return m.distance(t,s)/e}),[n=o.height,i=o.width,(s=o.bbox).xMin,s.xMax,s.yMin,s.yMax,s.crs.wkid,r,o]));return t.useMemo((function(){var e=u*l;return{currentScale:De(e),width:De(e)/l}}),[l,u])},exports.useUpdate=Ce,exports.useUpdateMapView=he;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),o=require("@evergis/api"),n=require("@evergis/sgis/es/Map"),i=require("@evergis/sgis/es/painters/DomPainter/DomPainter"),s=require("@evergis/sgis/es/features/Polyline"),a=require("@evergis/sgis/es/layers/FeatureLayer"),u=require("@evergis/sgis/es/features/Polygon"),l=e(require("react-dom")),c=require("@evergis/sgis/es/symbols/Symbol"),f=require("@evergis/sgis/es/renders/Arc"),d=require("@evergis/sgis/es/symbols/point/Point"),p=require("@evergis/sgis/es/features/PointFeature"),h=require("@evergis/sgis/es/symbols/PolylineSymbol"),v=require("@evergis/sgis/es/features/Poly"),m=require("@evergis/sgis/es/renders/Poly"),y=require("@evergis/sgis/es/controls/PolylineControl"),b=require("@evergis/sgis/es/features/Label"),g=require("@evergis/sgis/es/geotools"),L=require("@evergis/sgis/es/Crs"),w=require("@evergis/sgis/es/controls/Control"),x=require("@evergis/sgis/es/utils/math"),C=require("@evergis/sgis/es/controls/PolyEditor"),k=require("@evergis/sgis"),P=require("@evergis/sgis/es/commonEvents"),S=require("@evergis/sgis/es/Bbox"),M=require("@evergis/sgis/es/layers/TileLayer"),R=new o.Api({url:"/"}),_=t.createContext(R),E=function(){return t.useContext(_)},F=new n.Map,A=new i.DomPainter(F),D=t.createContext({map:F,painter:A}),z=function(){return t.useContext(D)};function q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function T(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function O(e,t,r){return t&&T(e.prototype,t),r&&T(e,r),e}function j(){return(j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function W(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){return(I=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function U(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function B(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=I(e);if(t){var n=I(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return U(this,r)}}function V(e,t,r){return(V="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var o=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=I(e)););return e}(e,t);if(o){var n=Object.getOwnPropertyDescriptor(o,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}var G=function(e){W(o,c.DynamicPointSymbol);var t=B(o);function o(e){var r,n=void 0===e?{}:e,i=n.component,s=n.offset;return q(this,o),(r=t.call(this,{offset:s})).component=i,r}return O(o,[{key:"_getFeatureNode",value:function(e){var t=document.createElement("div");return this.renderDom(e.content,t),t}},{key:"_updateFeatureNode",value:function(e){this.renderDom(e.content,this.getNode(e))}},{key:"renderDom",value:function(e,t){if(t){var o=this.component;o?l.render(r.createElement(o,{content:e}),t):t.innerText=e}}}]),o}(),X=[8,-16],$=function(e){var t=e||{},o=t.offset,n=t.renderLabel,i=void 0===n?function(e){return r.createElement("div",null,e.content)}:n,s=t.onClose,a=void 0===s?void 0:s;return new G({offset:void 0===o?X:o,component:function(e){return i({content:e.content,onClose:a})}})};function H(e,t){var r=t.strokeWidth,o=t.shadowSize,n=t.size;return new f.Arc(e,{fillColor:"transparent",strokeColor:t.shadowColor,strokeWidth:o,radius:((void 0===n?6:n)+(void 0===r?2:r)+o)/2})}function J(e,t){var r=t.strokeColor,o=t.strokeWidth,n=t.fillColor,i=t.size,s=void 0===i?0:i,a=s/2;return[H(e,{strokeWidth:o,strokeColor:r,shadowSize:t.shadowSize,shadowColor:t.shadowColor,size:s}),new f.Arc(e,{fillColor:n,strokeColor:r,strokeWidth:o,radius:a})]}var K=function(e){W(r,d.PointSymbol);var t=B(r);function r(e){return q(this,r),t.call(this,e)}return O(r,[{key:"renderFunction",value:function(e,t,r){if(!(e instanceof p.PointFeature))return[];var o=e.projectTo(r).position,n=[o[0]/t+(this.offset[0]||0),-o[1]/t+(this.offset[1]||0)],i=this.getShadow(n),s=this.getPoint(n);return i?[i,s]:[s]}},{key:"getShadow",value:function(e){return r.getShadowArc(e,this)}},{key:"getPoint",value:function(e){return r.getPointArc(e,this)}}],[{key:"getShadowArc",value:function(e,t){var r=t.strokeWidth,o=t.shadowSize,n=t.size;return new f.Arc(e,{fillColor:"transparent",strokeColor:t.shadowColor,strokeWidth:o,radius:((void 0===n?6:n)+(void 0===r?2:r)+o)/2})}},{key:"getPointArc",value:function(e,t){var r=t.size;return new f.Arc(e,{fillColor:t.fillColor,strokeColor:t.strokeColor,strokeWidth:t.strokeWidth,radius:(void 0===r?6:r)/2})}},{key:"getArcs",value:function(e,t){var o=r.getShadowArc(e,t),n=r.getPointArc(e,t);return o?[o,n]:[n]}}]),r}(),Q=function(e){W(r,h.PolylineSymbol);var t=B(r);function r(e){return q(this,r),t.call(this,e)}return O(r,[{key:"renderFunction",value:function(e,t,r){if(!(e instanceof v.Poly))return[];var o=h.PolylineSymbol.getRenderedCoordinates(e,t,r),n=this.getPolyRender(o),i=this.getShadow(o),s=this.getVertexRenders(o),a=[n];return i&&(a=[i,n]),s&&(a=a.concat(s)),a}},{key:"getShadow",value:function(e){return new m.PolyRender(e,{fillStyle:m.FillStyle.None,enclosed:this.enclose,strokeColor:this.shadowColor,strokeWidth:this.shadowSize,lineDash:this.lineDash})}},{key:"getPolyRender",value:function(e){return new m.PolyRender(e,{fillStyle:this.enclose?m.FillStyle.Color:m.FillStyle.None,enclosed:this.enclose,fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,lineDash:this.lineDash})}},{key:"getVertexRenders",value:function(e){var t=this;if(this.showVertex)return e.reduce((function(e,t){return e.concat(t)}),[]).map((function(e){return J(e,{size:6,strokeWidth:2,shadowColor:t.shadowColor,strokeColor:t.strokeColor,shadowSize:void 0!==t.vertexShadowSize?t.vertexShadowSize:2,fillColor:"#ffffff"})})).reduce((function(e,t){return e.concat(t)}),[])}}]),r}(),Y={strokeWidth:2,strokeColor:"#e33600",shadowSize:8,shadowColor:"rgba(227, 54, 0, 0.3)"},Z={strokeColor:"#ff6933",shadowSize:0,vertexShadowSize:0},ee=new Q(j({},Y,Z,{enclose:!1,showVertex:!0})),te=new Q(j({},Y,Z,{fillColor:"rgba(255, 105, 51, 0.25)",enclose:!0,showVertex:!0})),re=new K(j({},{size:10,strokeWidth:2,strokeColor:"#e33600",fillColor:"#ffffff",shadowColor:"rgba(227, 54, 0, 0.3)",shadowSize:3},{strokeColor:"#ff6933",shadowSize:0}));function oe(e,t){if(e[0].length<=3)return!1;var r=e[0],o=r[0],n=r[r.length-1],i=2*t;return x.softEquals(o[0],n[0],i)&&x.softEquals(o[1],n[1],i)}function ne(e,t,r){void 0===t&&(t=2),void 0===r&&(r=",");var o=e.toFixed(t).split("."),n=o[1];return[o[0].replace(/\B(?=(\d{3})+(?!\d))/g," "),n].join(r)}function ie(e){var t=e,r="м²";return e>=1e7?(t=e/1e6,r="км²"):e>=1e4&&(t=e/1e4,r="га"),ne(t)+" "+r}function se(e){var t=e,r="м";return e>1e4&&(t=e/1e3,r="км"),ne(t)+" "+r}function ae(e,t){return"S : "+ie(e)+" P : "+se(t)}var ue=[Infinity,Infinity],le=function(e){W(r,y.PolylineControl);var t=B(r);function r(e,o,n){var i;return q(this,r),(i=t.call(this,e,n)).cancel=function(){i.fire("cancel")},i.painter=o,i.renderLabelSymbol=n.renderLabelSymbol,i.on("pointAdd",i.handlePointAdd),i.on("change",i.updateDistance),i}return O(r,[{key:"_handleMousemove",value:function(e){V(I(r.prototype),"_handleMousemove",this).call(this,e),this.drawPointOnMouseMove(e)}},{key:"_activate",value:function(){V(I(r.prototype),"_activate",this).call(this),this.addTempLabel(),this.setCursor("pointer")}},{key:"_deactivate",value:function(){V(I(r.prototype),"_deactivate",this).call(this),this.removeCoordLabel(),this.removeTempLabel(),this.removeMeasureLabel(),this.removeTempPolygon(),this.setCursor("default")}},{key:"handlePointAdd",value:function(){var e=this.activeFeature;if(e){var t=e.rings,r=e.crs;if(oe(t,this.map.resolution))return this.finishDrawing(),void this.fire(new w.DrawingFinishEvent(e,new MouseEvent("mouseup")));if(2===t[0].length){var o=r.projectionTo(L.geo),n=t[0][0];if(!o)return;var i=o(n),s=i[0],a=i[1];this.removeTempLabel(),this.addMeasureResultLabel(),this.addCoordLabel(s.toFixed(6)+", "+a.toFixed(6),n)}else this.removeCoordLabel()}}},{key:"polygonPreview",value:function(){this.tempPolygon&&this._tempLayer&&this._tempLayer.remove(this.tempPolygon);var e=this.activeFeature;if(e){var t=e.crs,r=[].concat(e.rings[0]);r.shift(),this.tempPolygon=new u.Polygon(r,{crs:t}),this.tempPolygon.symbol=te,this.activeFeature&&this.activeFeature.hide(),this._tempLayer&&this._tempLayer.add(this.tempPolygon)}}},{key:"removeTempPolygon",value:function(){this.tempPolygon&&(this._tempLayer&&this._tempLayer.remove(this.tempPolygon),delete this.tempPolygon)}},{key:"updateDistance",value:function(e){var t=this.activeFeature,r=e.ringIndex,o=e.pointIndex;if(t&&null!==r&&null!==o){var n=t.rings,i=t.crs,s=n[r][o],a=g.length(n,i),u=se(a);oe(n,this.map.resolution)?(this.polygonPreview(),u=ae(g.area(n,i),a)):this.tempPolygon&&(t.show(),this.removeTempPolygon()),this.measureResultLabel&&(this.measureResultLabel.position=s,this.measureResultLabel.content=u)}}},{key:"addTempLabel",value:function(){this.tempLabel=new b.LabelFeature(ue,{content:"Нажмите на карту, чтобы начать измерение",crs:this.map.crs,symbol:$({renderLabel:this.renderLabelSymbol})}),this._tempLayer&&this._tempLayer.add(this.tempLabel)}},{key:"addCoordLabel",value:function(e,t){this.coordLabel=new b.LabelFeature(t,{content:e,crs:this.map.crs,symbol:$({renderLabel:this.renderLabelSymbol,onClose:this.cancel})}),this._tempLayer&&this.coordLabel&&this._tempLayer.add(this.coordLabel)}},{key:"addMeasureResultLabel",value:function(){this.measureResultLabel=new b.LabelFeature(ue,{crs:this.map.crs,symbol:$({renderLabel:this.renderLabelSymbol})}),this._tempLayer&&this.measureResultLabel&&this._tempLayer.add(this.measureResultLabel)}},{key:"removeTempLabel",value:function(){this.tempLabel&&(this._tempLayer&&this._tempLayer.remove(this.tempLabel),delete this.tempLabel)}},{key:"removeCoordLabel",value:function(){this.coordLabel&&(this._tempLayer&&this._tempLayer.remove(this.coordLabel),delete this.coordLabel)}},{key:"removeMeasureLabel",value:function(){this.measureResultLabel&&(this._tempLayer&&this._tempLayer.remove(this.measureResultLabel),delete this.measureResultLabel)}},{key:"drawPointOnMouseMove",value:function(e){this.tempLabel&&(this.tempLabel.position=e.point.position)}},{key:"setCursor",value:function(e){var t=this.painter.wrapper;t&&"string"!=typeof t&&(t.style.cursor=e)}}]),r}(),ce=function(e){W(r,C.PolyEditor);var t=B(r);function r(e,o,n){var i;return q(this,r),(i=t.call(this,e,n)).measureResult=function(){var e=i.activeFeature;if(!e)return null;var t=e.rings,r=e.isEnclosed,o=e.crs,n=t[0][t[0].length-1],s=g.area(t,o),a=g.length(t,o,r);return{content:r?ae(s,a):se(a),position:n}},i.removeFeature=function(){i.fire("remove")},i.painter=o,i.renderLabelSymbol=n.renderLabelSymbol,i.on("change",i.updateMeasureResult),i.on("edit",i.updateMeasureResult),i}return O(r,[{key:"_activate",value:function(){V(I(r.prototype),"_activate",this).call(this),this.addMeasureResultLabel()}},{key:"addMeasureResultLabel",value:function(){var e=this.measureResult();null!==e&&(this.measureResultLabel=new b.LabelFeature(e.position,{content:e.content,crs:this.map.crs,symbol:$({onClose:this.removeFeature,renderLabel:this.renderLabelSymbol})}),this._tempLayer&&this._tempLayer.add(this.measureResultLabel))}},{key:"updateMeasureResult",value:function(){if(this.measureResultLabel){var e=this.measureResult();if(null===e)return;var t=e.position;this.measureResultLabel.content=e.content,this.measureResultLabel.position=t}}}]),r}(),fe=function(e){W(o,r.Component);var t=B(o);function o(){var e;return q(this,o),(e=t.apply(this,arguments)).createFeature=function(t){var r=e.getFeature([].concat(t.feature.rings));e.layer&&e.layer.add(r),e.editorControl&&(e.editorControl.activeFeature=r),e.switchMode(!1,!0)},e.removeFeature=function(){e.editorControl&&e.editorControl.activeFeature&&e.layer&&e.layer.remove(e.editorControl.activeFeature),e.switchMode(!0,!1)},e.cancelFeatureCreation=function(){setTimeout((function(){e.switchMode(!1,!1),e.switchMode(!0,!1)}),10)},e}return O(o,[{key:"componentDidMount",value:function(){var e=this.props,t=e.map,r=e.painter,o=e.renderLabelSymbol;this.layer=new a.FeatureLayer,this.initCreateMode(t,r,o),this.initEditMode(t,r,o),this.props.map.addLayer(this.layer),this.switchMode(!0,!1)}},{key:"componentWillUnmount",value:function(){this.layer&&this.props.map.removeLayer(this.layer),this.switchMode(!1,!1),this.offEvents(),this.clearProperties()}},{key:"initCreateMode",value:function(e,t,r){this.createControl=new le(e,t,{isActive:!1,useTempLayer:!0,symbol:ee,dblClickMinTime:300,renderLabelSymbol:r}),this.createControl.on("drawingFinish",this.createFeature),this.createControl.on("cancel",this.cancelFeatureCreation)}},{key:"initEditMode",value:function(e,t,r){this.editorControl=new ce(e,t,{isActive:!1,activeLayer:this.layer,snappingSymbol:re,symbol:ee,renderLabelSymbol:r}),this.editorControl.featureDragAllowed=!1,this.editorControl.on("remove",this.removeFeature)}},{key:"offEvents",value:function(){this.createControl&&this.createControl.off("drawingFinish",this.createFeature),this.editorControl&&this.editorControl.off("remove",this.removeFeature),this.createControl&&this.createControl.off("cancel",this.cancelFeatureCreation)}},{key:"clearProperties",value:function(){delete this.createControl,delete this.editorControl,delete this.layer}},{key:"switchMode",value:function(e,t){this.createControl&&(this.createControl.isActive=e),this.editorControl&&(this.editorControl.isActive=t)}},{key:"getFeature",value:function(e){var t;return oe(e,this.props.map.resolution)?(e[0].shift(),(t=new u.Polygon(e,{crs:this.props.map.crs})).symbol=te):(t=new s.Polyline(e,{crs:this.props.map.crs})).symbol=ee,t}},{key:"render",value:function(){return r.createElement("div",{style:{display:"none"}})}}]),o}();function de(e){var r=e.onMount,o=e.onUnmount;t.useEffect((function(){return r&&r(),o}),[])}function pe(e,r){var o=e.factory,n=e.destructor,i=e.update;void 0===r&&(r=[]);var s=t.useRef();return de({onUnmount:function(){s.current&&n&&n(s.current)}}),t.useMemo((function(){if(s.current)if(i){var e=i(s.current,r,{factory:o,destructor:n});e&&(s.current=e)}else n&&n(s.current);else i&&s.current||(s.current=o(r));return s.current}),r)}function he(e){var r=e.onUpdate,o=e.shouldUpdate;t.useEffect((function(){o&&!o()||r()}),e.deps)}function ve(e,t){var r=z().map;he({onUpdate:function(){return r.insertLayer(e,t)},deps:[t,e]})}function me(e,t){void 0===t&&(t=!0),he({shouldUpdate:function(){return e.isDisplayed!==t},onUpdate:function(){return e.isDisplayed=t},deps:[t,e]})}function ye(e){var t=e.name,r=e.zIndex,n=e.style,i=e.condition,s=e.isDisplayed,a=E(),u=z().map,l=pe({factory:function(){return new o.EvergisDynamicLayer({name:t},a)},destructor:function(e){return-1!==u.indexOf(e)&&u.removeLayer(e)},update:function(e,t){var r=t[1],o=t[2];e.name=t[0],e.style=r,e.condition=o}},[t,n,i]);return ve(l,r),me(l,s),l}function be(e){var t=e.name,r=e.subDomains,n=e.zIndex,i=e.isDisplayed,s=E(),a=z().map,u=pe({factory:function(){return new o.EvergisTileLayer({name:t,subDomains:r},s)},update:function(e,t){var r=t[1];e.name=t[0],e.subDomains=r,"function"==typeof e.clearCache&&e.clearCache(),"function"==typeof e.redraw&&e.redraw()},destructor:function(e){return-1!==a.indexOf(e)&&a.removeLayer(e)}},[t,r]);return ve(u,n),me(u,i),u}function ge(e){var t=e.zIndex,r=e.isDisplayed,o=void 0===r||r,n=e.features,i=z().map,s=pe({factory:function(){return new k.FeatureLayer({features:n})},destructor:function(e){return-1!==i.indexOf(e)&&i.removeLayer(e)},update:function(e,t){e.features=t[0]}},[n]);return ve(s,t),me(s,o),s}function Le(e,r){var o=z().map,i=r?n.BboxChangeEvent:n.BboxChangeEndEvent,s=t.useCallback((function(){e&&e(we(o))}),[e,o,i]);t.useEffect((function(){return o.on(i.type,s),function(){o.off(i.type,s)}}),[s,i])}function we(e){return{position:e.position.slice(0),resolution:e.resolution}}function xe(e){return e._currentRender&&e._currentRender.bbox&&e._currentRender.bbox.coordinates}function Ce(e){for(var t,r={},n=function(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return N(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?N(e,void 0):void 0}}(e))){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}(e);!(t=n()).done;){var i=t.value;o.isEvergisDynamicLayer(i)&&(r[i.name]=xe(i))}return r}function ke(e){var r=z().map,o=t.useReducer(Pe,void 0,(function(){return we(r)}));return Le(t.useCallback(o[1],[]),e),we(r)}function Pe(e,t){return t}function Se(){var e=z(),r=e.map,o=e.painter,n=t.useCallback((function(e){r.zoom(e,r.position)}),[r]),i=t.useCallback((function(){return n(1)}),[n]),s=t.useCallback((function(){return n(-1)}),[n]),a=t.useCallback((function(e){var t=e.position,n=e.resolution,i=e.extent;if(t||n){var s=t?t.slice(0):r.position;r.animateTo(s,n||r.resolution)}if(i){var a=new S.Bbox([i.xMin,i.yMax],[i.xMax,i.yMin],r.crs);o&&o.show(a,!0)}}),[r,o]),u=t.useCallback((function(e){var t;r.zoom(1,null==e||null===(t=e.sourceObject)||void 0===t?void 0:t.point)}),[r]);return{zoomTo:n,zoomIn:i,zoomOut:s,zoomAround:u,animateTo:a}}function Me(){var e=z().painter,r=t.useRef(null);return de({onMount:function(){return e.wrapper=r.current},onUnmount:function(){return e.wrapper=null}}),r}var Re=function(e){return function(t){return t.zIndex===e}},_e=function(e,r,o,n){var i=z().map;t.useEffect((function(){var t=i.tileScheme.levels;if(void 0!==r){var s=t.find(Re(r))||{resolution:-1};i.minResolution=s.resolution}if(void 0!==e){var a=t.find(Re(e))||{resolution:-1};i.maxResolution=a.resolution}void 0===e&&void 0===r||Ee(i,o,n)}),[i,e,r])},Ee=function(e,t,r){if(t&&r){var o=Math.min(Math.max(r,e.minResolution||0),e.maxResolution||Number.MAX_VALUE);e.animateTo(t,o)}};function Fe(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),r=e/t;return t*(r>=10?10:r>=5?5:r>=3?3:r>=2?2:1)}function Ae(e,r){var o=e.position,n=e.resolution,i=z().map,s=Se().animateTo;t.useEffect((function(){De(i,{position:o,resolution:n})&&s({position:o,resolution:n})}),[o,n,r])}function De(e,t){var r=t.resolution;return function(e,t){return t&&(!x.softEquals(e.position[0],t[0])||!x.softEquals(e.position[1],t[1]))}(e,t.position)||function(e,t){return t&&!x.softEquals(e.resolution,t)}(e,r)}exports.AVAILABLE_BASE_MAPS=["2gis","osm_mono","carto_dm","sputnik","stamen_terrain","stamen_toner","stamen_watercolor"],exports.BaseMeasureToolCreator=le,exports.BaseMeasureToolEditor=ce,exports.EvergisDynamicLayer=function(e){return ye(e),null},exports.EvergisProvider=function(e){var o=e.api,n=e.children,i=t.useMemo((function(){return o||R}),[o]);return r.createElement(_.Provider,{value:i},n)},exports.EvergisTileLayer=function(e){return be(e),null},exports.FeatureLayer=function(e){return ge(e),null},exports.LabelSymbol=G,exports.Map=function(e){var o=e.className,n=e.position,i=e.resolution,s=e.minScale,a=e.maxScale,u=e.children,l=e.onBboxChange,c=e.style,f=Me(),d=z().map,p=t.useCallback((function(e){l&&De(d,{position:n,resolution:i})&&l(e)}),[d,l,n,i]);return Ae({position:n,resolution:i}),_e(s,a,n,i),Le(p),r.createElement("div",{className:o,ref:f,style:c},u)},exports.MapProvider=function(e){var o=e.map,n=e.children,s=t.useMemo((function(){return{map:o||F,painter:o?new i.DomPainter(o):A}}),[o]);return r.createElement(D.Provider,{value:s},n)},exports.MeasureTool=fe,exports.Measurer=function(e){var t=e.isActive,o=e.renderLabelSymbol,n=z();return t?r.createElement(fe,{map:n.map,painter:n.painter,renderLabelSymbol:o}):null},exports.ShadowedPointSymbol=K,exports.ShadowedPolySymbol=Q,exports.TileLayer=function(e){var t,r,o,n,i,s;return r=(t=e).maskUrl,o=t.zIndex,n=t.isDisplayed,i=z().map,ve(s=pe({factory:function(){return new M.TileLayer(r)},destructor:function(e){return-1!==i.indexOf(e)&&i.removeLayer(e)}},[r]),o),me(s,n),null},exports.createLabelSymbol=$,exports.createShadowRender=H,exports.defaultOffset=X,exports.formatArea=ie,exports.formatLength=se,exports.getEditorPointRenderer=J,exports.getMapState=we,exports.measureAreaSymbol=te,exports.measureLengthSymbol=ee,exports.measurePolygonSnapSymbol=re,exports.shouldUpdateMapState=De,exports.useEvergisContext=E,exports.useEvergisDynamicLayer=ye,exports.useEvergisTileLayer=be,exports.useFeatureLayer=ge,exports.useLayerOrder=ve,exports.useLayerVisibility=me,exports.useMapBboxChange=Le,exports.useMapContext=z,exports.useMapLevel=function(){var e=z().map,r=ke(!0).resolution;return t.useMemo((function(){var t=e.tileScheme.getLevel(r);if(void 0!==t||null!==t)return e.tileScheme.levels[t].zIndex}),[r])},exports.useMapPick=function(){var e=z(),r=e.map,o=e.painter,n=t.useState(),i=n[0],s=n[1],a=t.useMemo((function(){return r.layers}),[r.layers]),u=t.useCallback((function(e){if(e instanceof P.sGisClickEvent){var t=[0,0,o.width,o.height],r=o.getPxPosition(e.point.position),n=r[1];s({clickPoint:[Math.round(r[0]),Math.round(n)],envelopes:Ce(a),imageRectangle:t})}}),[r]);return de({onMount:function(){return r.on("click",u)},onUnmount:function(){return r.off("click",u)}}),i},exports.useMapState=ke,exports.useMapView=function(){var e=z(),r=e.map,o=e.painter,n=ke(),i=n.position,s=n.resolution,a=t.useMemo((function(){var e=r.tileScheme.getLevel(s);if(void 0!==e||null!==e)return r.tileScheme.levels[e].zIndex}),[s]),u=t.useMemo((function(){return o.bbox}),[i,s]);return{position:i,resolution:s,level:a,bbox:u}},exports.useMapViewActions=Se,exports.useMapWrapper=Me,exports.useMaxMinScale=_e,exports.useMount=de,exports.useProperty=pe,exports.useScale=function(e){var r,o,n,i,s,a=e.minLength,u=void 0===a?50:a,l=(r=e.resolution,o=z().painter,t.useMemo((function(){if(0===i)return r;var e=i/10,t=o.getPointFromPxPosition(0,n/2),s=o.getPointFromPxPosition(e,n/2);return g.distance(t,s)/e}),[n=o.height,i=o.width,(s=o.bbox).xMin,s.xMax,s.yMin,s.yMax,s.crs.wkid,r,o]));return t.useMemo((function(){var e=u*l;return{currentScale:Fe(e),width:Fe(e)/l}}),[l,u])},exports.useUpdate=he,exports.useUpdateMapView=Ae;
//# sourceMappingURL=react.cjs.production.min.js.map

@@ -1,2 +0,3 @@

import React__default, { useMemo, createElement, useContext, createContext, useEffect, useCallback, useRef, useState, useReducer } from 'react';
import React, { useMemo, useContext, createContext, useEffect, useRef, useCallback, useState, useReducer } from 'react';
import { Api, EvergisDynamicLayer as EvergisDynamicLayer$1, EvergisTileLayer as EvergisTileLayer$1, isEvergisDynamicLayer } from '@evergis/api';
import { Map as Map$1, BboxChangeEvent, BboxChangeEndEvent } from '@evergis/sgis/es/Map';

@@ -7,8 +8,10 @@ import { DomPainter } from '@evergis/sgis/es/painters/DomPainter/DomPainter';

import { Polygon } from '@evergis/sgis/es/features/Polygon';
import ReactDOM from 'react-dom';
import { DynamicPointSymbol } from '@evergis/sgis/es/symbols/Symbol';
import { Arc } from '@evergis/sgis/es/renders/Arc';
import { PointSymbol } from '@evergis/sgis/es/symbols/point/Point';
import { PointFeature } from '@evergis/sgis/es/features/PointFeature';
import { PolylineSymbol } from '@evergis/sgis/es/symbols/PolylineSymbol';
import { Poly } from '@evergis/sgis/es/features/Poly';
import { PolyRender, FillStyle } from '@evergis/sgis/es/renders/Poly';
import { Arc } from '@evergis/sgis/es/renders/Arc';
import { PointSymbol } from '@evergis/sgis/es/symbols/point/Point';
import { PointFeature } from '@evergis/sgis/es/features/PointFeature';
import { PolylineControl } from '@evergis/sgis/es/controls/PolylineControl';

@@ -19,12 +22,28 @@ import { LabelFeature } from '@evergis/sgis/es/features/Label';

import { DrawingFinishEvent } from '@evergis/sgis/es/controls/Control';
import ReactDOM from 'react-dom';
import { DynamicPointSymbol } from '@evergis/sgis/es/symbols/Symbol';
import { softEquals } from '@evergis/sgis/es/utils/math';
import { PolyEditor } from '@evergis/sgis/es/controls/PolyEditor';
import { FeatureLayer as FeatureLayer$2 } from '@evergis/sgis';
import { sGisClickEvent } from '@evergis/sgis/es/commonEvents';
import { Bbox } from '@evergis/sgis/es/Bbox';
import { Api, EvergisDynamicLayer as EvergisDynamicLayer$1, EvergisTileLayer as EvergisTileLayer$1, isEvergisDynamicLayer } from '@evergis/api';
import { FeatureLayer as FeatureLayer$2 } from '@evergis/sgis';
import { TileLayer as TileLayer$1 } from '@evergis/sgis/es/layers/TileLayer';
import { sGisClickEvent } from '@evergis/sgis/es/commonEvents';
var BASE_URL = '/';
var defaultApi = /*#__PURE__*/new Api({
url: BASE_URL
});
var evergisContext = /*#__PURE__*/createContext(defaultApi);
var EvergisProvider = function EvergisProvider(_ref) {
var api = _ref.api,
children = _ref.children;
var value = useMemo(function () {
return api || defaultApi;
}, [api]);
return React.createElement(evergisContext.Provider, {
value: value
}, children);
};
var useEvergisContext = function useEvergisContext() {
return useContext(evergisContext);
};
var defaultMap = /*#__PURE__*/new Map$1();

@@ -45,3 +64,3 @@ var defaultPainter = /*#__PURE__*/new DomPainter(defaultMap);

}, [map]);
return createElement(mapContext.Provider, {
return React.createElement(mapContext.Provider, {
value: value

@@ -245,2 +264,82 @@ }, children);

var LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
_inherits(LabelSymbol, _DynamicPointSymbol);
var _super = /*#__PURE__*/_createSuper(LabelSymbol);
function LabelSymbol(_temp) {
var _this;
var _ref = _temp === void 0 ? {} : _temp,
component = _ref.component,
offset = _ref.offset;
_classCallCheck(this, LabelSymbol);
_this = _super.call(this, {
offset: offset
});
_this.component = component;
return _this;
}
_createClass(LabelSymbol, [{
key: "_getFeatureNode",
value: function _getFeatureNode(feature) {
var node = document.createElement('div');
this.renderDom(feature.content, node);
return node;
}
}, {
key: "_updateFeatureNode",
value: function _updateFeatureNode(feature) {
this.renderDom(feature.content, this.getNode(feature));
}
}, {
key: "renderDom",
value: function renderDom(content, node) {
if (!node) {
return;
}
var Component = this.component;
if (Component) {
ReactDOM.render(React.createElement(Component, {
content: content
}), node);
} else {
node.innerText = content;
}
}
}]);
return LabelSymbol;
}(DynamicPointSymbol);
var defaultOffset = [8, -16];
var createLabelSymbol = function createLabelSymbol(props) {
var _ref = props || {},
_ref$offset = _ref.offset,
offset = _ref$offset === void 0 ? defaultOffset : _ref$offset,
_ref$renderLabel = _ref.renderLabel,
renderLabel = _ref$renderLabel === void 0 ? function (_ref2) {
var content = _ref2.content;
return React.createElement("div", null, content);
} : _ref$renderLabel,
_ref$onClose = _ref.onClose,
onClose = _ref$onClose === void 0 ? undefined : _ref$onClose;
return new LabelSymbol({
offset: offset,
component: function component(_ref3) {
var content = _ref3.content;
return renderLabel({
content: content,
onClose: onClose
});
}
});
};
function createShadowRender(position, _ref) {

@@ -476,82 +575,2 @@ var _ref$strokeWidth = _ref.strokeWidth,

var LabelSymbol = /*#__PURE__*/function (_DynamicPointSymbol) {
_inherits(LabelSymbol, _DynamicPointSymbol);
var _super = /*#__PURE__*/_createSuper(LabelSymbol);
function LabelSymbol(_temp) {
var _this;
var _ref = _temp === void 0 ? {} : _temp,
component = _ref.component,
offset = _ref.offset;
_classCallCheck(this, LabelSymbol);
_this = _super.call(this, {
offset: offset
});
_this.component = component;
return _this;
}
_createClass(LabelSymbol, [{
key: "_getFeatureNode",
value: function _getFeatureNode(feature) {
var node = document.createElement('div');
this.renderDom(feature.content, node);
return node;
}
}, {
key: "_updateFeatureNode",
value: function _updateFeatureNode(feature) {
this.renderDom(feature.content, this.getNode(feature));
}
}, {
key: "renderDom",
value: function renderDom(content, node) {
if (!node) {
return;
}
var Component = this.component;
if (Component) {
ReactDOM.render(React__default.createElement(Component, {
content: content
}), node);
} else {
node.innerText = content;
}
}
}]);
return LabelSymbol;
}(DynamicPointSymbol);
var defaultOffset = [8, -16];
var createLabelSymbol = function createLabelSymbol(props) {
var _ref = props || {},
_ref$offset = _ref.offset,
offset = _ref$offset === void 0 ? defaultOffset : _ref$offset,
_ref$renderLabel = _ref.renderLabel,
renderLabel = _ref$renderLabel === void 0 ? function (_ref2) {
var content = _ref2.content;
return React__default.createElement("div", null, content);
} : _ref$renderLabel,
_ref$onClose = _ref.onClose,
onClose = _ref$onClose === void 0 ? undefined : _ref$onClose;
return new LabelSymbol({
offset: offset,
component: function component(_ref3) {
var content = _ref3.content;
return renderLabel({
content: content,
onClose: onClose
});
}
});
};
function polylineLikePolygon(rings, resolution) {

@@ -693,7 +712,7 @@ if (rings[0].length <= 3) {

lat = _projection[0],
_long = _projection[1];
long = _projection[1];
this.removeTempLabel();
this.addMeasureResultLabel();
this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + _long.toFixed(COORD_FRACTION), point);
this.addCoordLabel(lat.toFixed(COORD_FRACTION) + ", " + long.toFixed(COORD_FRACTION), point);
} else {

@@ -1066,3 +1085,3 @@ this.removeCoordLabel();

value: function render() {
return React__default.createElement("div", {
return React.createElement("div", {
style: {

@@ -1076,3 +1095,3 @@ display: 'none'

return MeasureTool;
}(React__default.Component);
}(React.Component);

@@ -1087,3 +1106,3 @@ var Measurer = function Measurer(_ref) {

return isActive ? React__default.createElement(MeasureTool, {
return isActive ? React.createElement(MeasureTool, {
map: map,

@@ -1095,124 +1114,2 @@ painter: painter,

var byScale = function byScale(scale) {
return function (_ref) {
var zIndex = _ref.zIndex;
return zIndex === scale;
};
};
var useMaxMinScale = function useMaxMinScale(minScale, maxScale, currentPosition, currentResolution) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
useEffect(function () {
var levels = map.tileScheme.levels;
if (maxScale !== undefined) {
var _ref2 = levels.find(byScale(maxScale)) || {
resolution: -1
},
resolution = _ref2.resolution;
map.minResolution = resolution;
}
if (minScale !== undefined) {
var _ref3 = levels.find(byScale(minScale)) || {
resolution: -1
},
_resolution = _ref3.resolution;
map.maxResolution = _resolution;
}
if (minScale !== undefined || maxScale !== undefined) {
updateMapResolution(map, currentPosition, currentResolution);
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, minScale, maxScale]);
};
var updateMapResolution = function updateMapResolution(map, currentPosition, currentResolution) {
if (currentPosition && currentResolution) {
var newResolution = Math.min(Math.max(currentResolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE);
map.animateTo(currentPosition, newResolution);
}
};
function useMapViewActions() {
var _useMapContext = useMapContext(),
map = _useMapContext.map,
painter = _useMapContext.painter;
var zoomTo = useCallback(function (k) {
map.zoom(k, map.position);
}, [map]);
var animateTo = useCallback(function (_ref) {
var position = _ref.position,
resolution = _ref.resolution,
extent = _ref.extent;
if (position || resolution) {
var nextPosition = position ? position.slice(0) : map.position;
map.animateTo(nextPosition, resolution || map.resolution);
}
if (extent) {
var xMax = extent.xMax,
xMin = extent.xMin,
yMax = extent.yMax,
yMin = extent.yMin;
var bbox = new Bbox([xMin, yMax], [xMax, yMin], map.crs);
painter && painter.show(bbox, true);
}
}, [map, painter]);
var zoomAround = useCallback(function (event) {
var _event$sourceObject;
map.zoom(1, event === null || event === void 0 ? void 0 : (_event$sourceObject = event.sourceObject) === null || _event$sourceObject === void 0 ? void 0 : _event$sourceObject.point);
}, [map]);
return {
zoomTo: zoomTo,
animateTo: animateTo,
zoomAround: zoomAround
};
}
function useUpdateMapView(_ref, force) {
var position = _ref.position,
resolution = _ref.resolution;
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var _useMapViewActions = useMapViewActions(),
animateTo = _useMapViewActions.animateTo;
useEffect(function () {
if (shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
animateTo({
position: position,
resolution: resolution
});
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [position, resolution, force]);
}
function shouldUpdatePosition(map, position) {
return position && (!softEquals(map.position[0], position[0]) || !softEquals(map.position[1], position[1]));
}
function shouldUpdateResolution(map, resolution) {
return resolution && !softEquals(map.resolution, resolution);
}
function shouldUpdateMapState(map, _ref2) {
var position = _ref2.position,
resolution = _ref2.resolution;
return shouldUpdatePosition(map, position) || shouldUpdateResolution(map, resolution);
}
function useMount(_ref) {

@@ -1227,75 +1124,2 @@ var onMount = _ref.onMount,

function useMapWrapper() {
var _useMapContext = useMapContext(),
painter = _useMapContext.painter;
var wrapperRef = useRef(null);
useMount({
onMount: function onMount() {
return painter.wrapper = wrapperRef.current;
},
onUnmount: function onUnmount() {
return painter.wrapper = null;
}
});
return wrapperRef;
}
function useMapBboxChange(onBboxChange, force) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var event = force ? BboxChangeEvent : BboxChangeEndEvent;
var handleBboxChange = useCallback(function () {
onBboxChange && onBboxChange(getMapState(map)); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onBboxChange, map, event]);
useEffect(function () {
map.on(event.type, handleBboxChange);
return function () {
map.off(event.type, handleBboxChange);
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleBboxChange, event]);
}
function getMapState(map) {
return {
position: map.position.slice(0),
resolution: map.resolution
};
}
var Map = function Map(_ref) {
var className = _ref.className,
position = _ref.position,
resolution = _ref.resolution,
minScale = _ref.minScale,
maxScale = _ref.maxScale,
children = _ref.children,
onBboxChange = _ref.onBboxChange,
style = _ref.style;
var wrapperRef = useMapWrapper();
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var handleBboxChange = useCallback(function (state) {
if (onBboxChange && shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
onBboxChange(state);
}
}, [map, onBboxChange, position, resolution]);
useUpdateMapView({
position: position,
resolution: resolution
});
useMaxMinScale(minScale, maxScale, position, resolution);
useMapBboxChange(handleBboxChange);
return React__default.createElement("div", {
className: className,
ref: wrapperRef,
style: style
}, children);
};
function useProperty(_ref, deps) {

@@ -1339,20 +1163,2 @@ var factory = _ref.factory,

var defaultApi = /*#__PURE__*/new Api({
url: '/'
});
var evergisContext = /*#__PURE__*/createContext(defaultApi);
var EvergisProvider = function EvergisProvider(_ref) {
var api = _ref.api,
children = _ref.children;
var value = useMemo(function () {
return api || defaultApi;
}, [api]);
return createElement(evergisContext.Provider, {
value: value
}, children);
};
var useEvergisContext = function useEvergisContext() {
return useContext(evergisContext);
};
function useUpdate(_ref) {

@@ -1432,7 +1238,2 @@ var onUpdate = _ref.onUpdate,

var EvergisDynamicLayer = function EvergisDynamicLayer(props) {
useEvergisDynamicLayer(props);
return null;
};
function useEvergisTileLayer(_ref) {

@@ -1472,7 +1273,2 @@ var name = _ref.name,

var EvergisTileLayer = function EvergisTileLayer(props) {
useEvergisTileLayer(props);
return null;
};
function useFeatureLayer(_ref) {

@@ -1506,33 +1302,24 @@ var zIndex = _ref.zIndex,

var FeatureLayer = function FeatureLayer(props) {
useFeatureLayer(props);
return null;
};
function useTileLayer(_ref) {
var maskUrl = _ref.maskUrl,
zIndex = _ref.zIndex,
isDisplayed = _ref.isDisplayed;
function useMapBboxChange(onBboxChange, force) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var layer = useProperty({
factory: function factory() {
return new TileLayer$1(maskUrl);
},
destructor: function destructor(layer) {
return map.indexOf(layer) !== -1 && map.removeLayer(layer);
}
}, [maskUrl]);
useLayerOrder(layer, zIndex);
useLayerVisibility(layer, isDisplayed);
return layer;
var event = force ? BboxChangeEvent : BboxChangeEndEvent;
var handleBboxChange = useCallback(function () {
onBboxChange && onBboxChange(getMapState(map)); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onBboxChange, map, event]);
useEffect(function () {
map.on(event.type, handleBboxChange);
return function () {
map.off(event.type, handleBboxChange);
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleBboxChange, event]);
}
function getMapState(map) {
return {
position: map.position.slice(0),
resolution: map.resolution
};
}
var TileLayer = function TileLayer(props) {
useTileLayer(props);
return null;
};
var useMapPick = function useMapPick() {

@@ -1660,2 +1447,110 @@ var _useMapContext = useMapContext(),

function useMapViewActions() {
var _useMapContext = useMapContext(),
map = _useMapContext.map,
painter = _useMapContext.painter;
var zoomTo = useCallback(function (k) {
map.zoom(k, map.position);
}, [map]);
var zoomIn = useCallback(function () {
return zoomTo(1);
}, [zoomTo]);
var zoomOut = useCallback(function () {
return zoomTo(-1);
}, [zoomTo]);
var animateTo = useCallback(function (_ref) {
var position = _ref.position,
resolution = _ref.resolution,
extent = _ref.extent;
if (position || resolution) {
var nextPosition = position ? position.slice(0) : map.position;
map.animateTo(nextPosition, resolution || map.resolution);
}
if (extent) {
var xMax = extent.xMax,
xMin = extent.xMin,
yMax = extent.yMax,
yMin = extent.yMin;
var bbox = new Bbox([xMin, yMax], [xMax, yMin], map.crs);
painter && painter.show(bbox, true);
}
}, [map, painter]);
var zoomAround = useCallback(function (event) {
var _event$sourceObject;
map.zoom(1, event === null || event === void 0 ? void 0 : (_event$sourceObject = event.sourceObject) === null || _event$sourceObject === void 0 ? void 0 : _event$sourceObject.point);
}, [map]);
return {
zoomTo: zoomTo,
zoomIn: zoomIn,
zoomOut: zoomOut,
zoomAround: zoomAround,
animateTo: animateTo
};
}
function useMapWrapper() {
var _useMapContext = useMapContext(),
painter = _useMapContext.painter;
var wrapperRef = useRef(null);
useMount({
onMount: function onMount() {
return painter.wrapper = wrapperRef.current;
},
onUnmount: function onUnmount() {
return painter.wrapper = null;
}
});
return wrapperRef;
}
var byScale = function byScale(scale) {
return function (_ref) {
var zIndex = _ref.zIndex;
return zIndex === scale;
};
};
var useMaxMinScale = function useMaxMinScale(minScale, maxScale, currentPosition, currentResolution) {
var _useMapContext = useMapContext(),
map = _useMapContext.map;
useEffect(function () {
var levels = map.tileScheme.levels;
if (maxScale !== undefined) {
var _ref2 = levels.find(byScale(maxScale)) || {
resolution: -1
},
resolution = _ref2.resolution;
map.minResolution = resolution;
}
if (minScale !== undefined) {
var _ref3 = levels.find(byScale(minScale)) || {
resolution: -1
},
_resolution = _ref3.resolution;
map.maxResolution = _resolution;
}
if (minScale !== undefined || maxScale !== undefined) {
updateMapResolution(map, currentPosition, currentResolution);
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, minScale, maxScale]);
};
var updateMapResolution = function updateMapResolution(map, currentPosition, currentResolution) {
if (currentPosition && currentResolution) {
var newResolution = Math.min(Math.max(currentResolution, map.minResolution || 0), map.maxResolution || Number.MAX_VALUE);
map.animateTo(currentPosition, newResolution);
}
};
function getScale(scale) {

@@ -1707,3 +1602,118 @@ var pow10 = Math.pow(10, (Math.floor(scale) + '').length - 1);

export { BaseMeasureToolCreator, BaseMeasureToolEditor, EvergisDynamicLayer, EvergisProvider, EvergisTileLayer, FeatureLayer, LabelSymbol, Map, MapProvider, MeasureTool, Measurer, ShadowedPointSymbol, ShadowedPolySymbol, TileLayer, createLabelSymbol, createShadowRender, defaultOffset, formatArea, formatLength, getEditorPointRenderer, getMapState, measureAreaSymbol, measureLengthSymbol, measurePolygonSnapSymbol, useEvergisContext, useEvergisDynamicLayer, useEvergisTileLayer, useFeatureLayer, useLayerOrder, useLayerVisibility, useMapBboxChange, useMapContext, useMapLevel, useMapPick, useMapState, useMapView, useMapViewActions, useMapWrapper, useMaxMinScale, useMount, useProperty, useScale, useUpdate, useUpdateMapView };
function useUpdateMapView(_ref, force) {
var position = _ref.position,
resolution = _ref.resolution;
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var _useMapViewActions = useMapViewActions(),
animateTo = _useMapViewActions.animateTo;
useEffect(function () {
if (shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
animateTo({
position: position,
resolution: resolution
});
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [position, resolution, force]);
}
function shouldUpdatePosition(map, position) {
return position && (!softEquals(map.position[0], position[0]) || !softEquals(map.position[1], position[1]));
}
function shouldUpdateResolution(map, resolution) {
return resolution && !softEquals(map.resolution, resolution);
}
function shouldUpdateMapState(map, _ref2) {
var position = _ref2.position,
resolution = _ref2.resolution;
return shouldUpdatePosition(map, position) || shouldUpdateResolution(map, resolution);
}
var Map = function Map(_ref) {
var className = _ref.className,
position = _ref.position,
resolution = _ref.resolution,
minScale = _ref.minScale,
maxScale = _ref.maxScale,
children = _ref.children,
onBboxChange = _ref.onBboxChange,
style = _ref.style;
var wrapperRef = useMapWrapper();
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var handleBboxChange = useCallback(function (state) {
if (onBboxChange && shouldUpdateMapState(map, {
position: position,
resolution: resolution
})) {
onBboxChange(state);
}
}, [map, onBboxChange, position, resolution]);
useUpdateMapView({
position: position,
resolution: resolution
});
useMaxMinScale(minScale, maxScale, position, resolution);
useMapBboxChange(handleBboxChange);
return React.createElement("div", {
className: className,
ref: wrapperRef,
style: style
}, children);
};
var EvergisDynamicLayer = function EvergisDynamicLayer(props) {
useEvergisDynamicLayer(props);
return null;
};
var AVAILABLE_BASE_MAPS = ['2gis', 'osm_mono', 'carto_dm', 'sputnik', 'stamen_terrain', 'stamen_toner', 'stamen_watercolor'];
var EvergisTileLayer = function EvergisTileLayer(props) {
useEvergisTileLayer(props);
return null;
};
var FeatureLayer = function FeatureLayer(props) {
useFeatureLayer(props);
return null;
};
function useTileLayer(_ref) {
var maskUrl = _ref.maskUrl,
zIndex = _ref.zIndex,
isDisplayed = _ref.isDisplayed;
var _useMapContext = useMapContext(),
map = _useMapContext.map;
var layer = useProperty({
factory: function factory() {
return new TileLayer$1(maskUrl);
},
destructor: function destructor(layer) {
return map.indexOf(layer) !== -1 && map.removeLayer(layer);
}
}, [maskUrl]);
useLayerOrder(layer, zIndex);
useLayerVisibility(layer, isDisplayed);
return layer;
}
var TileLayer = function TileLayer(props) {
useTileLayer(props);
return null;
};
export { AVAILABLE_BASE_MAPS, BaseMeasureToolCreator, BaseMeasureToolEditor, EvergisDynamicLayer, EvergisProvider, EvergisTileLayer, FeatureLayer, LabelSymbol, Map, MapProvider, MeasureTool, Measurer, ShadowedPointSymbol, ShadowedPolySymbol, TileLayer, createLabelSymbol, createShadowRender, defaultOffset, formatArea, formatLength, getEditorPointRenderer, getMapState, measureAreaSymbol, measureLengthSymbol, measurePolygonSnapSymbol, shouldUpdateMapState, useEvergisContext, useEvergisDynamicLayer, useEvergisTileLayer, useFeatureLayer, useLayerOrder, useLayerVisibility, useMapBboxChange, useMapContext, useMapLevel, useMapPick, useMapState, useMapView, useMapViewActions, useMapWrapper, useMaxMinScale, useMount, useProperty, useScale, useUpdate, useUpdateMapView };
//# sourceMappingURL=react.esm.js.map
import { Offset } from '@evergis/sgis/es/baseTypes';
import { renderLabelSymbolType } from '../components/Measurer/Measurer';
import { renderLabelSymbolType } from '../components';
import { LabelSymbol } from './LabelSymbol';

@@ -4,0 +4,0 @@ export declare const defaultOffset: Offset;

{
"version": "1.0.4",
"version": "1.0.5",
"license": "MIT",

@@ -25,7 +25,8 @@ "main": "dist/index.js",

"@evergis/sgis": ">=0.5.0-alpha.1",
"react": ">=16"
"react": ">=16",
"react-dom": ">=16"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
"pre-push": "tsdx lint"
}

@@ -44,10 +45,13 @@ },

"@babel/core": "^7.11.1",
"@evergis/api": "^1.0.4",
"@evergis/api": "^1.0.5",
"@evergis/sgis": "^0.5.0-alpha.8",
"@storybook/addon-actions": "^6.0.5",
"@storybook/addon-docs": "^6.0.5",
"@storybook/addon-info": "^5.3.19",
"@storybook/addon-links": "^6.0.5",
"@storybook/addons": "^6.0.5",
"@storybook/react": "^6.0.5",
"@storybook/addon-actions": "^6.0.21",
"@storybook/addon-controls": "^6.0.21",
"@storybook/addon-docs": "^6.0.21",
"@storybook/addon-info": "^5.3.21",
"@storybook/addon-links": "^6.0.21",
"@storybook/addon-storysource": "^6.0.21",
"@storybook/addons": "^6.0.21",
"@storybook/react": "^6.0.21",
"@storybook/theming": "^6.0.21",
"@types/react": "^16.9.46",

@@ -63,3 +67,3 @@ "@types/react-dom": "^16.9.8",

},
"gitHead": "82262b9ccce25c7ce6da309075477bdde7c29c6e"
"gitHead": "03c3a33c18f36086e0e913bfd90c35bb9d38a256"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc