You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method takes any valid GeoJSON and adds it to Draw. The object will be turned into a GeoJSON feature and will be assigned a unique `drawId` that can be used to identify it. This method return the new feature's `drawId`. If an id is provided with the feature that ID will be used.
95
95
96
-
The second argument is an optional options object to add information to the geometry when creating the new element. Currently the only used option is `permanent`, which, if set to true, will cause the element to ignore click events, `Draw.select(:id:)` and `Draw.selectAll()`.
97
-
98
96
Draw does not enforce unique IDs to be passed to `.add`, but it does enforce unique ids inside of it. This means that if you provide an id for a feature that is not unqiue, Draw will override the exhisting feature with your new feature. You can think of this like PUT in http verbs.
99
97
100
98
If a FeatureCollection is provided to `.add` Draw will break it up into many features as if you looped through the features in the collection and added them one at a time. This is good for bulk adding, though it is no faster than looping yourself.
@@ -136,7 +134,6 @@ console.log(Draw.get(id));
136
134
137
135
This method returns all features added to Draw in a single GeoJSON FeatureCollection. The each feature's unique id will be found on the `id` attribute of the feature.
138
136
139
-
140
137
Example:
141
138
142
139
```js
@@ -173,71 +170,27 @@ console.log(Draw.getAll());
173
170
```
174
171
---
175
172
176
-
###`.getSelected() -> Object`
177
-
178
-
Get all selected features.
179
-
180
-
---
181
-
182
-
###`.select(String: drawId) -> Draw`
183
-
184
-
This method takes the `drawId` of a feature and selects it. It returns `this` to allow for method chaining.
185
-
186
-
---
187
-
188
-
###`.selectAll() -> Draw`
189
-
190
-
This method selects all features. It returns `this` to allow for method chaining.
191
-
192
-
---
193
-
194
-
###`.deselect(String: drawId) -> Draw`
195
173
196
-
This method takes the `drawId` of a feature and deselects it if selected. It returns `this` to allow for method chaining.
174
+
###`.delete(String: drawId) -> Draw`
197
175
198
-
---
199
-
200
-
####`.deselectAll() -> Draw`
176
+
This method takes the `drawId` of feature and removes it from draw.
201
177
202
-
This method deselects all features. It returns `this` to allow for method chaining.
203
-
204
-
---
205
-
206
-
###`.destroy(String: drawId) -> Draw`
207
-
208
-
This method takes the `drawId` of feature and removes it from draw. It returns `this` to allow for method chaining.
178
+
In `direct_select` mode, deleting the active feature will stop the mode and revert to the `default` mode.
209
179
210
180
Example:
211
181
212
182
```js
213
183
var feature = { type:'Point', coordinates: [0, 0] };
This method initiates drawing the specified type. The types are defined in constants in draw under `Draw.types.*`. The argument should be one of
211
+
This envokes the current modes trash event. For the `default` mode this deletes all active features. For the `direct_select` mode this deletes the active vertecies. For the draw modes, these cancels the current process.
259
212
260
-
-`Draw.types.POINT`
261
-
-`Draw.types.LINE`
262
-
-`Draw.types.POLYGON`
213
+
This is different from `delete` or `deleteAlll` in that it follows rules described by the current mode.
`startMode` triggers the mode switching process inside Draw. `mode` must be one of the below strings. Each mode takes its own arguments. They are descibed in detail below.
220
+
221
+
#### Mode: `default`
222
+
223
+
Lets you select, delete and drag features.
224
+
225
+
For `default` options is an array of featureIds. It is optional. If provided, these features will be active at the start of the mode. In this mode, features can have their active state changed by the user. To control what is active, react to changes as described in the events section below.
226
+
227
+
#### Mode: `direct_select`
228
+
229
+
Lets you select, delete and drag features.
230
+
231
+
For `direct_select`options is a single featureId. It is required. This feature will be active for the duration of the mode.
232
+
233
+
#### Draw modes:
234
+
235
+
The three draw modes work identically. They do not take an options argument.
0 commit comments