terra-draw 0.0.1-alpha.29 → 0.0.1-alpha.30

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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.1-alpha.30](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.29...v0.0.1-alpha.30) (2023-05-21)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * allow wait as a setCursor parameter ([839bb90](https://github.com/JamesLMilner/terra-draw/commit/839bb906999420931f3b2833be781688a2ec39be))
11
+ * clear now removes all rendered layers ([fd7a208](https://github.com/JamesLMilner/terra-draw/commit/fd7a2081338b4d6ebfc3e93a6580a38b9649343a))
12
+ * correctly name styling typings for rectangle mode ([a460a3a](https://github.com/JamesLMilner/terra-draw/commit/a460a3aa7411f275d72930f5d41bd76de107c1d9))
13
+
14
+
15
+ ### Chore
16
+
17
+ * update docs ([ea4f52c](https://github.com/JamesLMilner/terra-draw/commit/ea4f52ca091772c8bed2c1b6c103db7b4734eb6e))
18
+
5
19
  ### [0.0.1-alpha.29](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.28...v0.0.1-alpha.29) (2023-05-14)
6
20
 
7
21
 
@@ -34,6 +34,7 @@ export declare abstract class TerraDrawBaseAdapter {
34
34
  * stopping the drawing process.
35
35
  */
36
36
  unregister(): void;
37
+ abstract clear(): void;
37
38
  abstract project(...args: Parameters<Project>): ReturnType<Project>;
38
39
  abstract unproject(...args: Parameters<Unproject>): ReturnType<Unproject>;
39
40
  abstract setCursor(...args: Parameters<SetCursor>): ReturnType<SetCursor>;
@@ -71,10 +71,17 @@ export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
71
71
  * @param enabled Set to true to enable map dragging, or false to disable it.
72
72
  */
73
73
  setDraggability(enabled: boolean): void;
74
+ private renderedFeatures;
74
75
  /**
75
76
  * Renders GeoJSON features on the map using the provided styling configuration.
76
77
  * @param changes An object containing arrays of created, updated, and unchanged features to render.
77
78
  * @param styling An object mapping draw modes to feature styling functions
78
79
  */
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;
80
87
  }
@@ -20,6 +20,20 @@ export declare class TerraDrawLeafletAdapter extends TerraDrawBaseAdapter {
20
20
  * @returns The created style element
21
21
  */
22
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
+ * */
23
37
  private styleGeoJSONLayer;
24
38
  /**
25
39
  * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
@@ -76,4 +90,9 @@ export declare class TerraDrawLeafletAdapter extends TerraDrawBaseAdapter {
76
90
  * @param styling An object mapping draw modes to feature styling functions
77
91
  */
78
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;
79
98
  }
@@ -9,6 +9,11 @@ export declare class TerraDrawMapboxGLAdapter extends TerraDrawBaseAdapter {
9
9
  private _map;
10
10
  private _container;
11
11
  private _rendered;
12
+ /**
13
+ * Clears the map of rendered layers and sources
14
+ * @returns void
15
+ * */
16
+ private clearLayers;
12
17
  private _addGeoJSONSource;
13
18
  private _addFillLayer;
14
19
  private _addFillOutlineLayer;
@@ -72,4 +77,9 @@ export declare class TerraDrawMapboxGLAdapter extends TerraDrawBaseAdapter {
72
77
  * @param styling An object mapping draw modes to feature styling functions
73
78
  */
74
79
  render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
80
+ /**
81
+ * Clears the map and store of all rendered data layers
82
+ * @returns void
83
+ * */
84
+ clear(): void;
75
85
  }
@@ -1,4 +1,4 @@
1
- import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction } from "../common";
1
+ import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
2
2
  import { Map } from "maplibre-gl";
3
3
  import { TerraDrawBaseAdapter } from "./common/base.adapter";
4
4
  export declare class TerraDrawMapLibreGLAdapter extends TerraDrawBaseAdapter {
@@ -7,6 +7,8 @@ export declare class TerraDrawMapLibreGLAdapter extends TerraDrawBaseAdapter {
7
7
  map: Map;
8
8
  coordinatePrecision?: number;
9
9
  });
10
+ register(callbacks: TerraDrawCallbacks): void;
11
+ unregister(): void;
10
12
  /**
11
13
  * Returns the longitude and latitude coordinates from a given PointerEvent on the map.
12
14
  * @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
@@ -62,4 +64,9 @@ export declare class TerraDrawMapLibreGLAdapter extends TerraDrawBaseAdapter {
62
64
  * @param styling An object mapping draw modes to feature styling functions
63
65
  */
64
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;
65
72
  }
@@ -46,6 +46,11 @@ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
46
46
  * @returns an object to red green and blue (RGB) color
47
47
  */
48
48
  private getStyles;
49
+ /**
50
+ * Clears the layers created by the adapter
51
+ * @returns void
52
+ * */
53
+ private clearLayers;
49
54
  private addFeature;
50
55
  private removeFeature;
51
56
  /**
@@ -103,5 +108,10 @@ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
103
108
  * @param styling An object mapping draw modes to feature styling functions
104
109
  */
105
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;
106
116
  }
107
117
  export {};
package/dist/common.d.ts CHANGED
@@ -24,7 +24,7 @@ export interface TerraDrawMouseEvent {
24
24
  export interface TerraDrawKeyboardEvent {
25
25
  key: string;
26
26
  }
27
- export type SetCursor = (cursor: "unset" | "grab" | "grabbing" | "crosshair" | "pointer") => void;
27
+ export type SetCursor = (cursor: "unset" | "grab" | "grabbing" | "crosshair" | "pointer" | "wait") => void;
28
28
  export type Project = (lng: number, lat: number) => {
29
29
  x: number;
30
30
  y: number;
@@ -58,6 +58,7 @@ export interface TerraDrawCallbacks {
58
58
  onDragStart: (event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void) => void;
59
59
  onDrag: (event: TerraDrawMouseEvent) => void;
60
60
  onDragEnd: (event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void) => void;
61
+ onClear: () => void;
61
62
  }
62
63
  export interface TerraDrawChanges {
63
64
  created: GeoJSONStoreFeatures[];
@@ -77,6 +78,7 @@ export interface TerraDrawAdapter {
77
78
  register(callbacks: TerraDrawCallbacks): void;
78
79
  unregister(): void;
79
80
  render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
81
+ clear(): void;
80
82
  }
81
83
  export declare const SELECT_PROPERTIES: {
82
84
  readonly SELECTED: "selected";
@@ -31,6 +31,7 @@ export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
31
31
  register(config: TerraDrawModeRegisterConfig): void;
32
32
  abstract start(): void;
33
33
  abstract stop(): void;
34
+ abstract cleanUp(): void;
34
35
  abstract styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
35
36
  onDeselect(deselectedId: string): void;
36
37
  onSelect(selectedId: string): void;
@@ -5,20 +5,20 @@ type TerraDrawRectangleModeKeyEvents = {
5
5
  cancel: KeyboardEvent["key"] | null;
6
6
  finish: KeyboardEvent["key"] | null;
7
7
  };
8
- type FreehandPolygonStyling = {
8
+ type RectanglePolygonStyling = {
9
9
  fillColor: HexColor;
10
10
  outlineColor: HexColor;
11
11
  outlineWidth: number;
12
12
  fillOpacity: number;
13
13
  };
14
- export declare class TerraDrawRectangleMode extends TerraDrawBaseDrawMode<FreehandPolygonStyling> {
14
+ export declare class TerraDrawRectangleMode extends TerraDrawBaseDrawMode<RectanglePolygonStyling> {
15
15
  mode: string;
16
16
  private center;
17
17
  private clickCount;
18
18
  private currentRectangleId;
19
19
  private keyEvents;
20
20
  constructor(options?: {
21
- styles?: Partial<FreehandPolygonStyling>;
21
+ styles?: Partial<RectanglePolygonStyling>;
22
22
  keyEvents?: TerraDrawRectangleModeKeyEvents | null;
23
23
  });
24
24
  private close;
@@ -29,6 +29,8 @@ export declare class TerraDrawRenderMode extends TerraDrawBaseDrawMode<RenderMod
29
29
  /** @internal */
30
30
  onMouseMove(): void;
31
31
  /** @internal */
32
+ cleanUp(): void;
33
+ /** @internal */
32
34
  styleFeature(): TerraDrawAdapterStyling;
33
35
  }
34
36
  export {};
@@ -13,6 +13,7 @@ export declare class TerraDrawStaticMode extends TerraDrawBaseDrawMode<StaticMod
13
13
  onDrag(): void;
14
14
  onDragEnd(): void;
15
15
  onMouseMove(): void;
16
+ cleanUp(): void;
16
17
  styleFeature(): {
17
18
  pointColor: `#${string}`;
18
19
  pointWidth: number;