@carto/ps-react-maps 4.2.5 → 4.3.0
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/dist/index.js +1574 -1520
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/providers/map/types.d.ts +6 -1
- package/dist/types/utils/geometry/get-centroid.d.ts +20 -0
- package/dist/types/utils/geometry/get-centroid.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export { formatterTypes } from './utils/object-to-html/const';
|
|
|
57
57
|
export { objectToHtml } from './utils/object-to-html/object-to-html';
|
|
58
58
|
export { mappingLegendMeridian } from './utils/mapping-meridian';
|
|
59
59
|
export { sortLayers } from './utils/sort-layers';
|
|
60
|
+
export { getCentroid } from './utils/geometry/get-centroid';
|
|
60
61
|
export { ZoomControls } from './zoom-controls';
|
|
61
62
|
export { useStats } from './stats/use-stats';
|
|
62
63
|
export type { NumberStatsResponse, StringStatsResponse } from './stats/types';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MapViewState, WebMercatorViewport } from '@deck.gl/core';
|
|
2
2
|
import { DeckGLComponentProps, InstanceRef, MapComponentProps, OverlayRef } from '../../types';
|
|
3
3
|
import { SpatialFilter } from '@carto/api-client';
|
|
4
|
+
import { Position } from 'geojson';
|
|
4
5
|
interface ValueProps {
|
|
5
6
|
id: MapComponentProps['id'];
|
|
6
7
|
/**
|
|
@@ -75,7 +76,11 @@ export interface SpatialFilterSlice {
|
|
|
75
76
|
setSpatialFilter: (mapId: ValueProps['id'], id: string, value: SpatialFilter) => void;
|
|
76
77
|
removeSpatialFilter: (mapId: ValueProps['id'], id: string) => void;
|
|
77
78
|
}
|
|
78
|
-
export
|
|
79
|
+
export interface LayerActionsSlice {
|
|
80
|
+
setLayerHover: (mapId: ValueProps['id'], layerId: string, position: Position) => void;
|
|
81
|
+
clearLayersHover: (mapId: ValueProps['id']) => void;
|
|
82
|
+
}
|
|
83
|
+
export type MapStore = MapSlice & ViewStateSlice & CommonSlice & AreLayerLoadedSlice & SpatialFilterSlice & LayerActionsSlice;
|
|
79
84
|
export interface ViewportRect {
|
|
80
85
|
x: number;
|
|
81
86
|
y: number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Geometry, Position } from 'geojson';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the centroid of a geometry.
|
|
4
|
+
*
|
|
5
|
+
* @param geometry - The geometry to get the centroid of
|
|
6
|
+
* @returns The centroid coordinates [longitude, latitude] or undefined if geometry is invalid
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const geometry = {
|
|
11
|
+
* type: 'Polygon',
|
|
12
|
+
* coordinates: [
|
|
13
|
+
* [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]
|
|
14
|
+
* ]
|
|
15
|
+
* }
|
|
16
|
+
* const center = getCentroid(geometry)
|
|
17
|
+
* console.log(center) // [0.5, 0.5]
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function getCentroid(geometry: Geometry): Position | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|