Skip to content

Commit 8b3a20f

Browse files
authored
docs(terra-draw): add section on updateModeOptions to MODES guide (#491)
1 parent f5d9555 commit 8b3a20f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎guides/4.MODES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,21 @@ We can also provide a `toCustom` function which allows snapping to some arbitrar
169169
})
170170
```
171171

172+
#### Updating a Modes Options After Instantiation
173+
174+
If we want to dynamically change an option passed to a mode after it has been instantiated we can do this using the `updateModeOptions` method. It is used in the following way:
175+
176+
```typescript
177+
draw.updateModeOptions<typeof TerraDrawPolygonMode>('polygon', {
178+
snapping: {
179+
toLine: false,
180+
toCoordinate: true
181+
}
182+
})
183+
```
184+
185+
Here we can pass a partial object with the options we want to update. In the case above we are just updating the snapping option. This functionality can be used to change how your modes work on the fly.
186+
172187
#### Projections in Drawing Modes
173188

174189
As we move forward Terra Draw will work on supporting Web Mercator maps out the box with the ability to support Globes (i.e., 3D spherical representations of the earth with no projection) as a secondary option. This is made slightly more complicated by the fact we know sometimes users want to draw geodesic geometries on a web mercator map, for example a geodesic circle or a great circle line. In future we will better align by assuming developers want web mercator first behaviours, with secondary support for globes via the `projection` property for built in modes.

0 commit comments

Comments
 (0)