@@ -111,8 +111,8 @@ function updateDeck(inputJson, deckgl) {
111
111
deckgl . setProps ( results ) ;
112
112
}
113
113
114
- function missingLayers ( oldLayers , newLayers ) {
115
- return oldLayers . filter ( ol => ol && ol . id && ! newLayers . find ( nl => nl . id === ol . id ) ) ;
114
+ function missingProps ( oldProps , newProps ) {
115
+ return oldProps . filter ( op => op && op . id && ! newProps . find ( np => np . id === op . id ) ) ;
116
116
}
117
117
118
118
function createStandaloneFromProvider ( {
@@ -217,14 +217,17 @@ function createDeck({
217
217
}
218
218
219
219
const oldLayers = jsonInput . layers || [ ] ;
220
+ const oldWidgets = jsonInput . widgets || [ ] ;
220
221
const props = jsonConverter . convert ( jsonInput ) ;
221
222
222
223
addSupportComponents ( container , props ) ;
223
224
224
225
const convertedLayers = ( props . layers || [ ] ) . filter ( l => l ) ;
226
+ const convertedWidgets = ( props . widgets || [ ] ) . filter ( w => w ) ;
225
227
226
- // loading custom library is async, some layers might not be convertable before custom library loads
227
- const layerToLoad = missingLayers ( oldLayers , convertedLayers ) ;
228
+ // loading custom library is async, some layers/widgets might not be convertable before custom library loads
229
+ const layersToLoad = missingProps ( oldLayers , convertedLayers ) ;
230
+ const widgetsToLoad = missingProps ( oldWidgets , convertedWidgets ) ;
228
231
const getTooltip = makeTooltip ( tooltip ) ;
229
232
const { mapProvider} = props ;
230
233
@@ -240,14 +243,21 @@ function createDeck({
240
243
} ) ;
241
244
242
245
const onComplete = ( ) => {
243
- if ( layerToLoad . length ) {
244
- // convert input layer again to presist layer order
245
- const newProps = jsonConverter . convert ( { layers : jsonInput . layers } ) ;
246
- const newLayers = ( newProps . layers || [ ] ) . filter ( l => l ) ;
246
+ if ( layersToLoad . length || widgetsToLoad . length ) {
247
+ const newProps = jsonConverter . convert ( {
248
+ layers : jsonInput . layers ,
249
+ widgets : jsonInput . widgets
250
+ } ) ;
247
251
248
- if ( newLayers . length > convertedLayers . length ) {
249
- // if more layers are converted
250
- deckgl . setProps ( { layers : newLayers } ) ;
252
+ const newLayers = ( newProps . layers || [ ] ) . filter ( l => l ) ;
253
+ const newWidgets = ( newProps . widgets || [ ] ) . filter ( w => w ) ;
254
+
255
+ if (
256
+ newLayers . length > convertedLayers . length ||
257
+ newWidgets . length > convertedWidgets . length
258
+ ) {
259
+ // if more layers/widgets are converted
260
+ deckgl . setProps ( { layers : newLayers , widgets : newWidgets } ) ;
251
261
}
252
262
}
253
263
} ;
0 commit comments