@mapcomponents/react-maplibre 0.1.77 → 0.1.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -2
- package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +3 -40
- package/dist/components/MlTemporalController/MlTemporalController.d.ts +6 -0
- package/dist/components/MlTemporalController/MlTemporalController.stories.d.ts +1 -0
- package/dist/components/MlTemporalController/utils/TemporalControllerPlayer.d.ts +1 -0
- package/dist/components/MlTerrainLayer/MlTerrainLayer.cy.d.ts +1 -0
- package/dist/components/MlTerrainLayer/MlTerrainLayer.d.ts +28 -0
- package/dist/components/MlTerrainLayer/MlTerrainLayer.stories.d.ts +14 -0
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.d.ts +24 -9
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +1 -1
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +49 -3
- package/dist/contexts/LayerContext.d.ts +2 -0
- package/dist/decorators/TemporalControllerDecorator.d.ts +2 -0
- package/dist/hooks/useFeatureEditor.d.ts +46 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +288 -1402
- package/dist/index.esm.js.map +1 -1
- package/dist/ui_components/LayerList/LayerListItem.d.ts +4 -0
- package/dist/ui_components/LayerList/LayerListItemFactory.d.ts +0 -1
- package/dist/ui_components/SpeedDial/SpeedDial.d.ts +14 -0
- package/dist/ui_components/SpeedDial/SpeedDial.stories.d.ts +21 -0
- package/package.json +5 -5
- package/dist/components/MlFeatureEditor/custom-direct-select-mode.d.ts +0 -37
- package/dist/components/MlFeatureEditor/custom-polygon-mode.d.ts +0 -16
- package/dist/components/MlFeatureEditor/custom-select-mode.d.ts +0 -37
- package/dist/components/MlFeatureEditor/lib/common_selectors.d.ts +0 -11
- package/dist/components/MlFeatureEditor/lib/constants.d.ts +0 -85
- package/dist/components/MlFeatureEditor/lib/constrain_feature_movement.d.ts +0 -2
- package/dist/components/MlFeatureEditor/lib/create_midpoint.d.ts +0 -15
- package/dist/components/MlFeatureEditor/lib/create_supplementary_points.d.ts +0 -2
- package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +0 -13
- package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +0 -5
- package/dist/components/MlFeatureEditor/lib/euclidean_distance.d.ts +0 -5
- package/dist/components/MlFeatureEditor/lib/features_at.d.ts +0 -7
- package/dist/components/MlFeatureEditor/lib/get_features_and_set_cursor.d.ts +0 -1
- package/dist/components/MlFeatureEditor/lib/is_click.d.ts +0 -1
- package/dist/components/MlFeatureEditor/lib/is_event_at_coordinates.d.ts +0 -6
- package/dist/components/MlFeatureEditor/lib/is_tap.d.ts +0 -3
- package/dist/components/MlFeatureEditor/lib/map_event_to_bounding_box.d.ts +0 -12
- package/dist/components/MlFeatureEditor/lib/mode_handler.d.ts +0 -24
- package/dist/components/MlFeatureEditor/lib/mouse_event_point.d.ts +0 -11
- package/dist/components/MlFeatureEditor/lib/move_features.d.ts +0 -2
- package/dist/components/MlFeatureEditor/lib/sort_features.d.ts +0 -2
- package/dist/components/MlFeatureEditor/lib/string_set.d.ts +0 -21
- package/dist/components/MlFeatureEditor/lib/string_sets_are_equal.d.ts +0 -5
- package/dist/components/MlFeatureEditor/lib/theme.d.ts +0 -88
- package/dist/components/MlFeatureEditor/lib/to_dense_array.d.ts +0 -12
- package/dist/components/MlFeatureEditor/lib/utils.d.ts +0 -10
- package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +0 -10
- package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +0 -6
- package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +0 -12
- package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +0 -10
- package/dist/components/MlThreeJsLayer/MlThreejsLayer.d.ts +0 -30
package/dist/index.esm.js
CHANGED
|
@@ -18,10 +18,6 @@ var Moveable = require('react-moveable');
|
|
|
18
18
|
var turf = require('@turf/turf');
|
|
19
19
|
require('@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css');
|
|
20
20
|
var MapboxDraw = require('@mapbox/mapbox-gl-draw');
|
|
21
|
-
var Point = require('@mapbox/point-geometry');
|
|
22
|
-
var require$$0 = require('@mapbox/geojson-coords');
|
|
23
|
-
var require$$1 = require('traverse');
|
|
24
|
-
var require$$2 = require('@mapbox/extent');
|
|
25
21
|
var ButtonGroup = require('@mui/material/ButtonGroup');
|
|
26
22
|
var ControlPointIcon = require('@mui/icons-material/ControlPoint');
|
|
27
23
|
var RemoveCircleOutlineIcon = require('@mui/icons-material/RemoveCircleOutline');
|
|
@@ -54,6 +50,8 @@ var d3 = require('d3');
|
|
|
54
50
|
var TuneIcon = require('@mui/icons-material/Tune');
|
|
55
51
|
var reactColor = require('react-color');
|
|
56
52
|
var system = require('@mui/system');
|
|
53
|
+
var ArrowCircleDownIcon = require('@mui/icons-material/ArrowCircleDown');
|
|
54
|
+
var ArrowCircleUpIcon = require('@mui/icons-material/ArrowCircleUp');
|
|
57
55
|
var PlaylistAddIcon = require('@mui/icons-material/PlaylistAdd');
|
|
58
56
|
var DynamicFeedIcon = require('@mui/icons-material/DynamicFeed');
|
|
59
57
|
var AppBar = require('@mui/material/AppBar');
|
|
@@ -65,6 +63,12 @@ var react = require('@emotion/react');
|
|
|
65
63
|
var _ = require('@mui/material/');
|
|
66
64
|
var FileCopy = require('@mui/icons-material/FileCopy');
|
|
67
65
|
var WallpaperIcon = require('@mui/icons-material/Wallpaper');
|
|
66
|
+
var MuiSpeedDial = require('@mui/material/SpeedDial');
|
|
67
|
+
var MoreVertIcon = require('@mui/icons-material/MoreVert');
|
|
68
|
+
var SpeedDialAction = require('@mui/material/SpeedDialAction');
|
|
69
|
+
var LayersIcon = require('@mui/icons-material/Layers');
|
|
70
|
+
var DesignServicesIcon = require('@mui/icons-material/DesignServices');
|
|
71
|
+
var PictureAsPdfIcon = require('@mui/icons-material/PictureAsPdf');
|
|
68
72
|
|
|
69
73
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
70
74
|
|
|
@@ -97,10 +101,6 @@ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
|
97
101
|
var Moveable__default = /*#__PURE__*/_interopDefaultLegacy(Moveable);
|
|
98
102
|
var turf__namespace = /*#__PURE__*/_interopNamespace(turf);
|
|
99
103
|
var MapboxDraw__default = /*#__PURE__*/_interopDefaultLegacy(MapboxDraw);
|
|
100
|
-
var Point__default = /*#__PURE__*/_interopDefaultLegacy(Point);
|
|
101
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
102
|
-
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
103
|
-
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
104
104
|
var ButtonGroup__default = /*#__PURE__*/_interopDefaultLegacy(ButtonGroup);
|
|
105
105
|
var ControlPointIcon__default = /*#__PURE__*/_interopDefaultLegacy(ControlPointIcon);
|
|
106
106
|
var RemoveCircleOutlineIcon__default = /*#__PURE__*/_interopDefaultLegacy(RemoveCircleOutlineIcon);
|
|
@@ -128,6 +128,8 @@ var FastForwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(FastForwardIco
|
|
|
128
128
|
var FastRewindIcon__default = /*#__PURE__*/_interopDefaultLegacy(FastRewindIcon);
|
|
129
129
|
var d3__namespace = /*#__PURE__*/_interopNamespace(d3);
|
|
130
130
|
var TuneIcon__default = /*#__PURE__*/_interopDefaultLegacy(TuneIcon);
|
|
131
|
+
var ArrowCircleDownIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowCircleDownIcon);
|
|
132
|
+
var ArrowCircleUpIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowCircleUpIcon);
|
|
131
133
|
var PlaylistAddIcon__default = /*#__PURE__*/_interopDefaultLegacy(PlaylistAddIcon);
|
|
132
134
|
var DynamicFeedIcon__default = /*#__PURE__*/_interopDefaultLegacy(DynamicFeedIcon);
|
|
133
135
|
var AppBar__default = /*#__PURE__*/_interopDefaultLegacy(AppBar);
|
|
@@ -137,6 +139,12 @@ var MenuIcon__default = /*#__PURE__*/_interopDefaultLegacy(MenuIcon);
|
|
|
137
139
|
var CloseIcon__default = /*#__PURE__*/_interopDefaultLegacy(CloseIcon);
|
|
138
140
|
var FileCopy__default = /*#__PURE__*/_interopDefaultLegacy(FileCopy);
|
|
139
141
|
var WallpaperIcon__default = /*#__PURE__*/_interopDefaultLegacy(WallpaperIcon);
|
|
142
|
+
var MuiSpeedDial__default = /*#__PURE__*/_interopDefaultLegacy(MuiSpeedDial);
|
|
143
|
+
var MoreVertIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreVertIcon);
|
|
144
|
+
var SpeedDialAction__default = /*#__PURE__*/_interopDefaultLegacy(SpeedDialAction);
|
|
145
|
+
var LayersIcon__default = /*#__PURE__*/_interopDefaultLegacy(LayersIcon);
|
|
146
|
+
var DesignServicesIcon__default = /*#__PURE__*/_interopDefaultLegacy(DesignServicesIcon);
|
|
147
|
+
var PictureAsPdfIcon__default = /*#__PURE__*/_interopDefaultLegacy(PictureAsPdfIcon);
|
|
140
148
|
|
|
141
149
|
/******************************************************************************
|
|
142
150
|
Copyright (c) Microsoft Corporation.
|
|
@@ -772,8 +780,9 @@ var darkDefault = styles.createTheme({
|
|
|
772
780
|
var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode === 'light' ? lightDefault : darkDefault)), { palette: __assign({ mode: mode }, (mode === 'dark'
|
|
773
781
|
? {
|
|
774
782
|
primary: {
|
|
775
|
-
main: '#
|
|
783
|
+
main: '#009EE0',
|
|
776
784
|
},
|
|
785
|
+
secondary: { main: '#747577' },
|
|
777
786
|
background: {
|
|
778
787
|
default: '#222222',
|
|
779
788
|
paper: '#414141',
|
|
@@ -786,15 +795,16 @@ var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode ===
|
|
|
786
795
|
}
|
|
787
796
|
: {
|
|
788
797
|
primary: {
|
|
789
|
-
main: '#
|
|
798
|
+
main: '#009EE0',
|
|
790
799
|
},
|
|
800
|
+
secondary: { main: '#747577' },
|
|
791
801
|
background: {
|
|
792
802
|
default: '#fff',
|
|
793
803
|
paper: '#fdfdfd',
|
|
794
804
|
icon: '#bdbdbd',
|
|
795
805
|
},
|
|
796
806
|
text: {
|
|
797
|
-
primary: '#
|
|
807
|
+
primary: '#1A171B',
|
|
798
808
|
secondary: '#121212',
|
|
799
809
|
contrast: '#fff',
|
|
800
810
|
},
|
|
@@ -930,6 +940,7 @@ function LayerContextProvider(props) {
|
|
|
930
940
|
setSymbolLayers(symbolLayers);
|
|
931
941
|
};
|
|
932
942
|
React.useEffect(function () {
|
|
943
|
+
console.log('layers', layers);
|
|
933
944
|
if (layers.filter(function (el) { return !(el === null || el === void 0 ? void 0 : el.id); }).length) {
|
|
934
945
|
var _layers = __spreadArray([], layers, true);
|
|
935
946
|
_layers.forEach(function (el) {
|
|
@@ -940,6 +951,34 @@ function LayerContextProvider(props) {
|
|
|
940
951
|
setLayers(_layers);
|
|
941
952
|
}
|
|
942
953
|
}, [layers]);
|
|
954
|
+
var moveDown = React.useCallback(function (layerId) {
|
|
955
|
+
var _a;
|
|
956
|
+
var targetLayer = (_a = layers === null || layers === void 0 ? void 0 : layers.filter) === null || _a === void 0 ? void 0 : _a.call(layers, function (el) { return el.id === layerId; });
|
|
957
|
+
if (targetLayer.length > 0) {
|
|
958
|
+
var newLayers = __spreadArray([], layers, true);
|
|
959
|
+
var element = targetLayer[0];
|
|
960
|
+
var idx = layers.indexOf(element);
|
|
961
|
+
if (idx + 1 <= layers.length - 1) {
|
|
962
|
+
newLayers.splice(idx, 1);
|
|
963
|
+
newLayers.splice(idx + 1, 0, element);
|
|
964
|
+
setLayers(newLayers);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}, [layers]);
|
|
968
|
+
var moveUp = React.useCallback(function (layerId) {
|
|
969
|
+
var _a;
|
|
970
|
+
var targetLayer = (_a = layers === null || layers === void 0 ? void 0 : layers.filter) === null || _a === void 0 ? void 0 : _a.call(layers, function (el) { return el.id === layerId; });
|
|
971
|
+
if (targetLayer.length > 0) {
|
|
972
|
+
var newLayers = JSON.parse(JSON.stringify(layers));
|
|
973
|
+
var element = targetLayer[0];
|
|
974
|
+
var idx = layers.indexOf(element);
|
|
975
|
+
if (idx - 1 >= 0) {
|
|
976
|
+
newLayers.splice(idx, 1);
|
|
977
|
+
newLayers.splice(idx - 1, 0, element);
|
|
978
|
+
setLayers(newLayers);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}, [layers]);
|
|
943
982
|
var value = {
|
|
944
983
|
layers: layers,
|
|
945
984
|
setLayers: setLayers,
|
|
@@ -951,6 +990,8 @@ function LayerContextProvider(props) {
|
|
|
951
990
|
vtLayerConfig: vtLayerConfig,
|
|
952
991
|
tileUrl: tileUrl,
|
|
953
992
|
setTileUrl: setTileUrl,
|
|
993
|
+
moveUp: moveUp,
|
|
994
|
+
moveDown: moveDown,
|
|
954
995
|
};
|
|
955
996
|
return React__default["default"].createElement(LayerContext.Provider, { value: value }, props.children);
|
|
956
997
|
}
|
|
@@ -2030,1323 +2071,10 @@ MlCreatePdfForm.defaultProps = {
|
|
|
2030
2071
|
mapId: undefined,
|
|
2031
2072
|
};
|
|
2032
2073
|
|
|
2033
|
-
/**
|
|
2034
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2035
|
-
* and licensed under ISC
|
|
2036
|
-
*/
|
|
2037
|
-
var classes = {
|
|
2038
|
-
CONTROL_BASE: 'mapboxgl-ctrl',
|
|
2039
|
-
CONTROL_PREFIX: 'mapboxgl-ctrl-',
|
|
2040
|
-
CONTROL_BUTTON: 'mapbox-gl-draw_ctrl-draw-btn',
|
|
2041
|
-
CONTROL_BUTTON_LINE: 'mapbox-gl-draw_line',
|
|
2042
|
-
CONTROL_BUTTON_POLYGON: 'mapbox-gl-draw_polygon',
|
|
2043
|
-
CONTROL_BUTTON_POINT: 'mapbox-gl-draw_point',
|
|
2044
|
-
CONTROL_BUTTON_TRASH: 'mapbox-gl-draw_trash',
|
|
2045
|
-
CONTROL_BUTTON_COMBINE_FEATURES: 'mapbox-gl-draw_combine',
|
|
2046
|
-
CONTROL_BUTTON_UNCOMBINE_FEATURES: 'mapbox-gl-draw_uncombine',
|
|
2047
|
-
CONTROL_GROUP: 'mapboxgl-ctrl-group',
|
|
2048
|
-
ATTRIBUTION: 'mapboxgl-ctrl-attrib',
|
|
2049
|
-
ACTIVE_BUTTON: 'active',
|
|
2050
|
-
BOX_SELECT: 'mapbox-gl-draw_boxselect'
|
|
2051
|
-
};
|
|
2052
|
-
var cursors = {
|
|
2053
|
-
ADD: 'add',
|
|
2054
|
-
MOVE: 'move',
|
|
2055
|
-
DRAG: 'drag',
|
|
2056
|
-
POINTER: 'pointer',
|
|
2057
|
-
NONE: 'none'
|
|
2058
|
-
};
|
|
2059
|
-
var types$1 = {
|
|
2060
|
-
POLYGON: 'polygon',
|
|
2061
|
-
LINE: 'line_string',
|
|
2062
|
-
POINT: 'point'
|
|
2063
|
-
};
|
|
2064
|
-
var geojsonTypes = {
|
|
2065
|
-
FEATURE: 'Feature',
|
|
2066
|
-
POLYGON: 'Polygon',
|
|
2067
|
-
LINE_STRING: 'LineString',
|
|
2068
|
-
POINT: 'Point',
|
|
2069
|
-
FEATURE_COLLECTION: 'FeatureCollection',
|
|
2070
|
-
MULTI_PREFIX: 'Multi',
|
|
2071
|
-
MULTI_POINT: 'MultiPoint',
|
|
2072
|
-
MULTI_LINE_STRING: 'MultiLineString',
|
|
2073
|
-
MULTI_POLYGON: 'MultiPolygon'
|
|
2074
|
-
};
|
|
2075
|
-
var events = {
|
|
2076
|
-
CREATE: 'draw.create',
|
|
2077
|
-
DELETE: 'draw.delete',
|
|
2078
|
-
UPDATE: 'draw.update',
|
|
2079
|
-
SELECTION_CHANGE: 'draw.selectionchange',
|
|
2080
|
-
MODE_CHANGE: 'draw.modechange',
|
|
2081
|
-
ACTIONABLE: 'draw.actionable',
|
|
2082
|
-
RENDER: 'draw.render',
|
|
2083
|
-
COMBINE_FEATURES: 'draw.combine',
|
|
2084
|
-
UNCOMBINE_FEATURES: 'draw.uncombine'
|
|
2085
|
-
};
|
|
2086
|
-
var updateActions = {
|
|
2087
|
-
MOVE: 'move',
|
|
2088
|
-
CHANGE_COORDINATES: 'change_coordinates'
|
|
2089
|
-
};
|
|
2090
|
-
var meta = {
|
|
2091
|
-
FEATURE: 'feature',
|
|
2092
|
-
MIDPOINT: 'midpoint',
|
|
2093
|
-
VERTEX: 'vertex'
|
|
2094
|
-
};
|
|
2095
|
-
var activeStates = {
|
|
2096
|
-
ACTIVE: 'true',
|
|
2097
|
-
INACTIVE: 'false'
|
|
2098
|
-
};
|
|
2099
|
-
var LAT_MIN$1 = -90;
|
|
2100
|
-
var LAT_RENDERED_MIN$1 = -85;
|
|
2101
|
-
var LAT_MAX$1 = 90;
|
|
2102
|
-
var LAT_RENDERED_MAX$1 = 85;
|
|
2103
|
-
var LNG_MIN$1 = -270;
|
|
2104
|
-
var LNG_MAX$1 = 270;
|
|
2105
|
-
|
|
2106
|
-
/**
|
|
2107
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2108
|
-
* and licensed under ISC
|
|
2109
|
-
*/
|
|
2110
|
-
function isOfMetaType(type) {
|
|
2111
|
-
return function (e) {
|
|
2112
|
-
var featureTarget = e.featureTarget;
|
|
2113
|
-
if (!featureTarget) return false;
|
|
2114
|
-
if (!featureTarget.properties) return false;
|
|
2115
|
-
return featureTarget.properties.meta === type;
|
|
2116
|
-
};
|
|
2117
|
-
}
|
|
2118
|
-
function isShiftMousedown(e) {
|
|
2119
|
-
if (!e.originalEvent) return false;
|
|
2120
|
-
if (!e.originalEvent.shiftKey) return false;
|
|
2121
|
-
return e.originalEvent.button === 0;
|
|
2122
|
-
}
|
|
2123
|
-
function isActiveFeature(e) {
|
|
2124
|
-
if (!e.featureTarget) return false;
|
|
2125
|
-
if (!e.featureTarget.properties) return false;
|
|
2126
|
-
return e.featureTarget.properties.active === activeStates.ACTIVE && e.featureTarget.properties.meta === meta.FEATURE;
|
|
2127
|
-
}
|
|
2128
|
-
function isInactiveFeature(e) {
|
|
2129
|
-
if (!e.featureTarget) return false;
|
|
2130
|
-
if (!e.featureTarget.properties) return false;
|
|
2131
|
-
return e.featureTarget.properties.active === activeStates.INACTIVE && e.featureTarget.properties.meta === meta.FEATURE;
|
|
2132
|
-
}
|
|
2133
|
-
function noTarget(e) {
|
|
2134
|
-
return e.featureTarget === undefined;
|
|
2135
|
-
}
|
|
2136
|
-
function isFeature(e) {
|
|
2137
|
-
if (!e.featureTarget) return false;
|
|
2138
|
-
if (!e.featureTarget.properties) return false;
|
|
2139
|
-
return e.featureTarget.properties.meta === meta.FEATURE;
|
|
2140
|
-
}
|
|
2141
|
-
function isVertex$1(e) {
|
|
2142
|
-
var featureTarget = e.featureTarget;
|
|
2143
|
-
if (!featureTarget) return false;
|
|
2144
|
-
if (!featureTarget.properties) return false;
|
|
2145
|
-
return featureTarget.properties.meta === meta.VERTEX;
|
|
2146
|
-
}
|
|
2147
|
-
function isShiftDown(e) {
|
|
2148
|
-
if (!e.originalEvent) return false;
|
|
2149
|
-
return e.originalEvent.shiftKey === true;
|
|
2150
|
-
}
|
|
2151
|
-
function isEscapeKey(e) {
|
|
2152
|
-
return e.keyCode === 27;
|
|
2153
|
-
}
|
|
2154
|
-
function isEnterKey(e) {
|
|
2155
|
-
return e.keyCode === 13;
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
/**
|
|
2159
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2160
|
-
* and licensed under ISC
|
|
2161
|
-
*/
|
|
2162
|
-
var doubleClickZoom = {
|
|
2163
|
-
enable: function enable(ctx) {
|
|
2164
|
-
setTimeout(function () {
|
|
2165
|
-
// First check we've got a map and some context.
|
|
2166
|
-
if (!ctx.map || !ctx.map.doubleClickZoom || !ctx._ctx || !ctx._ctx.store || !ctx._ctx.store.getInitialConfigValue) return;
|
|
2167
|
-
// Now check initial state wasn't false (we leave it disabled if so)
|
|
2168
|
-
if (!ctx._ctx.store.getInitialConfigValue("doubleClickZoom")) return;
|
|
2169
|
-
ctx.map.doubleClickZoom.enable();
|
|
2170
|
-
}, 0);
|
|
2171
|
-
},
|
|
2172
|
-
disable: function disable(ctx) {
|
|
2173
|
-
setTimeout(function () {
|
|
2174
|
-
if (!ctx.map || !ctx.map.doubleClickZoom) return;
|
|
2175
|
-
// Always disable here, as it's necessary in some cases.
|
|
2176
|
-
ctx.map.doubleClickZoom.disable();
|
|
2177
|
-
}, 0);
|
|
2178
|
-
}
|
|
2179
|
-
};
|
|
2180
|
-
|
|
2181
|
-
/**
|
|
2182
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2183
|
-
* and licensed under ISC
|
|
2184
|
-
*/
|
|
2185
|
-
function isEventAtCoordinates(event, coordinates) {
|
|
2186
|
-
if (!event.lngLat) return false;
|
|
2187
|
-
return event.lngLat.lng === coordinates[0] && event.lngLat.lat === coordinates[1];
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
/**
|
|
2191
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2192
|
-
* and licensed under ISC
|
|
2193
|
-
*/
|
|
2194
|
-
|
|
2195
|
-
/**
|
|
2196
|
-
* Returns GeoJSON for a Point representing the
|
|
2197
|
-
* vertex of another feature.
|
|
2198
|
-
*
|
|
2199
|
-
* @param {string} parentId
|
|
2200
|
-
* @param {Array<number>} coordinates
|
|
2201
|
-
* @param {string} path - Dot-separated numbers indicating exactly
|
|
2202
|
-
* where the point exists within its parent feature's coordinates.
|
|
2203
|
-
* @param {boolean} selected
|
|
2204
|
-
* @return {GeoJSON} Point
|
|
2205
|
-
*/
|
|
2206
|
-
var create_vertex = function create_vertex(parentId, coordinates, path, selected) {
|
|
2207
|
-
return {
|
|
2208
|
-
type: geojsonTypes.FEATURE,
|
|
2209
|
-
properties: {
|
|
2210
|
-
meta: meta.VERTEX,
|
|
2211
|
-
parent: parentId,
|
|
2212
|
-
coord_path: path,
|
|
2213
|
-
active: selected ? activeStates.ACTIVE : activeStates.INACTIVE
|
|
2214
|
-
},
|
|
2215
|
-
geometry: {
|
|
2216
|
-
type: geojsonTypes.POINT,
|
|
2217
|
-
coordinates: coordinates
|
|
2218
|
-
}
|
|
2219
|
-
};
|
|
2220
|
-
};
|
|
2221
|
-
|
|
2222
|
-
/**
|
|
2223
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2224
|
-
* and licensed under ISC
|
|
2225
|
-
*/
|
|
2226
|
-
var CustomPolygonMode = {};
|
|
2227
|
-
CustomPolygonMode.onSetup = function () {
|
|
2228
|
-
console.log("Change mode: custom polygon");
|
|
2229
|
-
var polygon = this.newFeature({
|
|
2230
|
-
type: geojsonTypes.FEATURE,
|
|
2231
|
-
properties: {},
|
|
2232
|
-
geometry: {
|
|
2233
|
-
type: geojsonTypes.POLYGON,
|
|
2234
|
-
coordinates: [[]]
|
|
2235
|
-
}
|
|
2236
|
-
});
|
|
2237
|
-
this.addFeature(polygon);
|
|
2238
|
-
this.clearSelectedFeatures();
|
|
2239
|
-
doubleClickZoom.disable(this);
|
|
2240
|
-
this.updateUIClasses({
|
|
2241
|
-
mouse: cursors.ADD
|
|
2242
|
-
});
|
|
2243
|
-
this.activateUIButton(types$1.POLYGON);
|
|
2244
|
-
this.setActionableState({
|
|
2245
|
-
trash: true
|
|
2246
|
-
});
|
|
2247
|
-
return {
|
|
2248
|
-
polygon: polygon,
|
|
2249
|
-
currentVertexPosition: 0
|
|
2250
|
-
};
|
|
2251
|
-
};
|
|
2252
|
-
CustomPolygonMode.clickAnywhere = function (state, e) {
|
|
2253
|
-
if (state.currentVertexPosition > 0 && isEventAtCoordinates(e, state.polygon.coordinates[0][state.currentVertexPosition - 1])) {
|
|
2254
|
-
return this.changeMode("custom_select", {
|
|
2255
|
-
featureIds: [state.polygon.id]
|
|
2256
|
-
});
|
|
2257
|
-
}
|
|
2258
|
-
this.updateUIClasses({
|
|
2259
|
-
mouse: cursors.ADD
|
|
2260
|
-
});
|
|
2261
|
-
state.polygon.updateCoordinate("0.".concat(state.currentVertexPosition), e.lngLat.lng, e.lngLat.lat);
|
|
2262
|
-
state.currentVertexPosition++;
|
|
2263
|
-
state.polygon.updateCoordinate("0.".concat(state.currentVertexPosition), e.lngLat.lng, e.lngLat.lat);
|
|
2264
|
-
this.map.fire(events.CREATE, {
|
|
2265
|
-
features: [state.polygon.toGeoJSON()]
|
|
2266
|
-
});
|
|
2267
|
-
};
|
|
2268
|
-
CustomPolygonMode.clickOnVertex = function (state) {
|
|
2269
|
-
return this.changeMode("custom_select", {
|
|
2270
|
-
featureIds: [state.polygon.id]
|
|
2271
|
-
});
|
|
2272
|
-
};
|
|
2273
|
-
CustomPolygonMode.onMouseMove = function (state, e) {
|
|
2274
|
-
state.polygon.updateCoordinate("0.".concat(state.currentVertexPosition), e.lngLat.lng, e.lngLat.lat);
|
|
2275
|
-
if (isVertex$1(e)) {
|
|
2276
|
-
this.updateUIClasses({
|
|
2277
|
-
mouse: cursors.POINTER
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
};
|
|
2281
|
-
CustomPolygonMode.onTap = CustomPolygonMode.onClick = function (state, e) {
|
|
2282
|
-
if (isVertex$1(e)) return this.clickOnVertex(state, e);
|
|
2283
|
-
return this.clickAnywhere(state, e);
|
|
2284
|
-
};
|
|
2285
|
-
CustomPolygonMode.onKeyUp = function (state, e) {
|
|
2286
|
-
if (isEscapeKey(e)) {
|
|
2287
|
-
this.deleteFeature([state.polygon.id], {
|
|
2288
|
-
silent: true
|
|
2289
|
-
});
|
|
2290
|
-
this.changeMode("custom_select");
|
|
2291
|
-
} else if (isEnterKey(e)) {
|
|
2292
|
-
this.changeMode("custom_select", {
|
|
2293
|
-
featureIds: [state.polygon.id]
|
|
2294
|
-
});
|
|
2295
|
-
}
|
|
2296
|
-
};
|
|
2297
|
-
CustomPolygonMode.onStop = function (state) {
|
|
2298
|
-
this.updateUIClasses({
|
|
2299
|
-
mouse: cursors.NONE
|
|
2300
|
-
});
|
|
2301
|
-
doubleClickZoom.enable(this);
|
|
2302
|
-
this.activateUIButton();
|
|
2303
|
-
|
|
2304
|
-
// check to see if we've deleted this feature
|
|
2305
|
-
if (this.getFeature(state.polygon.id) === undefined) return;
|
|
2306
|
-
|
|
2307
|
-
//remove last added coordinate
|
|
2308
|
-
state.polygon.removeCoordinate("0.".concat(state.currentVertexPosition));
|
|
2309
|
-
if (state.polygon.isValid()) {
|
|
2310
|
-
this.map.fire(events.CREATE, {
|
|
2311
|
-
features: [state.polygon.toGeoJSON()]
|
|
2312
|
-
});
|
|
2313
|
-
} else {
|
|
2314
|
-
this.deleteFeature([state.polygon.id], {
|
|
2315
|
-
silent: true
|
|
2316
|
-
});
|
|
2317
|
-
this.changeMode("custom_select", {}, {
|
|
2318
|
-
silent: true
|
|
2319
|
-
});
|
|
2320
|
-
}
|
|
2321
|
-
};
|
|
2322
|
-
CustomPolygonMode.toDisplayFeatures = function (state, geojson, display) {
|
|
2323
|
-
var isActivePolygon = geojson.properties.id === state.polygon.id;
|
|
2324
|
-
geojson.properties.active = isActivePolygon ? activeStates.ACTIVE : activeStates.INACTIVE;
|
|
2325
|
-
if (!isActivePolygon) return display(geojson);
|
|
2326
|
-
|
|
2327
|
-
// Don't render a polygon until it has two positions
|
|
2328
|
-
// (and a 3rd which is just the first repeated)
|
|
2329
|
-
if (geojson.geometry.coordinates.length === 0) return;
|
|
2330
|
-
var coordinateCount = geojson.geometry.coordinates[0].length;
|
|
2331
|
-
// 2 coordinates after selecting a draw type
|
|
2332
|
-
// 3 after creating the first point
|
|
2333
|
-
if (coordinateCount < 3) {
|
|
2334
|
-
return;
|
|
2335
|
-
}
|
|
2336
|
-
geojson.properties.meta = meta.FEATURE;
|
|
2337
|
-
display(create_vertex(state.polygon.id, geojson.geometry.coordinates[0][0], "0.0", false));
|
|
2338
|
-
if (coordinateCount > 3) {
|
|
2339
|
-
// Add a start position marker to the map, clicking on this will finish the feature
|
|
2340
|
-
// This should only be shown when we're in a valid spot
|
|
2341
|
-
var endPos = geojson.geometry.coordinates[0].length - 3;
|
|
2342
|
-
display(create_vertex(state.polygon.id, geojson.geometry.coordinates[0][endPos], "0.".concat(endPos), false));
|
|
2343
|
-
}
|
|
2344
|
-
if (coordinateCount <= 4) {
|
|
2345
|
-
// If we've only drawn two positions (plus the closer),
|
|
2346
|
-
// make a LineString instead of a Polygon
|
|
2347
|
-
var lineCoordinates = [[geojson.geometry.coordinates[0][0][0], geojson.geometry.coordinates[0][0][1]], [geojson.geometry.coordinates[0][1][0], geojson.geometry.coordinates[0][1][1]]];
|
|
2348
|
-
// create an initial vertex so that we can track the first point on mobile devices
|
|
2349
|
-
display({
|
|
2350
|
-
type: geojsonTypes.FEATURE,
|
|
2351
|
-
properties: geojson.properties,
|
|
2352
|
-
geometry: {
|
|
2353
|
-
coordinates: lineCoordinates,
|
|
2354
|
-
type: geojsonTypes.LINE_STRING
|
|
2355
|
-
}
|
|
2356
|
-
});
|
|
2357
|
-
if (coordinateCount === 3) {
|
|
2358
|
-
return;
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
// render the Polygon
|
|
2362
|
-
return display(geojson);
|
|
2363
|
-
};
|
|
2364
|
-
CustomPolygonMode.onTrash = function (state) {
|
|
2365
|
-
this.deleteFeature([state.polygon.id], {
|
|
2366
|
-
silent: true
|
|
2367
|
-
});
|
|
2368
|
-
this.changeMode("custom_select");
|
|
2369
|
-
};
|
|
2370
|
-
|
|
2371
|
-
/**
|
|
2372
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2373
|
-
* and licensed under ISC
|
|
2374
|
-
*/
|
|
2375
|
-
|
|
2376
|
-
/**
|
|
2377
|
-
* Returns a Point representing a mouse event's position
|
|
2378
|
-
* relative to a containing element.
|
|
2379
|
-
*
|
|
2380
|
-
* @param {MouseEvent} mouseEvent
|
|
2381
|
-
* @param {Node} container
|
|
2382
|
-
* @returns {Point}
|
|
2383
|
-
*/
|
|
2384
|
-
function mouseEventPoint(mouseEvent, container) {
|
|
2385
|
-
var rect = container.getBoundingClientRect();
|
|
2386
|
-
return new Point__default["default"](mouseEvent.clientX - rect.left - (container.clientLeft || 0), mouseEvent.clientY - rect.top - (container.clientTop || 0));
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
/**
|
|
2390
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2391
|
-
* and licensed under ISC
|
|
2392
|
-
*/
|
|
2393
|
-
var create_midpoint = function create_midpoint(parent, startVertex, endVertex) {
|
|
2394
|
-
var startCoord = startVertex.geometry.coordinates;
|
|
2395
|
-
var endCoord = endVertex.geometry.coordinates;
|
|
2396
|
-
|
|
2397
|
-
// If a coordinate exceeds the projection, we can't calculate a midpoint,
|
|
2398
|
-
// so run away
|
|
2399
|
-
if (startCoord[1] > LAT_RENDERED_MAX$1 || startCoord[1] < LAT_RENDERED_MIN$1 || endCoord[1] > LAT_RENDERED_MAX$1 || endCoord[1] < LAT_RENDERED_MIN$1) {
|
|
2400
|
-
return null;
|
|
2401
|
-
}
|
|
2402
|
-
var mid = {
|
|
2403
|
-
lng: (startCoord[0] + endCoord[0]) / 2,
|
|
2404
|
-
lat: (startCoord[1] + endCoord[1]) / 2
|
|
2405
|
-
};
|
|
2406
|
-
return {
|
|
2407
|
-
type: geojsonTypes.FEATURE,
|
|
2408
|
-
properties: {
|
|
2409
|
-
meta: meta.MIDPOINT,
|
|
2410
|
-
parent: parent,
|
|
2411
|
-
lng: mid.lng,
|
|
2412
|
-
lat: mid.lat,
|
|
2413
|
-
coord_path: endVertex.properties.coord_path
|
|
2414
|
-
},
|
|
2415
|
-
geometry: {
|
|
2416
|
-
type: geojsonTypes.POINT,
|
|
2417
|
-
coordinates: [mid.lng, mid.lat]
|
|
2418
|
-
}
|
|
2419
|
-
};
|
|
2420
|
-
};
|
|
2421
|
-
|
|
2422
|
-
/**
|
|
2423
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2424
|
-
* and licensed under ISC
|
|
2425
|
-
*/
|
|
2426
|
-
function createSupplementaryPoints(geojson) {
|
|
2427
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2428
|
-
var basePath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2429
|
-
var _geojson$geometry = geojson.geometry,
|
|
2430
|
-
type = _geojson$geometry.type,
|
|
2431
|
-
coordinates = _geojson$geometry.coordinates;
|
|
2432
|
-
var featureId = geojson.properties && geojson.properties.id;
|
|
2433
|
-
var supplementaryPoints = [];
|
|
2434
|
-
if (type === geojsonTypes.POINT) {
|
|
2435
|
-
// For points, just create a vertex
|
|
2436
|
-
supplementaryPoints.push(create_vertex(featureId, coordinates, basePath, isSelectedPath(basePath)));
|
|
2437
|
-
} else if (type === geojsonTypes.POLYGON) {
|
|
2438
|
-
// Cycle through a Polygon's rings and
|
|
2439
|
-
// process each line
|
|
2440
|
-
coordinates.forEach(function (line, lineIndex) {
|
|
2441
|
-
processLine(line, basePath !== null ? "".concat(basePath, ".").concat(lineIndex) : String(lineIndex));
|
|
2442
|
-
});
|
|
2443
|
-
} else if (type === geojsonTypes.LINE_STRING) {
|
|
2444
|
-
processLine(coordinates, basePath);
|
|
2445
|
-
} else if (type.indexOf(geojsonTypes.MULTI_PREFIX) === 0) {
|
|
2446
|
-
processMultiGeometry();
|
|
2447
|
-
}
|
|
2448
|
-
function processLine(line, lineBasePath) {
|
|
2449
|
-
var firstPointString = "";
|
|
2450
|
-
var lastVertex = null;
|
|
2451
|
-
line.forEach(function (point, pointIndex) {
|
|
2452
|
-
var pointPath = lineBasePath !== undefined && lineBasePath !== null ? "".concat(lineBasePath, ".").concat(pointIndex) : String(pointIndex);
|
|
2453
|
-
var vertex = create_vertex(featureId, point, pointPath, isSelectedPath(pointPath));
|
|
2454
|
-
|
|
2455
|
-
// If we're creating midpoints, check if there was a
|
|
2456
|
-
// vertex before this one. If so, add a midpoint
|
|
2457
|
-
// between that vertex and this one.
|
|
2458
|
-
if (options.midpoints && lastVertex) {
|
|
2459
|
-
var midpoint = create_midpoint(featureId, lastVertex, vertex);
|
|
2460
|
-
if (midpoint) {
|
|
2461
|
-
supplementaryPoints.push(midpoint);
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
lastVertex = vertex;
|
|
2465
|
-
|
|
2466
|
-
// A Polygon line's last point is the same as the first point. If we're on the last
|
|
2467
|
-
// point, we want to draw a midpoint before it but not another vertex on it
|
|
2468
|
-
// (since we already a vertex there, from the first point).
|
|
2469
|
-
var stringifiedPoint = JSON.stringify(point);
|
|
2470
|
-
if (firstPointString !== stringifiedPoint) {
|
|
2471
|
-
supplementaryPoints.push(vertex);
|
|
2472
|
-
}
|
|
2473
|
-
if (pointIndex === 0) {
|
|
2474
|
-
firstPointString = stringifiedPoint;
|
|
2475
|
-
}
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
|
-
function isSelectedPath(path) {
|
|
2479
|
-
if (!options.selectedPaths) return false;
|
|
2480
|
-
return options.selectedPaths.indexOf(path) !== -1;
|
|
2481
|
-
}
|
|
2482
|
-
|
|
2483
|
-
// Split a multi-geometry into constituent
|
|
2484
|
-
// geometries, and accumulate the supplementary points
|
|
2485
|
-
// for each of those constituents
|
|
2486
|
-
function processMultiGeometry() {
|
|
2487
|
-
var subType = type.replace(geojsonTypes.MULTI_PREFIX, "");
|
|
2488
|
-
coordinates.forEach(function (subCoordinates, index) {
|
|
2489
|
-
var subFeature = {
|
|
2490
|
-
type: geojsonTypes.FEATURE,
|
|
2491
|
-
properties: geojson.properties,
|
|
2492
|
-
geometry: {
|
|
2493
|
-
type: subType,
|
|
2494
|
-
coordinates: subCoordinates
|
|
2495
|
-
}
|
|
2496
|
-
};
|
|
2497
|
-
supplementaryPoints = supplementaryPoints.concat(createSupplementaryPoints(subFeature, options, index));
|
|
2498
|
-
});
|
|
2499
|
-
}
|
|
2500
|
-
return supplementaryPoints;
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
/**
|
|
2504
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2505
|
-
* and licensed under ISC
|
|
2506
|
-
*/
|
|
2507
|
-
function StringSet(items) {
|
|
2508
|
-
this._items = {};
|
|
2509
|
-
this._nums = {};
|
|
2510
|
-
this._length = items ? items.length : 0;
|
|
2511
|
-
if (!items) return;
|
|
2512
|
-
for (var i = 0, l = items.length; i < l; i++) {
|
|
2513
|
-
this.add(items[i]);
|
|
2514
|
-
if (items[i] === undefined) continue;
|
|
2515
|
-
if (typeof items[i] === 'string') this._items[items[i]] = i;else this._nums[items[i]] = i;
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
StringSet.prototype.add = function (x) {
|
|
2519
|
-
if (this.has(x)) return this;
|
|
2520
|
-
this._length++;
|
|
2521
|
-
if (typeof x === 'string') this._items[x] = this._length;else this._nums[x] = this._length;
|
|
2522
|
-
return this;
|
|
2523
|
-
};
|
|
2524
|
-
StringSet.prototype["delete"] = function (x) {
|
|
2525
|
-
if (this.has(x) === false) return this;
|
|
2526
|
-
this._length--;
|
|
2527
|
-
delete this._items[x];
|
|
2528
|
-
delete this._nums[x];
|
|
2529
|
-
return this;
|
|
2530
|
-
};
|
|
2531
|
-
StringSet.prototype.has = function (x) {
|
|
2532
|
-
if (typeof x !== 'string' && typeof x !== 'number') return false;
|
|
2533
|
-
return this._items[x] !== undefined || this._nums[x] !== undefined;
|
|
2534
|
-
};
|
|
2535
|
-
StringSet.prototype.values = function () {
|
|
2536
|
-
var _this = this;
|
|
2537
|
-
var values = [];
|
|
2538
|
-
Object.keys(this._items).forEach(function (k) {
|
|
2539
|
-
values.push({
|
|
2540
|
-
k: k,
|
|
2541
|
-
v: _this._items[k]
|
|
2542
|
-
});
|
|
2543
|
-
});
|
|
2544
|
-
Object.keys(this._nums).forEach(function (k) {
|
|
2545
|
-
values.push({
|
|
2546
|
-
k: JSON.parse(k),
|
|
2547
|
-
v: _this._nums[k]
|
|
2548
|
-
});
|
|
2549
|
-
});
|
|
2550
|
-
return values.sort(function (a, b) {
|
|
2551
|
-
return a.v - b.v;
|
|
2552
|
-
}).map(function (a) {
|
|
2553
|
-
return a.k;
|
|
2554
|
-
});
|
|
2555
|
-
};
|
|
2556
|
-
StringSet.prototype.clear = function () {
|
|
2557
|
-
this._length = 0;
|
|
2558
|
-
this._items = {};
|
|
2559
|
-
this._nums = {};
|
|
2560
|
-
return this;
|
|
2561
|
-
};
|
|
2562
|
-
|
|
2563
|
-
var geojsonExtentExports = {};
|
|
2564
|
-
var geojsonExtent = {
|
|
2565
|
-
get exports(){ return geojsonExtentExports; },
|
|
2566
|
-
set exports(v){ geojsonExtentExports = v; },
|
|
2567
|
-
};
|
|
2568
|
-
|
|
2569
|
-
var geojsonCoords = require$$0__default["default"],
|
|
2570
|
-
traverse = require$$1__default["default"],
|
|
2571
|
-
extent = require$$2__default["default"];
|
|
2572
|
-
var geojsonTypesByDataAttributes = {
|
|
2573
|
-
features: ['FeatureCollection'],
|
|
2574
|
-
coordinates: ['Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', 'MultiPolygon'],
|
|
2575
|
-
geometry: ['Feature'],
|
|
2576
|
-
geometries: ['GeometryCollection']
|
|
2577
|
-
};
|
|
2578
|
-
var dataAttributes = Object.keys(geojsonTypesByDataAttributes);
|
|
2579
|
-
geojsonExtent.exports = function (_) {
|
|
2580
|
-
return getExtent(_).bbox();
|
|
2581
|
-
};
|
|
2582
|
-
geojsonExtentExports.polygon = function (_) {
|
|
2583
|
-
return getExtent(_).polygon();
|
|
2584
|
-
};
|
|
2585
|
-
geojsonExtentExports.bboxify = function (_) {
|
|
2586
|
-
return traverse(_).map(function (value) {
|
|
2587
|
-
if (!value) return;
|
|
2588
|
-
var isValid = dataAttributes.some(function (attribute) {
|
|
2589
|
-
if (value[attribute]) {
|
|
2590
|
-
return geojsonTypesByDataAttributes[attribute].indexOf(value.type) !== -1;
|
|
2591
|
-
}
|
|
2592
|
-
return false;
|
|
2593
|
-
});
|
|
2594
|
-
if (isValid) {
|
|
2595
|
-
value.bbox = getExtent(value).bbox();
|
|
2596
|
-
this.update(value);
|
|
2597
|
-
}
|
|
2598
|
-
});
|
|
2599
|
-
};
|
|
2600
|
-
function getExtent(_) {
|
|
2601
|
-
var ext = extent(),
|
|
2602
|
-
coords = geojsonCoords(_);
|
|
2603
|
-
for (var i = 0; i < coords.length; i++) ext.include(coords[i]);
|
|
2604
|
-
return ext;
|
|
2605
|
-
}
|
|
2606
|
-
|
|
2607
|
-
/**
|
|
2608
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2609
|
-
* and licensed under ISC
|
|
2610
|
-
*/
|
|
2611
|
-
var LAT_MIN = LAT_MIN$1,
|
|
2612
|
-
LAT_MAX = LAT_MAX$1,
|
|
2613
|
-
LAT_RENDERED_MIN = LAT_RENDERED_MIN$1,
|
|
2614
|
-
LAT_RENDERED_MAX = LAT_RENDERED_MAX$1,
|
|
2615
|
-
LNG_MIN = LNG_MIN$1,
|
|
2616
|
-
LNG_MAX = LNG_MAX$1;
|
|
2617
|
-
|
|
2618
|
-
// Ensure that we do not drag north-south far enough for
|
|
2619
|
-
// - any part of any feature to exceed the poles
|
|
2620
|
-
// - any feature to be completely lost in the space between the projection's
|
|
2621
|
-
// edge and the poles, such that it couldn't be re-selected and moved back
|
|
2622
|
-
var constrain_feature_movement = function constrain_feature_movement(geojsonFeatures, delta) {
|
|
2623
|
-
// "inner edge" = a feature's latitude closest to the equator
|
|
2624
|
-
var northInnerEdge = LAT_MIN;
|
|
2625
|
-
var southInnerEdge = LAT_MAX;
|
|
2626
|
-
// "outer edge" = a feature's latitude furthest from the equator
|
|
2627
|
-
var northOuterEdge = LAT_MIN;
|
|
2628
|
-
var southOuterEdge = LAT_MAX;
|
|
2629
|
-
var westEdge = LNG_MAX;
|
|
2630
|
-
var eastEdge = LNG_MIN;
|
|
2631
|
-
geojsonFeatures.forEach(function (feature) {
|
|
2632
|
-
var bounds = geojsonExtentExports(feature);
|
|
2633
|
-
var featureSouthEdge = bounds[1];
|
|
2634
|
-
var featureNorthEdge = bounds[3];
|
|
2635
|
-
var featureWestEdge = bounds[0];
|
|
2636
|
-
var featureEastEdge = bounds[2];
|
|
2637
|
-
if (featureSouthEdge > northInnerEdge) northInnerEdge = featureSouthEdge;
|
|
2638
|
-
if (featureNorthEdge < southInnerEdge) southInnerEdge = featureNorthEdge;
|
|
2639
|
-
if (featureNorthEdge > northOuterEdge) northOuterEdge = featureNorthEdge;
|
|
2640
|
-
if (featureSouthEdge < southOuterEdge) southOuterEdge = featureSouthEdge;
|
|
2641
|
-
if (featureWestEdge < westEdge) westEdge = featureWestEdge;
|
|
2642
|
-
if (featureEastEdge > eastEdge) eastEdge = featureEastEdge;
|
|
2643
|
-
});
|
|
2644
|
-
|
|
2645
|
-
// These changes are not mutually exclusive: we might hit the inner
|
|
2646
|
-
// edge but also have hit the outer edge and therefore need
|
|
2647
|
-
// another readjustment
|
|
2648
|
-
var constrainedDelta = delta;
|
|
2649
|
-
if (northInnerEdge + constrainedDelta.lat > LAT_RENDERED_MAX) {
|
|
2650
|
-
constrainedDelta.lat = LAT_RENDERED_MAX - northInnerEdge;
|
|
2651
|
-
}
|
|
2652
|
-
if (northOuterEdge + constrainedDelta.lat > LAT_MAX) {
|
|
2653
|
-
constrainedDelta.lat = LAT_MAX - northOuterEdge;
|
|
2654
|
-
}
|
|
2655
|
-
if (southInnerEdge + constrainedDelta.lat < LAT_RENDERED_MIN) {
|
|
2656
|
-
constrainedDelta.lat = LAT_RENDERED_MIN - southInnerEdge;
|
|
2657
|
-
}
|
|
2658
|
-
if (southOuterEdge + constrainedDelta.lat < LAT_MIN) {
|
|
2659
|
-
constrainedDelta.lat = LAT_MIN - southOuterEdge;
|
|
2660
|
-
}
|
|
2661
|
-
if (westEdge + constrainedDelta.lng <= LNG_MIN) {
|
|
2662
|
-
constrainedDelta.lng += Math.ceil(Math.abs(constrainedDelta.lng) / 360) * 360;
|
|
2663
|
-
}
|
|
2664
|
-
if (eastEdge + constrainedDelta.lng >= LNG_MAX) {
|
|
2665
|
-
constrainedDelta.lng -= Math.ceil(Math.abs(constrainedDelta.lng) / 360) * 360;
|
|
2666
|
-
}
|
|
2667
|
-
return constrainedDelta;
|
|
2668
|
-
};
|
|
2669
|
-
|
|
2670
|
-
/**
|
|
2671
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2672
|
-
* and licensed under ISC
|
|
2673
|
-
*/
|
|
2674
|
-
var move_features = function move_features(features, delta) {
|
|
2675
|
-
var constrainedDelta = constrain_feature_movement(features.map(function (feature) {
|
|
2676
|
-
return feature.toGeoJSON();
|
|
2677
|
-
}), delta);
|
|
2678
|
-
features.forEach(function (feature) {
|
|
2679
|
-
var currentCoordinates = feature.getCoordinates();
|
|
2680
|
-
var moveCoordinate = function moveCoordinate(coord) {
|
|
2681
|
-
var point = {
|
|
2682
|
-
lng: coord[0] + constrainedDelta.lng,
|
|
2683
|
-
lat: coord[1] + constrainedDelta.lat
|
|
2684
|
-
};
|
|
2685
|
-
return [point.lng, point.lat];
|
|
2686
|
-
};
|
|
2687
|
-
var moveRing = function moveRing(ring) {
|
|
2688
|
-
return ring.map(function (coord) {
|
|
2689
|
-
return moveCoordinate(coord);
|
|
2690
|
-
});
|
|
2691
|
-
};
|
|
2692
|
-
var moveMultiPolygon = function moveMultiPolygon(multi) {
|
|
2693
|
-
return multi.map(function (ring) {
|
|
2694
|
-
return moveRing(ring);
|
|
2695
|
-
});
|
|
2696
|
-
};
|
|
2697
|
-
var nextCoordinates;
|
|
2698
|
-
if (feature.type === geojsonTypes.POINT) {
|
|
2699
|
-
nextCoordinates = moveCoordinate(currentCoordinates);
|
|
2700
|
-
} else if (feature.type === geojsonTypes.LINE_STRING || feature.type === geojsonTypes.MULTI_POINT) {
|
|
2701
|
-
nextCoordinates = currentCoordinates.map(moveCoordinate);
|
|
2702
|
-
} else if (feature.type === geojsonTypes.POLYGON || feature.type === geojsonTypes.MULTI_LINE_STRING) {
|
|
2703
|
-
nextCoordinates = currentCoordinates.map(moveRing);
|
|
2704
|
-
} else if (feature.type === geojsonTypes.MULTI_POLYGON) {
|
|
2705
|
-
nextCoordinates = currentCoordinates.map(moveMultiPolygon);
|
|
2706
|
-
}
|
|
2707
|
-
feature.incomingCoords(nextCoordinates);
|
|
2708
|
-
});
|
|
2709
|
-
};
|
|
2710
|
-
|
|
2711
|
-
/**
|
|
2712
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
2713
|
-
* and licensed under ISC
|
|
2714
|
-
*/
|
|
2715
|
-
var CustomSelectMode = {};
|
|
2716
|
-
CustomSelectMode.onSetup = function (opts) {
|
|
2717
|
-
var _this = this;
|
|
2718
|
-
console.log("Change mode: custom select");
|
|
2719
|
-
|
|
2720
|
-
// turn the opts into state.
|
|
2721
|
-
var state = {
|
|
2722
|
-
dragMoveLocation: null,
|
|
2723
|
-
boxSelectStartLocation: null,
|
|
2724
|
-
boxSelectElement: undefined,
|
|
2725
|
-
boxSelecting: false,
|
|
2726
|
-
canBoxSelect: false,
|
|
2727
|
-
dragMoving: false,
|
|
2728
|
-
canDragMove: false,
|
|
2729
|
-
initiallySelectedFeatureIds: opts.featureIds || []
|
|
2730
|
-
};
|
|
2731
|
-
this.setSelected(state.initiallySelectedFeatureIds.filter(function (id) {
|
|
2732
|
-
return _this.getFeature(id) !== undefined;
|
|
2733
|
-
}));
|
|
2734
|
-
this.fireActionable();
|
|
2735
|
-
this.setActionableState({
|
|
2736
|
-
combineFeatures: true,
|
|
2737
|
-
uncombineFeatures: true,
|
|
2738
|
-
trash: true
|
|
2739
|
-
});
|
|
2740
|
-
return state;
|
|
2741
|
-
};
|
|
2742
|
-
CustomSelectMode.fireUpdate = function () {
|
|
2743
|
-
this.map.fire(events.UPDATE, {
|
|
2744
|
-
action: updateActions.MOVE,
|
|
2745
|
-
features: this.getSelected().map(function (f) {
|
|
2746
|
-
return f.toGeoJSON();
|
|
2747
|
-
})
|
|
2748
|
-
});
|
|
2749
|
-
};
|
|
2750
|
-
CustomSelectMode.fireActionable = function () {
|
|
2751
|
-
var _this2 = this;
|
|
2752
|
-
var selectedFeatures = this.getSelected();
|
|
2753
|
-
var multiFeatures = selectedFeatures.filter(function (feature) {
|
|
2754
|
-
return _this2.isInstanceOf("MultiFeature", feature);
|
|
2755
|
-
});
|
|
2756
|
-
var combineFeatures = false;
|
|
2757
|
-
if (selectedFeatures.length > 1) {
|
|
2758
|
-
combineFeatures = true;
|
|
2759
|
-
var featureType = selectedFeatures[0].type.replace("Multi", "");
|
|
2760
|
-
selectedFeatures.forEach(function (feature) {
|
|
2761
|
-
if (feature.type.replace("Multi", "") !== featureType) {
|
|
2762
|
-
combineFeatures = false;
|
|
2763
|
-
}
|
|
2764
|
-
});
|
|
2765
|
-
}
|
|
2766
|
-
var uncombineFeatures = multiFeatures.length > 0;
|
|
2767
|
-
var trash = selectedFeatures.length > 0;
|
|
2768
|
-
this.setActionableState({
|
|
2769
|
-
combineFeatures: combineFeatures,
|
|
2770
|
-
uncombineFeatures: uncombineFeatures,
|
|
2771
|
-
trash: trash
|
|
2772
|
-
});
|
|
2773
|
-
};
|
|
2774
|
-
CustomSelectMode.getUniqueIds = function (allFeatures) {
|
|
2775
|
-
if (!allFeatures.length) return [];
|
|
2776
|
-
var ids = allFeatures.map(function (s) {
|
|
2777
|
-
return s.properties.id;
|
|
2778
|
-
}).filter(function (id) {
|
|
2779
|
-
return id !== undefined;
|
|
2780
|
-
}).reduce(function (memo, id) {
|
|
2781
|
-
memo.add(id);
|
|
2782
|
-
return memo;
|
|
2783
|
-
}, new StringSet());
|
|
2784
|
-
return ids.values();
|
|
2785
|
-
};
|
|
2786
|
-
CustomSelectMode.stopExtendedInteractions = function (state) {
|
|
2787
|
-
if (state.boxSelectElement) {
|
|
2788
|
-
if (state.boxSelectElement.parentNode) state.boxSelectElement.parentNode.removeChild(state.boxSelectElement);
|
|
2789
|
-
state.boxSelectElement = null;
|
|
2790
|
-
}
|
|
2791
|
-
this.map.dragPan.enable();
|
|
2792
|
-
state.boxSelecting = false;
|
|
2793
|
-
state.canBoxSelect = false;
|
|
2794
|
-
state.dragMoving = false;
|
|
2795
|
-
state.canDragMove = false;
|
|
2796
|
-
};
|
|
2797
|
-
CustomSelectMode.onStop = function () {
|
|
2798
|
-
doubleClickZoom.enable(this);
|
|
2799
|
-
};
|
|
2800
|
-
CustomSelectMode.onMouseMove = function (state) {
|
|
2801
|
-
// On mousemove that is not a drag, stop extended interactions.
|
|
2802
|
-
// This is useful if you drag off the canvas, release the button,
|
|
2803
|
-
// then move the mouse back over the canvas --- we don't allow the
|
|
2804
|
-
// interaction to continue then, but we do let it continue if you held
|
|
2805
|
-
// the mouse button that whole time
|
|
2806
|
-
return this.stopExtendedInteractions(state);
|
|
2807
|
-
};
|
|
2808
|
-
CustomSelectMode.onMouseOut = function (state) {
|
|
2809
|
-
// As soon as you mouse leaves the canvas, update the feature
|
|
2810
|
-
if (state.dragMoving) return this.fireUpdate();
|
|
2811
|
-
};
|
|
2812
|
-
CustomSelectMode.onTap = CustomSelectMode.onClick = function (state, e) {
|
|
2813
|
-
// Click (with or without shift) on no feature
|
|
2814
|
-
if (noTarget(e)) return this.clickAnywhere(state, e); // also tap
|
|
2815
|
-
if (isOfMetaType(meta.VERTEX)(e)) return this.clickOnVertex(state, e); //tap
|
|
2816
|
-
if (isFeature(e)) return this.clickOnFeature(state, e);
|
|
2817
|
-
};
|
|
2818
|
-
CustomSelectMode.clickAnywhere = function (state) {
|
|
2819
|
-
var _this3 = this;
|
|
2820
|
-
// Clear the re-render selection
|
|
2821
|
-
var wasSelected = this.getSelectedIds();
|
|
2822
|
-
if (wasSelected.length) {
|
|
2823
|
-
this.clearSelectedFeatures();
|
|
2824
|
-
wasSelected.forEach(function (id) {
|
|
2825
|
-
return _this3.doRender(id);
|
|
2826
|
-
});
|
|
2827
|
-
}
|
|
2828
|
-
doubleClickZoom.enable(this);
|
|
2829
|
-
this.stopExtendedInteractions(state);
|
|
2830
|
-
};
|
|
2831
|
-
CustomSelectMode.clickOnVertex = function (state, e) {
|
|
2832
|
-
// Enter direct select mode
|
|
2833
|
-
this.changeMode("custom_direct_select", {
|
|
2834
|
-
featureId: e.featureTarget.properties.parent,
|
|
2835
|
-
coordPath: e.featureTarget.properties.coord_path,
|
|
2836
|
-
startPos: e.lngLat
|
|
2837
|
-
// groupMove_vertices: matchingVertices,
|
|
2838
|
-
});
|
|
2839
|
-
|
|
2840
|
-
this.updateUIClasses({
|
|
2841
|
-
mouse: cursors.MOVE
|
|
2842
|
-
});
|
|
2843
|
-
};
|
|
2844
|
-
CustomSelectMode.startOnActiveFeature = function (state, e) {
|
|
2845
|
-
// Stop any already-underway extended interactions
|
|
2846
|
-
this.stopExtendedInteractions(state);
|
|
2847
|
-
|
|
2848
|
-
// Disable map.dragPan immediately so it can't start
|
|
2849
|
-
this.map.dragPan.disable();
|
|
2850
|
-
|
|
2851
|
-
// Re-render it and enable drag move
|
|
2852
|
-
this.doRender(e.featureTarget.properties.id);
|
|
2853
|
-
|
|
2854
|
-
// Set up the state for drag moving
|
|
2855
|
-
state.canDragMove = true;
|
|
2856
|
-
state.dragMoveLocation = e.lngLat;
|
|
2857
|
-
};
|
|
2858
|
-
CustomSelectMode.clickOnFeature = function (state, e) {
|
|
2859
|
-
var _this4 = this;
|
|
2860
|
-
// Stop everything
|
|
2861
|
-
doubleClickZoom.disable(this);
|
|
2862
|
-
this.stopExtendedInteractions(state);
|
|
2863
|
-
var isShiftClick = isShiftDown(e);
|
|
2864
|
-
var selectedFeatureIds = this.getSelectedIds();
|
|
2865
|
-
var featureId = e.featureTarget.properties.id;
|
|
2866
|
-
var isFeatureSelected = this.isSelected(featureId);
|
|
2867
|
-
|
|
2868
|
-
// Click (without shift) on any selected feature but a point
|
|
2869
|
-
if (!isShiftClick && isFeatureSelected && this.getFeature(featureId).type !== geojsonTypes.POINT) {
|
|
2870
|
-
// Enter direct select mode
|
|
2871
|
-
return this.changeMode("custom_direct_select", {
|
|
2872
|
-
featureId: featureId
|
|
2873
|
-
});
|
|
2874
|
-
}
|
|
2875
|
-
|
|
2876
|
-
// Shift-click on a selected feature
|
|
2877
|
-
if (isFeatureSelected && isShiftClick) {
|
|
2878
|
-
// Deselect it
|
|
2879
|
-
this.deselect(featureId);
|
|
2880
|
-
this.updateUIClasses({
|
|
2881
|
-
mouse: cursors.POINTER
|
|
2882
|
-
});
|
|
2883
|
-
if (selectedFeatureIds.length === 1) {
|
|
2884
|
-
doubleClickZoom.enable(this);
|
|
2885
|
-
}
|
|
2886
|
-
// Shift-click on an unselected feature
|
|
2887
|
-
} else if (!isFeatureSelected && isShiftClick) {
|
|
2888
|
-
// Add it to the selection
|
|
2889
|
-
this.select(featureId);
|
|
2890
|
-
this.updateUIClasses({
|
|
2891
|
-
mouse: cursors.MOVE
|
|
2892
|
-
});
|
|
2893
|
-
// Click (without shift) on an unselected feature
|
|
2894
|
-
} else if (!isFeatureSelected && !isShiftClick) {
|
|
2895
|
-
// Make it the only selected feature
|
|
2896
|
-
selectedFeatureIds.forEach(function (id) {
|
|
2897
|
-
return _this4.doRender(id);
|
|
2898
|
-
});
|
|
2899
|
-
this.setSelected(featureId);
|
|
2900
|
-
this.updateUIClasses({
|
|
2901
|
-
mouse: cursors.MOVE
|
|
2902
|
-
});
|
|
2903
|
-
}
|
|
2904
|
-
|
|
2905
|
-
// No matter what, re-render the clicked feature
|
|
2906
|
-
this.doRender(featureId);
|
|
2907
|
-
};
|
|
2908
|
-
CustomSelectMode.onMouseDown = function (state, e) {
|
|
2909
|
-
if (isActiveFeature(e)) return this.startOnActiveFeature(state, e);
|
|
2910
|
-
if (this.drawConfig.boxSelect && isShiftMousedown(e)) return this.startBoxSelect(state, e);
|
|
2911
|
-
};
|
|
2912
|
-
CustomSelectMode.startBoxSelect = function (state, e) {
|
|
2913
|
-
this.stopExtendedInteractions(state);
|
|
2914
|
-
this.map.dragPan.disable();
|
|
2915
|
-
// Enable box select
|
|
2916
|
-
state.boxSelectStartLocation = mouseEventPoint(e.originalEvent, this.map.getContainer());
|
|
2917
|
-
state.canBoxSelect = true;
|
|
2918
|
-
};
|
|
2919
|
-
CustomSelectMode.onTouchStart = function (state, e) {
|
|
2920
|
-
if (isActiveFeature(e)) return this.startOnActiveFeature(state, e);
|
|
2921
|
-
};
|
|
2922
|
-
CustomSelectMode.onDrag = function (state, e) {
|
|
2923
|
-
if (state.canDragMove) return this.dragMove(state, e);
|
|
2924
|
-
if (this.drawConfig.boxSelect && state.canBoxSelect) return this.whileBoxSelect(state, e);
|
|
2925
|
-
};
|
|
2926
|
-
CustomSelectMode.whileBoxSelect = function (state, e) {
|
|
2927
|
-
state.boxSelecting = true;
|
|
2928
|
-
this.updateUIClasses({
|
|
2929
|
-
mouse: cursors.ADD
|
|
2930
|
-
});
|
|
2931
|
-
|
|
2932
|
-
// Create the box node if it doesn't exist
|
|
2933
|
-
if (!state.boxSelectElement) {
|
|
2934
|
-
state.boxSelectElement = document.createElement("div");
|
|
2935
|
-
state.boxSelectElement.classList.add(classes.BOX_SELECT);
|
|
2936
|
-
this.map.getContainer().appendChild(state.boxSelectElement);
|
|
2937
|
-
}
|
|
2938
|
-
|
|
2939
|
-
// Adjust the box node's width and xy position
|
|
2940
|
-
var current = mouseEventPoint(e.originalEvent, this.map.getContainer());
|
|
2941
|
-
var minX = Math.min(state.boxSelectStartLocation.x, current.x);
|
|
2942
|
-
var maxX = Math.max(state.boxSelectStartLocation.x, current.x);
|
|
2943
|
-
var minY = Math.min(state.boxSelectStartLocation.y, current.y);
|
|
2944
|
-
var maxY = Math.max(state.boxSelectStartLocation.y, current.y);
|
|
2945
|
-
var translateValue = "translate(".concat(minX, "px, ").concat(minY, "px)");
|
|
2946
|
-
state.boxSelectElement.style.transform = translateValue;
|
|
2947
|
-
state.boxSelectElement.style.WebkitTransform = translateValue;
|
|
2948
|
-
state.boxSelectElement.style.width = "".concat(maxX - minX, "px");
|
|
2949
|
-
state.boxSelectElement.style.height = "".concat(maxY - minY, "px");
|
|
2950
|
-
};
|
|
2951
|
-
CustomSelectMode.dragMove = function (state, e) {
|
|
2952
|
-
// Dragging when drag move is enabled
|
|
2953
|
-
state.dragMoving = true;
|
|
2954
|
-
e.originalEvent.stopPropagation();
|
|
2955
|
-
var delta = {
|
|
2956
|
-
lng: e.lngLat.lng - state.dragMoveLocation.lng,
|
|
2957
|
-
lat: e.lngLat.lat - state.dragMoveLocation.lat
|
|
2958
|
-
};
|
|
2959
|
-
move_features(this.getSelected(), delta);
|
|
2960
|
-
state.dragMoveLocation = e.lngLat;
|
|
2961
|
-
};
|
|
2962
|
-
CustomSelectMode.onMouseUp = function (state, e) {
|
|
2963
|
-
var _this5 = this;
|
|
2964
|
-
// End any extended interactions
|
|
2965
|
-
if (state.dragMoving) {
|
|
2966
|
-
this.fireUpdate();
|
|
2967
|
-
} else if (state.boxSelecting) {
|
|
2968
|
-
var bbox = [state.boxSelectStartLocation, mouseEventPoint(e.originalEvent, this.map.getContainer())];
|
|
2969
|
-
var featuresInBox = this.featuresAt(null, bbox, "click");
|
|
2970
|
-
var idsToSelect = this.getUniqueIds(featuresInBox).filter(function (id) {
|
|
2971
|
-
return !_this5.isSelected(id);
|
|
2972
|
-
});
|
|
2973
|
-
if (idsToSelect.length) {
|
|
2974
|
-
this.select(idsToSelect);
|
|
2975
|
-
idsToSelect.forEach(function (id) {
|
|
2976
|
-
return _this5.doRender(id);
|
|
2977
|
-
});
|
|
2978
|
-
this.updateUIClasses({
|
|
2979
|
-
mouse: cursors.MOVE
|
|
2980
|
-
});
|
|
2981
|
-
}
|
|
2982
|
-
}
|
|
2983
|
-
this.stopExtendedInteractions(state);
|
|
2984
|
-
};
|
|
2985
|
-
CustomSelectMode.toDisplayFeatures = function (state, geojson, display) {
|
|
2986
|
-
geojson.properties.active = this.isSelected(geojson.properties.id) ? activeStates.ACTIVE : activeStates.INACTIVE;
|
|
2987
|
-
display(geojson);
|
|
2988
|
-
this.fireActionable();
|
|
2989
|
-
if (geojson.properties.active !== activeStates.ACTIVE || geojson.geometry.type === geojsonTypes.POINT) return;
|
|
2990
|
-
createSupplementaryPoints(geojson).forEach(display);
|
|
2991
|
-
};
|
|
2992
|
-
CustomSelectMode.onTrash = function () {
|
|
2993
|
-
this.deleteFeature(this.getSelectedIds());
|
|
2994
|
-
this.fireActionable();
|
|
2995
|
-
};
|
|
2996
|
-
CustomSelectMode.onCombineFeatures = function () {
|
|
2997
|
-
var selectedFeatures = this.getSelected();
|
|
2998
|
-
if (selectedFeatures.length === 0 || selectedFeatures.length < 2) return;
|
|
2999
|
-
var coordinates = [],
|
|
3000
|
-
featuresCombined = [];
|
|
3001
|
-
var featureType = selectedFeatures[0].type.replace("Multi", "");
|
|
3002
|
-
for (var i = 0; i < selectedFeatures.length; i++) {
|
|
3003
|
-
var feature = selectedFeatures[i];
|
|
3004
|
-
if (feature.type.replace("Multi", "") !== featureType) {
|
|
3005
|
-
return;
|
|
3006
|
-
}
|
|
3007
|
-
if (feature.type.includes("Multi")) {
|
|
3008
|
-
feature.getCoordinates().forEach(function (subcoords) {
|
|
3009
|
-
coordinates.push(subcoords);
|
|
3010
|
-
});
|
|
3011
|
-
} else {
|
|
3012
|
-
coordinates.push(feature.getCoordinates());
|
|
3013
|
-
}
|
|
3014
|
-
featuresCombined.push(feature.toGeoJSON());
|
|
3015
|
-
}
|
|
3016
|
-
if (featuresCombined.length > 1) {
|
|
3017
|
-
var multiFeature = this.newFeature({
|
|
3018
|
-
type: geojsonTypes.FEATURE,
|
|
3019
|
-
properties: featuresCombined[0].properties,
|
|
3020
|
-
geometry: {
|
|
3021
|
-
type: "Multi".concat(featureType),
|
|
3022
|
-
coordinates: coordinates
|
|
3023
|
-
}
|
|
3024
|
-
});
|
|
3025
|
-
this.addFeature(multiFeature);
|
|
3026
|
-
this.deleteFeature(this.getSelectedIds(), {
|
|
3027
|
-
silent: true
|
|
3028
|
-
});
|
|
3029
|
-
this.setSelected([multiFeature.id]);
|
|
3030
|
-
this.map.fire(events.COMBINE_FEATURES, {
|
|
3031
|
-
createdFeatures: [multiFeature.toGeoJSON()],
|
|
3032
|
-
deletedFeatures: featuresCombined
|
|
3033
|
-
});
|
|
3034
|
-
}
|
|
3035
|
-
this.fireActionable();
|
|
3036
|
-
};
|
|
3037
|
-
CustomSelectMode.onUncombineFeatures = function () {
|
|
3038
|
-
var _this6 = this;
|
|
3039
|
-
var selectedFeatures = this.getSelected();
|
|
3040
|
-
if (selectedFeatures.length === 0) return;
|
|
3041
|
-
var createdFeatures = [];
|
|
3042
|
-
var featuresUncombined = [];
|
|
3043
|
-
var _loop = function _loop() {
|
|
3044
|
-
var feature = selectedFeatures[i];
|
|
3045
|
-
if (_this6.isInstanceOf("MultiFeature", feature)) {
|
|
3046
|
-
feature.getFeatures().forEach(function (subFeature) {
|
|
3047
|
-
_this6.addFeature(subFeature);
|
|
3048
|
-
subFeature.properties = feature.properties;
|
|
3049
|
-
createdFeatures.push(subFeature.toGeoJSON());
|
|
3050
|
-
_this6.select([subFeature.id]);
|
|
3051
|
-
});
|
|
3052
|
-
_this6.deleteFeature(feature.id, {
|
|
3053
|
-
silent: true
|
|
3054
|
-
});
|
|
3055
|
-
featuresUncombined.push(feature.toGeoJSON());
|
|
3056
|
-
}
|
|
3057
|
-
};
|
|
3058
|
-
for (var i = 0; i < selectedFeatures.length; i++) {
|
|
3059
|
-
_loop();
|
|
3060
|
-
}
|
|
3061
|
-
if (createdFeatures.length > 1) {
|
|
3062
|
-
this.map.fire(events.UNCOMBINE_FEATURES, {
|
|
3063
|
-
createdFeatures: createdFeatures,
|
|
3064
|
-
deletedFeatures: featuresUncombined
|
|
3065
|
-
});
|
|
3066
|
-
}
|
|
3067
|
-
this.fireActionable();
|
|
3068
|
-
};
|
|
3069
|
-
|
|
3070
|
-
/**
|
|
3071
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
3072
|
-
* and licensed under ISC
|
|
3073
|
-
*/
|
|
3074
|
-
var drawUtils = {
|
|
3075
|
-
getMatchingVertices: function getMatchingVertices(vertex, featureId, allFeatures, map) {
|
|
3076
|
-
// number of decimals should probably be dynamic depending on zoom level
|
|
3077
|
-
var decimals = 5;
|
|
3078
|
-
var matchingVertices = [];
|
|
3079
|
-
var v_lng = vertex[0].toFixed(decimals);
|
|
3080
|
-
var v_lat = vertex[1].toFixed(decimals);
|
|
3081
|
-
for (var i = 0; i < allFeatures.length; i++) {
|
|
3082
|
-
if (allFeatures[i].id !== featureId) {
|
|
3083
|
-
for (var k = 0; k < allFeatures[i].geometry.coordinates.length; k++) {
|
|
3084
|
-
for (var m = 0; m < allFeatures[i].geometry.coordinates[k].length; m++) {
|
|
3085
|
-
if (v_lng === allFeatures[i].geometry.coordinates[k][m][0].toFixed(decimals) && v_lat === allFeatures[i].geometry.coordinates[k][m][1].toFixed(decimals)) {
|
|
3086
|
-
matchingVertices.push({
|
|
3087
|
-
featureId: allFeatures[i].id,
|
|
3088
|
-
coord_path: k + "." + m,
|
|
3089
|
-
//feature: map.getFeature(allFeatures[i].id),
|
|
3090
|
-
lng: allFeatures[i].geometry.coordinates[k][m][0],
|
|
3091
|
-
lat: allFeatures[i].geometry.coordinates[k][m][1]
|
|
3092
|
-
});
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
}
|
|
3096
|
-
}
|
|
3097
|
-
}
|
|
3098
|
-
return matchingVertices;
|
|
3099
|
-
},
|
|
3100
|
-
getDrawInstance: function getDrawInstance(map) {
|
|
3101
|
-
for (var i = map._controls.length - 1; i >= 0; i--) {
|
|
3102
|
-
var _map$_controls$i, _map$_controls$i$mode;
|
|
3103
|
-
if (((_map$_controls$i = map._controls[i]) === null || _map$_controls$i === void 0 ? void 0 : (_map$_controls$i$mode = _map$_controls$i.modes) === null || _map$_controls$i$mode === void 0 ? void 0 : _map$_controls$i$mode.SIMPLE_SELECT) === "simple_select") {
|
|
3104
|
-
return map._controls[i];
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
return null;
|
|
3108
|
-
}
|
|
3109
|
-
};
|
|
3110
|
-
|
|
3111
|
-
/**
|
|
3112
|
-
* Code from https://github.com/mapbox/mapbox-gl-draw
|
|
3113
|
-
* and licensed under ISC
|
|
3114
|
-
*/
|
|
3115
|
-
var isVertex = isOfMetaType(meta.VERTEX);
|
|
3116
|
-
var isMidpoint = isOfMetaType(meta.MIDPOINT);
|
|
3117
|
-
var DirectSelect = {};
|
|
3118
|
-
|
|
3119
|
-
// INTERNAL FUNCTIONS
|
|
3120
|
-
|
|
3121
|
-
DirectSelect.fireUpdate = function () {
|
|
3122
|
-
this.map.fire(events.UPDATE, {
|
|
3123
|
-
action: updateActions.CHANGE_COORDINATES,
|
|
3124
|
-
features: this.getSelected().map(function (f) {
|
|
3125
|
-
return f.toGeoJSON();
|
|
3126
|
-
})
|
|
3127
|
-
});
|
|
3128
|
-
};
|
|
3129
|
-
DirectSelect.fireActionable = function (state) {
|
|
3130
|
-
this.setActionableState({
|
|
3131
|
-
combineFeatures: false,
|
|
3132
|
-
uncombineFeatures: false,
|
|
3133
|
-
trash: state.selectedCoordPaths.length > 0
|
|
3134
|
-
});
|
|
3135
|
-
};
|
|
3136
|
-
DirectSelect.startDragging = function (state, e) {
|
|
3137
|
-
this.map.dragPan.disable();
|
|
3138
|
-
state.canDragMove = true;
|
|
3139
|
-
state.dragMoveLocation = e.lngLat;
|
|
3140
|
-
};
|
|
3141
|
-
DirectSelect.stopDragging = function (state) {
|
|
3142
|
-
this.map.dragPan.enable();
|
|
3143
|
-
state.dragMoving = false;
|
|
3144
|
-
state.canDragMove = false;
|
|
3145
|
-
state.dragMoveLocation = null;
|
|
3146
|
-
};
|
|
3147
|
-
DirectSelect.onVertex = function (state, e) {
|
|
3148
|
-
this.startDragging(state, e);
|
|
3149
|
-
var about = e.featureTarget.properties;
|
|
3150
|
-
var selectedIndex = state.selectedCoordPaths.indexOf(about.coord_path);
|
|
3151
|
-
if (!isShiftDown(e) && selectedIndex === -1) {
|
|
3152
|
-
state.selectedCoordPaths = [about.coord_path];
|
|
3153
|
-
} else if (isShiftDown(e) && selectedIndex === -1) {
|
|
3154
|
-
state.selectedCoordPaths.push(about.coord_path);
|
|
3155
|
-
}
|
|
3156
|
-
|
|
3157
|
-
// currently this work with single selected vertices only
|
|
3158
|
-
var allFeatures = drawUtils.getDrawInstance(this.map).getAll();
|
|
3159
|
-
var matchingVertices = drawUtils.getMatchingVertices(e.featureTarget._geometry.coordinates, e.featureTarget.properties.parent, allFeatures.features, this.map);
|
|
3160
|
-
state.groupMove_vertices = matchingVertices;
|
|
3161
|
-
for (var i = 0; i < state.groupMove_vertices.length; i++) {
|
|
3162
|
-
state.groupMove_vertices[i].feature = this.getFeature(state.groupMove_vertices[i].featureId);
|
|
3163
|
-
}
|
|
3164
|
-
var selectedCoordinates = this.pathsToCoordinates(state.featureId, state.selectedCoordPaths);
|
|
3165
|
-
this.setSelectedCoordinates(selectedCoordinates);
|
|
3166
|
-
};
|
|
3167
|
-
DirectSelect.onMidpoint = function (state, e) {
|
|
3168
|
-
this.startDragging(state, e);
|
|
3169
|
-
var about = e.featureTarget.properties;
|
|
3170
|
-
state.feature.addCoordinate(about.coord_path, about.lng, about.lat);
|
|
3171
|
-
this.fireUpdate();
|
|
3172
|
-
state.selectedCoordPaths = [about.coord_path];
|
|
3173
|
-
};
|
|
3174
|
-
DirectSelect.pathsToCoordinates = function (featureId, paths) {
|
|
3175
|
-
return paths.map(function (coord_path) {
|
|
3176
|
-
return {
|
|
3177
|
-
feature_id: featureId,
|
|
3178
|
-
coord_path: coord_path
|
|
3179
|
-
};
|
|
3180
|
-
});
|
|
3181
|
-
};
|
|
3182
|
-
DirectSelect.onFeature = function (state, e) {
|
|
3183
|
-
if (state.selectedCoordPaths.length === 0) this.startDragging(state, e);else this.stopDragging(state);
|
|
3184
|
-
};
|
|
3185
|
-
DirectSelect.dragFeature = function (state, e, delta) {
|
|
3186
|
-
move_features(this.getSelected(), delta);
|
|
3187
|
-
state.dragMoveLocation = e.lngLat;
|
|
3188
|
-
};
|
|
3189
|
-
DirectSelect.dragVertex = function (state, e, delta) {
|
|
3190
|
-
var selectedCoords = state.selectedCoordPaths.map(function (coord_path) {
|
|
3191
|
-
return state.feature.getCoordinate(coord_path);
|
|
3192
|
-
});
|
|
3193
|
-
var selectedCoordPoints = selectedCoords.map(function (coords) {
|
|
3194
|
-
return {
|
|
3195
|
-
type: geojsonTypes.FEATURE,
|
|
3196
|
-
properties: {},
|
|
3197
|
-
geometry: {
|
|
3198
|
-
type: geojsonTypes.POINT,
|
|
3199
|
-
coordinates: coords
|
|
3200
|
-
}
|
|
3201
|
-
};
|
|
3202
|
-
});
|
|
3203
|
-
var constrainedDelta = constrain_feature_movement(selectedCoordPoints, delta);
|
|
3204
|
-
for (var i = 0; i < selectedCoords.length; i++) {
|
|
3205
|
-
var coord = selectedCoords[i];
|
|
3206
|
-
state.feature.updateCoordinate(state.selectedCoordPaths[i], coord[0] + constrainedDelta.lng, coord[1] + constrainedDelta.lat);
|
|
3207
|
-
for (var k = 0; k < state.groupMove_vertices.length; k++) {
|
|
3208
|
-
var coord_path_m = state.groupMove_vertices[k].coord_path.split(".");
|
|
3209
|
-
if (typeof coord_path_m[0] !== "undefined" && typeof coord_path_m[1] !== "undefined" && typeof state.groupMove_vertices[k].feature.coordinates[coord_path_m[0]] !== "undefined" && typeof state.groupMove_vertices[k].feature.coordinates[coord_path_m[0]][coord_path_m[1]] !== "undefined") {
|
|
3210
|
-
var coord_m = state.groupMove_vertices[k].feature.coordinates[coord_path_m[0]][coord_path_m[1]];
|
|
3211
|
-
state.groupMove_vertices[k].feature.updateCoordinate(state.groupMove_vertices[k].coord_path, coord_m[0] + constrainedDelta.lng, coord_m[1] + constrainedDelta.lat);
|
|
3212
|
-
}
|
|
3213
|
-
}
|
|
3214
|
-
}
|
|
3215
|
-
};
|
|
3216
|
-
DirectSelect.clickNoTarget = function () {
|
|
3217
|
-
this.changeMode("custom_select");
|
|
3218
|
-
};
|
|
3219
|
-
DirectSelect.clickInactive = function () {
|
|
3220
|
-
this.changeMode("custom_select");
|
|
3221
|
-
};
|
|
3222
|
-
DirectSelect.clickActiveFeature = function (state) {
|
|
3223
|
-
state.selectedCoordPaths = [];
|
|
3224
|
-
this.clearSelectedCoordinates();
|
|
3225
|
-
state.feature.changed();
|
|
3226
|
-
};
|
|
3227
|
-
|
|
3228
|
-
// EXTERNAL FUNCTIONS
|
|
3229
|
-
|
|
3230
|
-
DirectSelect.onSetup = function (opts) {
|
|
3231
|
-
var featureId = opts.featureId;
|
|
3232
|
-
var feature = this.getFeature(featureId);
|
|
3233
|
-
if (!feature) {
|
|
3234
|
-
throw new Error("You must provide a featureId to enter direct_select mode");
|
|
3235
|
-
}
|
|
3236
|
-
if (feature.type === geojsonTypes.POINT) {
|
|
3237
|
-
throw new TypeError("direct_select mode doesn't handle point features");
|
|
3238
|
-
}
|
|
3239
|
-
var state = {
|
|
3240
|
-
featureId: featureId,
|
|
3241
|
-
feature: feature,
|
|
3242
|
-
dragMoveLocation: opts.startPos || null,
|
|
3243
|
-
dragMoving: false,
|
|
3244
|
-
canDragMove: false,
|
|
3245
|
-
selectedCoordPaths: opts.coordPath ? [opts.coordPath] : [],
|
|
3246
|
-
groupMove_vertices: opts.groupMove_vertices ? opts.groupMove_vertices : []
|
|
3247
|
-
};
|
|
3248
|
-
this.setSelectedCoordinates(this.pathsToCoordinates(featureId, state.selectedCoordPaths));
|
|
3249
|
-
this.setSelected(featureId);
|
|
3250
|
-
doubleClickZoom.disable(this);
|
|
3251
|
-
this.setActionableState({
|
|
3252
|
-
trash: true
|
|
3253
|
-
});
|
|
3254
|
-
return state;
|
|
3255
|
-
};
|
|
3256
|
-
DirectSelect.onStop = function () {
|
|
3257
|
-
doubleClickZoom.enable(this);
|
|
3258
|
-
this.clearSelectedCoordinates();
|
|
3259
|
-
};
|
|
3260
|
-
DirectSelect.toDisplayFeatures = function (state, geojson, push) {
|
|
3261
|
-
if (state.featureId === geojson.properties.id) {
|
|
3262
|
-
geojson.properties.active = activeStates.ACTIVE;
|
|
3263
|
-
push(geojson);
|
|
3264
|
-
createSupplementaryPoints(geojson, {
|
|
3265
|
-
map: this.map,
|
|
3266
|
-
midpoints: true,
|
|
3267
|
-
selectedPaths: state.selectedCoordPaths
|
|
3268
|
-
}).forEach(push);
|
|
3269
|
-
} else {
|
|
3270
|
-
geojson.properties.active = activeStates.INACTIVE;
|
|
3271
|
-
push(geojson);
|
|
3272
|
-
}
|
|
3273
|
-
this.fireActionable(state);
|
|
3274
|
-
};
|
|
3275
|
-
DirectSelect.onTrash = function (state) {
|
|
3276
|
-
// Uses number-aware sorting to make sure '9' < '10'. Comparison is reversed because we want them
|
|
3277
|
-
// in reverse order so that we can remove by index safely.
|
|
3278
|
-
state.selectedCoordPaths.sort(function (a, b) {
|
|
3279
|
-
return b.localeCompare(a, "en", {
|
|
3280
|
-
numeric: true
|
|
3281
|
-
});
|
|
3282
|
-
}).forEach(function (id) {
|
|
3283
|
-
return state.feature.removeCoordinate(id);
|
|
3284
|
-
});
|
|
3285
|
-
this.fireUpdate();
|
|
3286
|
-
state.selectedCoordPaths = [];
|
|
3287
|
-
this.clearSelectedCoordinates();
|
|
3288
|
-
this.fireActionable(state);
|
|
3289
|
-
if (state.feature.isValid() === false) {
|
|
3290
|
-
this.deleteFeature([state.featureId]);
|
|
3291
|
-
this.changeMode("custom_select", {});
|
|
3292
|
-
}
|
|
3293
|
-
};
|
|
3294
|
-
DirectSelect.onMouseMove = function (state, e) {
|
|
3295
|
-
// On mousemove that is not a drag, stop vertex movement.
|
|
3296
|
-
var isFeature = isActiveFeature(e);
|
|
3297
|
-
var onVertex = isVertex(e);
|
|
3298
|
-
var noCoords = state.selectedCoordPaths.length === 0;
|
|
3299
|
-
if (isFeature && noCoords) this.updateUIClasses({
|
|
3300
|
-
mouse: cursors.MOVE
|
|
3301
|
-
});else if (onVertex && !noCoords) this.updateUIClasses({
|
|
3302
|
-
mouse: cursors.MOVE
|
|
3303
|
-
});else this.updateUIClasses({
|
|
3304
|
-
mouse: cursors.NONE
|
|
3305
|
-
});
|
|
3306
|
-
this.stopDragging(state);
|
|
3307
|
-
};
|
|
3308
|
-
DirectSelect.onMouseOut = function (state) {
|
|
3309
|
-
// As soon as you mouse leaves the canvas, update the feature
|
|
3310
|
-
if (state.dragMoving) this.fireUpdate();
|
|
3311
|
-
};
|
|
3312
|
-
DirectSelect.onTouchStart = DirectSelect.onMouseDown = function (state, e) {
|
|
3313
|
-
if (isVertex(e)) return this.onVertex(state, e);
|
|
3314
|
-
if (isActiveFeature(e)) return this.onFeature(state, e);
|
|
3315
|
-
if (isMidpoint(e)) return this.onMidpoint(state, e);
|
|
3316
|
-
};
|
|
3317
|
-
DirectSelect.onDrag = function (state, e) {
|
|
3318
|
-
if (state.canDragMove !== true) return;
|
|
3319
|
-
state.dragMoving = true;
|
|
3320
|
-
e.originalEvent.stopPropagation();
|
|
3321
|
-
var delta = {
|
|
3322
|
-
lng: e.lngLat.lng - state.dragMoveLocation.lng,
|
|
3323
|
-
lat: e.lngLat.lat - state.dragMoveLocation.lat
|
|
3324
|
-
};
|
|
3325
|
-
if (state.selectedCoordPaths.length > 0) this.dragVertex(state, e, delta);else this.dragFeature(state, e, delta);
|
|
3326
|
-
state.dragMoveLocation = e.lngLat;
|
|
3327
|
-
};
|
|
3328
|
-
DirectSelect.onClick = function (state, e) {
|
|
3329
|
-
if (noTarget(e)) return this.clickNoTarget(state, e);
|
|
3330
|
-
if (isActiveFeature(e)) return this.clickActiveFeature(state, e);
|
|
3331
|
-
if (isInactiveFeature(e)) return this.clickInactive(state, e);
|
|
3332
|
-
this.stopDragging(state);
|
|
3333
|
-
};
|
|
3334
|
-
DirectSelect.onTap = function (state, e) {
|
|
3335
|
-
if (noTarget(e)) return this.clickNoTarget(state, e);
|
|
3336
|
-
if (isActiveFeature(e)) return this.clickActiveFeature(state, e);
|
|
3337
|
-
if (isInactiveFeature(e)) return this.clickInactive(state, e);
|
|
3338
|
-
};
|
|
3339
|
-
DirectSelect.onTouchEnd = DirectSelect.onMouseUp = function (state) {
|
|
3340
|
-
if (state.dragMoving) {
|
|
3341
|
-
this.fireUpdate();
|
|
3342
|
-
}
|
|
3343
|
-
this.stopDragging(state);
|
|
3344
|
-
};
|
|
3345
|
-
|
|
3346
2074
|
/**
|
|
3347
2075
|
* GeoJson Feature editor that allows to create or manipulate GeoJson data
|
|
3348
2076
|
*/
|
|
3349
|
-
var
|
|
2077
|
+
var useFeatureEditor = function (props) {
|
|
3350
2078
|
var draw = React.useRef();
|
|
3351
2079
|
var mapHook = useMap({
|
|
3352
2080
|
mapId: props.mapId,
|
|
@@ -3354,14 +2082,15 @@ var MlFeatureEditor = function (props) {
|
|
|
3354
2082
|
});
|
|
3355
2083
|
var drawToolsInitialized = React.useRef(false);
|
|
3356
2084
|
var _a = React.useState(false), drawToolsReady = _a[0], setDrawToolsReady = _a[1];
|
|
3357
|
-
var
|
|
2085
|
+
var _b = React.useState(), feature = _b[0], setFeature = _b[1];
|
|
2086
|
+
var modeChangeHandler = React.useCallback(function (e) {
|
|
3358
2087
|
console.log('MlFeatureEditor mode change to ' + e.mode);
|
|
3359
2088
|
//setDrawMode(e.mode);
|
|
3360
2089
|
if (typeof props.onFinish === 'function' &&
|
|
3361
|
-
(e.mode === '
|
|
2090
|
+
(e.mode === 'simple_select')) {
|
|
3362
2091
|
props.onFinish();
|
|
3363
2092
|
}
|
|
3364
|
-
};
|
|
2093
|
+
}, [props.onFinish]);
|
|
3365
2094
|
React.useEffect(function () {
|
|
3366
2095
|
var _a;
|
|
3367
2096
|
if (mapHook.map && !drawToolsInitialized.current) {
|
|
@@ -3376,20 +2105,16 @@ var MlFeatureEditor = function (props) {
|
|
|
3376
2105
|
}
|
|
3377
2106
|
draw.current = new MapboxDraw__default["default"]({
|
|
3378
2107
|
displayControlsDefault: false,
|
|
3379
|
-
defaultMode: props.mode || '
|
|
2108
|
+
defaultMode: props.mode || 'simple_select',
|
|
3380
2109
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3381
2110
|
// @ts-ignore
|
|
3382
|
-
modes: Object.assign({
|
|
3383
|
-
custom_polygon: CustomPolygonMode,
|
|
3384
|
-
custom_select: CustomSelectMode,
|
|
3385
|
-
custom_direct_select: DirectSelect,
|
|
3386
|
-
}, MapboxDraw__default["default"].modes),
|
|
2111
|
+
modes: Object.assign({}, MapboxDraw__default["default"].modes),
|
|
3387
2112
|
});
|
|
3388
2113
|
mapHook.map.addControl(draw.current, 'top-left', mapHook.componentId);
|
|
3389
2114
|
mapHook.map.on('draw.modechange', modeChangeHandler, mapHook.componentId);
|
|
3390
2115
|
setDrawToolsReady(true);
|
|
3391
2116
|
}
|
|
3392
|
-
}, [mapHook.map, props, drawToolsInitialized]);
|
|
2117
|
+
}, [mapHook.map, props, drawToolsInitialized, modeChangeHandler]);
|
|
3393
2118
|
React.useEffect(function () {
|
|
3394
2119
|
if (!mapHook.map || !drawToolsReady)
|
|
3395
2120
|
return;
|
|
@@ -3397,8 +2122,9 @@ var MlFeatureEditor = function (props) {
|
|
|
3397
2122
|
var _a, _b;
|
|
3398
2123
|
if (draw.current) {
|
|
3399
2124
|
// update drawnFeatures state object
|
|
2125
|
+
var currentFeatureCollection = (_b = (_a = draw.current).getAll) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
2126
|
+
setFeature(currentFeatureCollection === null || currentFeatureCollection === void 0 ? void 0 : currentFeatureCollection.features);
|
|
3400
2127
|
if (typeof props.onChange === 'function') {
|
|
3401
|
-
var currentFeatureCollection = (_b = (_a = draw.current).getAll) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3402
2128
|
props.onChange(currentFeatureCollection === null || currentFeatureCollection === void 0 ? void 0 : currentFeatureCollection.features);
|
|
3403
2129
|
}
|
|
3404
2130
|
}
|
|
@@ -3415,17 +2141,38 @@ var MlFeatureEditor = function (props) {
|
|
|
3415
2141
|
React.useEffect(function () {
|
|
3416
2142
|
var _a;
|
|
3417
2143
|
if (draw.current && ((_a = props.geojson) === null || _a === void 0 ? void 0 : _a.geometry)) {
|
|
2144
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2145
|
+
// @ts-ignore
|
|
3418
2146
|
draw.current.set({ type: 'FeatureCollection', features: [props.geojson] });
|
|
3419
2147
|
}
|
|
3420
2148
|
}, [props.geojson, drawToolsReady]);
|
|
3421
2149
|
React.useEffect(function () {
|
|
3422
|
-
|
|
2150
|
+
var _a, _b, _c, _d;
|
|
2151
|
+
if (props.mode && draw.current && ((_b = (_a = draw.current) === null || _a === void 0 ? void 0 : _a.getMode) === null || _b === void 0 ? void 0 : _b.call(_a)) !== props.mode) {
|
|
3423
2152
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3424
2153
|
// @ts-ignore
|
|
3425
|
-
draw.current.changeMode(props.mode);
|
|
2154
|
+
(_d = (_c = draw.current) === null || _c === void 0 ? void 0 : _c.changeMode) === null || _d === void 0 ? void 0 : _d.call(_c, props.mode);
|
|
2155
|
+
if (props.mode !== 'simple_select' && props.mode !== 'direct_select') {
|
|
2156
|
+
draw.current.set({ type: 'FeatureCollection', features: [] });
|
|
2157
|
+
}
|
|
3426
2158
|
}
|
|
3427
|
-
}, [props.mode]);
|
|
3428
|
-
return
|
|
2159
|
+
}, [props.mode, mapHook.map]);
|
|
2160
|
+
return {
|
|
2161
|
+
feature: feature,
|
|
2162
|
+
drawToolsReady: drawToolsReady,
|
|
2163
|
+
draw: draw.current
|
|
2164
|
+
};
|
|
2165
|
+
};
|
|
2166
|
+
|
|
2167
|
+
var MlFeatureEditor = function (props) {
|
|
2168
|
+
useFeatureEditor({
|
|
2169
|
+
mode: props.mode,
|
|
2170
|
+
geojson: props.geojson,
|
|
2171
|
+
onChange: props.onChange,
|
|
2172
|
+
onFinish: props.onFinish,
|
|
2173
|
+
mapId: props.mapId,
|
|
2174
|
+
});
|
|
2175
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null));
|
|
3429
2176
|
};
|
|
3430
2177
|
|
|
3431
2178
|
var legalLayerTypes = [
|
|
@@ -3571,6 +2318,14 @@ function useLayer(props) {
|
|
|
3571
2318
|
layerPaintConfRef.current = paintString;
|
|
3572
2319
|
}
|
|
3573
2320
|
}, [props.options, mapHook.map]);
|
|
2321
|
+
React.useEffect(function () {
|
|
2322
|
+
if (!props.insertBeforeLayer ||
|
|
2323
|
+
!mapHook.map ||
|
|
2324
|
+
!mapHook.map.getLayer(props.insertBeforeLayer) ||
|
|
2325
|
+
!mapHook.map.getLayer(layerId.current))
|
|
2326
|
+
return;
|
|
2327
|
+
mapHook.map.moveLayer(layerId.current, props.insertBeforeLayer);
|
|
2328
|
+
}, [mapHook.map, props.insertBeforeLayer]);
|
|
3574
2329
|
React.useEffect(function () {
|
|
3575
2330
|
return function () {
|
|
3576
2331
|
initializedRef.current = false;
|
|
@@ -3869,7 +2624,7 @@ function getUnitLabel(measureType) {
|
|
|
3869
2624
|
}
|
|
3870
2625
|
var MlMeasureTool = function (props) {
|
|
3871
2626
|
var _a = React.useState(0), length = _a[0], setLength = _a[1];
|
|
3872
|
-
var _b = React.useState([
|
|
2627
|
+
var _b = React.useState([]), currentFeatures = _b[0], setCurrentFeatures = _b[1];
|
|
3873
2628
|
React.useEffect(function () {
|
|
3874
2629
|
if (currentFeatures[0]) {
|
|
3875
2630
|
setLength(props.measureType === "polygon"
|
|
@@ -3880,7 +2635,7 @@ var MlMeasureTool = function (props) {
|
|
|
3880
2635
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
3881
2636
|
React__default["default"].createElement(MlFeatureEditor, { onChange: function (features) {
|
|
3882
2637
|
setCurrentFeatures(features);
|
|
3883
|
-
}, mode: props.measureType === "polygon" ? "
|
|
2638
|
+
}, mode: props.measureType === "polygon" ? "draw_polygon" : "draw_line_string" }),
|
|
3884
2639
|
length.toFixed(2),
|
|
3885
2640
|
" ",
|
|
3886
2641
|
getUnitLabel(props.unit),
|
|
@@ -6429,16 +5184,17 @@ var MlWmsLoader = function (props) {
|
|
|
6429
5184
|
setFeatureInfoLngLat(undefined);
|
|
6430
5185
|
setFeatureInfoContent(undefined);
|
|
6431
5186
|
};
|
|
6432
|
-
var getFeatureInfo = React.useCallback(
|
|
6433
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
6434
|
-
function (ev) {
|
|
5187
|
+
var getFeatureInfo = React.useCallback(function (ev) {
|
|
6435
5188
|
var _a, _b, _c;
|
|
6436
5189
|
if (!mapHook.map)
|
|
6437
5190
|
return;
|
|
6438
5191
|
resetFeatureInfo();
|
|
6439
|
-
var
|
|
6440
|
-
var
|
|
6441
|
-
var
|
|
5192
|
+
var unprojected = mapHook.map.unproject([ev.point.x, ev.point.y]);
|
|
5193
|
+
var point = turf__namespace.point([unprojected.lng, unprojected.lat]);
|
|
5194
|
+
var buffered = turf__namespace.buffer(point, 50, { units: 'meters' });
|
|
5195
|
+
var _bbox = turf__namespace.bbox(buffered);
|
|
5196
|
+
var _sw = lngLatToMeters({ lng: _bbox[0], lat: _bbox[1] });
|
|
5197
|
+
var _ne = lngLatToMeters({ lng: _bbox[2], lat: _bbox[3] });
|
|
6442
5198
|
var bbox = [_sw[0], _sw[1], _ne[0], _ne[1]];
|
|
6443
5199
|
var _getFeatureInfoUrlParams = {
|
|
6444
5200
|
REQUEST: 'GetFeatureInfo',
|
|
@@ -6454,15 +5210,15 @@ var MlWmsLoader = function (props) {
|
|
|
6454
5210
|
QUERY_LAYERS: layers
|
|
6455
5211
|
.map(function (layer) { return (layer.visible && layer.queryable ? layer.Name : undefined); })
|
|
6456
5212
|
.filter(function (n) { return n; }),
|
|
6457
|
-
WIDTH:
|
|
6458
|
-
HEIGHT:
|
|
5213
|
+
WIDTH: 100,
|
|
5214
|
+
HEIGHT: 100,
|
|
6459
5215
|
srs: 'EPSG:3857',
|
|
6460
5216
|
CRS: 'EPSG:3857',
|
|
6461
5217
|
version: '1.3.0',
|
|
6462
|
-
X:
|
|
6463
|
-
Y:
|
|
6464
|
-
I:
|
|
6465
|
-
J:
|
|
5218
|
+
X: 50,
|
|
5219
|
+
Y: 50,
|
|
5220
|
+
I: 50,
|
|
5221
|
+
J: 50,
|
|
6466
5222
|
buffer: '50',
|
|
6467
5223
|
};
|
|
6468
5224
|
var _gfiUrl = getFeatureInfoUrl;
|
|
@@ -6562,6 +5318,7 @@ var MlWmsLoader = function (props) {
|
|
|
6562
5318
|
React__default["default"].createElement(material.Box, null, error))),
|
|
6563
5319
|
wmsUrl && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6564
5320
|
React__default["default"].createElement(ListItem__default["default"], { secondaryAction: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
5321
|
+
props.buttons,
|
|
6565
5322
|
props.featureInfoEnabled && (React__default["default"].createElement(IconButton__default["default"], { sx: {
|
|
6566
5323
|
padding: '4px',
|
|
6567
5324
|
marginTop: '-3px',
|
|
@@ -6697,7 +5454,8 @@ function paintPicker(props) {
|
|
|
6697
5454
|
};
|
|
6698
5455
|
var defaultLinePaint = {
|
|
6699
5456
|
'line-color': props.featuresColor,
|
|
6700
|
-
'line-
|
|
5457
|
+
'line-width': 3,
|
|
5458
|
+
'line-opacity': opacityInterpolate
|
|
6701
5459
|
};
|
|
6702
5460
|
var circleAccumulatePaint = {
|
|
6703
5461
|
'circle-color': props.featuresColor,
|
|
@@ -6727,7 +5485,8 @@ function paintPicker(props) {
|
|
|
6727
5485
|
};
|
|
6728
5486
|
var lineAccumulatePaint = {
|
|
6729
5487
|
'line-color': props.featuresColor,
|
|
6730
|
-
'line-
|
|
5488
|
+
'line-width': 3,
|
|
5489
|
+
'line-opacity': accumulatedOpacityInterpolate
|
|
6731
5490
|
};
|
|
6732
5491
|
if (props.userPaint !== undefined) {
|
|
6733
5492
|
return props.userPaint;
|
|
@@ -6832,7 +5591,7 @@ function MlTemporalControllerLabels(props) {
|
|
|
6832
5591
|
|
|
6833
5592
|
var bigScreenBoxStyle = {
|
|
6834
5593
|
marginLeft: '15%',
|
|
6835
|
-
marginBottom: '
|
|
5594
|
+
marginBottom: '3%',
|
|
6836
5595
|
width: '70%',
|
|
6837
5596
|
height: '90px',
|
|
6838
5597
|
alignItems: 'center',
|
|
@@ -6874,21 +5633,20 @@ function TemporalControllerPlayer(props) {
|
|
|
6874
5633
|
setCurrentVal(function (val) { return val + props.step; });
|
|
6875
5634
|
}
|
|
6876
5635
|
counter = counter + props.step;
|
|
6877
|
-
},
|
|
5636
|
+
}, props.interval);
|
|
6878
5637
|
}, [props.step, props.maxVal, currentVal]);
|
|
6879
5638
|
// Player buttons
|
|
6880
|
-
var
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
};
|
|
6884
|
-
var handlePause = function () {
|
|
6885
|
-
setIsPlaying(!isPlaying);
|
|
6886
|
-
if (isPlaying) {
|
|
6887
|
-
clearInterval(intervalRef.current);
|
|
6888
|
-
}
|
|
6889
|
-
else if (!isPlaying) {
|
|
5639
|
+
var handlePlayPause = function () {
|
|
5640
|
+
if (!isPlaying) {
|
|
5641
|
+
setIsPlaying(true);
|
|
6890
5642
|
play();
|
|
6891
5643
|
}
|
|
5644
|
+
else {
|
|
5645
|
+
setIsPlaying(false);
|
|
5646
|
+
if (isPlaying) {
|
|
5647
|
+
clearInterval(intervalRef.current);
|
|
5648
|
+
}
|
|
5649
|
+
}
|
|
6892
5650
|
};
|
|
6893
5651
|
var handleStop = function () {
|
|
6894
5652
|
clearInterval(intervalRef.current);
|
|
@@ -6940,10 +5698,7 @@ function TemporalControllerPlayer(props) {
|
|
|
6940
5698
|
React__default["default"].createElement(FastRewindIcon__default["default"], null)),
|
|
6941
5699
|
React__default["default"].createElement(material.Button, { onClick: handleStop },
|
|
6942
5700
|
React__default["default"].createElement(StopIcon__default["default"], null)),
|
|
6943
|
-
React__default["default"].createElement(material.Button, { onClick:
|
|
6944
|
-
React__default["default"].createElement(PlayArrowIcon__default["default"], null)),
|
|
6945
|
-
React__default["default"].createElement(material.Button, { onClick: handlePause },
|
|
6946
|
-
React__default["default"].createElement(PauseIcon__default["default"], null)),
|
|
5701
|
+
React__default["default"].createElement(material.Button, { onClick: handlePlayPause }, isPlaying ? React__default["default"].createElement(PauseIcon__default["default"], null) : React__default["default"].createElement(PlayArrowIcon__default["default"], null)),
|
|
6947
5702
|
React__default["default"].createElement(material.Button, { onClick: handleFastForward },
|
|
6948
5703
|
React__default["default"].createElement(FastForwardIcon__default["default"], null))),
|
|
6949
5704
|
props.display && !mediaIsMobile && (React__default["default"].createElement(material.Grid, { item: true, xs: 3 },
|
|
@@ -7110,13 +5865,14 @@ var MlTemporalController = function (props) {
|
|
|
7110
5865
|
},
|
|
7111
5866
|
} })),
|
|
7112
5867
|
props.label && (React__default["default"].createElement(MlTemporalControllerLabels, { data: filteredData, currentVal: currentVal, fadeIn: props.labelFadeIn, fadeOut: props.labelFadeOut, step: props.step, labelField: labelField, labelColor: labelColor, timeField: props.timeField, minVal: minVal, accumulate: props.accumulate, isPlaying: isPlaying })),
|
|
7113
|
-
React__default["default"].createElement(TemporalControllerPlayer, { currentVal: currentVal, isPlaying: isPlaying, step: props.step, minVal: minVal, maxVal: maxVal, returnCurrent: setCurrentVal, returnPlaying: setIsPlaying, open: false, fadeIn: props.fadeIn, fadeOut: props.fadeOut, featuresColor: featuresColor, labels: props.label, labelColor: labelColor, labelFadeIn: props.labelFadeIn, labelFadeOut: props.labelFadeOut, accumulate: props.accumulate, display: props.displayCurrentValue })));
|
|
5868
|
+
React__default["default"].createElement(TemporalControllerPlayer, { currentVal: currentVal, isPlaying: isPlaying, step: props.step, interval: props.interval, minVal: minVal, maxVal: maxVal, returnCurrent: setCurrentVal, returnPlaying: setIsPlaying, open: false, fadeIn: props.fadeIn, fadeOut: props.fadeOut, featuresColor: featuresColor, labels: props.label, labelColor: labelColor, labelFadeIn: props.labelFadeIn, labelFadeOut: props.labelFadeOut, accumulate: props.accumulate, display: props.displayCurrentValue })));
|
|
7114
5869
|
};
|
|
7115
5870
|
MlTemporalController.defaultProps = {
|
|
7116
5871
|
mapId: undefined,
|
|
7117
5872
|
ownLayer: true,
|
|
7118
5873
|
type: 'circle',
|
|
7119
5874
|
step: 1,
|
|
5875
|
+
interval: 200,
|
|
7120
5876
|
fadeIn: 5,
|
|
7121
5877
|
fadeOut: 5,
|
|
7122
5878
|
labelFadeIn: 5,
|
|
@@ -7167,11 +5923,11 @@ var MlOrderLayers = function (props) {
|
|
|
7167
5923
|
var _a;
|
|
7168
5924
|
return (React__default["default"].createElement(React__default["default"].Fragment, null, (_a = props === null || props === void 0 ? void 0 : props.layerIds) === null || _a === void 0 ? void 0 : _a.map(function (layer, idx) {
|
|
7169
5925
|
var _a;
|
|
7170
|
-
return (React__default["default"].createElement(MlLayer, __assign({ layerId:
|
|
5926
|
+
return (React__default["default"].createElement(MlLayer, __assign({ layerId: layer, options: {
|
|
7171
5927
|
display: 'none',
|
|
7172
5928
|
}, key: layer }, (idx > 0
|
|
7173
5929
|
? {
|
|
7174
|
-
insertBeforeLayer:
|
|
5930
|
+
insertBeforeLayer: (_a = props === null || props === void 0 ? void 0 : props.layerIds) === null || _a === void 0 ? void 0 : _a[idx - 1],
|
|
7175
5931
|
}
|
|
7176
5932
|
: { insertBeforeLayer: props.insertBeforeLayer }))));
|
|
7177
5933
|
})));
|
|
@@ -7181,6 +5937,41 @@ MlOrderLayers.defaultProps = {
|
|
|
7181
5937
|
insertBeforeLayer: undefined,
|
|
7182
5938
|
};
|
|
7183
5939
|
|
|
5940
|
+
/**
|
|
5941
|
+
* Create Terrain Layer Component
|
|
5942
|
+
*
|
|
5943
|
+
*/
|
|
5944
|
+
var MlTerrainLayer = function (props) {
|
|
5945
|
+
var mapHook = useMap({ mapId: 'map_1' });
|
|
5946
|
+
React.useEffect(function () {
|
|
5947
|
+
if (!mapHook.map)
|
|
5948
|
+
return;
|
|
5949
|
+
if (!mapHook.map.map.getSource('terrain')) {
|
|
5950
|
+
mapHook.map.map.addSource('terrain', __assign({ type: 'raster-dem', encoding: 'mapbox', maxzoom: 14, minzoom: 4 }, props.sourceOptions));
|
|
5951
|
+
}
|
|
5952
|
+
mapHook.map.map.setTerrain(__assign({ source: 'terrain', exaggeration: 1 }, props.terrainOptions));
|
|
5953
|
+
mapHook.map.addLayer({
|
|
5954
|
+
id: 'hills',
|
|
5955
|
+
type: 'hillshade',
|
|
5956
|
+
source: 'terrain',
|
|
5957
|
+
layout: { visibility: 'visible' },
|
|
5958
|
+
paint: { 'hillshade-shadow-color': 'rgba(71,59,36,0.4)' },
|
|
5959
|
+
});
|
|
5960
|
+
return function () {
|
|
5961
|
+
var _a, _b;
|
|
5962
|
+
(_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map.setTerrain(null);
|
|
5963
|
+
if ((_b = mapHook.map) === null || _b === void 0 ? void 0 : _b.map.getSource('terrain')) {
|
|
5964
|
+
mapHook.map.map.removeLayer('hills');
|
|
5965
|
+
mapHook.map.map.removeSource('terrain');
|
|
5966
|
+
}
|
|
5967
|
+
};
|
|
5968
|
+
}, [mapHook.map, props.sourceOptions, props.terrainOptions]);
|
|
5969
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null);
|
|
5970
|
+
};
|
|
5971
|
+
MlTerrainLayer.defaultProps = {
|
|
5972
|
+
mapId: undefined,
|
|
5973
|
+
};
|
|
5974
|
+
|
|
7184
5975
|
/**
|
|
7185
5976
|
* Component template
|
|
7186
5977
|
*
|
|
@@ -7783,13 +6574,9 @@ function LayerListItem(_a) {
|
|
|
7783
6574
|
return undefined;
|
|
7784
6575
|
}, [layerComponent]);
|
|
7785
6576
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7786
|
-
!((_f = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _f === void 0 ? void 0 : _f.layers) && (React__default["default"].createElement(material.ListItem, { sx: {
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
paddingTop: 0,
|
|
7790
|
-
paddingBottom: '4px',
|
|
7791
|
-
}, secondaryAction: configurable && ((_g = Object.keys(paintProps)) === null || _g === void 0 ? void 0 : _g.length) > 0 ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7792
|
-
React__default["default"].createElement(material.IconButton, { edge: props.showDeleteButton ? false : 'end', "aria-label": "visibility", onClick: function () {
|
|
6577
|
+
!((_f = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _f === void 0 ? void 0 : _f.layers) && (React__default["default"].createElement(material.ListItem, { sx: __assign({ paddingRight: configurable ? '56px' : 0, paddingLeft: 0, paddingTop: 0, paddingBottom: '4px' }, props.listItemSx), secondaryAction: configurable && ((_g = Object.keys(paintProps)) === null || _g === void 0 ? void 0 : _g.length) > 0 ? (React__default["default"].createElement(React__default["default"].Fragment, null, props === null || props === void 0 ? void 0 :
|
|
6578
|
+
props.buttons,
|
|
6579
|
+
React__default["default"].createElement(material.IconButton, { edge: props.showDeleteButton ? false : 'end', "aria-label": "settings", onClick: function () {
|
|
7793
6580
|
setPaintPropsFormVisible(function (current) {
|
|
7794
6581
|
return !current;
|
|
7795
6582
|
});
|
|
@@ -7818,7 +6605,7 @@ function LayerListItem(_a) {
|
|
|
7818
6605
|
React__default["default"].createElement(material.Checkbox, { disabled: !visible, checked: localVisible, sx: { padding: 0 }, onClick: function () {
|
|
7819
6606
|
setLocalVisible(function (val) { return !val; });
|
|
7820
6607
|
} })),
|
|
7821
|
-
React__default["default"].createElement(material.ListItemText, { variant: "layerlist", primary: name, secondary: description }))),
|
|
6608
|
+
React__default["default"].createElement(material.ListItemText, { variant: "layerlist", primary: name, secondary: description, primaryTypographyProps: { overflow: 'hidden' } }))),
|
|
7822
6609
|
_layerComponent,
|
|
7823
6610
|
!((_h = layerComponent === null || layerComponent === void 0 ? void 0 : layerComponent.props) === null || _h === void 0 ? void 0 : _h.layers) &&
|
|
7824
6611
|
Object.keys(paintProps).length > 0 &&
|
|
@@ -7830,26 +6617,68 @@ LayerListItem.defaultProps = {
|
|
|
7830
6617
|
type: 'layer',
|
|
7831
6618
|
visible: true,
|
|
7832
6619
|
showDeleteButton: false,
|
|
6620
|
+
buttons: React__default["default"].createElement(React__default["default"].Fragment, null),
|
|
7833
6621
|
};
|
|
7834
6622
|
|
|
7835
6623
|
function LayerListItemFactory(props) {
|
|
7836
6624
|
var _a, _b;
|
|
7837
6625
|
var layerContext = useLayerContext();
|
|
6626
|
+
var orderLayers = React.useMemo(function () {
|
|
6627
|
+
var layerIds = __spreadArray(__spreadArray([
|
|
6628
|
+
'order-background'
|
|
6629
|
+
], __spreadArray([], layerContext.layers, true).map(function (_el, idx) { return 'content_order_' + idx; }), true), [
|
|
6630
|
+
'order-labels',
|
|
6631
|
+
], false);
|
|
6632
|
+
return layerIds.reverse();
|
|
6633
|
+
}, [layerContext.layers]);
|
|
6634
|
+
var layers = React.useMemo(function () {
|
|
6635
|
+
if (props.layers)
|
|
6636
|
+
return props.layers;
|
|
6637
|
+
if (layerContext === null || layerContext === void 0 ? void 0 : layerContext.layers)
|
|
6638
|
+
return layerContext.layers;
|
|
6639
|
+
return [];
|
|
6640
|
+
}, [props.layers, layerContext.layers]);
|
|
6641
|
+
var setLayers = React.useMemo(function () {
|
|
6642
|
+
if (props.setLayers)
|
|
6643
|
+
return props.setLayers;
|
|
6644
|
+
return layerContext.setLayers;
|
|
6645
|
+
}, [props.setLayers, layerContext.setLayers]);
|
|
7838
6646
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7839
|
-
React__default["default"].createElement(MlOrderLayers, { layerIds:
|
|
7840
|
-
((_a = layerContext === null || layerContext === void 0 ? void 0 : layerContext.
|
|
7841
|
-
layerContext.
|
|
7842
|
-
}, visible: true, configurable: true, type: "layer", name: "
|
|
7843
|
-
|
|
6647
|
+
React__default["default"].createElement(MlOrderLayers, { layerIds: orderLayers, insertBeforeLayer: '_background' }),
|
|
6648
|
+
((_a = layerContext === null || layerContext === void 0 ? void 0 : layerContext.symbolLayers) === null || _a === void 0 ? void 0 : _a.length) > 0 && (React__default["default"].createElement(LayerListItem, { key: 'background_labels', layerComponent: React__default["default"].createElement(MlVectorTileLayer, __assign({}, layerContext.vtLayerConfig, { layers: layerContext.symbolLayers, mapId: props === null || props === void 0 ? void 0 : props.mapId, insertBeforeLayer: 'order-labels' })), setLayerState: function (state) {
|
|
6649
|
+
return layerContext.setSymbolLayers(state === null || state === void 0 ? void 0 : state.layers);
|
|
6650
|
+
}, visible: true, configurable: true, type: "layer", name: "Labels" })),
|
|
6651
|
+
__spreadArray([], layers, true).map(function (layer, idx) {
|
|
7844
6652
|
var _a, _b;
|
|
7845
6653
|
if (!(layer === null || layer === void 0 ? void 0 : layer.id))
|
|
7846
6654
|
return null;
|
|
7847
6655
|
switch (layer.type) {
|
|
7848
6656
|
case 'geojson':
|
|
7849
6657
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7850
|
-
React__default["default"].createElement(LayerListItem, { key: layer.id, name: (layer === null || layer === void 0 ? void 0 : layer.name) || ((_a = layer === null || layer === void 0 ? void 0 : layer.config) === null || _a === void 0 ? void 0 : _a.type) + ' layer' || 'unnamed layer', layerComponent: React__default["default"].createElement(MlGeoJsonLayer, __assign({}, layer.config, { mapId: props === null || props === void 0 ? void 0 : props.mapId,
|
|
7851
|
-
|
|
7852
|
-
|
|
6658
|
+
React__default["default"].createElement(LayerListItem, { key: layer.id, name: (layer === null || layer === void 0 ? void 0 : layer.name) || ((_a = layer === null || layer === void 0 ? void 0 : layer.config) === null || _a === void 0 ? void 0 : _a.type) + ' layer' || 'unnamed layer', layerComponent: React__default["default"].createElement(MlGeoJsonLayer, __assign({}, layer.config, { mapId: props === null || props === void 0 ? void 0 : props.mapId, layerId: layer.id, insertBeforeLayer: 'content_order_' + (layers.length - 1 - idx) })), buttons: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6659
|
+
React__default["default"].createElement(material.IconButton, { disabled: idx === layers.length - 1, onClick: function () {
|
|
6660
|
+
layerContext.moveDown(layer.id || '');
|
|
6661
|
+
}, sx: {
|
|
6662
|
+
padding: '4px',
|
|
6663
|
+
marginTop: '-3px',
|
|
6664
|
+
background: 'none',
|
|
6665
|
+
"&:hover": {
|
|
6666
|
+
background: "none"
|
|
6667
|
+
}
|
|
6668
|
+
} },
|
|
6669
|
+
React__default["default"].createElement(ArrowCircleDownIcon__default["default"], null)),
|
|
6670
|
+
React__default["default"].createElement(material.IconButton, { disabled: idx === 0, onClick: function () {
|
|
6671
|
+
layerContext.moveUp(layer.id || '');
|
|
6672
|
+
}, sx: {
|
|
6673
|
+
padding: '4px',
|
|
6674
|
+
marginTop: '-3px',
|
|
6675
|
+
background: 'none',
|
|
6676
|
+
"&:hover": {
|
|
6677
|
+
background: "none"
|
|
6678
|
+
}
|
|
6679
|
+
} },
|
|
6680
|
+
React__default["default"].createElement(ArrowCircleUpIcon__default["default"], null))), setLayerState: function (layerConfig) {
|
|
6681
|
+
return setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7853
6682
|
var _layers = __spreadArray([], current, true);
|
|
7854
6683
|
if (layerConfig === false) {
|
|
7855
6684
|
_layers.splice(idx, 1);
|
|
@@ -7862,9 +6691,8 @@ function LayerListItemFactory(props) {
|
|
|
7862
6691
|
}, configurable: true, showDeleteButton: true })));
|
|
7863
6692
|
case 'wms':
|
|
7864
6693
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
7865
|
-
React__default["default"].createElement(MlWmsLoader, __assign({}, layer.config, { key: layer.id, mapId: props === null || props === void 0 ? void 0 : props.mapId, insertBeforeLayer:
|
|
7866
|
-
|
|
7867
|
-
(_a = props === null || props === void 0 ? void 0 : props.setLayers) === null || _a === void 0 ? void 0 : _a.call(props, function (current) {
|
|
6694
|
+
React__default["default"].createElement(MlWmsLoader, __assign({}, layer.config, { key: layer.id, mapId: props === null || props === void 0 ? void 0 : props.mapId, insertBeforeLayer: 'content_order_' + (layers.length - 1 - idx), onConfigChange: function (layerConfig) {
|
|
6695
|
+
setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7868
6696
|
var _layers = __spreadArray([], current, true);
|
|
7869
6697
|
if (layerConfig === false) {
|
|
7870
6698
|
_layers.splice(idx, 1);
|
|
@@ -7875,27 +6703,48 @@ function LayerListItemFactory(props) {
|
|
|
7875
6703
|
return _layers;
|
|
7876
6704
|
});
|
|
7877
6705
|
}, featureInfoActive: ((_b = layer === null || layer === void 0 ? void 0 : layer.config) === null || _b === void 0 ? void 0 : _b.featureInfoActive) || false, setFeatureInfoActive: function (updateFunction) {
|
|
7878
|
-
|
|
7879
|
-
(_a = props === null || props === void 0 ? void 0 : props.setLayers) === null || _a === void 0 ? void 0 : _a.call(props, function (current) {
|
|
6706
|
+
setLayers === null || setLayers === void 0 ? void 0 : setLayers(function (current) {
|
|
7880
6707
|
var _a;
|
|
7881
6708
|
var _layers = __spreadArray([], current, true);
|
|
7882
6709
|
if (typeof updateFunction === 'function') {
|
|
7883
|
-
_layers[idx].config.featureInfoActive =
|
|
6710
|
+
_layers[idx].config.featureInfoActive =
|
|
6711
|
+
updateFunction(((_a = _layers[idx].config) === null || _a === void 0 ? void 0 : _a.featureInfoActive) || false);
|
|
7884
6712
|
}
|
|
7885
6713
|
return _layers;
|
|
7886
6714
|
});
|
|
7887
|
-
}, showDeleteButton: true
|
|
6715
|
+
}, showDeleteButton: true, buttons: React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
6716
|
+
React__default["default"].createElement(material.IconButton, { disabled: idx === layers.length - 1, onClick: function () {
|
|
6717
|
+
layerContext.moveDown(layer.id || '');
|
|
6718
|
+
}, sx: {
|
|
6719
|
+
padding: '4px',
|
|
6720
|
+
marginTop: '-3px',
|
|
6721
|
+
background: 'none',
|
|
6722
|
+
"&:hover": {
|
|
6723
|
+
background: "none"
|
|
6724
|
+
}
|
|
6725
|
+
} },
|
|
6726
|
+
React__default["default"].createElement(ArrowCircleDownIcon__default["default"], null)),
|
|
6727
|
+
React__default["default"].createElement(material.IconButton, { disabled: idx === 0, onClick: function () {
|
|
6728
|
+
layerContext.moveUp(layer.id || '');
|
|
6729
|
+
}, sx: {
|
|
6730
|
+
padding: '4px',
|
|
6731
|
+
marginTop: '-3px',
|
|
6732
|
+
background: 'none',
|
|
6733
|
+
"&:hover": {
|
|
6734
|
+
background: "none"
|
|
6735
|
+
}
|
|
6736
|
+
} },
|
|
6737
|
+
React__default["default"].createElement(ArrowCircleUpIcon__default["default"], null))) }))));
|
|
7888
6738
|
default:
|
|
7889
6739
|
return null;
|
|
7890
6740
|
}
|
|
7891
6741
|
}),
|
|
7892
|
-
((_b = layerContext === null || layerContext === void 0 ? void 0 : layerContext.
|
|
7893
|
-
|
|
7894
|
-
}, visible: true, configurable: true, type: "layer", name: "
|
|
6742
|
+
((_b = layerContext === null || layerContext === void 0 ? void 0 : layerContext.backgroundLayers) === null || _b === void 0 ? void 0 : _b.length) > 0 && (React__default["default"].createElement(LayerListItem, { key: 'background_geometry', layerComponent: React__default["default"].createElement(MlVectorTileLayer, __assign({}, layerContext.vtLayerConfig, { layers: layerContext.backgroundLayers, mapId: props === null || props === void 0 ? void 0 : props.mapId, insertBeforeLayer: 'order-background' })), setLayerState: function (state) {
|
|
6743
|
+
layerContext.setBackgroundLayers(state === null || state === void 0 ? void 0 : state.layers);
|
|
6744
|
+
}, visible: true, configurable: true, type: "layer", name: "Background" }))));
|
|
7895
6745
|
}
|
|
7896
6746
|
LayerListItemFactory.defaultProps = {
|
|
7897
6747
|
mapId: undefined,
|
|
7898
|
-
layers: [],
|
|
7899
6748
|
};
|
|
7900
6749
|
|
|
7901
6750
|
var types = [
|
|
@@ -20988,6 +19837,40 @@ SelectStyleButton.defaultProps = {
|
|
|
20988
19837
|
defaultStyles: true,
|
|
20989
19838
|
};
|
|
20990
19839
|
|
|
19840
|
+
var actions = [
|
|
19841
|
+
{ icon: React__default["default"].createElement(PictureAsPdfIcon__default["default"], null), name: 'Create PDF' },
|
|
19842
|
+
{ icon: React__default["default"].createElement(DesignServicesIcon__default["default"], null), name: 'Sketch' },
|
|
19843
|
+
{ icon: React__default["default"].createElement(LayersIcon__default["default"], null), name: 'Layers' },
|
|
19844
|
+
{ icon: React__default["default"].createElement(WallpaperIcon__default["default"], null), name: 'Background' },
|
|
19845
|
+
];
|
|
19846
|
+
/*
|
|
19847
|
+
* SpeedDial Button, which opens up options for Background, Layers, Sketch and Create PDF
|
|
19848
|
+
*/
|
|
19849
|
+
var SpeedDial = function () {
|
|
19850
|
+
var _a = React.useState(false), open = _a[0], setOpen = _a[1];
|
|
19851
|
+
var handleOpen = function (_event, reason) {
|
|
19852
|
+
if (reason === 'toggle') {
|
|
19853
|
+
setOpen(true);
|
|
19854
|
+
}
|
|
19855
|
+
};
|
|
19856
|
+
var handleClose = function () { return setOpen(false); };
|
|
19857
|
+
var theme = getTheme('light');
|
|
19858
|
+
return (React__default["default"].createElement(Box__default["default"], { sx: {
|
|
19859
|
+
height: 330,
|
|
19860
|
+
transform: 'translateZ(0px)',
|
|
19861
|
+
flexGrow: 1,
|
|
19862
|
+
position: 'absolute',
|
|
19863
|
+
bottom: 0,
|
|
19864
|
+
right: 0,
|
|
19865
|
+
width: '100px',
|
|
19866
|
+
zIndex: '1000',
|
|
19867
|
+
} },
|
|
19868
|
+
React__default["default"].createElement(MuiSpeedDial__default["default"], { ariaLabel: "SpeedDial tooltip example", sx: { position: 'absolute', bottom: 16, right: 16 }, icon: open ? React__default["default"].createElement(CloseIcon__default["default"], null) : React__default["default"].createElement(MoreVertIcon__default["default"], null), onClick: open ? handleClose : handleOpen, onOpen: handleOpen, open: open }, actions.map(function (action) { return (React__default["default"].createElement(SpeedDialAction__default["default"], { key: action.name, icon: action.icon, tooltipTitle: action.name, tooltipOpen: true, onClick: handleClose, FabProps: { sx: { color: theme.palette.secondary.main } } })); }))));
|
|
19869
|
+
};
|
|
19870
|
+
SpeedDial.defaultProps = {
|
|
19871
|
+
mapId: undefined,
|
|
19872
|
+
};
|
|
19873
|
+
|
|
20991
19874
|
exports.AddLayerButton = AddLayerButton;
|
|
20992
19875
|
exports.AddLayerPopup = AddLayerPopup;
|
|
20993
19876
|
exports.ColorPicker = PaintPropsColorPicker;
|
|
@@ -21035,6 +19918,7 @@ exports.MlScaleReference = MlScaleReference;
|
|
|
21035
19918
|
exports.MlShareMapState = MlShareMapState;
|
|
21036
19919
|
exports.MlSpatialElevationProfile = MlSpatialElevationProfile;
|
|
21037
19920
|
exports.MlTemporalController = MlTemporalController;
|
|
19921
|
+
exports.MlTerrainLayer = MlTerrainLayer;
|
|
21038
19922
|
exports.MlTransitionGeoJsonLayer = MlTransitionGeoJsonLayer;
|
|
21039
19923
|
exports.MlVectorTileLayer = MlVectorTileLayer;
|
|
21040
19924
|
exports.MlWmsFeatureInfoPopup = MlWmsFeatureInfoPopup;
|
|
@@ -21050,12 +19934,14 @@ exports.Sidebar = Sidebar;
|
|
|
21050
19934
|
exports.SimpleDataContext = SimpleDataContext;
|
|
21051
19935
|
exports.SimpleDataProvider = SimpleDataProvider;
|
|
21052
19936
|
exports.SolarizedStyle = SolarizedStyle;
|
|
19937
|
+
exports.SpeedDial = SpeedDial;
|
|
21053
19938
|
exports.TopToolbar = TopToolbar;
|
|
21054
19939
|
exports.UploadButton = UploadButton;
|
|
21055
19940
|
exports.WmsLayerForm = WmsLayerForm;
|
|
21056
19941
|
exports.getTheme = getTheme;
|
|
21057
19942
|
exports.useCameraFollowPath = useCameraFollowPath;
|
|
21058
19943
|
exports.useExportMap = useExportMap;
|
|
19944
|
+
exports.useFeatureEditor = useFeatureEditor;
|
|
21059
19945
|
exports.useFilterData = useFilterData;
|
|
21060
19946
|
exports.useGpx = useGpx;
|
|
21061
19947
|
exports.useLayer = useLayer;
|