terra-draw 0.0.1-alpha.3 → 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.
Files changed (82) hide show
  1. package/CHANGELOG.md +311 -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 +31 -0
  5. package/dist/adapters/common/base.adapter.d.ts +47 -0
  6. package/dist/adapters/google-maps.adapter.d.ts +87 -38
  7. package/dist/adapters/leaflet.adapter.d.ts +98 -35
  8. package/dist/adapters/mapbox-gl.adapter.d.ts +85 -36
  9. package/dist/adapters/maplibre-gl.adapter.d.ts +72 -0
  10. package/dist/adapters/openlayers.adapter.d.ts +117 -0
  11. package/dist/common.d.ts +90 -99
  12. package/dist/extend-types.d.ts +4 -0
  13. package/dist/geometry/boolean/point-in-polygon.d.ts +2 -2
  14. package/dist/geometry/boolean/self-intersects.d.ts +2 -2
  15. package/dist/geometry/centroid.d.ts +2 -2
  16. package/dist/geometry/coordinates-identical.d.ts +2 -2
  17. package/dist/geometry/get-coordinates-as-points.d.ts +6 -6
  18. package/dist/geometry/get-midpoints.d.ts +8 -7
  19. package/dist/geometry/helpers.d.ts +4 -4
  20. package/dist/geometry/limit-decimal-precision.d.ts +1 -1
  21. package/dist/geometry/measure/haversine-distance.d.ts +2 -2
  22. package/dist/geometry/measure/pixel-distance-to-line.d.ts +10 -10
  23. package/dist/geometry/measure/pixel-distance.d.ts +7 -7
  24. package/dist/geometry/measure/rhumb-bearing.d.ts +2 -2
  25. package/dist/geometry/measure/rhumb-destination.d.ts +2 -2
  26. package/dist/geometry/measure/rhumb-distance.d.ts +2 -2
  27. package/dist/geometry/midpoint-coordinate.d.ts +3 -2
  28. package/dist/geometry/shape/create-circle.d.ts +8 -7
  29. package/dist/geometry/shape/great-circle-line.d.ts +12 -0
  30. package/dist/geometry/transform/rotate.d.ts +2 -2
  31. package/dist/geometry/transform/scale.d.ts +2 -2
  32. package/dist/modes/base.behavior.d.ts +19 -19
  33. package/dist/modes/base.mode.d.ts +46 -30
  34. package/dist/modes/circle/circle.mode.d.ts +48 -27
  35. package/dist/modes/click-bounding-box.behavior.d.ts +7 -7
  36. package/dist/modes/freehand/freehand.mode.d.ts +54 -29
  37. package/dist/modes/great-circle-snapping.behavior.d.ts +13 -0
  38. package/dist/modes/greatcircle/great-circle.mode.d.ts +57 -0
  39. package/dist/modes/linestring/linestring.mode.d.ts +60 -34
  40. package/dist/modes/pixel-distance.behavior.d.ts +7 -7
  41. package/dist/modes/point/point.mode.d.ts +38 -18
  42. package/dist/modes/polygon/behaviors/closing-points.behavior.d.ts +19 -0
  43. package/dist/modes/polygon/polygon.mode.d.ts +63 -37
  44. package/dist/modes/rectangle/rectangle.mode.d.ts +48 -0
  45. package/dist/modes/render/render.mode.d.ts +36 -0
  46. package/dist/modes/select/behaviors/drag-coordinate.behavior.d.ts +13 -13
  47. package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +17 -17
  48. package/dist/modes/select/behaviors/features-at-mouse-event.behavior.d.ts +15 -15
  49. package/dist/modes/select/behaviors/midpoint.behavior.d.ts +18 -18
  50. package/dist/modes/select/behaviors/rotate-feature.behavior.d.ts +13 -13
  51. package/dist/modes/select/behaviors/scale-feature.behavior.d.ts +13 -13
  52. package/dist/modes/select/behaviors/selection-point.behavior.d.ts +18 -18
  53. package/dist/modes/select/select.mode.d.ts +89 -62
  54. package/dist/modes/snapping.behavior.d.ts +13 -13
  55. package/dist/modes/static/static.mode.d.ts +31 -13
  56. package/dist/store/spatial-index/quickselect.d.ts +2 -2
  57. package/dist/store/spatial-index/rbush.d.ts +35 -35
  58. package/dist/store/spatial-index/spatial-index.d.ts +18 -18
  59. package/dist/store/store.d.ts +50 -48
  60. package/dist/terra-draw.cjs +1 -1
  61. package/dist/terra-draw.cjs.map +1 -1
  62. package/dist/terra-draw.d.ts +139 -47
  63. package/dist/terra-draw.modern.js +1 -1
  64. package/dist/terra-draw.modern.js.map +1 -1
  65. package/dist/terra-draw.module.js +1 -1
  66. package/dist/terra-draw.module.js.map +1 -1
  67. package/dist/terra-draw.umd.js +1 -1
  68. package/dist/terra-draw.umd.js.map +1 -1
  69. package/dist/util/geoms.d.ts +3 -3
  70. package/dist/util/id.d.ts +1 -1
  71. package/dist/util/styling.d.ts +2 -2
  72. package/{CONTRIBUTING.md → guides/CONTRIBUTING.md} +7 -7
  73. package/guides/DEVELOPMENT.md +156 -0
  74. package/guides/GETTING_STARTED.md +211 -0
  75. package/jest.config.ts +22 -22
  76. package/logo.png +0 -0
  77. package/package.json +151 -87
  78. package/readme.gif +0 -0
  79. package/scratch/release.sh +6 -0
  80. package/tsconfig.json +20 -12
  81. package/DEVELOPMENT.md +0 -77
  82. /package/{CODE_OF_CONDUCT.md → guides/CODE_OF_CONDUCT.md} +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,311 @@
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.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
+
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)
20
+
21
+
22
+ ### Chore
23
+
24
+ * prefer top level types for easier importing ([5570bb2](https://github.com/JamesLMilner/terra-draw/commit/5570bb29ac1ca351f5b4c71625ddfd666738cbac))
25
+
26
+ ### [0.0.1-alpha.28](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.27...v0.0.1-alpha.28) (2023-05-14)
27
+
28
+
29
+ ### Chore
30
+
31
+ * export necessary types for proper 3rd party extension ([843fe2f](https://github.com/JamesLMilner/terra-draw/commit/843fe2fb5a992055908347028d50db9433399385))
32
+
33
+ ### [0.0.1-alpha.27](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.26...v0.0.1-alpha.27) (2023-05-06)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * address potential issue with spreading Sets for the held keys ([7fdf0b0](https://github.com/JamesLMilner/terra-draw/commit/7fdf0b0e9acfb108dd45e3a23f0e1d2160ca9b53))
39
+ * ensure that container coordinates are correct when they are nested ([13aef09](https://github.com/JamesLMilner/terra-draw/commit/13aef09abfbab22815790a4968b365a2e3c06176))
40
+
41
+
42
+ ### Chore
43
+
44
+ * add leaflet adapter unit tests ([8f4e6f3](https://github.com/JamesLMilner/terra-draw/commit/8f4e6f35771cd82d89823c66878a4e64732397b0))
45
+ * update docs ([1a8b15b](https://github.com/JamesLMilner/terra-draw/commit/1a8b15b82ba5b14eba9bcdfb225941611dc5d4bd))
46
+
47
+ ### [0.0.1-alpha.26](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.25...v0.0.1-alpha.26) (2023-04-10)
48
+
49
+
50
+ ### Features
51
+
52
+ * avoid mass creation and deletion of geometries in leaflet adapter render ([773208a](https://github.com/JamesLMilner/terra-draw/commit/773208a9350069849fab45e814a4ba8ad20187dd))
53
+
54
+ ### [0.0.1-alpha.25](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.24...v0.0.1-alpha.25) (2023-04-07)
55
+
56
+
57
+ ### Features
58
+
59
+ * allow zIndexing of linestrings and polygons for TerraDrawLeafletAdapter ([17a4441](https://github.com/JamesLMilner/terra-draw/commit/17a44416244490b5710560ef1fb20dc728a4730d))
60
+
61
+ ### [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)
62
+
63
+
64
+ ### Features
65
+
66
+ * export base adapter and mode so that 3rd party developers can extend ([1662960](https://github.com/JamesLMilner/terra-draw/commit/16629602d8cb7f9b7d163c581ebe23abfd734c5d))
67
+
68
+
69
+ ### Chore
70
+
71
+ * add example drawing gif image to readme ([edde444](https://github.com/JamesLMilner/terra-draw/commit/edde4442bc3aa6b6854d708edb477bb068331f8e))
72
+ * crop gif to make it a bit cleaner ([6fc4adf](https://github.com/JamesLMilner/terra-draw/commit/6fc4adfb12236428101b8a579649b9ff8ee3e946))
73
+ * update docs ([75c0848](https://github.com/JamesLMilner/terra-draw/commit/75c0848e582db24e287ff81d628de0486ad1e4e7))
74
+
75
+ ### [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)
76
+
77
+
78
+ ### Features
79
+
80
+ * cache container for all adapters to avoid refetching it ([d0e3332](https://github.com/JamesLMilner/terra-draw/commit/d0e3332c873587f5c148b4999b46fc4392d84393))
81
+ * google maps adapter now uses base pointer based event system ([03b131d](https://github.com/JamesLMilner/terra-draw/commit/03b131db9d5ed4fd4658bf7dd2fba16dbb45b04a))
82
+ * move google maps to use base adapter ([5e52f4d](https://github.com/JamesLMilner/terra-draw/commit/5e52f4d849ec3fd2e0371f121a1bf5aac2b5491e))
83
+ * move mapbox adapter to use the base adapter ([08ddb8e](https://github.com/JamesLMilner/terra-draw/commit/08ddb8e0ff3b37628aef9893a28d52ef1e98536b))
84
+ * move openlayers adapter to use base event adapter ([92213f8](https://github.com/JamesLMilner/terra-draw/commit/92213f8ee4943825e6ddb036ceea21658b5ca8a7))
85
+
86
+
87
+ ### Bug Fixes
88
+
89
+ * turn off tolerance on geojson layers for mapbox/maplibre adapters ([fb1e7a2](https://github.com/JamesLMilner/terra-draw/commit/fb1e7a2b26f30a26026bb1211211d18a7600a6f5))
90
+
91
+
92
+ ### Chore
93
+
94
+ * add better comments around the getting started example ([811d5b6](https://github.com/JamesLMilner/terra-draw/commit/811d5b6178c5cc4eb63fa5aacd4cdca6928aa87f))
95
+ * add getting started guide ([c926568](https://github.com/JamesLMilner/terra-draw/commit/c926568f68ee87fb48795b9d34b176ba82bf99a0))
96
+ * add useful comments to adapter listener ([e882911](https://github.com/JamesLMilner/terra-draw/commit/e8829119658f0d636beb8ff9ef4cf4d8f8d69706))
97
+ * better typescript typing for onStyleChange ([476fe3c](https://github.com/JamesLMilner/terra-draw/commit/476fe3c6f89a34a66e916dbc91a9fd6a3b2accb0))
98
+ * bump typedoc ([be457de](https://github.com/JamesLMilner/terra-draw/commit/be457de36e03a2d00c9831af7247079e08914dc0))
99
+ * bump typescript to version 5 ([0dedc54](https://github.com/JamesLMilner/terra-draw/commit/0dedc54042d2019f00117b3764ee09a5195deaf0))
100
+ * create start and stop as abstract methods on base.mode ([bb1d330](https://github.com/JamesLMilner/terra-draw/commit/bb1d330060dfad72af921e1c76672b6b151427d3))
101
+ * fix polygon.mode.spec test for offset change ([23ef0ab](https://github.com/JamesLMilner/terra-draw/commit/23ef0ab981115e1a5172e68cd13cf19c0c5c2f0b))
102
+ * improve guides with additional information for new users ([ec785d5](https://github.com/JamesLMilner/terra-draw/commit/ec785d5f82f2f40acc730ad11cbb388cd312d480))
103
+ * minor tidy up to all adapters ([e644459](https://github.com/JamesLMilner/terra-draw/commit/e644459459faee21854d51436c6730b3932e80f0))
104
+ * remove logs ([a7c00c2](https://github.com/JamesLMilner/terra-draw/commit/a7c00c28b69e54cfe69454e4501dd4fee8eaa1d7))
105
+ * remove uncessary override of point mode setStarted ([e8bebca](https://github.com/JamesLMilner/terra-draw/commit/e8bebcadc34315d3da1d0e05bb4939343cbe0c64))
106
+ * rename base-adapter.ts to base.adapter.ts for consistency ([753c77c](https://github.com/JamesLMilner/terra-draw/commit/753c77c8ecc2f6b88c668ba5432e681db98b5221))
107
+ * swap leaflet and openlayers ordering in development app ([4ebf3c8](https://github.com/JamesLMilner/terra-draw/commit/4ebf3c837dc84d710fd0fd8e341e4f63d820c05e))
108
+ * update docs ([29ff37a](https://github.com/JamesLMilner/terra-draw/commit/29ff37a37f1b744df299a724d6da324ed31f1045))
109
+ * update wording around getting started guide ([f6bc21e](https://github.com/JamesLMilner/terra-draw/commit/f6bc21eb6c811af2bd1f59289dedc124c29cfca6))
110
+
111
+ ### [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)
112
+
113
+
114
+ ### Features
115
+
116
+ * add custom event pointer event handling system, use in leaflet adapter ([68c551b](https://github.com/JamesLMilner/terra-draw/commit/68c551bf99f0ca37053456a3815cee8fad0c1108))
117
+
118
+
119
+ ### Chore
120
+
121
+ * update docs ([a8a91c3](https://github.com/JamesLMilner/terra-draw/commit/a8a91c39a899b5715d74875da63735360b9129f8))
122
+
123
+ ### [0.0.1-alpha.21](https://github.com/JamesLMilner/terra-draw/compare/v0.0.1-alpha.20...v0.0.1-alpha.21) (2023-03-24)
124
+
125
+
126
+ ### Bug Fixes
127
+
128
+ * remove scratch folder ([6c671d6](https://github.com/JamesLMilner/terra-draw/commit/6c671d67ac9fec88e00774095beeb0d17738b563))
129
+
130
+ ### [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)
131
+
132
+
133
+ ### Bug Fixes
134
+
135
+ * reuse draw even in leaflet adapter to prevent runtime error ([d7f6f34](https://github.com/JamesLMilner/terra-draw/commit/d7f6f34667ccb39715c6f22a1941d2e0c37d002f))
136
+
137
+ ### [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)
138
+
139
+
140
+ ### Bug Fixes
141
+
142
+ * remove mousemove event listener from leaflet adapter and replace with pointermove ([b7baa4c](https://github.com/JamesLMilner/terra-draw/commit/b7baa4c828cce1a8a1e8cd94b8f44f0a30ea6762))
143
+
144
+
145
+ ### Chore
146
+
147
+ * update docs folder ([62b80dc](https://github.com/JamesLMilner/terra-draw/commit/62b80dce039ebfb4f0729fa41c07392dc5eedf0d))
148
+
149
+ ### [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)
150
+
151
+
152
+ ### Bug Fixes
153
+
154
+ * better parity between mouse and pointer experiences ([00c219d](https://github.com/JamesLMilner/terra-draw/commit/00c219de114383d7e3f7ad58d91fc6de9c2bb7c9))
155
+ * ensure that closing points for polygons are update on click ([25c0886](https://github.com/JamesLMilner/terra-draw/commit/25c0886237c56881073e44da839b07527362662c))
156
+
157
+
158
+ ### Chore
159
+
160
+ * fix issues with prettier conflicting with eslint ([9849bce](https://github.com/JamesLMilner/terra-draw/commit/9849bce825f2073d1b72b0dc9a29718a0cb994d9))
161
+
162
+ ### [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)
163
+
164
+
165
+ ### Bug Fixes
166
+
167
+ * fix unit test for great-circle-snapping.behavior ([c90cd86](https://github.com/JamesLMilner/terra-draw/commit/c90cd86125339d43768bf6f0936f85bc09bd6833))
168
+ * use project/unproject to get midpoints that are visually centered ([3581da2](https://github.com/JamesLMilner/terra-draw/commit/3581da2cd89ace7c555c747cdae8115c90ec851d))
169
+
170
+
171
+ ### Chore
172
+
173
+ * add better test coverage for great circle mode ([4073553](https://github.com/JamesLMilner/terra-draw/commit/4073553563cdfece1f48c3b00a86a6a19457a820))
174
+ * husk precommit only readd linted files ([2eb6138](https://github.com/JamesLMilner/terra-draw/commit/2eb6138a47fc5f48334bcf7b657fa4ac8783dc76))
175
+ * make sure all mode tests are labelled correctly ([a5dfe4b](https://github.com/JamesLMilner/terra-draw/commit/a5dfe4bd79cfb33daaf47195e05b72e0fba4087c))
176
+ * make sure test files are no covered in jest coverage when type checking disabled ([0b271b6](https://github.com/JamesLMilner/terra-draw/commit/0b271b6bf9f764c03bea1f3f4a9bc949ffa830e6))
177
+ * remove unused import from static.mode.spec.ts ([e2bf578](https://github.com/JamesLMilner/terra-draw/commit/e2bf5785f00bf92c72f6054441212a1e98d07abe))
178
+
179
+ ### [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)
180
+
181
+
182
+ ### Features
183
+
184
+ * add great circle line mode ([72136a0](https://github.com/JamesLMilner/terra-draw/commit/72136a044ed3a7c9192e92fbb383e64243ce8bd6))
185
+
186
+
187
+ ### Chore
188
+
189
+ * add local scratch folder to allow for experimentation ([828e1dd](https://github.com/JamesLMilner/terra-draw/commit/828e1ddfa575a8a9703c63c3bf8d1f11535e3fef))
190
+ * fix scratch pad folder location for local development ([107db58](https://github.com/JamesLMilner/terra-draw/commit/107db581a94852925f7b647f77b67b67f0a7598d))
191
+
192
+ ### [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)
193
+
194
+
195
+ ### Features
196
+
197
+ * allow keyEvents to be set to null to prevent keyboard interactions on modes ([6af865c](https://github.com/JamesLMilner/terra-draw/commit/6af865cffa58063e422c69a4201b2ab9f37f019a))
198
+
199
+
200
+ ### Chore
201
+
202
+ * better handle event listening in adapters by creating AdapterListener abstraction ([7f0cac6](https://github.com/JamesLMilner/terra-draw/commit/7f0cac6cc28c33387e049ef4cf3bd7f05c4a57a2))
203
+ * readd precommit git add command ([bc57234](https://github.com/JamesLMilner/terra-draw/commit/bc57234cb7ceca1ee8c9aa8592e87ce0c389e70c))
204
+ * update docs ([d0c9454](https://github.com/JamesLMilner/terra-draw/commit/d0c94547eb7cd9fc4379c40ef827b9f15df577a5))
205
+
206
+ ### [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)
207
+
208
+
209
+ ### Features
210
+
211
+ * add clear to the public API ([6a8fa72](https://github.com/JamesLMilner/terra-draw/commit/6a8fa722b52047bdf7bc4cfb42d1432eaf7ff038))
212
+
213
+
214
+ ### Bug Fixes
215
+
216
+ * ensure that terra draw is enabled before calling setMode ([deff0fb](https://github.com/JamesLMilner/terra-draw/commit/deff0fb34888fd8a36778254ed8448e7711abdb8))
217
+ * make sure circle mode respects configured coordinate precision ([cba0aa7](https://github.com/JamesLMilner/terra-draw/commit/cba0aa73d2d623f53b66e2d503077519f920dc96))
218
+
219
+
220
+ ### Chore
221
+
222
+ * add npm badge to README, shorten CI badge text ([e9d7b66](https://github.com/JamesLMilner/terra-draw/commit/e9d7b6611f7b342d2dc65a381f940babcea4f889))
223
+ * bump dependency packages ([a7a2bcf](https://github.com/JamesLMilner/terra-draw/commit/a7a2bcfdee6c9da773f4cf973c7f342f75822a12))
224
+ * fix the README logo ([b48d6d7](https://github.com/JamesLMilner/terra-draw/commit/b48d6d7d4da0dbc43da86bf43d08bc17c1463073))
225
+
226
+ ### [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)
227
+
228
+
229
+ ### Chore
230
+
231
+ * add initial tests feature styling tests for circle, freehand and polygon ([066967c](https://github.com/JamesLMilner/terra-draw/commit/066967cd56c879186207dad9f912a1e6435904e5))
232
+ * add TerraDrawMapLibreGLAdapter and TerraDrawOpenLayersAdapter to docs ([6b78c01](https://github.com/JamesLMilner/terra-draw/commit/6b78c01df8f9bad83738bf560a9b365c7fa01290))
233
+ * add TerraDrawOpenLayersAdapter to terra-draw exports ([c5f3ade](https://github.com/JamesLMilner/terra-draw/commit/c5f3ade9b9cf51b99aa78d3730581dac6f37f0fd))
234
+ * remove default controls from all maps ([6ffde55](https://github.com/JamesLMilner/terra-draw/commit/6ffde55b4c8cf95b1fb46f76db07d47d37504c96))
235
+ * remove outdated list of adapters in README introduction ([21a6aca](https://github.com/JamesLMilner/terra-draw/commit/21a6aca27f15f0f7d90bc434865f4d362960d8d9))
236
+
237
+ ### [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)
238
+
239
+
240
+ ### Features
241
+
242
+ * add openlayers adapter ([1454086](https://github.com/JamesLMilner/terra-draw/commit/1454086220e0b18eb504e23cca433c5db51075e3))
243
+ * add rectangle mode as a builtin mode ([ca9a12b](https://github.com/JamesLMilner/terra-draw/commit/ca9a12b449dc9ce35a268a92e8d3cdb06ba07aee))
244
+ * disable double click when a drawing mode is enabled ([ba02ac6](https://github.com/JamesLMilner/terra-draw/commit/ba02ac689052726f8a059b0548ad541bd842555f))
245
+
246
+
247
+ ### Chore
248
+
249
+ * add keywords to package.json ([1270f26](https://github.com/JamesLMilner/terra-draw/commit/1270f26f0d650c97fc8c264d730231c5aac9fe43))
250
+ * add openlayers to development example ([0d24796](https://github.com/JamesLMilner/terra-draw/commit/0d24796754819bc622a071eae9af4c40d7fd1d16))
251
+ * do not use git add . with husky pre-commit hook ([032d002](https://github.com/JamesLMilner/terra-draw/commit/032d002a9212e767715876f63e4ca5bc90857a3a))
252
+ * update list of supported libraries in README ([2825d6c](https://github.com/JamesLMilner/terra-draw/commit/2825d6cb095f6709cae15887cb56a7ed26b1ef3d))
253
+
254
+ ### [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)
255
+
256
+
257
+ ### Features
258
+
259
+ * add MapLibre adapter ([464dce4](https://github.com/JamesLMilner/terra-draw/commit/464dce418bd6f18f3043d9072f3636d051ad900a))
260
+
261
+
262
+ ### Chore
263
+
264
+ * add automated documentation to the project ([0bbefbb](https://github.com/JamesLMilner/terra-draw/commit/0bbefbb8b69a18d73159b73ccdff5f79c7c0b843))
265
+
266
+ ### 0.0.1-alpha.10 (2022-11-24)
267
+
268
+
269
+ ### Features
270
+
271
+ * add closing point to linestring ot make easier to close for users ([e14b276](https://github.com/JamesLMilner/terra-draw/commit/e14b2769f3eb00faea55f30a24ebd4beabae92fe))
272
+ * add keybinding to allow finishing of geometries on keypress ([9b2b88e](https://github.com/JamesLMilner/terra-draw/commit/9b2b88ef4df94b8fdb5f16ded22cab6315d59cc6))
273
+ * adding closing points for drawing polygons ([c569ed6](https://github.com/JamesLMilner/terra-draw/commit/c569ed6c000683c2c9cba8fc8bec7ab5f5779a8c))
274
+ * use minimum distance approach instead of nth event for freehand ([240952d](https://github.com/JamesLMilner/terra-draw/commit/240952d2360568cba1f46340fa37360860125eed))
275
+
276
+
277
+ ### Chore
278
+
279
+ * add better unit test coverage for select mode ([46f3e3c](https://github.com/JamesLMilner/terra-draw/commit/46f3e3c7dc01d8d03261af762434c296f438d2e3))
280
+ * add development to .npmignore ([8fa412f](https://github.com/JamesLMilner/terra-draw/commit/8fa412fcaef0f39d584ef6a1190391478ad12bb7))
281
+ * add docs to .npmignore ([df907c3](https://github.com/JamesLMilner/terra-draw/commit/df907c3448385d24eb2afee3ec3f083a48c14325))
282
+ * add documentaiton for development and contributing ([4148d3e](https://github.com/JamesLMilner/terra-draw/commit/4148d3e22ffce5558278e148ea569d49f63ad8a7))
283
+ * add links and licenses where appropriate ([7e5aa62](https://github.com/JamesLMilner/terra-draw/commit/7e5aa621c64e1124b9a40dc5b8570ad3247a8ba2))
284
+ * add logo to README ([149a519](https://github.com/JamesLMilner/terra-draw/commit/149a5196b37e3263fa4246c78214725f861e38be))
285
+ * add npm install instructions to README ([2094716](https://github.com/JamesLMilner/terra-draw/commit/209471665318dc9fbd4fbd31e0ba17c7843bab72))
286
+ * add precommit hooks ([752c2f8](https://github.com/JamesLMilner/terra-draw/commit/752c2f850d5db7f0d3f4a0b4f6580a1b578ca167))
287
+ * add src to .npmignore ([0d769b8](https://github.com/JamesLMilner/terra-draw/commit/0d769b8618837c2f0672034654d7a91bc1183649))
288
+ * add TerraDrawRenderMode as an export ([8f7fd60](https://github.com/JamesLMilner/terra-draw/commit/8f7fd60697ed17a2bacd7d6eddc85aced46e6fad))
289
+ * add types property at top level of package.json ([2b53b63](https://github.com/JamesLMilner/terra-draw/commit/2b53b636f5688d3bfd45b02139e61a0474739abf))
290
+ * add types to exports in package.json ([94f5b5c](https://github.com/JamesLMilner/terra-draw/commit/94f5b5c4e83124b11a2c991c7948189f53d9d865))
291
+ * bump to 0.0.1-alpha.9 ([a4bb461](https://github.com/JamesLMilner/terra-draw/commit/a4bb46192cd80199f943a9e05e1808409a75b859))
292
+ * bump to 0.1-alpha.2 ([003ddb2](https://github.com/JamesLMilner/terra-draw/commit/003ddb2055ffad92121b9c71db115466575c4378))
293
+ * bump to 0.1-alpha.3 ([f56c5d8](https://github.com/JamesLMilner/terra-draw/commit/f56c5d85d3f6eaef0ba50de9741327f5db777ad7))
294
+ * bump to 0.1-alpha.4 ([198b281](https://github.com/JamesLMilner/terra-draw/commit/198b281891dcd19c5f7396c4dcad033fec93265c))
295
+ * bump to 0.1-alpha.5 ([daa6630](https://github.com/JamesLMilner/terra-draw/commit/daa6630070452cf633e67f64c61408cb7e215a86))
296
+ * bump to 0.1-alpha.6 ([86f17d6](https://github.com/JamesLMilner/terra-draw/commit/86f17d61eb1fe59e3b9ffcb0e84ef616ccab6d84))
297
+ * bump to 0.1-alpha.7 ([0e98f38](https://github.com/JamesLMilner/terra-draw/commit/0e98f384a8813097626cec13fa0f17ffc8d5e5b9))
298
+ * bump to 0.1-alpha.8 ([5065f83](https://github.com/JamesLMilner/terra-draw/commit/5065f833534f8e117cfddebb93f164bee3c6fcd8))
299
+ * change styling API to work on a per feature level ([ef43294](https://github.com/JamesLMilner/terra-draw/commit/ef4329449f20399425c7212e50eb730e760a9dda))
300
+ * clean up website section of README ([214b39f](https://github.com/JamesLMilner/terra-draw/commit/214b39f25096f4928637c93386861d73fbe99955))
301
+ * ensure default comes last in exports object of package.json ([1b7c849](https://github.com/JamesLMilner/terra-draw/commit/1b7c8498e14db4c83d7d5c52912532379e59d114))
302
+ * fix typescript typings location ([756586a](https://github.com/JamesLMilner/terra-draw/commit/756586a8dfb283b11372ecd9df6381d375e7939a))
303
+ * more select unit tests ([e440db8](https://github.com/JamesLMilner/terra-draw/commit/e440db8328a4be85e1c4f95646c5fb447d0060a9))
304
+ * polygon closing snapping, identical coord protection ([27eceaf](https://github.com/JamesLMilner/terra-draw/commit/27eceaf102ffa1a4f57b739f061106cbd2345df2))
305
+ * readd logo ([63ee2dc](https://github.com/JamesLMilner/terra-draw/commit/63ee2dc58d544949edff61336d93996fe61424e9))
306
+ * remove docs folder ([2f74921](https://github.com/JamesLMilner/terra-draw/commit/2f749215af2854c22f61293752bac6de24e30467))
307
+ * remove futher files from publish ([b71ea63](https://github.com/JamesLMilner/terra-draw/commit/b71ea63819fd68acbc577ed79b2a4a7e81fb9ceb))
308
+ * remove styling experiment from development ([808dfbb](https://github.com/JamesLMilner/terra-draw/commit/808dfbb18fa697511a3c96595106d28046398b91))
309
+ * remove top level files ([ed39533](https://github.com/JamesLMilner/terra-draw/commit/ed3953365dbc5d1ed06f655967fac523cd33eddb))
310
+ * remove unused imports ([a2ba004](https://github.com/JamesLMilner/terra-draw/commit/a2ba004a1f4b95b83d2aefecf83fab60237a477b))
311
+ * use webpack-dev-server for development folder ([7783e6a](https://github.com/JamesLMilner/terra-draw/commit/7783e6ad79137323e9d3aceab062f62e258590e6))
package/README.md CHANGED
@@ -1,18 +1,39 @@
1
- <img src="docs/logo.png" alt="Terra Draw Logo" width="400"/>
1
+ <img src="./logo.png" alt="Terra Draw Logo" width="400"/>
2
2
 
3
3
  ![Terra Draw CI Badge](https://github.com/JamesLMilner/terra-draw/actions/workflows/ci.yml/badge.svg)
4
+ [![npm version](https://badge.fury.io/js/terra-draw.svg)](https://badge.fury.io/js/terra-draw)
4
5
 
5
6
  Frictionless map drawing across mapping libraries.
6
7
 
7
- TerraDraw centralises map drawing logic and provides a host of out the box drawing modes that work across map providers (currently Leaflet, Mapbox, Google) via adapters.
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
+ ![An example of drawing geodesic lines using Terra Draw with Leaflet](./readme.gif)
11
+
12
+ ### Library Support
13
+
14
+ Terra Draw uses the concept of 'adapters' to allow it to work with a host of different mapping libraries. Currently supported are:
15
+
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
21
+
22
+ ### Getting Started
23
+
24
+ Please see the [the getting started guide](./guides/GETTING_STARTED.md)
8
25
 
9
26
  ### Development
10
27
 
11
- Please see the [the development documentation](./DEVELOPMENT.md)
28
+ Please see the [the development documentation](./guides/DEVELOPMENT.md)
12
29
 
13
30
  ### Contributing
14
31
 
15
- Please see the [the contributing documentation](./CONTRIBUTING.md)
32
+ Please see the [the contributing documentation](./guides/CONTRIBUTING.md)
33
+
34
+ ### Project Website
35
+
36
+ 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).
16
37
 
17
38
  ### License
18
39
 
@@ -0,0 +1,22 @@
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,31 @@
1
+ import { Project, Unproject, TerraDrawCallbacks, TerraDrawChanges, TerraDrawMouseEvent, SetCursor, TerraDrawStylingFunction } from "../../common";
2
+ import { AdapterListener } from "./adapter-listener";
3
+ export declare abstract class TerraDrawAdapterBase {
4
+ constructor(config: {
5
+ coordinatePrecision?: number;
6
+ minPixelDragDistance?: number;
7
+ });
8
+ protected dragConter: number;
9
+ protected _minPixelDragDistance: number;
10
+ protected _lastDrawEvent: TerraDrawMouseEvent | undefined;
11
+ protected _coordinatePrecision: number;
12
+ protected _heldKeys: Set<string>;
13
+ protected listeners: AdapterListener[];
14
+ protected dragState: "not-dragging" | "pre-dragging" | "dragging";
15
+ protected currentModeCallbacks: TerraDrawCallbacks | undefined;
16
+ protected getButton(event: PointerEvent): "neither" | "left" | "middle" | "right";
17
+ protected getDrawEventFromPointerEvent(event: PointerEvent): TerraDrawMouseEvent;
18
+ abstract project(...args: Parameters<Project>): ReturnType<Project>;
19
+ abstract unproject(...args: Parameters<Unproject>): ReturnType<Unproject>;
20
+ abstract setCursor(...args: Parameters<SetCursor>): ReturnType<SetCursor>;
21
+ abstract getLngLatFromPointerEvent(event: PointerEvent): {
22
+ lng: number;
23
+ lat: number;
24
+ };
25
+ abstract setDraggability(enabled: boolean): void;
26
+ abstract setDoubleClickToZoom(enabled: boolean): void;
27
+ abstract getMapContainer(): HTMLElement;
28
+ abstract register(callbacks: TerraDrawCallbacks): void;
29
+ abstract unregister(): void;
30
+ abstract render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
31
+ }
@@ -0,0 +1,47 @@
1
+ import { Project, Unproject, TerraDrawCallbacks, TerraDrawChanges, TerraDrawMouseEvent, SetCursor, TerraDrawStylingFunction, GetLngLatFromEvent } 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 getContainerXYPosition(event: PointerEvent | MouseEvent): {
20
+ containerX: number;
21
+ containerY: number;
22
+ };
23
+ protected getDrawEventFromEvent(event: PointerEvent | MouseEvent): TerraDrawMouseEvent | null;
24
+ /**
25
+ * Registers the provided callbacks for the current drawing mode and attaches
26
+ * the necessary event listeners.
27
+ * @param {TerraDrawCallbacks} callbacks - An object containing callback functions
28
+ * for handling various drawing events in the current mode.
29
+ */
30
+ register(callbacks: TerraDrawCallbacks): void;
31
+ /**
32
+ * Unregisters the event listeners for the current drawing mode.
33
+ * This is typically called when switching between drawing modes or
34
+ * stopping the drawing process.
35
+ */
36
+ unregister(): void;
37
+ abstract clear(): void;
38
+ abstract project(...args: Parameters<Project>): ReturnType<Project>;
39
+ abstract unproject(...args: Parameters<Unproject>): ReturnType<Unproject>;
40
+ abstract setCursor(...args: Parameters<SetCursor>): ReturnType<SetCursor>;
41
+ abstract getLngLatFromEvent(...event: Parameters<GetLngLatFromEvent>): ReturnType<GetLngLatFromEvent>;
42
+ abstract setDraggability(enabled: boolean): void;
43
+ abstract setDoubleClickToZoom(enabled: boolean): void;
44
+ abstract getMapContainer(): HTMLElement;
45
+ abstract render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
46
+ }
47
+ export {};
@@ -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
+ }