@map-colonies/react-components 3.12.3 → 3.13.1
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 +22 -0
- package/dist/cesium-map/data-sources/drawings.data-source.js +6 -0
- package/dist/cesium-map/map-legend/MapLegend.css +3 -2
- package/dist/cesium-map/map.d.ts +4 -0
- package/dist/cesium-map/map.js +9 -3
- package/dist/cesium-map/proxied.types.d.ts +1 -1
- package/dist/cesium-map/proxied.types.js +2 -1
- package/dist/cesium-map/tools/coordinates-tracker.tool.js +15 -11
- package/dist/cesium-map/tools/geojson/point.geojson.d.ts +4 -0
- package/dist/cesium-map/tools/geojson/point.geojson.js +26 -4
- package/jest_html_reporters.html +78 -0
- package/package.json +2 -2
- package/src/lib/cesium-map/data-sources/drawings.data-source.tsx +9 -0
- package/src/lib/cesium-map/layers/geojson.layer.stories.tsx +64 -3
- package/src/lib/cesium-map/map-legend/MapLegend.css +3 -2
- package/src/lib/cesium-map/map.tsx +14 -1
- package/src/lib/cesium-map/proxied.types.ts +5 -1
- package/src/lib/cesium-map/tools/coordinates-tracker.tool.tsx +13 -12
- package/src/lib/cesium-map/tools/geojson/point.geojson.ts +43 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.13.1](https://github.com/MapColonies/shared-components/compare/@map-colonies/react-components@3.13.0...@map-colonies/react-components@3.13.1) (2023-01-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* imports from cesium ([#136](https://github.com/MapColonies/shared-components/issues/136)) ([0b12f11](https://github.com/MapColonies/shared-components/commit/0b12f119275285682e13b2a83b75f34151b9553f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.13.0](https://github.com/MapColonies/shared-components/compare/@map-colonies/react-components@3.12.3...@map-colonies/react-components@3.13.0) (2023-01-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add coords value in map context ([#135](https://github.com/MapColonies/shared-components/issues/135)) ([c056f44](https://github.com/MapColonies/shared-components/commit/c056f44ac230a0c956bd7a5d75b6dde0374b2405))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [3.12.3](https://github.com/MapColonies/shared-components/compare/@map-colonies/react-components@3.12.2...@map-colonies/react-components@3.12.3) (2022-08-25)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @map-colonies/react-components
|
|
@@ -89,6 +89,8 @@ var CesiumDrawingsDataSource = function (props) {
|
|
|
89
89
|
if (drawState.drawing) {
|
|
90
90
|
switch (drawState.type) {
|
|
91
91
|
case models_1.DrawType.POLYGON:
|
|
92
|
+
// Disable terrain accounting before drawing.
|
|
93
|
+
mapViewer.scene.globe.depthTestAgainstTerrain = false;
|
|
92
94
|
// eslint-disable-next-line
|
|
93
95
|
drawHelperInstance.startDrawingPolygon({
|
|
94
96
|
callback: function (positions) {
|
|
@@ -113,6 +115,8 @@ var CesiumDrawingsDataSource = function (props) {
|
|
|
113
115
|
});
|
|
114
116
|
break;
|
|
115
117
|
case models_1.DrawType.BOX:
|
|
118
|
+
// Disable terrain accounting before drawing.
|
|
119
|
+
mapViewer.scene.globe.depthTestAgainstTerrain = false;
|
|
116
120
|
// eslint-disable-next-line
|
|
117
121
|
drawHelperInstance.startDrawingExtent({
|
|
118
122
|
callback: function (positions) {
|
|
@@ -143,6 +147,8 @@ var CesiumDrawingsDataSource = function (props) {
|
|
|
143
147
|
else {
|
|
144
148
|
// eslint-disable-next-line
|
|
145
149
|
drawHelperInstance.stopDrawing();
|
|
150
|
+
// Enable terrain accounting after drawing.
|
|
151
|
+
mapViewer.scene.globe.depthTestAgainstTerrain = true;
|
|
146
152
|
}
|
|
147
153
|
}
|
|
148
154
|
}, [drawState, drawHelper]);
|
package/dist/cesium-map/map.d.ts
CHANGED
package/dist/cesium-map/map.js
CHANGED
|
@@ -64,6 +64,7 @@ var map_legend_1 = require("./map-legend");
|
|
|
64
64
|
var layers_manager_1 = __importDefault(require("./layers-manager"));
|
|
65
65
|
var map_types_1 = require("./map.types");
|
|
66
66
|
require("./map.css");
|
|
67
|
+
var point_geojson_1 = require("./tools/geojson/point.geojson");
|
|
67
68
|
var DEFAULT_HEIGHT = 212;
|
|
68
69
|
var DEFAULT_WIDTH = 260;
|
|
69
70
|
var DEFAULT_DYNAMIC_HEIGHT_INCREMENT = 0;
|
|
@@ -101,6 +102,7 @@ var CesiumMap = function (props) {
|
|
|
101
102
|
var _y = react_1.useState(false), showImageryMenu = _y[0], setShowImageryMenu = _y[1];
|
|
102
103
|
var _z = react_1.useState(undefined), imageryMenuPosition = _z[0], setImageryMenuPosition = _z[1];
|
|
103
104
|
var _0 = react_1.useState(false), isLegendsSidebarOpen = _0[0], setIsLegendsSidebarOpen = _0[1];
|
|
105
|
+
var _1 = react_1.useState(), rightClickCoordinates = _1[0], setRightClickCoordinates = _1[1];
|
|
104
106
|
var viewerProps = __assign({ fullscreenButton: true, timeline: false, animation: false, baseLayerPicker: false, geocoder: false, navigationHelpButton: false, homeButton: false, sceneModePicker: false }, props);
|
|
105
107
|
var getImageryMenuStyle = function (x, y, menuWidth, menuHeight, menuDynamicHeightIncrement) {
|
|
106
108
|
var container = mapViewRef.container;
|
|
@@ -117,12 +119,14 @@ var CesiumMap = function (props) {
|
|
|
117
119
|
react_1.useEffect(function () {
|
|
118
120
|
var _a;
|
|
119
121
|
if (ref.current) {
|
|
120
|
-
var
|
|
122
|
+
var viewer_1 = ref.current.cesiumElement;
|
|
121
123
|
if (props.imageryContextMenu) {
|
|
122
|
-
|
|
124
|
+
viewer_1.screenSpaceEventHandler.setInputAction(function (evt) {
|
|
123
125
|
// console.log('RIGHT click', evt.position);
|
|
126
|
+
var pos = evt.position;
|
|
124
127
|
setShowImageryMenu(false);
|
|
125
|
-
setImageryMenuPosition(
|
|
128
|
+
setImageryMenuPosition(pos);
|
|
129
|
+
setRightClickCoordinates(point_geojson_1.pointToLonLat(viewer_1, pos.x, pos.y));
|
|
126
130
|
setShowImageryMenu(true);
|
|
127
131
|
}, cesium_1.ScreenSpaceEventType.RIGHT_CLICK);
|
|
128
132
|
}
|
|
@@ -286,12 +290,14 @@ var CesiumMap = function (props) {
|
|
|
286
290
|
props.imageryContextMenu &&
|
|
287
291
|
showImageryMenu &&
|
|
288
292
|
imageryMenuPosition &&
|
|
293
|
+
rightClickCoordinates &&
|
|
289
294
|
react_1.default.cloneElement(props.imageryContextMenu, {
|
|
290
295
|
data: (_f = mapViewRef === null || mapViewRef === void 0 ? void 0 : mapViewRef.layersManager) === null || _f === void 0 ? void 0 : _f.findLayerByPOI(imageryMenuPosition.x, imageryMenuPosition.y),
|
|
291
296
|
position: {
|
|
292
297
|
x: imageryMenuPosition.x,
|
|
293
298
|
y: imageryMenuPosition.y,
|
|
294
299
|
},
|
|
300
|
+
coordinates: rightClickCoordinates,
|
|
295
301
|
style: getImageryMenuStyle(imageryMenuPosition.x, imageryMenuPosition.y, (_h = (_g = props.imageryContextMenuSize) === null || _g === void 0 ? void 0 : _g.width) !== null && _h !== void 0 ? _h : DEFAULT_WIDTH, (_k = (_j = props.imageryContextMenuSize) === null || _j === void 0 ? void 0 : _j.height) !== null && _k !== void 0 ? _k : DEFAULT_HEIGHT, (_m = (_l = props.imageryContextMenuSize) === null || _l === void 0 ? void 0 : _l.dynamicHeightIncrement) !== null && _m !== void 0 ? _m : DEFAULT_DYNAMIC_HEIGHT_INCREMENT),
|
|
296
302
|
size: (_o = props.imageryContextMenuSize) !== null && _o !== void 0 ? _o : {
|
|
297
303
|
height: DEFAULT_HEIGHT,
|
|
@@ -27,4 +27,4 @@ export declare class CesiumCesiumTerrainProvider extends CesiumTerrainProvider {
|
|
|
27
27
|
}
|
|
28
28
|
export declare const CesiumVerticalOrigin: typeof VerticalOrigin;
|
|
29
29
|
export declare const CesiumLabelStyle: typeof LabelStyle;
|
|
30
|
-
export { sampleTerrainMostDetailed as cesiumSampleTerrainMostDetailed } from 'cesium';
|
|
30
|
+
export { sampleTerrainMostDetailed as cesiumSampleTerrainMostDetailed, Math as CesiumMath, } from 'cesium';
|
|
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.cesiumSampleTerrainMostDetailed = exports.CesiumLabelStyle = exports.CesiumVerticalOrigin = exports.CesiumCesiumTerrainProvider = exports.CesiumEllipsoidTerrainProvider = exports.CesiumResource = exports.CesiumRectangle = exports.CesiumGeographicTilingScheme = exports.CesiumEllipsoid = exports.CesiumBoundingSphere = exports.CesiumCartographic = exports.CesiumCartesian3 = exports.CesiumCartesian2 = exports.CesiumConstantPositionProperty = exports.CesiumConstantProperty = exports.CesiumPolylineDashMaterialProperty = void 0;
|
|
18
|
+
exports.CesiumMath = exports.cesiumSampleTerrainMostDetailed = exports.CesiumLabelStyle = exports.CesiumVerticalOrigin = exports.CesiumCesiumTerrainProvider = exports.CesiumEllipsoidTerrainProvider = exports.CesiumResource = exports.CesiumRectangle = exports.CesiumGeographicTilingScheme = exports.CesiumEllipsoid = exports.CesiumBoundingSphere = exports.CesiumCartographic = exports.CesiumCartesian3 = exports.CesiumCartesian2 = exports.CesiumConstantPositionProperty = exports.CesiumConstantProperty = exports.CesiumPolylineDashMaterialProperty = void 0;
|
|
19
19
|
var cesium_1 = require("cesium");
|
|
20
20
|
// PROXIED CLASSES
|
|
21
21
|
var CesiumPolylineDashMaterialProperty = /** @class */ (function (_super) {
|
|
@@ -130,3 +130,4 @@ exports.CesiumLabelStyle = cesium_1.LabelStyle;
|
|
|
130
130
|
// PROXIED FUNCTIONS
|
|
131
131
|
var cesium_2 = require("cesium");
|
|
132
132
|
Object.defineProperty(exports, "cesiumSampleTerrainMostDetailed", { enumerable: true, get: function () { return cesium_2.sampleTerrainMostDetailed; } });
|
|
133
|
+
Object.defineProperty(exports, "CesiumMath", { enumerable: true, get: function () { return cesium_2.Math; } });
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -30,18 +41,11 @@ var CoordinatesTrackerTool = function (props) {
|
|
|
30
41
|
var ref = react_1.useRef(null);
|
|
31
42
|
var _a = react_1.useState({ x: 0, y: 0 }), position = _a[0], setPosition = _a[1];
|
|
32
43
|
react_1.useEffect(function () {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
mapViewer.scene.canvas.addEventListener('mousemove', setFromEvent);
|
|
37
|
-
return function () {
|
|
38
|
-
try {
|
|
39
|
-
mapViewer.scene.canvas.removeEventListener('mousemove', setFromEvent);
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
console.log('CESIUM canvas "mousemove" remove listener failed', e);
|
|
44
|
+
mapViewer.screenSpaceEventHandler.setInputAction(function (evt) {
|
|
45
|
+
if (evt === null || evt === void 0 ? void 0 : evt.endPosition) {
|
|
46
|
+
setPosition(__assign({}, evt.endPosition));
|
|
43
47
|
}
|
|
44
|
-
};
|
|
48
|
+
}, cesium_1.ScreenSpaceEventType.MOUSE_MOVE);
|
|
45
49
|
}, [ref, mapViewer]);
|
|
46
50
|
react_1.useEffect(function () {
|
|
47
51
|
var ellipsoid = mapViewer.scene.globe.ellipsoid;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { GeoJSON } from 'geojson';
|
|
2
2
|
import { CesiumViewer } from '../../map';
|
|
3
3
|
export declare const pointToGeoJSON: (mapViewer: CesiumViewer, x: number, y: number) => GeoJSON;
|
|
4
|
+
export declare const pointToLonLat: (mapViewer: CesiumViewer, x: number, y: number) => {
|
|
5
|
+
longitude: number;
|
|
6
|
+
latitude: number;
|
|
7
|
+
} | undefined;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pointToGeoJSON = void 0;
|
|
3
|
+
exports.pointToLonLat = exports.pointToGeoJSON = void 0;
|
|
4
4
|
var cesium_1 = require("cesium");
|
|
5
|
+
var pointToCartographic = function (mapViewer, x, y) {
|
|
6
|
+
var cartesian;
|
|
7
|
+
if (mapViewer.scene.mode !== cesium_1.SceneMode.SCENE2D) {
|
|
8
|
+
cartesian = mapViewer.scene.pickPosition(new cesium_1.Cartesian2(x, y));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
var ellipsoid = mapViewer.scene.globe.ellipsoid;
|
|
12
|
+
cartesian = mapViewer.camera.pickEllipsoid(new cesium_1.Cartesian2(x, y), ellipsoid);
|
|
13
|
+
}
|
|
14
|
+
return cesium_1.Cartographic.fromCartesian(cartesian);
|
|
15
|
+
};
|
|
5
16
|
var pointToGeoJSON = function (mapViewer, x, y) {
|
|
6
|
-
var
|
|
7
|
-
var cartesian = mapViewer.camera.pickEllipsoid(new cesium_1.Cartesian3(x, y), ellipsoid);
|
|
8
|
-
var cartographic = ellipsoid.cartesianToCartographic(cartesian);
|
|
17
|
+
var cartographic = pointToCartographic(mapViewer, x, y);
|
|
9
18
|
return {
|
|
10
19
|
type: 'Feature',
|
|
11
20
|
properties: {},
|
|
@@ -19,3 +28,16 @@ var pointToGeoJSON = function (mapViewer, x, y) {
|
|
|
19
28
|
};
|
|
20
29
|
};
|
|
21
30
|
exports.pointToGeoJSON = pointToGeoJSON;
|
|
31
|
+
var pointToLonLat = function (mapViewer, x, y) {
|
|
32
|
+
try {
|
|
33
|
+
var cartographic = pointToCartographic(mapViewer, x, y);
|
|
34
|
+
return {
|
|
35
|
+
longitude: cesium_1.Math.toDegrees(cartographic.longitude),
|
|
36
|
+
latitude: cesium_1.Math.toDegrees(cartographic.latitude),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.pointToLonLat = pointToLonLat;
|