diff --git a/guides/2.STORE.md b/guides/2.STORE.md index 79029eb..74bc160 100644 --- a/guides/2.STORE.md +++ b/guides/2.STORE.md @@ -46,6 +46,9 @@ The data contained with the store is exposed via the `getSnapshot` method, which const features = draw.getSnapshot(); ``` +> [!TIP] +> The `getSnapshot` method returns a deep copy of the Store, so you can safely mutate the returned array without affecting the Store. + We can then filter through this array to get the features we're looking for, as an example only returning `TerraDrawPolygonMode` features: ```javascript @@ -56,10 +59,14 @@ features.filter((feature) => feature.properties.mode === 'polygon') Features are added to the Store when interacting with the Map using a number of available drawing Modes (such as `TerraDrawRectangleMode` or `TerraDrawPolygonMode`). -> [!TIP] -> The `getSnapshot` method returns a deep copy of the Store, so you can safely mutate the returned array without affecting the Store. -Features can also be added to the Store programmatically using the `addFeatures` method: +Features can also be added to the Store programmatically using the `addFeatures` method. The method takes a valid array of Point, LineString and/or Polygon features which have a mode that is enabled in the current Terra Draw instance and adds them to that mode. It returns an array of success/failures with any reasons for given failures. + +> [!IMPORTANT] +> The addFeatures method only accepts features of type Point, LineString and Polygon. Multi feature types like MultiPolygon, MultiLineString and MultiPoint are not supported. You can break down these multi features programmatically and add them individually if required. + + +Here is an example of how to use addFeatures: ```javascript // Add a Point to the Store @@ -85,7 +92,7 @@ console.log(result) // }] ``` -`addFeatures` returns an array of objects providing information about the added features such as the id and the feature was valid. Only valid features are added to the store. This allows developers to handle failure cases how they see fit: +As mentioned above, `addFeatures` returns an array of objects providing information about the added features such as the id and the feature was valid. Only valid features are added to the store. This allows developers to handle failure cases how they see fit: ```typescript // Create a list of features that did not pass validation