terra-draw 0.0.1-alpha.48 → 0.0.1-alpha.49
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/.devcontainer/Dockerfile +8 -0
- package/.devcontainer/devcontainer.json +21 -0
- package/.devcontainer/post-create.sh +16 -0
- package/README.md +3 -3
- package/dist/adapters/common/base.adapter.d.ts +3 -2
- package/dist/adapters/google-maps.adapter.d.ts +9 -5
- package/dist/adapters/leaflet.adapter.d.ts +2 -2
- package/dist/adapters/mapbox-gl.adapter.d.ts +2 -2
- package/dist/adapters/maplibre-gl.adapter.d.ts +2 -2
- package/dist/adapters/openlayers.adapter.d.ts +3 -2
- package/dist/common.d.ts +1 -1
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/jest.nocheck.config.ts +9 -0
- package/package.json +14 -12
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "terra-draw",
|
|
3
|
+
"dockerFile": "Dockerfile",
|
|
4
|
+
"build": {
|
|
5
|
+
"args": { "NODE_MAJOR_VERSION": "18" }
|
|
6
|
+
},
|
|
7
|
+
"postCreateCommand": [".devcontainer/post-create.sh"],
|
|
8
|
+
"portsAttributes": {
|
|
9
|
+
"3000": { "label": "Docs" },
|
|
10
|
+
"9000": { "label": "Development" }
|
|
11
|
+
},
|
|
12
|
+
"customizations": {
|
|
13
|
+
"vscode": {
|
|
14
|
+
"extensions": [
|
|
15
|
+
"dbaeumer.vscode-eslint",
|
|
16
|
+
"esbenp.prettier-vscode",
|
|
17
|
+
"mikestead.dotenv"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -eo pipefail
|
|
4
|
+
|
|
5
|
+
# when in a VS Code or GitHub Codespaces devcontainer
|
|
6
|
+
if [ -n "${REMOTE_CONTAINERS}" ] || [ -n "${CODESPACES}" ]; then
|
|
7
|
+
this_dir=$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)
|
|
8
|
+
workspace_root=$(realpath ${this_dir}/..)
|
|
9
|
+
|
|
10
|
+
# perform additional one-time setup just after
|
|
11
|
+
# the devcontainer is created
|
|
12
|
+
npm ci --prefix "${workspace_root}" # install lib node dependencies
|
|
13
|
+
npm ci --prefix "${workspace_root}/development" # install dev node dependencies
|
|
14
|
+
touch "${workspace_root}/development/.env" # ensure dev .env file exists
|
|
15
|
+
|
|
16
|
+
fi
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Frictionless map drawing across mapping libraries.
|
|
7
7
|
|
|
8
|
-
Terra Draw
|
|
8
|
+
Terra Draw centralizes map drawing logic and provides a host of out-of-the-box drawing modes that work across different JavaScript mapping libraries. It also allows you to bring your own modes!
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
|
@@ -22,7 +22,7 @@ Terra Draw uses the concept of 'adapters' to allow it to work with a host of dif
|
|
|
22
22
|
|
|
23
23
|
### Getting Started
|
|
24
24
|
|
|
25
|
-
Please see the [the getting started guide](./guides/GETTING_STARTED.md) - this provides a host of information on how get up and running with Terra Draw. You may also find some useful pointers for things you may be finding yourself wanting to do in the [common patterns guide](./guides/COMMON_PATTERNS.md).
|
|
25
|
+
Please see the [the getting started guide](./guides/GETTING_STARTED.md) - this provides a host of information on how to get up and running with Terra Draw. You may also find some useful pointers for things you may be finding yourself wanting to do in the [common patterns guide](./guides/COMMON_PATTERNS.md).
|
|
26
26
|
|
|
27
27
|
### Development
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ Please see the [the contributing documentation](./guides/CONTRIBUTING.md)
|
|
|
34
34
|
|
|
35
35
|
### Project Website
|
|
36
36
|
|
|
37
|
-
You can
|
|
37
|
+
You can check out the official Terra Draw website at [terradraw.io](https://www.terradraw.io). If you are interested in contributing to the website please see [this repository](https://www.github.com/JamesLMilner/terra-draw-website).
|
|
38
38
|
|
|
39
39
|
### License
|
|
40
40
|
|
|
@@ -19,8 +19,9 @@ export declare abstract class TerraDrawBaseAdapter {
|
|
|
19
19
|
protected _listeners: AdapterListener<BasePointerListener | BaseKeyboardListener | BaseMouseListener>[];
|
|
20
20
|
protected _dragState: "not-dragging" | "pre-dragging" | "dragging";
|
|
21
21
|
protected _currentModeCallbacks: TerraDrawCallbacks | undefined;
|
|
22
|
+
protected abstract getMapEventElement(): HTMLElement;
|
|
22
23
|
protected getButton(event: PointerEvent | MouseEvent): "neither" | "left" | "middle" | "right";
|
|
23
|
-
protected
|
|
24
|
+
protected getMapElementXYPosition(event: PointerEvent | MouseEvent): {
|
|
24
25
|
containerX: number;
|
|
25
26
|
containerY: number;
|
|
26
27
|
};
|
|
@@ -32,6 +33,7 @@ export declare abstract class TerraDrawBaseAdapter {
|
|
|
32
33
|
* for handling various drawing events in the current mode.
|
|
33
34
|
*/
|
|
34
35
|
register(callbacks: TerraDrawCallbacks): void;
|
|
36
|
+
private getAdapterListeners;
|
|
35
37
|
/**
|
|
36
38
|
* Unregisters the event listeners for the current drawing mode.
|
|
37
39
|
* This is typically called when switching between drawing modes or
|
|
@@ -45,7 +47,6 @@ export declare abstract class TerraDrawBaseAdapter {
|
|
|
45
47
|
abstract getLngLatFromEvent(...event: Parameters<GetLngLatFromEvent>): ReturnType<GetLngLatFromEvent>;
|
|
46
48
|
abstract setDraggability(enabled: boolean): void;
|
|
47
49
|
abstract setDoubleClickToZoom(enabled: boolean): void;
|
|
48
|
-
abstract getMapContainer(): HTMLElement;
|
|
49
50
|
abstract render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
50
51
|
}
|
|
51
52
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
|
-
import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction } from "../common";
|
|
2
|
+
import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction, TerraDrawCallbacks } from "../common";
|
|
3
3
|
import { TerraDrawBaseAdapter } from "./common/base.adapter";
|
|
4
4
|
export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
|
|
5
5
|
constructor(config: {
|
|
@@ -11,8 +11,10 @@ export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
|
|
|
11
11
|
private _cursorStyleSheet;
|
|
12
12
|
private _lib;
|
|
13
13
|
private _map;
|
|
14
|
-
private _layers;
|
|
15
14
|
private _overlay;
|
|
15
|
+
private _clickEventListener;
|
|
16
|
+
private _mouseMoveEventListener;
|
|
17
|
+
private get _layers();
|
|
16
18
|
/**
|
|
17
19
|
* Generates an SVG path string for a circle with the given center coordinates and radius.
|
|
18
20
|
* Based off this StackOverflow answer: https://stackoverflow.com/a/27905268/1363484
|
|
@@ -22,6 +24,8 @@ export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
|
|
|
22
24
|
* @returns The SVG path string representing the circle.
|
|
23
25
|
*/
|
|
24
26
|
private circlePath;
|
|
27
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
28
|
+
unregister(): void;
|
|
25
29
|
/**
|
|
26
30
|
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
27
31
|
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
@@ -32,10 +36,10 @@ export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
|
|
|
32
36
|
lat: number;
|
|
33
37
|
} | null;
|
|
34
38
|
/**
|
|
35
|
-
* Retrieves the HTML
|
|
39
|
+
* Retrieves the HTML element of the Google Map element that handles interaction events
|
|
36
40
|
* @returns The HTMLElement representing the map container.
|
|
37
41
|
*/
|
|
38
|
-
|
|
42
|
+
getMapEventElement(): HTMLDivElement;
|
|
39
43
|
/**
|
|
40
44
|
* Converts longitude and latitude coordinates to pixel coordinates in the map container.
|
|
41
45
|
* @param lng The longitude coordinate to project.
|
|
@@ -71,7 +75,7 @@ export declare class TerraDrawGoogleMapsAdapter extends TerraDrawBaseAdapter {
|
|
|
71
75
|
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
72
76
|
*/
|
|
73
77
|
setDraggability(enabled: boolean): void;
|
|
74
|
-
private
|
|
78
|
+
private renderedFeatureIds;
|
|
75
79
|
/**
|
|
76
80
|
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
77
81
|
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
@@ -45,10 +45,10 @@ export declare class TerraDrawLeafletAdapter extends TerraDrawBaseAdapter {
|
|
|
45
45
|
lat: number;
|
|
46
46
|
} | null;
|
|
47
47
|
/**
|
|
48
|
-
* Retrieves the HTML
|
|
48
|
+
* Retrieves the HTML element of the Leaflet element that handles interaction events
|
|
49
49
|
* @returns The HTMLElement representing the map container.
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
getMapEventElement(): HTMLElement;
|
|
52
52
|
/**
|
|
53
53
|
* Enables or disables the draggable functionality of the map.
|
|
54
54
|
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
@@ -36,10 +36,10 @@ export declare class TerraDrawMapboxGLAdapter extends TerraDrawBaseAdapter {
|
|
|
36
36
|
lat: number;
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
*Retrieves the HTML element of the Mapbox element that handles interaction events
|
|
40
40
|
* @returns The HTMLElement representing the map container.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
getMapEventElement(): HTMLCanvasElement;
|
|
43
43
|
/**
|
|
44
44
|
* Enables or disables the draggable functionality of the map.
|
|
45
45
|
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
@@ -19,10 +19,10 @@ export declare class TerraDrawMapLibreGLAdapter extends TerraDrawBaseAdapter {
|
|
|
19
19
|
lat: number;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Retrieves the HTML
|
|
22
|
+
* Retrieves the HTML element of the MapLibre element that handles interaction events
|
|
23
23
|
* @returns The HTMLElement representing the map container.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
getMapEventElement(): HTMLCanvasElement;
|
|
26
26
|
/**
|
|
27
27
|
* Enables or disables the draggable functionality of the map.
|
|
28
28
|
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
@@ -27,6 +27,7 @@ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
|
|
|
27
27
|
lib: InjectableOL;
|
|
28
28
|
coordinatePrecision?: number;
|
|
29
29
|
});
|
|
30
|
+
private stylingFunction;
|
|
30
31
|
private _lib;
|
|
31
32
|
private _map;
|
|
32
33
|
private _container;
|
|
@@ -63,10 +64,10 @@ export declare class TerraDrawOpenLayersAdapter extends TerraDrawBaseAdapter {
|
|
|
63
64
|
lat: number;
|
|
64
65
|
} | null;
|
|
65
66
|
/**
|
|
66
|
-
* Retrieves the HTML
|
|
67
|
+
* Retrieves the HTML element of the OpenLayers element that handles interaction events
|
|
67
68
|
* @returns The HTMLElement representing the map container.
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
+
getMapEventElement(): HTMLCanvasElement;
|
|
70
71
|
/**
|
|
71
72
|
* Enables or disables the draggable functionality of the map.
|
|
72
73
|
* @param enabled Set to true to enable map dragging, or false to disable it.
|
package/dist/common.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export interface TerraDrawAdapter {
|
|
|
84
84
|
setCursor: SetCursor;
|
|
85
85
|
getLngLatFromEvent: GetLngLatFromEvent;
|
|
86
86
|
setDoubleClickToZoom: (enabled: boolean) => void;
|
|
87
|
-
|
|
87
|
+
getMapEventElement: () => HTMLElement;
|
|
88
88
|
register(callbacks: TerraDrawCallbacks): void;
|
|
89
89
|
unregister(): void;
|
|
90
90
|
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|