terra-draw 0.0.1-alpha.22 → 0.0.1-alpha.24
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 +50 -0
- package/README.md +12 -16
- package/dist/adapters/common/adapter-listener.d.ts +22 -14
- package/dist/adapters/common/base.adapter.d.ts +45 -0
- package/dist/adapters/google-maps.adapter.d.ts +80 -31
- package/dist/adapters/leaflet.adapter.d.ts +78 -35
- package/dist/adapters/mapbox-gl.adapter.d.ts +75 -34
- package/dist/adapters/maplibre-gl.adapter.d.ts +65 -20
- package/dist/adapters/openlayers.adapter.d.ts +107 -55
- package/dist/common.d.ts +100 -100
- package/dist/geometry/boolean/point-in-polygon.d.ts +2 -2
- package/dist/geometry/boolean/self-intersects.d.ts +2 -2
- package/dist/geometry/centroid.d.ts +2 -2
- package/dist/geometry/coordinates-identical.d.ts +2 -2
- package/dist/geometry/get-coordinates-as-points.d.ts +6 -6
- package/dist/geometry/get-midpoints.d.ts +8 -8
- package/dist/geometry/helpers.d.ts +4 -4
- package/dist/geometry/limit-decimal-precision.d.ts +1 -1
- package/dist/geometry/measure/haversine-distance.d.ts +2 -2
- package/dist/geometry/measure/pixel-distance-to-line.d.ts +10 -10
- package/dist/geometry/measure/pixel-distance.d.ts +7 -7
- package/dist/geometry/measure/rhumb-bearing.d.ts +2 -2
- package/dist/geometry/measure/rhumb-destination.d.ts +2 -2
- package/dist/geometry/measure/rhumb-distance.d.ts +2 -2
- package/dist/geometry/midpoint-coordinate.d.ts +3 -3
- package/dist/geometry/shape/create-circle.d.ts +8 -8
- package/dist/geometry/shape/great-circle-line.d.ts +12 -12
- package/dist/geometry/transform/rotate.d.ts +2 -2
- package/dist/geometry/transform/scale.d.ts +2 -2
- package/dist/modes/base.behavior.d.ts +19 -19
- package/dist/modes/base.mode.d.ts +37 -35
- package/dist/modes/circle/circle.mode.d.ts +48 -48
- package/dist/modes/click-bounding-box.behavior.d.ts +7 -7
- package/dist/modes/freehand/freehand.mode.d.ts +54 -54
- package/dist/modes/great-circle-snapping.behavior.d.ts +13 -13
- package/dist/modes/greatcircle/great-circle.mode.d.ts +57 -57
- package/dist/modes/linestring/linestring.mode.d.ts +60 -60
- package/dist/modes/pixel-distance.behavior.d.ts +7 -7
- package/dist/modes/point/point.mode.d.ts +38 -39
- package/dist/modes/polygon/behaviors/closing-points.behavior.d.ts +19 -19
- package/dist/modes/polygon/polygon.mode.d.ts +63 -63
- package/dist/modes/rectangle/rectangle.mode.d.ts +48 -48
- package/dist/modes/render/render.mode.d.ts +34 -34
- package/dist/modes/select/behaviors/drag-coordinate.behavior.d.ts +13 -13
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +17 -17
- package/dist/modes/select/behaviors/features-at-mouse-event.behavior.d.ts +15 -15
- package/dist/modes/select/behaviors/midpoint.behavior.d.ts +18 -18
- package/dist/modes/select/behaviors/rotate-feature.behavior.d.ts +13 -13
- package/dist/modes/select/behaviors/scale-feature.behavior.d.ts +13 -13
- package/dist/modes/select/behaviors/selection-point.behavior.d.ts +18 -18
- package/dist/modes/select/select.mode.d.ts +89 -89
- package/dist/modes/snapping.behavior.d.ts +13 -13
- package/dist/modes/static/static.mode.d.ts +30 -30
- package/dist/store/spatial-index/quickselect.d.ts +2 -2
- package/dist/store/spatial-index/rbush.d.ts +35 -35
- package/dist/store/spatial-index/spatial-index.d.ts +18 -18
- package/dist/store/store.d.ts +50 -50
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +135 -129
- 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/dist/util/geoms.d.ts +3 -3
- package/dist/util/id.d.ts +1 -1
- package/dist/util/styling.d.ts +2 -2
- package/{CONTRIBUTING.md → guides/CONTRIBUTING.md} +7 -7
- package/guides/DEVELOPMENT.md +156 -0
- package/guides/GETTING_STARTED.md +211 -0
- package/package.json +6 -6
- package/readme.gif +0 -0
- package/scratch/release.sh +1 -1
- package/tsconfig.json +0 -1
- package/DEVELOPMENT.md +0 -77
- /package/{CODE_OF_CONDUCT.md → guides/CODE_OF_CONDUCT.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
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.24](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.23...v0.0.1-alpha.24) (2023-04-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* export base adapter and mode so that 3rd party developers can extend ([1662960](https://github.com/JamesLMilner/terra-draw/commit/16629602d8cb7f9b7d163c581ebe23abfd734c5d))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Chore
|
|
14
|
+
|
|
15
|
+
* add example drawing gif image to readme ([edde444](https://github.com/JamesLMilner/terra-draw/commit/edde4442bc3aa6b6854d708edb477bb068331f8e))
|
|
16
|
+
* crop gif to make it a bit cleaner ([6fc4adf](https://github.com/JamesLMilner/terra-draw/commit/6fc4adfb12236428101b8a579649b9ff8ee3e946))
|
|
17
|
+
* update docs ([75c0848](https://github.com/JamesLMilner/terra-draw/commit/75c0848e582db24e287ff81d628de0486ad1e4e7))
|
|
18
|
+
|
|
19
|
+
### [0.0.1-alpha.23](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.22...v0.0.1-alpha.23) (2023-04-04)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* cache container for all adapters to avoid refetching it ([d0e3332](https://github.com/JamesLMilner/terra-draw/commit/d0e3332c873587f5c148b4999b46fc4392d84393))
|
|
25
|
+
* google maps adapter now uses base pointer based event system ([03b131d](https://github.com/JamesLMilner/terra-draw/commit/03b131db9d5ed4fd4658bf7dd2fba16dbb45b04a))
|
|
26
|
+
* move google maps to use base adapter ([5e52f4d](https://github.com/JamesLMilner/terra-draw/commit/5e52f4d849ec3fd2e0371f121a1bf5aac2b5491e))
|
|
27
|
+
* move mapbox adapter to use the base adapter ([08ddb8e](https://github.com/JamesLMilner/terra-draw/commit/08ddb8e0ff3b37628aef9893a28d52ef1e98536b))
|
|
28
|
+
* move openlayers adapter to use base event adapter ([92213f8](https://github.com/JamesLMilner/terra-draw/commit/92213f8ee4943825e6ddb036ceea21658b5ca8a7))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* turn off tolerance on geojson layers for mapbox/maplibre adapters ([fb1e7a2](https://github.com/JamesLMilner/terra-draw/commit/fb1e7a2b26f30a26026bb1211211d18a7600a6f5))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Chore
|
|
37
|
+
|
|
38
|
+
* add better comments around the getting started example ([811d5b6](https://github.com/JamesLMilner/terra-draw/commit/811d5b6178c5cc4eb63fa5aacd4cdca6928aa87f))
|
|
39
|
+
* add getting started guide ([c926568](https://github.com/JamesLMilner/terra-draw/commit/c926568f68ee87fb48795b9d34b176ba82bf99a0))
|
|
40
|
+
* add useful comments to adapter listener ([e882911](https://github.com/JamesLMilner/terra-draw/commit/e8829119658f0d636beb8ff9ef4cf4d8f8d69706))
|
|
41
|
+
* better typescript typing for onStyleChange ([476fe3c](https://github.com/JamesLMilner/terra-draw/commit/476fe3c6f89a34a66e916dbc91a9fd6a3b2accb0))
|
|
42
|
+
* bump typedoc ([be457de](https://github.com/JamesLMilner/terra-draw/commit/be457de36e03a2d00c9831af7247079e08914dc0))
|
|
43
|
+
* bump typescript to version 5 ([0dedc54](https://github.com/JamesLMilner/terra-draw/commit/0dedc54042d2019f00117b3764ee09a5195deaf0))
|
|
44
|
+
* create start and stop as abstract methods on base.mode ([bb1d330](https://github.com/JamesLMilner/terra-draw/commit/bb1d330060dfad72af921e1c76672b6b151427d3))
|
|
45
|
+
* fix polygon.mode.spec test for offset change ([23ef0ab](https://github.com/JamesLMilner/terra-draw/commit/23ef0ab981115e1a5172e68cd13cf19c0c5c2f0b))
|
|
46
|
+
* improve guides with additional information for new users ([ec785d5](https://github.com/JamesLMilner/terra-draw/commit/ec785d5f82f2f40acc730ad11cbb388cd312d480))
|
|
47
|
+
* minor tidy up to all adapters ([e644459](https://github.com/JamesLMilner/terra-draw/commit/e644459459faee21854d51436c6730b3932e80f0))
|
|
48
|
+
* remove logs ([a7c00c2](https://github.com/JamesLMilner/terra-draw/commit/a7c00c28b69e54cfe69454e4501dd4fee8eaa1d7))
|
|
49
|
+
* remove uncessary override of point mode setStarted ([e8bebca](https://github.com/JamesLMilner/terra-draw/commit/e8bebcadc34315d3da1d0e05bb4939343cbe0c64))
|
|
50
|
+
* rename base-adapter.ts to base.adapter.ts for consistency ([753c77c](https://github.com/JamesLMilner/terra-draw/commit/753c77c8ecc2f6b88c668ba5432e681db98b5221))
|
|
51
|
+
* swap leaflet and openlayers ordering in development app ([4ebf3c8](https://github.com/JamesLMilner/terra-draw/commit/4ebf3c837dc84d710fd0fd8e341e4f63d820c05e))
|
|
52
|
+
* update docs ([29ff37a](https://github.com/JamesLMilner/terra-draw/commit/29ff37a37f1b744df299a724d6da324ed31f1045))
|
|
53
|
+
* update wording around getting started guide ([f6bc21e](https://github.com/JamesLMilner/terra-draw/commit/f6bc21eb6c811af2bd1f59289dedc124c29cfca6))
|
|
54
|
+
|
|
5
55
|
### [0.0.1-alpha.22](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.21...v0.0.1-alpha.22) (2023-03-26)
|
|
6
56
|
|
|
7
57
|
|
package/README.md
CHANGED
|
@@ -7,33 +7,29 @@ Frictionless map drawing across mapping libraries.
|
|
|
7
7
|
|
|
8
8
|
Terra Draw centralises map drawing logic and provides a host of out the box drawing modes that work across different JavaScript mapping libraries. It also also you bring your own modes!
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+

|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* [Leaflet](https://leafletjs.com/) v1
|
|
15
|
-
* [OpenLayers](https://openlayers.org/) v7
|
|
16
|
-
* [Mapbox GL JS](https://www.mapbox.com/mapbox-gljs) v2
|
|
17
|
-
* [MapLibre](https://maplibre.org/projects/maplibre-gl-js/) v2
|
|
18
|
-
* [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/overview) v3
|
|
12
|
+
### Library Support
|
|
19
13
|
|
|
20
|
-
|
|
14
|
+
Terra Draw uses the concept of 'adapters' to allow it to work with a host of different mapping libraries. Currently supported are:
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
- [Leaflet](https://leafletjs.com/) v1
|
|
17
|
+
- [OpenLayers](https://openlayers.org/) v7
|
|
18
|
+
- [Mapbox GL JS](https://www.mapbox.com/mapbox-gljs) v2
|
|
19
|
+
- [MapLibre](https://maplibre.org/projects/maplibre-gl-js/) v2
|
|
20
|
+
- [Google Maps JS API](https://developers.google.com/maps/documentation/javascript/overview) v3
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
npm install terra-draw
|
|
26
|
-
```
|
|
22
|
+
### Getting Started
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
Please see the [the getting started guide](./guides/GETTING_STARTED.md)
|
|
29
25
|
|
|
30
26
|
### Development
|
|
31
27
|
|
|
32
|
-
Please see the [the development documentation](./DEVELOPMENT.md)
|
|
28
|
+
Please see the [the development documentation](./guides/DEVELOPMENT.md)
|
|
33
29
|
|
|
34
30
|
### Contributing
|
|
35
31
|
|
|
36
|
-
Please see the [the contributing documentation](./CONTRIBUTING.md)
|
|
32
|
+
Please see the [the contributing documentation](./guides/CONTRIBUTING.md)
|
|
37
33
|
|
|
38
34
|
### Project Website
|
|
39
35
|
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
export declare class AdapterListener {
|
|
2
|
-
name: string;
|
|
3
|
-
callback: (...args: any[]) => any;
|
|
4
|
-
registered: boolean;
|
|
5
|
-
register: any;
|
|
6
|
-
unregister: any;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
1
|
+
export declare class AdapterListener<Callback extends (...args: any[]) => any> {
|
|
2
|
+
name: string;
|
|
3
|
+
callback: (...args: any[]) => any;
|
|
4
|
+
registered: boolean;
|
|
5
|
+
register: any;
|
|
6
|
+
unregister: any;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new AdapterListener instance with the provided configuration.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} config - The configuration object for the listener.
|
|
11
|
+
* @param {string} config.name - The name of the event listener.
|
|
12
|
+
* @param {Function} config.callback - The callback function to be called when the event is triggered.
|
|
13
|
+
* @param {Function} config.unregister - The function to unregister the event listeners.
|
|
14
|
+
* @param {Function} config.register - The function to register the event listeners.
|
|
15
|
+
*/
|
|
16
|
+
constructor({ name, callback, unregister, register, }: {
|
|
17
|
+
name: string;
|
|
18
|
+
callback: Callback;
|
|
19
|
+
unregister: (callbacks: Callback) => void;
|
|
20
|
+
register: (callback: Callback) => void;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Project, Unproject, TerraDrawCallbacks, TerraDrawChanges, TerraDrawMouseEvent, SetCursor, TerraDrawStylingFunction } from "../../common";
|
|
2
|
+
import { AdapterListener } from "./adapter-listener";
|
|
3
|
+
type BasePointerListener = (event: PointerEvent) => void;
|
|
4
|
+
type BaseKeyboardListener = (event: KeyboardEvent) => void;
|
|
5
|
+
type BaseMouseListener = (event: MouseEvent) => void;
|
|
6
|
+
export declare abstract class TerraDrawBaseAdapter {
|
|
7
|
+
constructor(config: {
|
|
8
|
+
coordinatePrecision?: number;
|
|
9
|
+
minPixelDragDistance?: number;
|
|
10
|
+
});
|
|
11
|
+
protected _minPixelDragDistance: number;
|
|
12
|
+
protected _lastDrawEvent: TerraDrawMouseEvent | undefined;
|
|
13
|
+
protected _coordinatePrecision: number;
|
|
14
|
+
protected _heldKeys: Set<string>;
|
|
15
|
+
protected _listeners: AdapterListener<BasePointerListener | BaseKeyboardListener | BaseMouseListener>[];
|
|
16
|
+
protected _dragState: "not-dragging" | "pre-dragging" | "dragging";
|
|
17
|
+
protected _currentModeCallbacks: TerraDrawCallbacks | undefined;
|
|
18
|
+
protected getButton(event: PointerEvent | MouseEvent): "neither" | "left" | "middle" | "right";
|
|
19
|
+
protected getDrawEventFromEvent(event: PointerEvent | MouseEvent): TerraDrawMouseEvent | null;
|
|
20
|
+
/**
|
|
21
|
+
* Registers the provided callbacks for the current drawing mode and attaches
|
|
22
|
+
* the necessary event listeners.
|
|
23
|
+
* @param {TerraDrawCallbacks} callbacks - An object containing callback functions
|
|
24
|
+
* for handling various drawing events in the current mode.
|
|
25
|
+
*/
|
|
26
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
27
|
+
/**
|
|
28
|
+
* Unregisters the event listeners for the current drawing mode.
|
|
29
|
+
* This is typically called when switching between drawing modes or
|
|
30
|
+
* stopping the drawing process.
|
|
31
|
+
*/
|
|
32
|
+
unregister(): void;
|
|
33
|
+
abstract project(...args: Parameters<Project>): ReturnType<Project>;
|
|
34
|
+
abstract unproject(...args: Parameters<Unproject>): ReturnType<Unproject>;
|
|
35
|
+
abstract setCursor(...args: Parameters<SetCursor>): ReturnType<SetCursor>;
|
|
36
|
+
abstract getLngLatFromEvent(event: PointerEvent | MouseEvent): {
|
|
37
|
+
lng: number;
|
|
38
|
+
lat: number;
|
|
39
|
+
} | null;
|
|
40
|
+
abstract setDraggability(enabled: boolean): void;
|
|
41
|
+
abstract setDoubleClickToZoom(enabled: boolean): void;
|
|
42
|
+
abstract getMapContainer(): HTMLElement;
|
|
43
|
+
abstract render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -1,31 +1,80 @@
|
|
|
1
|
-
/// <reference types="google.maps" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class TerraDrawGoogleMapsAdapter
|
|
5
|
-
constructor(config: {
|
|
6
|
-
lib: typeof google.maps;
|
|
7
|
-
map: google.maps.Map;
|
|
8
|
-
coordinatePrecision?: number;
|
|
9
|
-
});
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
/**
|
|
75
|
+
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
76
|
+
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
77
|
+
* @param styling An object mapping draw modes to feature styling functions
|
|
78
|
+
*/
|
|
79
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
80
|
+
}
|
|
@@ -1,35 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import L from "leaflet";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 _layer;
|
|
14
|
+
private _panes;
|
|
15
|
+
private _container;
|
|
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
|
+
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
25
|
+
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
26
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
|
|
27
|
+
*/
|
|
28
|
+
getLngLatFromEvent(event: PointerEvent | MouseEvent): {
|
|
29
|
+
lng: number;
|
|
30
|
+
lat: number;
|
|
31
|
+
} | null;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the HTML container element of the Leaflet map.
|
|
34
|
+
* @returns The HTMLElement representing the map container.
|
|
35
|
+
*/
|
|
36
|
+
getMapContainer(): HTMLElement;
|
|
37
|
+
/**
|
|
38
|
+
* Enables or disables the draggable functionality of the map.
|
|
39
|
+
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
40
|
+
*/
|
|
41
|
+
setDraggability(enabled: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* Converts longitude and latitude coordinates to pixel coordinates in the map container.
|
|
44
|
+
* @param lng The longitude coordinate to project.
|
|
45
|
+
* @param lat The latitude coordinate to project.
|
|
46
|
+
* @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
|
|
47
|
+
*/
|
|
48
|
+
project(lng: number, lat: number): {
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Converts pixel coordinates in the map container to longitude and latitude coordinates.
|
|
54
|
+
* @param x The x-coordinate in the map container to unproject.
|
|
55
|
+
* @param y The y-coordinate in the map container to unproject.
|
|
56
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
|
|
57
|
+
*/
|
|
58
|
+
unproject(x: number, y: number): {
|
|
59
|
+
lng: number;
|
|
60
|
+
lat: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Sets the cursor style for the map container.
|
|
64
|
+
* @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
|
|
65
|
+
*/
|
|
66
|
+
setCursor(cursor: Parameters<SetCursor>[0]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Enables or disables the double-click to zoom functionality on the map.
|
|
69
|
+
* @param enabled Set to true to enable double-click to zoom, or false to disable it.
|
|
70
|
+
*/
|
|
71
|
+
setDoubleClickToZoom(enabled: boolean): void;
|
|
72
|
+
/**
|
|
73
|
+
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
74
|
+
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
75
|
+
* @param styling An object mapping draw modes to feature styling functions
|
|
76
|
+
*/
|
|
77
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
78
|
+
}
|
|
@@ -1,34 +1,75 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import mapboxgl from "mapbox-gl";
|
|
3
|
-
import {
|
|
4
|
-
export declare class TerraDrawMapboxGLAdapter
|
|
5
|
-
constructor(config: {
|
|
6
|
-
map: mapboxgl.Map;
|
|
7
|
-
coordinatePrecision?: number;
|
|
8
|
-
});
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 _map;
|
|
10
|
+
private _container;
|
|
11
|
+
private _rendered;
|
|
12
|
+
private _addGeoJSONSource;
|
|
13
|
+
private _addFillLayer;
|
|
14
|
+
private _addFillOutlineLayer;
|
|
15
|
+
private _addLineLayer;
|
|
16
|
+
private _addPointLayer;
|
|
17
|
+
private _addLayer;
|
|
18
|
+
private _addGeoJSONLayer;
|
|
19
|
+
private _setGeoJSONLayerData;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
22
|
+
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
23
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
|
|
24
|
+
*/
|
|
25
|
+
getLngLatFromEvent(event: PointerEvent | MouseEvent): {
|
|
26
|
+
lng: number;
|
|
27
|
+
lat: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the HTML container element of the Leaflet map.
|
|
31
|
+
* @returns The HTMLElement representing the map container.
|
|
32
|
+
*/
|
|
33
|
+
getMapContainer(): HTMLElement;
|
|
34
|
+
/**
|
|
35
|
+
* Enables or disables the draggable functionality of the map.
|
|
36
|
+
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
37
|
+
*/
|
|
38
|
+
setDraggability(enabled: boolean): void;
|
|
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(style: 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
|
+
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
71
|
+
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
72
|
+
* @param styling An object mapping draw modes to feature styling functions
|
|
73
|
+
*/
|
|
74
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
75
|
+
}
|
|
@@ -1,20 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Map } from "maplibre-gl";
|
|
3
|
-
import {
|
|
4
|
-
export declare class TerraDrawMapLibreGLAdapter
|
|
5
|
-
private mapboxglAdapter;
|
|
6
|
-
constructor(config: {
|
|
7
|
-
map: Map;
|
|
8
|
-
coordinatePrecision?: number;
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { TerraDrawChanges, SetCursor, TerraDrawStylingFunction } 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
|
+
/**
|
|
11
|
+
* Returns the longitude and latitude coordinates from a given PointerEvent on the map.
|
|
12
|
+
* @param event The PointerEvent or MouseEvent containing the screen coordinates of the pointer.
|
|
13
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude, or null if the conversion is not possible.
|
|
14
|
+
*/
|
|
15
|
+
getLngLatFromEvent(event: PointerEvent | MouseEvent): {
|
|
16
|
+
lng: number;
|
|
17
|
+
lat: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves the HTML container element of the Leaflet map.
|
|
21
|
+
* @returns The HTMLElement representing the map container.
|
|
22
|
+
*/
|
|
23
|
+
getMapContainer(): HTMLElement;
|
|
24
|
+
/**
|
|
25
|
+
* Enables or disables the draggable functionality of the map.
|
|
26
|
+
* @param enabled Set to true to enable map dragging, or false to disable it.
|
|
27
|
+
*/
|
|
28
|
+
setDraggability(enabled: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Converts longitude and latitude coordinates to pixel coordinates in the map container.
|
|
31
|
+
* @param lng The longitude coordinate to project.
|
|
32
|
+
* @param lat The latitude coordinate to project.
|
|
33
|
+
* @returns An object with 'x' and 'y' properties representing the pixel coordinates within the map container.
|
|
34
|
+
*/
|
|
35
|
+
project(lng: number, lat: number): {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Converts pixel coordinates in the map container to longitude and latitude coordinates.
|
|
41
|
+
* @param x The x-coordinate in the map container to unproject.
|
|
42
|
+
* @param y The y-coordinate in the map container to unproject.
|
|
43
|
+
* @returns An object with 'lng' and 'lat' properties representing the longitude and latitude coordinates.
|
|
44
|
+
*/
|
|
45
|
+
unproject(x: number, y: number): {
|
|
46
|
+
lng: number;
|
|
47
|
+
lat: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Sets the cursor style for the map container.
|
|
51
|
+
* @param cursor The CSS cursor style to apply, or 'unset' to remove any previously applied cursor style.
|
|
52
|
+
*/
|
|
53
|
+
setCursor(style: Parameters<SetCursor>[0]): void;
|
|
54
|
+
/**
|
|
55
|
+
* Enables or disables the double-click to zoom functionality on the map.
|
|
56
|
+
* @param enabled Set to true to enable double-click to zoom, or false to disable it.
|
|
57
|
+
*/
|
|
58
|
+
setDoubleClickToZoom(enabled: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Renders GeoJSON features on the map using the provided styling configuration.
|
|
61
|
+
* @param changes An object containing arrays of created, updated, and unchanged features to render.
|
|
62
|
+
* @param styling An object mapping draw modes to feature styling functions
|
|
63
|
+
*/
|
|
64
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
65
|
+
}
|