terra-draw 0.0.1-alpha.2 → 0.0.1-alpha.20
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 +186 -0
- package/README.md +27 -2
- package/dist/adapters/common/adapter-listener.d.ts +14 -0
- package/dist/adapters/google-maps.adapter.d.ts +7 -14
- package/dist/adapters/leaflet.adapter.d.ts +7 -12
- package/dist/adapters/mapbox-gl.adapter.d.ts +7 -9
- package/dist/adapters/maplibre-gl.adapter.d.ts +20 -0
- package/dist/adapters/openlayers.adapter.d.ts +55 -0
- package/dist/common.d.ts +23 -22
- package/dist/geometry/get-midpoints.d.ts +3 -2
- package/dist/geometry/midpoint-coordinate.d.ts +2 -1
- package/dist/geometry/shape/create-circle.d.ts +1 -0
- package/dist/geometry/shape/great-circle-line.d.ts +12 -0
- package/dist/modes/base.behavior.d.ts +1 -1
- package/dist/modes/base.mode.d.ts +12 -8
- package/dist/modes/circle/circle.mode.d.ts +27 -6
- package/dist/modes/freehand/freehand.mode.d.ts +34 -9
- package/dist/modes/great-circle-snapping.behavior.d.ts +13 -0
- package/dist/modes/greatcircle/great-circle.mode.d.ts +57 -0
- package/dist/modes/linestring/linestring.mode.d.ts +32 -6
- package/dist/modes/point/point.mode.d.ts +23 -3
- package/dist/modes/polygon/behaviors/closing-points.behavior.d.ts +19 -0
- package/dist/modes/polygon/polygon.mode.d.ts +34 -8
- package/dist/modes/rectangle/rectangle.mode.d.ts +48 -0
- package/dist/modes/render/render.mode.d.ts +34 -0
- package/dist/modes/select/select.mode.d.ts +36 -9
- package/dist/modes/static/static.mode.d.ts +18 -1
- package/dist/store/spatial-index/quickselect.d.ts +1 -1
- package/dist/store/spatial-index/rbush.d.ts +1 -1
- package/dist/store/store.d.ts +11 -9
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +90 -8
- 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.config.ts +22 -22
- package/logo.png +0 -0
- package/package.json +151 -86
- package/scratch/release.sh +5 -0
- package/tsconfig.json +21 -12
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
### [0.0.1-alpha.20](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.19...v0.0.1-alpha.20) (2023-03-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* reuse draw even in leaflet adapter to prevent runtime error ([d7f6f34](https://github.com/JamesLMilner/terra-draw/commit/d7f6f34667ccb39715c6f22a1941d2e0c37d002f))
|
|
11
|
+
|
|
12
|
+
### [0.0.1-alpha.19](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.18...v0.0.1-alpha.19) (2023-03-23)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* remove mousemove event listener from leaflet adapter and replace with pointermove ([b7baa4c](https://github.com/JamesLMilner/terra-draw/commit/b7baa4c828cce1a8a1e8cd94b8f44f0a30ea6762))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Chore
|
|
21
|
+
|
|
22
|
+
* update docs folder ([62b80dc](https://github.com/JamesLMilner/terra-draw/commit/62b80dce039ebfb4f0729fa41c07392dc5eedf0d))
|
|
23
|
+
|
|
24
|
+
### [0.0.1-alpha.18](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.17...v0.0.1-alpha.18) (2023-03-19)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* better parity between mouse and pointer experiences ([00c219d](https://github.com/JamesLMilner/terra-draw/commit/00c219de114383d7e3f7ad58d91fc6de9c2bb7c9))
|
|
30
|
+
* ensure that closing points for polygons are update on click ([25c0886](https://github.com/JamesLMilner/terra-draw/commit/25c0886237c56881073e44da839b07527362662c))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Chore
|
|
34
|
+
|
|
35
|
+
* fix issues with prettier conflicting with eslint ([9849bce](https://github.com/JamesLMilner/terra-draw/commit/9849bce825f2073d1b72b0dc9a29718a0cb994d9))
|
|
36
|
+
|
|
37
|
+
### [0.0.1-alpha.17](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.16...v0.0.1-alpha.17) (2023-03-12)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* fix unit test for great-circle-snapping.behavior ([c90cd86](https://github.com/JamesLMilner/terra-draw/commit/c90cd86125339d43768bf6f0936f85bc09bd6833))
|
|
43
|
+
* use project/unproject to get midpoints that are visually centered ([3581da2](https://github.com/JamesLMilner/terra-draw/commit/3581da2cd89ace7c555c747cdae8115c90ec851d))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Chore
|
|
47
|
+
|
|
48
|
+
* add better test coverage for great circle mode ([4073553](https://github.com/JamesLMilner/terra-draw/commit/4073553563cdfece1f48c3b00a86a6a19457a820))
|
|
49
|
+
* husk precommit only readd linted files ([2eb6138](https://github.com/JamesLMilner/terra-draw/commit/2eb6138a47fc5f48334bcf7b657fa4ac8783dc76))
|
|
50
|
+
* make sure all mode tests are labelled correctly ([a5dfe4b](https://github.com/JamesLMilner/terra-draw/commit/a5dfe4bd79cfb33daaf47195e05b72e0fba4087c))
|
|
51
|
+
* make sure test files are no covered in jest coverage when type checking disabled ([0b271b6](https://github.com/JamesLMilner/terra-draw/commit/0b271b6bf9f764c03bea1f3f4a9bc949ffa830e6))
|
|
52
|
+
* remove unused import from static.mode.spec.ts ([e2bf578](https://github.com/JamesLMilner/terra-draw/commit/e2bf5785f00bf92c72f6054441212a1e98d07abe))
|
|
53
|
+
|
|
54
|
+
### [0.0.1-alpha.16](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.15...v0.0.1-alpha.16) (2023-02-19)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Features
|
|
58
|
+
|
|
59
|
+
* add great circle line mode ([72136a0](https://github.com/JamesLMilner/terra-draw/commit/72136a044ed3a7c9192e92fbb383e64243ce8bd6))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Chore
|
|
63
|
+
|
|
64
|
+
* add local scratch folder to allow for experimentation ([828e1dd](https://github.com/JamesLMilner/terra-draw/commit/828e1ddfa575a8a9703c63c3bf8d1f11535e3fef))
|
|
65
|
+
* fix scratch pad folder location for local development ([107db58](https://github.com/JamesLMilner/terra-draw/commit/107db581a94852925f7b647f77b67b67f0a7598d))
|
|
66
|
+
|
|
67
|
+
### [0.0.1-alpha.15](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.14...v0.0.1-alpha.15) (2023-02-05)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Features
|
|
71
|
+
|
|
72
|
+
* allow keyEvents to be set to null to prevent keyboard interactions on modes ([6af865c](https://github.com/JamesLMilner/terra-draw/commit/6af865cffa58063e422c69a4201b2ab9f37f019a))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Chore
|
|
76
|
+
|
|
77
|
+
* better handle event listening in adapters by creating AdapterListener abstraction ([7f0cac6](https://github.com/JamesLMilner/terra-draw/commit/7f0cac6cc28c33387e049ef4cf3bd7f05c4a57a2))
|
|
78
|
+
* readd precommit git add command ([bc57234](https://github.com/JamesLMilner/terra-draw/commit/bc57234cb7ceca1ee8c9aa8592e87ce0c389e70c))
|
|
79
|
+
* update docs ([d0c9454](https://github.com/JamesLMilner/terra-draw/commit/d0c94547eb7cd9fc4379c40ef827b9f15df577a5))
|
|
80
|
+
|
|
81
|
+
### [0.0.1-alpha.14](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.13...v0.0.1-alpha.14) (2023-01-08)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### Features
|
|
85
|
+
|
|
86
|
+
* add clear to the public API ([6a8fa72](https://github.com/JamesLMilner/terra-draw/commit/6a8fa722b52047bdf7bc4cfb42d1432eaf7ff038))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### Bug Fixes
|
|
90
|
+
|
|
91
|
+
* ensure that terra draw is enabled before calling setMode ([deff0fb](https://github.com/JamesLMilner/terra-draw/commit/deff0fb34888fd8a36778254ed8448e7711abdb8))
|
|
92
|
+
* make sure circle mode respects configured coordinate precision ([cba0aa7](https://github.com/JamesLMilner/terra-draw/commit/cba0aa73d2d623f53b66e2d503077519f920dc96))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Chore
|
|
96
|
+
|
|
97
|
+
* add npm badge to README, shorten CI badge text ([e9d7b66](https://github.com/JamesLMilner/terra-draw/commit/e9d7b6611f7b342d2dc65a381f940babcea4f889))
|
|
98
|
+
* bump dependency packages ([a7a2bcf](https://github.com/JamesLMilner/terra-draw/commit/a7a2bcfdee6c9da773f4cf973c7f342f75822a12))
|
|
99
|
+
* fix the README logo ([b48d6d7](https://github.com/JamesLMilner/terra-draw/commit/b48d6d7d4da0dbc43da86bf43d08bc17c1463073))
|
|
100
|
+
|
|
101
|
+
### [0.0.1-alpha.13](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.12...v0.0.1-alpha.13) (2022-12-20)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Chore
|
|
105
|
+
|
|
106
|
+
* add initial tests feature styling tests for circle, freehand and polygon ([066967c](https://github.com/JamesLMilner/terra-draw/commit/066967cd56c879186207dad9f912a1e6435904e5))
|
|
107
|
+
* add TerraDrawMapLibreGLAdapter and TerraDrawOpenLayersAdapter to docs ([6b78c01](https://github.com/JamesLMilner/terra-draw/commit/6b78c01df8f9bad83738bf560a9b365c7fa01290))
|
|
108
|
+
* add TerraDrawOpenLayersAdapter to terra-draw exports ([c5f3ade](https://github.com/JamesLMilner/terra-draw/commit/c5f3ade9b9cf51b99aa78d3730581dac6f37f0fd))
|
|
109
|
+
* remove default controls from all maps ([6ffde55](https://github.com/JamesLMilner/terra-draw/commit/6ffde55b4c8cf95b1fb46f76db07d47d37504c96))
|
|
110
|
+
* remove outdated list of adapters in README introduction ([21a6aca](https://github.com/JamesLMilner/terra-draw/commit/21a6aca27f15f0f7d90bc434865f4d362960d8d9))
|
|
111
|
+
|
|
112
|
+
### [0.0.1-alpha.12](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.11...v0.0.1-alpha.12) (2022-12-11)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
### Features
|
|
116
|
+
|
|
117
|
+
* add openlayers adapter ([1454086](https://github.com/JamesLMilner/terra-draw/commit/1454086220e0b18eb504e23cca433c5db51075e3))
|
|
118
|
+
* add rectangle mode as a builtin mode ([ca9a12b](https://github.com/JamesLMilner/terra-draw/commit/ca9a12b449dc9ce35a268a92e8d3cdb06ba07aee))
|
|
119
|
+
* disable double click when a drawing mode is enabled ([ba02ac6](https://github.com/JamesLMilner/terra-draw/commit/ba02ac689052726f8a059b0548ad541bd842555f))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### Chore
|
|
123
|
+
|
|
124
|
+
* add keywords to package.json ([1270f26](https://github.com/JamesLMilner/terra-draw/commit/1270f26f0d650c97fc8c264d730231c5aac9fe43))
|
|
125
|
+
* add openlayers to development example ([0d24796](https://github.com/JamesLMilner/terra-draw/commit/0d24796754819bc622a071eae9af4c40d7fd1d16))
|
|
126
|
+
* do not use git add . with husky pre-commit hook ([032d002](https://github.com/JamesLMilner/terra-draw/commit/032d002a9212e767715876f63e4ca5bc90857a3a))
|
|
127
|
+
* update list of supported libraries in README ([2825d6c](https://github.com/JamesLMilner/terra-draw/commit/2825d6cb095f6709cae15887cb56a7ed26b1ef3d))
|
|
128
|
+
|
|
129
|
+
### [0.0.1-alpha.11](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.10...v0.0.1-alpha.11) (2022-11-29)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
### Features
|
|
133
|
+
|
|
134
|
+
* add MapLibre adapter ([464dce4](https://github.com/JamesLMilner/terra-draw/commit/464dce418bd6f18f3043d9072f3636d051ad900a))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
### Chore
|
|
138
|
+
|
|
139
|
+
* add automated documentation to the project ([0bbefbb](https://github.com/JamesLMilner/terra-draw/commit/0bbefbb8b69a18d73159b73ccdff5f79c7c0b843))
|
|
140
|
+
|
|
141
|
+
### 0.0.1-alpha.10 (2022-11-24)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### Features
|
|
145
|
+
|
|
146
|
+
* add closing point to linestring ot make easier to close for users ([e14b276](https://github.com/JamesLMilner/terra-draw/commit/e14b2769f3eb00faea55f30a24ebd4beabae92fe))
|
|
147
|
+
* add keybinding to allow finishing of geometries on keypress ([9b2b88e](https://github.com/JamesLMilner/terra-draw/commit/9b2b88ef4df94b8fdb5f16ded22cab6315d59cc6))
|
|
148
|
+
* adding closing points for drawing polygons ([c569ed6](https://github.com/JamesLMilner/terra-draw/commit/c569ed6c000683c2c9cba8fc8bec7ab5f5779a8c))
|
|
149
|
+
* use minimum distance approach instead of nth event for freehand ([240952d](https://github.com/JamesLMilner/terra-draw/commit/240952d2360568cba1f46340fa37360860125eed))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
### Chore
|
|
153
|
+
|
|
154
|
+
* add better unit test coverage for select mode ([46f3e3c](https://github.com/JamesLMilner/terra-draw/commit/46f3e3c7dc01d8d03261af762434c296f438d2e3))
|
|
155
|
+
* add development to .npmignore ([8fa412f](https://github.com/JamesLMilner/terra-draw/commit/8fa412fcaef0f39d584ef6a1190391478ad12bb7))
|
|
156
|
+
* add docs to .npmignore ([df907c3](https://github.com/JamesLMilner/terra-draw/commit/df907c3448385d24eb2afee3ec3f083a48c14325))
|
|
157
|
+
* add documentaiton for development and contributing ([4148d3e](https://github.com/JamesLMilner/terra-draw/commit/4148d3e22ffce5558278e148ea569d49f63ad8a7))
|
|
158
|
+
* add links and licenses where appropriate ([7e5aa62](https://github.com/JamesLMilner/terra-draw/commit/7e5aa621c64e1124b9a40dc5b8570ad3247a8ba2))
|
|
159
|
+
* add logo to README ([149a519](https://github.com/JamesLMilner/terra-draw/commit/149a5196b37e3263fa4246c78214725f861e38be))
|
|
160
|
+
* add npm install instructions to README ([2094716](https://github.com/JamesLMilner/terra-draw/commit/209471665318dc9fbd4fbd31e0ba17c7843bab72))
|
|
161
|
+
* add precommit hooks ([752c2f8](https://github.com/JamesLMilner/terra-draw/commit/752c2f850d5db7f0d3f4a0b4f6580a1b578ca167))
|
|
162
|
+
* add src to .npmignore ([0d769b8](https://github.com/JamesLMilner/terra-draw/commit/0d769b8618837c2f0672034654d7a91bc1183649))
|
|
163
|
+
* add TerraDrawRenderMode as an export ([8f7fd60](https://github.com/JamesLMilner/terra-draw/commit/8f7fd60697ed17a2bacd7d6eddc85aced46e6fad))
|
|
164
|
+
* add types property at top level of package.json ([2b53b63](https://github.com/JamesLMilner/terra-draw/commit/2b53b636f5688d3bfd45b02139e61a0474739abf))
|
|
165
|
+
* add types to exports in package.json ([94f5b5c](https://github.com/JamesLMilner/terra-draw/commit/94f5b5c4e83124b11a2c991c7948189f53d9d865))
|
|
166
|
+
* bump to 0.0.1-alpha.9 ([a4bb461](https://github.com/JamesLMilner/terra-draw/commit/a4bb46192cd80199f943a9e05e1808409a75b859))
|
|
167
|
+
* bump to 0.1-alpha.2 ([003ddb2](https://github.com/JamesLMilner/terra-draw/commit/003ddb2055ffad92121b9c71db115466575c4378))
|
|
168
|
+
* bump to 0.1-alpha.3 ([f56c5d8](https://github.com/JamesLMilner/terra-draw/commit/f56c5d85d3f6eaef0ba50de9741327f5db777ad7))
|
|
169
|
+
* bump to 0.1-alpha.4 ([198b281](https://github.com/JamesLMilner/terra-draw/commit/198b281891dcd19c5f7396c4dcad033fec93265c))
|
|
170
|
+
* bump to 0.1-alpha.5 ([daa6630](https://github.com/JamesLMilner/terra-draw/commit/daa6630070452cf633e67f64c61408cb7e215a86))
|
|
171
|
+
* bump to 0.1-alpha.6 ([86f17d6](https://github.com/JamesLMilner/terra-draw/commit/86f17d61eb1fe59e3b9ffcb0e84ef616ccab6d84))
|
|
172
|
+
* bump to 0.1-alpha.7 ([0e98f38](https://github.com/JamesLMilner/terra-draw/commit/0e98f384a8813097626cec13fa0f17ffc8d5e5b9))
|
|
173
|
+
* bump to 0.1-alpha.8 ([5065f83](https://github.com/JamesLMilner/terra-draw/commit/5065f833534f8e117cfddebb93f164bee3c6fcd8))
|
|
174
|
+
* change styling API to work on a per feature level ([ef43294](https://github.com/JamesLMilner/terra-draw/commit/ef4329449f20399425c7212e50eb730e760a9dda))
|
|
175
|
+
* clean up website section of README ([214b39f](https://github.com/JamesLMilner/terra-draw/commit/214b39f25096f4928637c93386861d73fbe99955))
|
|
176
|
+
* ensure default comes last in exports object of package.json ([1b7c849](https://github.com/JamesLMilner/terra-draw/commit/1b7c8498e14db4c83d7d5c52912532379e59d114))
|
|
177
|
+
* fix typescript typings location ([756586a](https://github.com/JamesLMilner/terra-draw/commit/756586a8dfb283b11372ecd9df6381d375e7939a))
|
|
178
|
+
* more select unit tests ([e440db8](https://github.com/JamesLMilner/terra-draw/commit/e440db8328a4be85e1c4f95646c5fb447d0060a9))
|
|
179
|
+
* polygon closing snapping, identical coord protection ([27eceaf](https://github.com/JamesLMilner/terra-draw/commit/27eceaf102ffa1a4f57b739f061106cbd2345df2))
|
|
180
|
+
* readd logo ([63ee2dc](https://github.com/JamesLMilner/terra-draw/commit/63ee2dc58d544949edff61336d93996fe61424e9))
|
|
181
|
+
* remove docs folder ([2f74921](https://github.com/JamesLMilner/terra-draw/commit/2f749215af2854c22f61293752bac6de24e30467))
|
|
182
|
+
* remove futher files from publish ([b71ea63](https://github.com/JamesLMilner/terra-draw/commit/b71ea63819fd68acbc577ed79b2a4a7e81fb9ceb))
|
|
183
|
+
* remove styling experiment from development ([808dfbb](https://github.com/JamesLMilner/terra-draw/commit/808dfbb18fa697511a3c96595106d28046398b91))
|
|
184
|
+
* remove top level files ([ed39533](https://github.com/JamesLMilner/terra-draw/commit/ed3953365dbc5d1ed06f655967fac523cd33eddb))
|
|
185
|
+
* remove unused imports ([a2ba004](https://github.com/JamesLMilner/terra-draw/commit/a2ba004a1f4b95b83d2aefecf83fab60237a477b))
|
|
186
|
+
* use webpack-dev-server for development folder ([7783e6a](https://github.com/JamesLMilner/terra-draw/commit/7783e6ad79137323e9d3aceab062f62e258590e6))
|
package/README.md
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
<img src="
|
|
1
|
+
<img src="./logo.png" alt="Terra Draw Logo" width="400"/>
|
|
2
2
|
|
|
3
3
|

|
|
4
|
+
[](https://badge.fury.io/js/terra-draw)
|
|
4
5
|
|
|
5
6
|
Frictionless map drawing across mapping libraries.
|
|
6
7
|
|
|
7
|
-
|
|
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
|
+
|
|
10
|
+
### Library Support
|
|
11
|
+
|
|
12
|
+
Terra Draw uses the concept of 'adapters' to allow it to work with a host of different mapping libraries. Currently supported are:
|
|
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
|
|
19
|
+
|
|
20
|
+
### Install
|
|
21
|
+
|
|
22
|
+
You can install the Terra Draw into your project like so:
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
npm install terra-draw
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Be aware Terra Draw is currently in alpha, the initial API is still being finalised
|
|
8
29
|
|
|
9
30
|
### Development
|
|
10
31
|
|
|
@@ -14,6 +35,10 @@ Please see the [the development documentation](./DEVELOPMENT.md)
|
|
|
14
35
|
|
|
15
36
|
Please see the [the contributing documentation](./CONTRIBUTING.md)
|
|
16
37
|
|
|
38
|
+
### Project Website
|
|
39
|
+
|
|
40
|
+
You can checkout the offical 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).
|
|
41
|
+
|
|
17
42
|
### License
|
|
18
43
|
|
|
19
44
|
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class AdapterListener {
|
|
2
|
+
name: string;
|
|
3
|
+
callback: (...args: any[]) => any;
|
|
4
|
+
registered: boolean;
|
|
5
|
+
register: any;
|
|
6
|
+
unregister: any;
|
|
7
|
+
private listeners;
|
|
8
|
+
constructor({ name, callback, unregister, register, }: {
|
|
9
|
+
name: string;
|
|
10
|
+
callback: (...args: any[]) => any;
|
|
11
|
+
unregister: (...callbacks: any[]) => void;
|
|
12
|
+
register: (callback: (...args: any[]) => any) => any[];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="google.maps" />
|
|
2
2
|
import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
|
|
3
|
+
import { GeoJSONStoreFeatures } from "../store/store";
|
|
3
4
|
export declare class TerraDrawGoogleMapsAdapter implements TerraDrawAdapter {
|
|
4
5
|
constructor(config: {
|
|
5
6
|
lib: typeof google.maps;
|
|
@@ -12,27 +13,19 @@ export declare class TerraDrawGoogleMapsAdapter implements TerraDrawAdapter {
|
|
|
12
13
|
private _coordinatePrecision;
|
|
13
14
|
private _lib;
|
|
14
15
|
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
16
|
private _layers;
|
|
25
17
|
getMapContainer: () => HTMLElement;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
lat: number;
|
|
29
|
-
};
|
|
18
|
+
setDoubleClickToZoom: TerraDrawModeRegisterConfig["setDoubleClickToZoom"];
|
|
19
|
+
unproject: TerraDrawModeRegisterConfig["unproject"];
|
|
30
20
|
project: TerraDrawModeRegisterConfig["project"];
|
|
31
21
|
setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
32
22
|
private circlePath;
|
|
23
|
+
private currentModeCallbacks;
|
|
24
|
+
private listeners;
|
|
25
|
+
private dragState;
|
|
33
26
|
register(callbacks: TerraDrawCallbacks): void;
|
|
34
27
|
unregister(): void;
|
|
35
28
|
render(changes: TerraDrawChanges, styling: {
|
|
36
|
-
[mode: string]: TerraDrawAdapterStyling;
|
|
29
|
+
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
37
30
|
}): void;
|
|
38
31
|
}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
|
|
2
2
|
import L from "leaflet";
|
|
3
|
+
import { GeoJSONStoreFeatures } from "../store/store";
|
|
3
4
|
export declare class TerraDrawLeafletAdapter implements TerraDrawAdapter {
|
|
4
5
|
constructor(config: {
|
|
5
6
|
lib: typeof L;
|
|
6
7
|
map: L.Map;
|
|
7
8
|
coordinatePrecision?: number;
|
|
8
9
|
});
|
|
10
|
+
private listeners;
|
|
9
11
|
private _heldKeys;
|
|
10
12
|
private _lib;
|
|
11
13
|
private _coordinatePrecision;
|
|
12
14
|
private _map;
|
|
13
|
-
private _onMouseMoveListener;
|
|
14
|
-
private _onClickListener;
|
|
15
|
-
private _onKeyUpListener;
|
|
16
|
-
private _onKeyDownListener;
|
|
17
|
-
private _onDragStartListener;
|
|
18
|
-
private _onDragListener;
|
|
19
|
-
private _onDragEndListener;
|
|
20
15
|
private _layer;
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
|
|
16
|
+
private _panes;
|
|
17
|
+
private dragState;
|
|
18
|
+
private currentModeCallbacks;
|
|
19
|
+
setDoubleClickToZoom: TerraDrawModeRegisterConfig["setDoubleClickToZoom"];
|
|
25
20
|
project: TerraDrawModeRegisterConfig["project"];
|
|
26
21
|
unproject: TerraDrawModeRegisterConfig["unproject"];
|
|
27
22
|
setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
@@ -30,6 +25,6 @@ export declare class TerraDrawLeafletAdapter implements TerraDrawAdapter {
|
|
|
30
25
|
register(callbacks: TerraDrawCallbacks): void;
|
|
31
26
|
unregister(): void;
|
|
32
27
|
render(changes: TerraDrawChanges, styling: {
|
|
33
|
-
[mode: string]: TerraDrawAdapterStyling;
|
|
28
|
+
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
34
29
|
}): void;
|
|
35
30
|
}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
|
|
2
2
|
import mapboxgl from "mapbox-gl";
|
|
3
|
+
import { GeoJSONStoreFeatures } from "../store/store";
|
|
3
4
|
export declare class TerraDrawMapboxGLAdapter implements TerraDrawAdapter {
|
|
4
5
|
constructor(config: {
|
|
5
6
|
map: mapboxgl.Map;
|
|
6
|
-
coordinatePrecision
|
|
7
|
+
coordinatePrecision?: number;
|
|
7
8
|
});
|
|
9
|
+
private dragState;
|
|
10
|
+
setDoubleClickToZoom: TerraDrawModeRegisterConfig["setDoubleClickToZoom"];
|
|
8
11
|
unproject: TerraDrawModeRegisterConfig["unproject"];
|
|
9
12
|
project: TerraDrawModeRegisterConfig["project"];
|
|
10
13
|
setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
11
14
|
getMapContainer: () => HTMLElement;
|
|
15
|
+
private _listeners;
|
|
16
|
+
private _currentModeCallbacks;
|
|
12
17
|
private _heldKeys;
|
|
13
18
|
private _coordinatePrecision;
|
|
14
19
|
private _map;
|
|
15
|
-
private _onMouseMoveListener;
|
|
16
|
-
private _onClickListener;
|
|
17
|
-
private _onDragStartListener;
|
|
18
|
-
private _onDragListener;
|
|
19
|
-
private _onDragEndListener;
|
|
20
|
-
private _onKeyDownListener;
|
|
21
|
-
private _onKeyUpListener;
|
|
22
20
|
private _rendered;
|
|
23
21
|
private _addGeoJSONSource;
|
|
24
22
|
private _addFillLayer;
|
|
@@ -31,6 +29,6 @@ export declare class TerraDrawMapboxGLAdapter implements TerraDrawAdapter {
|
|
|
31
29
|
register(callbacks: TerraDrawCallbacks): void;
|
|
32
30
|
unregister(): void;
|
|
33
31
|
render(changes: TerraDrawChanges, styling: {
|
|
34
|
-
[mode: string]: TerraDrawAdapterStyling;
|
|
32
|
+
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
35
33
|
}): void;
|
|
36
34
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
|
|
2
|
+
import { Map } from "maplibre-gl";
|
|
3
|
+
import { GeoJSONStoreFeatures } from "../store/store";
|
|
4
|
+
export declare class TerraDrawMapLibreGLAdapter implements TerraDrawAdapter {
|
|
5
|
+
private mapboxglAdapter;
|
|
6
|
+
constructor(config: {
|
|
7
|
+
map: Map;
|
|
8
|
+
coordinatePrecision?: number;
|
|
9
|
+
});
|
|
10
|
+
setDoubleClickToZoom: TerraDrawModeRegisterConfig["setDoubleClickToZoom"];
|
|
11
|
+
unproject: TerraDrawModeRegisterConfig["unproject"];
|
|
12
|
+
project: TerraDrawModeRegisterConfig["project"];
|
|
13
|
+
setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
14
|
+
getMapContainer: () => HTMLElement;
|
|
15
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
16
|
+
unregister(): void;
|
|
17
|
+
render(changes: TerraDrawChanges, styling: {
|
|
18
|
+
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TerraDrawCallbacks, TerraDrawAdapter, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawChanges } from "../common";
|
|
2
|
+
import { GeoJSONStoreFeatures } from "../store/store";
|
|
3
|
+
import CircleGeom from "ol/geom/Circle";
|
|
4
|
+
import Feature from "ol/Feature";
|
|
5
|
+
import GeoJSON from "ol/format/GeoJSON";
|
|
6
|
+
import Map from "ol/Map";
|
|
7
|
+
import Circle from "ol/style/Circle";
|
|
8
|
+
import Stroke from "ol/style/Stroke";
|
|
9
|
+
import Style from "ol/style/Style";
|
|
10
|
+
import VectorSource from "ol/source/Vector";
|
|
11
|
+
import VectorLayer from "ol/layer/Vector";
|
|
12
|
+
import { toLonLat } from "ol/proj";
|
|
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 implements TerraDrawAdapter {
|
|
25
|
+
constructor(config: {
|
|
26
|
+
map: Map;
|
|
27
|
+
lib: InjectableOL;
|
|
28
|
+
coordinatePrecision?: number;
|
|
29
|
+
});
|
|
30
|
+
private _dragState;
|
|
31
|
+
private _listeners;
|
|
32
|
+
private _currentModeCallbacks;
|
|
33
|
+
private _lib;
|
|
34
|
+
private _map;
|
|
35
|
+
private _heldKeys;
|
|
36
|
+
private _coordinatePrecision;
|
|
37
|
+
private HexToRGB;
|
|
38
|
+
setDoubleClickToZoom: TerraDrawModeRegisterConfig["setDoubleClickToZoom"];
|
|
39
|
+
unproject: TerraDrawModeRegisterConfig["unproject"];
|
|
40
|
+
project: TerraDrawModeRegisterConfig["project"];
|
|
41
|
+
setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
42
|
+
getMapContainer: () => HTMLElement;
|
|
43
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
44
|
+
unregister(): void;
|
|
45
|
+
private vectorSource;
|
|
46
|
+
private getStyles;
|
|
47
|
+
private geoJSONReader;
|
|
48
|
+
private addFeature;
|
|
49
|
+
private removeFeature;
|
|
50
|
+
private projection;
|
|
51
|
+
render(changes: TerraDrawChanges, styling: {
|
|
52
|
+
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
53
|
+
}): void;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
package/dist/common.d.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { StoreChangeHandler, GeoJSONStore, GeoJSONStoreFeatures } from "./store/store";
|
|
2
|
+
export type HexColor = `#${string}`;
|
|
2
3
|
export interface TerraDrawAdapterStyling {
|
|
3
|
-
pointColor:
|
|
4
|
+
pointColor: HexColor;
|
|
4
5
|
pointWidth: number;
|
|
5
|
-
pointOutlineColor:
|
|
6
|
-
|
|
6
|
+
pointOutlineColor: HexColor;
|
|
7
|
+
pointOutlineWidth: number;
|
|
8
|
+
polygonFillColor: HexColor;
|
|
7
9
|
polygonFillOpacity: number;
|
|
8
|
-
polygonOutlineColor:
|
|
10
|
+
polygonOutlineColor: HexColor;
|
|
9
11
|
polygonOutlineWidth: number;
|
|
10
12
|
lineStringWidth: number;
|
|
11
|
-
lineStringColor:
|
|
12
|
-
|
|
13
|
-
selectionPointWidth: number;
|
|
14
|
-
selectedPointOutlineColor: string;
|
|
15
|
-
midPointColor: string;
|
|
16
|
-
midPointWidth: number;
|
|
17
|
-
midPointOutlineColor: string;
|
|
18
|
-
closingPointColor: string;
|
|
19
|
-
closingPointOutlineColor: string;
|
|
20
|
-
closingPointWidth: number;
|
|
13
|
+
lineStringColor: HexColor;
|
|
14
|
+
zIndex: number;
|
|
21
15
|
}
|
|
22
16
|
export interface TerraDrawMouseEvent {
|
|
23
17
|
lng: number;
|
|
@@ -30,18 +24,19 @@ export interface TerraDrawMouseEvent {
|
|
|
30
24
|
export interface TerraDrawKeyboardEvent {
|
|
31
25
|
key: string;
|
|
32
26
|
}
|
|
33
|
-
|
|
34
|
-
export
|
|
27
|
+
type SetCursor = (cursor: "unset" | "grab" | "grabbing" | "crosshair" | "pointer") => void;
|
|
28
|
+
export type Project = (lng: number, lat: number) => {
|
|
35
29
|
x: number;
|
|
36
30
|
y: number;
|
|
37
31
|
};
|
|
38
|
-
export
|
|
32
|
+
export type Unproject = (x: number, y: number) => {
|
|
39
33
|
lat: number;
|
|
40
34
|
lng: number;
|
|
41
35
|
};
|
|
42
36
|
export interface TerraDrawModeRegisterConfig {
|
|
43
37
|
mode: string;
|
|
44
38
|
store: GeoJSONStore;
|
|
39
|
+
setDoubleClickToZoom: (enabled: boolean) => void;
|
|
45
40
|
setCursor: SetCursor;
|
|
46
41
|
onChange: StoreChangeHandler;
|
|
47
42
|
onSelect: (selectedId: string) => void;
|
|
@@ -49,10 +44,11 @@ export interface TerraDrawModeRegisterConfig {
|
|
|
49
44
|
project: Project;
|
|
50
45
|
unproject: Unproject;
|
|
51
46
|
}
|
|
52
|
-
export
|
|
47
|
+
export type TerraDrawModeState = "unregistered" | "registered" | "started" | "stopped";
|
|
53
48
|
export interface TerraDrawMode {
|
|
54
49
|
mode: string;
|
|
55
|
-
|
|
50
|
+
styleFeature: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
51
|
+
styles: any;
|
|
56
52
|
state: TerraDrawModeState;
|
|
57
53
|
start: () => void;
|
|
58
54
|
stop: () => void;
|
|
@@ -80,20 +76,25 @@ export interface TerraDrawChanges {
|
|
|
80
76
|
unchanged: GeoJSONStoreFeatures[];
|
|
81
77
|
deletedIds: string[];
|
|
82
78
|
}
|
|
79
|
+
type TerraDrawStylingFunction = {
|
|
80
|
+
[mode: string]: (feature: GeoJSONStoreFeatures) => TerraDrawAdapterStyling;
|
|
81
|
+
};
|
|
83
82
|
export interface TerraDrawAdapter {
|
|
84
83
|
project: Project;
|
|
85
84
|
unproject: Unproject;
|
|
86
85
|
setCursor: SetCursor;
|
|
86
|
+
setDoubleClickToZoom: (enabled: boolean) => void;
|
|
87
87
|
getMapContainer: () => HTMLElement;
|
|
88
88
|
register(callbacks: TerraDrawCallbacks): void;
|
|
89
89
|
unregister(): void;
|
|
90
|
-
render(changes: TerraDrawChanges, styling:
|
|
91
|
-
[mode: string]: TerraDrawAdapterStyling;
|
|
92
|
-
}): void;
|
|
90
|
+
render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
93
91
|
}
|
|
94
92
|
export declare const SELECT_PROPERTIES: {
|
|
95
93
|
readonly SELECTED: "selected";
|
|
96
94
|
readonly MID_POINT: "midPoint";
|
|
97
95
|
readonly SELECTION_POINT: "selectionPoint";
|
|
98
96
|
};
|
|
97
|
+
export declare const POLYGON_PROPERTIES: {
|
|
98
|
+
CLOSING_POINT: string;
|
|
99
|
+
};
|
|
99
100
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Point, Position } from "geojson";
|
|
2
|
+
import { Project, Unproject } from "../common";
|
|
2
3
|
import { JSONObject } from "../store/store";
|
|
3
|
-
export declare function getMidPointCoordinates(featureCoords: Position[], precision: number): Position[];
|
|
4
|
-
export declare function getMidPoints(selectedCoords: Position[], properties: (index: number) => JSONObject, precision: number): {
|
|
4
|
+
export declare function getMidPointCoordinates(featureCoords: Position[], precision: number, project: Project, unproject: Unproject): Position[];
|
|
5
|
+
export declare function getMidPoints(selectedCoords: Position[], properties: (index: number) => JSONObject, precision: number, project: Project, unproject: Unproject): {
|
|
5
6
|
geometry: Point;
|
|
6
7
|
properties: JSONObject;
|
|
7
8
|
}[];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Position } from "geojson";
|
|
2
|
-
|
|
2
|
+
import { Project, Unproject } from "../common";
|
|
3
|
+
export declare function midpointCoordinate(coordinates1: Position, coordinates2: Position, precision: number, project: Project, unproject: Unproject): number[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Feature, LineString, Position } from "geojson";
|
|
2
|
+
import { JSONObject } from "../../store/store";
|
|
3
|
+
export declare function greatCircleLine<Properties extends JSONObject>({ start, end, options, }: {
|
|
4
|
+
start: Position;
|
|
5
|
+
end: Position;
|
|
6
|
+
options?: {
|
|
7
|
+
numberOfPoints?: number;
|
|
8
|
+
offset?: number;
|
|
9
|
+
properties?: Properties;
|
|
10
|
+
coordinatePrecision?: number;
|
|
11
|
+
};
|
|
12
|
+
}): Feature<LineString, import("geojson").GeoJsonProperties> | null;
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
-
import {
|
|
3
|
-
import { GeoJSONStore } from "../store/store";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { TerraDrawModeRegisterConfig, TerraDrawModeState } from "../common";
|
|
3
|
+
import { GeoJSONStore, GeoJSONStoreFeatures } from "../store/store";
|
|
4
|
+
type CustomStyling = Record<string, string | number>;
|
|
5
|
+
export declare abstract class TerraDrawBaseDrawMode<T extends CustomStyling> {
|
|
6
|
+
protected _state: TerraDrawModeState;
|
|
7
7
|
get state(): TerraDrawModeState;
|
|
8
8
|
set state(_: TerraDrawModeState);
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
protected _styles: Partial<T>;
|
|
10
|
+
get styles(): Partial<T>;
|
|
11
|
+
set styles(styling: Partial<T>);
|
|
11
12
|
protected behaviors: TerraDrawModeBehavior[];
|
|
12
13
|
protected pointerDistance: number;
|
|
13
14
|
protected coordinatePrecision: number;
|
|
14
15
|
protected onStyleChange: any;
|
|
15
16
|
protected store: GeoJSONStore;
|
|
17
|
+
protected setDoubleClickToZoom: TerraDrawModeRegisterConfig["setDoubleClickToZoom"];
|
|
16
18
|
protected unproject: TerraDrawModeRegisterConfig["unproject"];
|
|
17
19
|
protected project: TerraDrawModeRegisterConfig["project"];
|
|
18
20
|
protected setCursor: TerraDrawModeRegisterConfig["setCursor"];
|
|
19
21
|
protected registerBehaviors(behaviorConfig: BehaviorConfig): void;
|
|
20
22
|
constructor(options?: {
|
|
21
|
-
|
|
23
|
+
styles?: Partial<T>;
|
|
22
24
|
pointerDistance?: number;
|
|
23
25
|
coordinatePrecision?: number;
|
|
24
26
|
});
|
|
@@ -27,4 +29,6 @@ export declare abstract class TerraDrawBaseDrawMode {
|
|
|
27
29
|
register(config: TerraDrawModeRegisterConfig): void;
|
|
28
30
|
onDeselect(deselectedId: string): void;
|
|
29
31
|
onSelect(selectedId: string): void;
|
|
32
|
+
styleFeature(feature: GeoJSONStoreFeatures): void;
|
|
30
33
|
}
|
|
34
|
+
export {};
|