@@ -65,13 +65,11 @@ export type Props = {
65
65
/** Over ride the default modes with your own. */
66
66
modes ?: Object ,
67
67
68
- /** The mode that user will first land in. */
69
- defaultMode ?:
70
- 'simple_select'
71
- | 'direct_select'
72
- | 'draw_line_string'
73
- | 'draw_polygon'
74
- | 'draw_point' ,
68
+ /** The mode that will used. */
69
+ mode ?: String ,
70
+
71
+ /** The mode options. */
72
+ modeOptions ?: Object ,
75
73
76
74
/**
77
75
* Properties of a feature will also be available for styling
@@ -223,7 +221,8 @@ class Draw extends React.PureComponent<Props> {
223
221
displayControlsDefault : true ,
224
222
styles : theme ,
225
223
modes,
226
- defaultMode : 'simple_select' ,
224
+ mode : 'simple_select' ,
225
+ modeOptions : { } ,
227
226
userProperties : false ,
228
227
data : null ,
229
228
onDrawCreate : null ,
@@ -258,7 +257,8 @@ class Draw extends React.PureComponent<Props> {
258
257
displayControlsDefault : this . props . displayControlsDefault ,
259
258
styles : this . props . styles ,
260
259
modes : this . props . modes ,
261
- defaultMode : this . props . defaultMode ,
260
+ defaultMode : this . props . mode ,
261
+ modeOptions : this . props . modeOptions ,
262
262
userProperties : this . props . userProperties
263
263
} , this . props . position ) ;
264
264
@@ -286,11 +286,15 @@ class Draw extends React.PureComponent<Props> {
286
286
this . _draw = draw ;
287
287
}
288
288
289
- componentDidUpdate ( ) {
289
+ componentDidUpdate ( prevProps ) {
290
290
if ( this . props . data ) {
291
291
// $FlowFixMe
292
292
this . _draw . set ( this . props . data ) ;
293
293
}
294
+
295
+ if ( prevProps . mode !== this . props . mode ) {
296
+ this . _draw . changeMode ( this . props . mode ) ;
297
+ }
294
298
}
295
299
296
300
componentWillUnmount ( ) : void {
0 commit comments