terra-draw 0.0.1-alpha.4 → 0.0.1-alpha.41

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +432 -0
  2. package/README.md +25 -4
  3. package/dist/adapters/common/adapter-listener.d.ts +22 -0
  4. package/dist/adapters/common/base.adapter.d.ts +47 -0
  5. package/dist/adapters/google-maps.adapter.d.ts +87 -38
  6. package/dist/adapters/leaflet.adapter.d.ts +98 -35
  7. package/dist/adapters/mapbox-gl.adapter.d.ts +89 -36
  8. package/dist/adapters/maplibre-gl.adapter.d.ts +72 -0
  9. package/dist/adapters/openlayers.adapter.d.ts +117 -0
  10. package/dist/common.d.ts +93 -99
  11. package/dist/geometry/boolean/is-valid-coordinate.d.ts +4 -0
  12. package/dist/geometry/boolean/is-valid-linestring-feature.d.ts +2 -0
  13. package/dist/geometry/boolean/is-valid-point.d.ts +2 -0
  14. package/dist/geometry/boolean/is-valid-polygon-feature.d.ts +3 -0
  15. package/dist/geometry/boolean/point-in-polygon.d.ts +2 -2
  16. package/dist/geometry/boolean/self-intersects.d.ts +2 -2
  17. package/dist/geometry/centroid.d.ts +2 -2
  18. package/dist/geometry/coordinates-identical.d.ts +2 -2
  19. package/dist/geometry/get-coordinates-as-points.d.ts +6 -6
  20. package/dist/geometry/get-midpoints.d.ts +8 -7
  21. package/dist/geometry/helpers.d.ts +4 -4
  22. package/dist/geometry/limit-decimal-precision.d.ts +1 -1
  23. package/dist/geometry/measure/haversine-distance.d.ts +2 -2
  24. package/dist/geometry/measure/pixel-distance-to-line.d.ts +10 -10
  25. package/dist/geometry/measure/pixel-distance.d.ts +7 -7
  26. package/dist/geometry/measure/rhumb-bearing.d.ts +2 -2
  27. package/dist/geometry/measure/rhumb-destination.d.ts +2 -2
  28. package/dist/geometry/measure/rhumb-distance.d.ts +2 -2
  29. package/dist/geometry/midpoint-coordinate.d.ts +3 -2
  30. package/dist/geometry/shape/create-circle.d.ts +7 -7
  31. package/dist/geometry/shape/great-circle-line.d.ts +12 -0
  32. package/dist/geometry/transform/rotate.d.ts +2 -2
  33. package/dist/geometry/transform/scale.d.ts +2 -2
  34. package/dist/modes/base.behavior.d.ts +19 -19
  35. package/dist/modes/base.mode.d.ts +55 -30
  36. package/dist/modes/circle/circle.mode.d.ts +49 -27
  37. package/dist/modes/click-bounding-box.behavior.d.ts +7 -7
  38. package/dist/modes/freehand/freehand.mode.d.ts +55 -29
  39. package/dist/modes/great-circle-snapping.behavior.d.ts +13 -0
  40. package/dist/modes/greatcircle/great-circle.mode.d.ts +58 -0
  41. package/dist/modes/linestring/linestring.mode.d.ts +61 -34
  42. package/dist/modes/pixel-distance.behavior.d.ts +7 -7
  43. package/dist/modes/point/point.mode.d.ts +39 -18
  44. package/dist/modes/polygon/behaviors/closing-points.behavior.d.ts +19 -0
  45. package/dist/modes/polygon/polygon.mode.d.ts +64 -37
  46. package/dist/modes/rectangle/rectangle.mode.d.ts +50 -0
  47. package/dist/modes/render/render.mode.d.ts +39 -0
  48. package/dist/modes/select/behaviors/drag-coordinate.behavior.d.ts +19 -13
  49. package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +19 -17
  50. package/dist/modes/select/behaviors/features-at-mouse-event.behavior.d.ts +15 -15
  51. package/dist/modes/select/behaviors/midpoint.behavior.d.ts +18 -18
  52. package/dist/modes/select/behaviors/rotate-feature.behavior.d.ts +13 -13
  53. package/dist/modes/select/behaviors/scale-feature.behavior.d.ts +13 -13
  54. package/dist/modes/select/behaviors/selection-point.behavior.d.ts +18 -18
  55. package/dist/modes/select/select.mode.d.ts +100 -62
  56. package/dist/modes/snapping.behavior.d.ts +13 -13
  57. package/dist/modes/static/static.mode.d.ts +32 -13
  58. package/dist/store/spatial-index/quickselect.d.ts +2 -2
  59. package/dist/store/spatial-index/rbush.d.ts +35 -35
  60. package/dist/store/spatial-index/spatial-index.d.ts +18 -18
  61. package/dist/store/store-feature-validation.d.ts +15 -0
  62. package/dist/store/store.d.ts +48 -48
  63. package/dist/terra-draw.cjs +1 -1
  64. package/dist/terra-draw.cjs.map +1 -1
  65. package/dist/terra-draw.d.ts +159 -47
  66. package/dist/terra-draw.modern.js +1 -1
  67. package/dist/terra-draw.modern.js.map +1 -1
  68. package/dist/terra-draw.module.js +1 -1
  69. package/dist/terra-draw.module.js.map +1 -1
  70. package/dist/terra-draw.umd.js +1 -1
  71. package/dist/terra-draw.umd.js.map +1 -1
  72. package/dist/util/geoms.d.ts +3 -3
  73. package/dist/util/id.d.ts +1 -1
  74. package/dist/util/styling.d.ts +2 -2
  75. package/{CONTRIBUTING.md → guides/CONTRIBUTING.md} +7 -7
  76. package/guides/DEVELOPMENT.md +156 -0
  77. package/guides/GETTING_STARTED.md +292 -0
  78. package/jest.config.ts +22 -22
  79. package/logo.png +0 -0
  80. package/package.json +155 -87
  81. package/readme.gif +0 -0
  82. package/scripts/next-alpha-version.ts +21 -0
  83. package/tsconfig.json +20 -12
  84. package/DEVELOPMENT.md +0 -77
  85. package/dist/bundle.js +0 -6
  86. package/dist/bundle.js.LICENSE.txt +0 -4
  87. package/dist/geometry/create-circle.d.ts +0 -6
  88. package/dist/geometry/get-pixel-distance-to-line.d.ts +0 -10
  89. package/dist/geometry/get-pixel-distance.d.ts +0 -7
  90. package/dist/geometry/haversine-distance.d.ts +0 -1
  91. package/dist/geometry/point-in-polygon.d.ts +0 -1
  92. package/dist/geometry/self-intersects.d.ts +0 -2
  93. package/dist/modes/circle.mode.d.ts +0 -18
  94. package/dist/modes/freehand.mode.d.ts +0 -20
  95. package/dist/modes/line-string.mode.d.ts +0 -21
  96. package/dist/modes/point.mode.d.ts +0 -14
  97. package/dist/modes/polygon/behaviors/start-end-point.behavior.d.ts +0 -11
  98. package/dist/modes/polygon.mode.d.ts +0 -21
  99. package/dist/modes/select.mode.d.ts +0 -21
  100. package/dist/modes/static.mode.d.ts +0 -10
  101. /package/{CODE_OF_CONDUCT.md → guides/CODE_OF_CONDUCT.md} +0 -0
@@ -1,38 +1,87 @@
1
- /// <reference types="google.maps" />
2
- import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
3
- export declare class TerraDrawGoogleMapsAdapter implements TerraDrawAdapter {
4
- constructor(config: {
5
- lib: typeof google.maps;
6
- map: google.maps.Map;
7
- coordinatePrecision?: number;
8
- });
9
- private _heldKeys;
10
- private _cursor;
11
- private _cursorStyleSheet;
12
- private _coordinatePrecision;
13
- private _lib;
14
- private _map;
15
- private _onMouseMoveListener;
16
- private _onMouseMoveCallback;
17
- private _onClickListener;
18
- private _onRightClickListener;
19
- private _onClickCallback;
20
- private _onKeyUpListener;
21
- private _onDragStartListener;
22
- private _onDragListener;
23
- private _onDragEndListener;
24
- private _layers;
25
- getMapContainer: () => HTMLElement;
26
- unproject: (x: number, y: number) => {
27
- lng: number;
28
- lat: number;
29
- };
30
- project: TerraDrawModeRegisterConfig["project"];
31
- setCursor: TerraDrawModeRegisterConfig["setCursor"];
32
- private circlePath;
33
- register(callbacks: TerraDrawCallbacks): void;
34
- unregister(): void;
35
- render(changes: TerraDrawChanges, styling: {
36
- [mode: string]: TerraDrawAdapterStyling;
37
- }): void;
38
- }
1
+ /// <reference types="google.maps" />
2
+ import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction } from "../common";
3
+ import { TerraDrawBaseAdapter } from "./common/base.adapter";
4
+ export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
5
+ constructor(config: {
6
+ lib: typeof google.maps;
7
+ map: google.maps.Map;
8
+ coordinatePrecision?: number;
9
+ });
10
+ private _cursor;
11
+ private _cursorStyleSheet;
12
+ private _lib;
13
+ private _map;
14
+ private _layers;
15
+ private _overlay;
16
+ /**
17
+ * Generates an SVG path string for a circle with the given center coordinates and radius.
18
+ * Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484
19
+ * @param cx The x-coordinate of the circle's center.
20
+ * @param cy The y-coordinate of the circle's center.
21
+ * @param r The radius of the circle.
22
+ * @returns The SVG path string representing the circle.
23
+ */
24
+ private circlePath;
25
+ /**
26
+ * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
27
+ * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
28
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
29
+ */
30
+ getLngLatFromEvent(event: PointerEvent | MouseEvent): {
31
+ lng: number;
32
+ lat: number;
33
+ } | null;
34
+ /**
35
+ * Retrieves the HTML container element of the Leaflet map.
36
+ * @returns The HTMLElement representing the map container.
37
+ */
38
+ getMapContainer(): HTMLElement;
39
+ /**
40
+ * Converts longitude and latitude coordinates to pixel coordinates in the map container.
41
+ * @param lng The longitude coordinate to project.
42
+ * @param lat The latitude coordinate to project.
43
+ * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
44
+ */
45
+ project(lng: number, lat: number): {
46
+ x: number;
47
+ y: number;
48
+ };
49
+ /**
50
+ * Converts pixel coordinates in the map container to longitude and latitude coordinates.
51
+ * @param x The x-coordinate in the map container to unproject.
52
+ * @param y The y-coordinate in the map container to unproject.
53
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
54
+ */
55
+ unproject(x: number, y: number): {
56
+ lng: number;
57
+ lat: number;
58
+ };
59
+ /**
60
+ * Sets the cursor style for the map container.
61
+ * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
62
+ */
63
+ setCursor(cursor: Parameters<SetCursor>[0]): void;
64
+ /**
65
+ * Enables or disables the double-click to zoom functionality on the map.
66
+ * @param enabled Set to true to enable double-click to zoom, or false to disable it.
67
+ */
68
+ setDoubleClickToZoom(enabled: boolean): void;
69
+ /**
70
+ * Enables or disables the draggable functionality of the map.
71
+ * @param enabled Set to true to enable map dragging, or false to disable it.
72
+ */
73
+ setDraggability(enabled: boolean): void;
74
+ private renderedFeatures;
75
+ /**
76
+ * Renders GeoJSON features on the map using the provided styling configuration.
77
+ * @param changes An object containing arrays of created, updated, and unchanged features to render.
78
+ * @param styling An object mapping draw modes to feature styling functions
79
+ */
80
+ render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
81
+ private clearLayers;
82
+ /**
83
+ * Clears the map and store of all rendered data layers
84
+ * @returns void
85
+ * */
86
+ clear(): void;
87
+ }
@@ -1,35 +1,98 @@
1
- import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
2
- import L from "leaflet";
3
- export declare class TerraDrawLeafletAdapter implements TerraDrawAdapter {
4
- constructor(config: {
5
- lib: typeof L;
6
- map: L.Map;
7
- coordinatePrecision?: number;
8
- });
9
- private _heldKeys;
10
- private _lib;
11
- private _coordinatePrecision;
12
- private _map;
13
- private _onMouseMoveListener;
14
- private _onClickListener;
15
- private _onKeyUpListener;
16
- private _onKeyDownListener;
17
- private _onDragStartListener;
18
- private _onDragListener;
19
- private _onDragEndListener;
20
- private _layer;
21
- private _midPointPaneZIndexStyleSheet;
22
- private _midPointPane;
23
- private _selectionPaneZIndexStyleSheet;
24
- private _selectedPane;
25
- project: TerraDrawModeRegisterConfig["project"];
26
- unproject: TerraDrawModeRegisterConfig["unproject"];
27
- setCursor: TerraDrawModeRegisterConfig["setCursor"];
28
- getMapContainer: () => HTMLElement;
29
- private createPaneStyleSheet;
30
- register(callbacks: TerraDrawCallbacks): void;
31
- unregister(): void;
32
- render(changes: TerraDrawChanges, styling: {
33
- [mode: string]: TerraDrawAdapterStyling;
34
- }): void;
35
- }
1
+ import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction } from "../common";
2
+ import L from "leaflet";
3
+ import { TerraDrawBaseAdapter } from "./common/base.adapter";
4
+ export declare class TerraDrawLeafletAdapter extends TerraDrawBaseAdapter {
5
+ constructor(config: {
6
+ lib: typeof L;
7
+ map: L.Map;
8
+ coordinatePrecision?: number;
9
+ minPixelDragDistance?: number;
10
+ });
11
+ private _lib;
12
+ private _map;
13
+ private _panes;
14
+ private _container;
15
+ private _layers;
16
+ /**
17
+ * Creates a pane and its associated style sheet
18
+ * @param pane - The pane name
19
+ * @param zIndex - The zIndex value for the pane
20
+ * @returns The created style element
21
+ */
22
+ private createPaneStyleSheet;
23
+ /**
24
+ * Clears the panes created by the adapter
25
+ * @returns void
26
+ * */
27
+ private clearPanes;
28
+ /**
29
+ * Clears the leaflet layers created by the adapter
30
+ * @returns void
31
+ * */
32
+ private clearLayers;
33
+ /**
34
+ * Styles a GeoJSON layer based on the styling function
35
+ * @param styling - The styling function
36
+ * */
37
+ private styleGeoJSONLayer;
38
+ /**
39
+ * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
40
+ * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
41
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
42
+ */
43
+ getLngLatFromEvent(event: PointerEvent | MouseEvent): {
44
+ lng: number;
45
+ lat: number;
46
+ } | null;
47
+ /**
48
+ * Retrieves the HTML container element of the Leaflet map.
49
+ * @returns The HTMLElement representing the map container.
50
+ */
51
+ getMapContainer(): HTMLElement;
52
+ /**
53
+ * Enables or disables the draggable functionality of the map.
54
+ * @param enabled Set to true to enable map dragging, or false to disable it.
55
+ */
56
+ setDraggability(enabled: boolean): void;
57
+ /**
58
+ * Converts longitude and latitude coordinates to pixel coordinates in the map container.
59
+ * @param lng The longitude coordinate to project.
60
+ * @param lat The latitude coordinate to project.
61
+ * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
62
+ */
63
+ project(lng: number, lat: number): {
64
+ x: number;
65
+ y: number;
66
+ };
67
+ /**
68
+ * Converts pixel coordinates in the map container to longitude and latitude coordinates.
69
+ * @param x The x-coordinate in the map container to unproject.
70
+ * @param y The y-coordinate in the map container to unproject.
71
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
72
+ */
73
+ unproject(x: number, y: number): {
74
+ lng: number;
75
+ lat: number;
76
+ };
77
+ /**
78
+ * Sets the cursor style for the map container.
79
+ * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
80
+ */
81
+ setCursor(cursor: Parameters<SetCursor>[0]): void;
82
+ /**
83
+ * Enables or disables the double-click to zoom functionality on the map.
84
+ * @param enabled Set to true to enable double-click to zoom, or false to disable it.
85
+ */
86
+ setDoubleClickToZoom(enabled: boolean): void;
87
+ /**
88
+ * Renders GeoJSON features on the map using the provided styling configuration.
89
+ * @param changes An object containing arrays of created, updated, and unchanged features to render.
90
+ * @param styling An object mapping draw modes to feature styling functions
91
+ */
92
+ render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
93
+ /**
94
+ * Clears the map and store of all rendered data layers
95
+ * @returns void
96
+ * */
97
+ clear(): void;
98
+ }
@@ -1,36 +1,89 @@
1
- import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
2
- import mapboxgl from "mapbox-gl";
3
- export declare class TerraDrawMapboxGLAdapter implements TerraDrawAdapter {
4
- constructor(config: {
5
- map: mapboxgl.Map;
6
- coordinatePrecision: number;
7
- });
8
- unproject: TerraDrawModeRegisterConfig["unproject"];
9
- project: TerraDrawModeRegisterConfig["project"];
10
- setCursor: TerraDrawModeRegisterConfig["setCursor"];
11
- getMapContainer: () => HTMLElement;
12
- private _heldKeys;
13
- private _coordinatePrecision;
14
- private _map;
15
- private _onMouseMoveListener;
16
- private _onClickListener;
17
- private _onDragStartListener;
18
- private _onDragListener;
19
- private _onDragEndListener;
20
- private _onKeyDownListener;
21
- private _onKeyUpListener;
22
- private _rendered;
23
- private _addGeoJSONSource;
24
- private _addFillLayer;
25
- private _addFillOutlineLayer;
26
- private _addLineLayer;
27
- private _addPointLayer;
28
- private _addLayer;
29
- private _addGeoJSONLayer;
30
- private _setGeoJSONLayerData;
31
- register(callbacks: TerraDrawCallbacks): void;
32
- unregister(): void;
33
- render(changes: TerraDrawChanges, styling: {
34
- [mode: string]: TerraDrawAdapterStyling;
35
- }): void;
36
- }
1
+ import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction } from "../common";
2
+ import mapboxgl from "mapbox-gl";
3
+ import { TerraDrawBaseAdapter } from "./common/base.adapter";
4
+ export declare class TerraDrawMapboxGLAdapter extends TerraDrawBaseAdapter {
5
+ constructor(config: {
6
+ map: mapboxgl.Map;
7
+ coordinatePrecision?: number;
8
+ });
9
+ private _nextRender;
10
+ private _map;
11
+ private _container;
12
+ private _rendered;
13
+ /**
14
+ * Clears the map of rendered layers and sources
15
+ * @returns void
16
+ * */
17
+ private clearLayers;
18
+ private _addGeoJSONSource;
19
+ private _addFillLayer;
20
+ private _addFillOutlineLayer;
21
+ private _addLineLayer;
22
+ private _addPointLayer;
23
+ private _addLayer;
24
+ private _addGeoJSONLayer;
25
+ private _setGeoJSONLayerData;
26
+ private getEmptyGeometries;
27
+ private changedIds;
28
+ private updateChangedIds;
29
+ /**
30
+ * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
31
+ * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
32
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
33
+ */
34
+ getLngLatFromEvent(event: PointerEvent | MouseEvent): {
35
+ lng: number;
36
+ lat: number;
37
+ };
38
+ /**
39
+ * Retrieves the HTML container element of the Leaflet map.
40
+ * @returns The HTMLElement representing the map container.
41
+ */
42
+ getMapContainer(): HTMLElement;
43
+ /**
44
+ * Enables or disables the draggable functionality of the map.
45
+ * @param enabled Set to true to enable map dragging, or false to disable it.
46
+ */
47
+ setDraggability(enabled: boolean): void;
48
+ /**
49
+ * Converts longitude and latitude coordinates to pixel coordinates in the map container.
50
+ * @param lng The longitude coordinate to project.
51
+ * @param lat The latitude coordinate to project.
52
+ * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
53
+ */
54
+ project(lng: number, lat: number): {
55
+ x: number;
56
+ y: number;
57
+ };
58
+ /**
59
+ * Converts pixel coordinates in the map container to longitude and latitude coordinates.
60
+ * @param x The x-coordinate in the map container to unproject.
61
+ * @param y The y-coordinate in the map container to unproject.
62
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
63
+ */
64
+ unproject(x: number, y: number): {
65
+ lng: number;
66
+ lat: number;
67
+ };
68
+ /**
69
+ * Sets the cursor style for the map container.
70
+ * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
71
+ */
72
+ setCursor(cursor: Parameters<SetCursor>[0]): void;
73
+ /**
74
+ * Enables or disables the double-click to zoom functionality on the map.
75
+ * @param enabled Set to true to enable double-click to zoom, or false to disable it.
76
+ */
77
+ setDoubleClickToZoom(enabled: boolean): void;
78
+ /**
79
+ * Renders GeoJSON features on the map using the provided styling configuration.
80
+ * @param changes An object containing arrays of created, updated, and unchanged features to render.
81
+ * @param styling An object mapping draw modes to feature styling functions
82
+ */
83
+ render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
84
+ /**
85
+ * Clears the map and store of all rendered data layers
86
+ * @returns void
87
+ * */
88
+ clear(): void;
89
+ }
@@ -0,0 +1,72 @@
1
+ import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
2
+ import { Map } from "maplibre-gl";
3
+ import { TerraDrawBaseAdapter } from "./common/base.adapter";
4
+ export declare class TerraDrawMapLibreGLAdapter extends TerraDrawBaseAdapter {
5
+ private mapboxglAdapter;
6
+ constructor(config: {
7
+ map: Map;
8
+ coordinatePrecision?: number;
9
+ });
10
+ register(callbacks: TerraDrawCallbacks): void;
11
+ unregister(): void;
12
+ /**
13
+ * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
14
+ * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
15
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
16
+ */
17
+ getLngLatFromEvent(event: PointerEvent | MouseEvent): {
18
+ lng: number;
19
+ lat: number;
20
+ };
21
+ /**
22
+ * Retrieves the HTML container element of the Leaflet map.
23
+ * @returns The HTMLElement representing the map container.
24
+ */
25
+ getMapContainer(): HTMLElement;
26
+ /**
27
+ * Enables or disables the draggable functionality of the map.
28
+ * @param enabled Set to true to enable map dragging, or false to disable it.
29
+ */
30
+ setDraggability(enabled: boolean): void;
31
+ /**
32
+ * Converts longitude and latitude coordinates to pixel coordinates in the map container.
33
+ * @param lng The longitude coordinate to project.
34
+ * @param lat The latitude coordinate to project.
35
+ * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
36
+ */
37
+ project(lng: number, lat: number): {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ /**
42
+ * Converts pixel coordinates in the map container to longitude and latitude coordinates.
43
+ * @param x The x-coordinate in the map container to unproject.
44
+ * @param y The y-coordinate in the map container to unproject.
45
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
46
+ */
47
+ unproject(x: number, y: number): {
48
+ lng: number;
49
+ lat: number;
50
+ };
51
+ /**
52
+ * Sets the cursor style for the map container.
53
+ * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
54
+ */
55
+ setCursor(style: Parameters<SetCursor>[0]): void;
56
+ /**
57
+ * Enables or disables the double-click to zoom functionality on the map.
58
+ * @param enabled Set to true to enable double-click to zoom, or false to disable it.
59
+ */
60
+ setDoubleClickToZoom(enabled: boolean): void;
61
+ /**
62
+ * Renders GeoJSON features on the map using the provided styling configuration.
63
+ * @param changes An object containing arrays of created, updated, and unchanged features to render.
64
+ * @param styling An object mapping draw modes to feature styling functions
65
+ */
66
+ render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
67
+ /**
68
+ * Clears the map and store of all rendered data layers
69
+ * @returns void
70
+ * */
71
+ clear(): void;
72
+ }
@@ -0,0 +1,117 @@
1
+ import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction } from "../common";
2
+ import CircleGeom from "ol/geom/Circle";
3
+ import Feature from "ol/Feature";
4
+ import GeoJSON from "ol/format/GeoJSON";
5
+ import Map from "ol/Map";
6
+ import Circle from "ol/style/Circle";
7
+ import Stroke from "ol/style/Stroke";
8
+ import Style from "ol/style/Style";
9
+ import VectorSource from "ol/source/Vector";
10
+ import VectorLayer from "ol/layer/Vector";
11
+ import { toLonLat } from "ol/proj";
12
+ import { TerraDrawBaseAdapter } from "./common/base.adapter";
13
+ type InjectableOL = {
14
+ Circle: typeof CircleGeom;
15
+ Feature: typeof Feature;
16
+ GeoJSON: typeof GeoJSON;
17
+ Style: typeof Style;
18
+ CircleStyle: typeof Circle;
19
+ VectorLayer: typeof VectorLayer;
20
+ VectorSource: typeof VectorSource;
21
+ Stroke: typeof Stroke;
22
+ toLonLat: typeof toLonLat;
23
+ };
24
+ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
25
+ constructor(config: {
26
+ map: Map;
27
+ lib: InjectableOL;
28
+ coordinatePrecision?: number;
29
+ });
30
+ private _lib;
31
+ private _map;
32
+ private _container;
33
+ private _projection;
34
+ private _vectorSource;
35
+ private _geoJSONReader;
36
+ /**
37
+ * Converts a hexideciaml color to RGB
38
+ * @param hex a string of the hexidecimal string
39
+ * @returns an object to red green and blue (RGB) color
40
+ */
41
+ private hexToRGB;
42
+ /**
43
+ * Converts a hexideciaml color to RGB
44
+ * @param feature
45
+ * @param styling
46
+ * @returns an object to red green and blue (RGB) color
47
+ */
48
+ private getStyles;
49
+ /**
50
+ * Clears the layers created by the adapter
51
+ * @returns void
52
+ * */
53
+ private clearLayers;
54
+ private addFeature;
55
+ private removeFeature;
56
+ /**
57
+ * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
58
+ * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
59
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
60
+ */
61
+ getLngLatFromEvent(event: PointerEvent | MouseEvent): {
62
+ lng: number;
63
+ lat: number;
64
+ } | null;
65
+ /**
66
+ * Retrieves the HTML container element of the Leaflet map.
67
+ * @returns The HTMLElement representing the map container.
68
+ */
69
+ getMapContainer(): HTMLElement;
70
+ /**
71
+ * Enables or disables the draggable functionality of the map.
72
+ * @param enabled Set to true to enable map dragging, or false to disable it.
73
+ */
74
+ setDraggability(enabled: boolean): void;
75
+ /**
76
+ * Converts longitude and latitude coordinates to pixel coordinates in the map container.
77
+ * @param lng The longitude coordinate to project.
78
+ * @param lat The latitude coordinate to project.
79
+ * @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
80
+ */
81
+ project(lng: number, lat: number): {
82
+ x: number;
83
+ y: number;
84
+ };
85
+ /**
86
+ * Converts pixel coordinates in the map container to longitude and latitude coordinates.
87
+ * @param x The x-coordinate in the map container to unproject.
88
+ * @param y The y-coordinate in the map container to unproject.
89
+ * @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
90
+ */
91
+ unproject(x: number, y: number): {
92
+ lng: number;
93
+ lat: number;
94
+ };
95
+ /**
96
+ * Sets the cursor style for the map container.
97
+ * @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
98
+ */
99
+ setCursor(cursor: Parameters<SetCursor>[0]): void;
100
+ /**
101
+ * Enables or disables the double-click to zoom functionality on the map.
102
+ * @param enabled Set to true to enable double-click to zoom, or false to disable it.
103
+ */
104
+ setDoubleClickToZoom(enabled: boolean): void;
105
+ /**
106
+ * Renders GeoJSON features on the map using the provided styling configuration.
107
+ * @param changes An object containing arrays of created, updated, and unchanged features to render.
108
+ * @param styling An object mapping draw modes to feature styling functions
109
+ */
110
+ render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
111
+ /**
112
+ * Clears the map and store of all rendered data layers
113
+ * @returns void
114
+ * */
115
+ clear(): void;
116
+ }
117
+ export {};