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

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.
@@ -198,6 +198,47 @@ Coming soon - please see development folder for example for now.
198
198
 
199
199
  Coming soon - please see development folder for example for now.
200
200
 
201
+ ## Common Patterns
202
+
203
+ ### Loading in External Data
204
+
205
+ It is common pattern to want to load in data from an external source (GeoJSON file, API call, etc). This can be achieved with the `addFeatures` method on the Terra Draw instance. The method call works out which mode to add the feature based on looking at its `mode` property in the Features `properties` property. All modes have a method called `validateFeature` that ensures that a given feature is valid for the mode. For example if you wanted to add a series of points to the TerraDrawPointMode you could do this by ensuring that the points you feed in have the `mode` property set to `point`.
206
+
207
+ ```javascript
208
+ points.forEach((point) => {
209
+ point.properties.mode = "point";
210
+ });
211
+
212
+ draw.addFeatures(points);
213
+ ```
214
+
215
+ ### Render Only Modes with TerraDrawRenderMode
216
+
217
+ If you just want to render some data onto the map without it being editable, you can use `TerraDrawRenderMode` in combination with `addFeatures` like so:
218
+
219
+ ```javascript
220
+ const draw = new TerraDraw({
221
+ adapter: new TerraDrawLeafletAdapter({
222
+ lib: L,
223
+ map,
224
+ coordinatePrecision: 9,
225
+ }),
226
+ modes: {
227
+ arbitary: new TerraDrawRenderMode(),
228
+ },
229
+ });
230
+
231
+ draw.start();
232
+
233
+ points.forEach((point) => {
234
+ point.properties.mode = "arbitary";
235
+ });
236
+
237
+ draw.addFeatures(points);
238
+
239
+ // This will add the points to hte TerraDrawRenderMode 'arbitary' rendering them to the screen
240
+ ```
241
+
201
242
  ## Other Examples
202
243
 
203
244
  There are a few other working examples that you can use as points of reference for creating a new app using Terra Draw.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terra-draw",
3
- "version": "0.0.1-alpha.30",
3
+ "version": "0.0.1-alpha.32",
4
4
  "description": "Frictionless map drawing across mapping provider",
5
5
  "scripts": {
6
6
  "docs": "typedoc",
@@ -1,6 +1,6 @@
1
1
  npm run docs
2
2
 
3
3
  npm run build
4
- npm run release -- --prerelease --release-as 0.0.1-alpha.30
4
+ npm run release -- --prerelease --release-as 0.0.1-alpha.31
5
5
  git push origin main --tags
6
6
  npm publish