Skip to content

Commit

Permalink
georchestra#169 Making sure that vector layer is initialized only aft…
Browse files Browse the repository at this point in the history
…er raster layer
  • Loading branch information
alexander-fedorenko committed Aug 30, 2022
1 parent 98d5c1e commit 01ff738
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
28 changes: 16 additions & 12 deletions js/extension/epics/layerSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SET_STYLES,
ZOOM_TO_RESULTS,
UPDATE_LAYER_STYLE,
ADD_PLOT_SELECTION
ADD_PLOT_SELECTION, TEAR_DOWN
} from '../actions/cadastrapp';
import {
getCurrentPlotFeatures,
Expand All @@ -33,18 +33,22 @@ import {


export const syncLayerForPlots = (action$, {getState = () => {}})=>
action$.ofType(SETUP_COMPLETED, ADD_PLOT_SELECTION, ADD_PLOTS, REMOVE_PLOTS, SET_ACTIVE_PLOT_SELECTION, REMOVE_PLOT_SELECTION, SELECT_PLOTS, DESELECT_PLOTS, SET_LAYER_STYLE, SET_STYLES, UPDATE_LAYER_STYLE) // actions that modify the layer, so it needs an update.
action$.ofType(SETUP_COMPLETED)
.switchMap(() => {
const features = getCurrentPlotFeatures(getState());
const options = getCadastrappVectorLayer(getState());
return Rx.Observable.of(
updateAdditionalLayer(
CADASTRAPP_VECTOR_LAYER_ID,
CADASTRAPP_OWNER,
"overlay", {
...options,
features
}));
return action$.ofType(ADD_PLOT_SELECTION, ADD_PLOTS, REMOVE_PLOTS, SET_ACTIVE_PLOT_SELECTION, REMOVE_PLOT_SELECTION, SELECT_PLOTS, DESELECT_PLOTS, SET_LAYER_STYLE, SET_STYLES, UPDATE_LAYER_STYLE) // actions that modify the layer, so it needs an update.
.switchMap(() => {
const features = getCurrentPlotFeatures(getState());
const options = getCadastrappVectorLayer(getState());
return Rx.Observable.of(
updateAdditionalLayer(
CADASTRAPP_VECTOR_LAYER_ID,
CADASTRAPP_OWNER,
"overlay", {
...options,
features
}));
})
.takeUntil(action$.ofType(TEAR_DOWN));
});

export const zoomToExtentAllResultsEpic = (action$, {getState = () => {}})=>
Expand Down
40 changes: 24 additions & 16 deletions js/extension/epics/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ export const cadastrappSetup = (action$, store) =>
.switchMap(data => {
return Rx.Observable.of(setConfiguration(data));
})
.startWith(updateDockPanelsList(CONTROL_NAME, 'add', 'right'));
.startWith({
type: 'MAP_LAYOUT:UPDATE_DOCK_PANELS',
name: 'cadastrapp',
action: 'add',
location: 'right'
});
const mapInfoEnabled = get(store.getState(), "mapInfo.enabled");
return initStream$.concat(
Rx.Observable.defer(() => {
// here the configuration has been loaded
Expand All @@ -72,7 +78,7 @@ export const cadastrappSetup = (action$, store) =>
cadastreWFSLayerName,
cadastreWFSURL
} = configurationSelector(store.getState());
return Rx.Observable.from([
return Rx.Observable.of(
updateAdditionalLayer(
CADASTRAPP_RASTER_LAYER_ID,
CADASTRAPP_OWNER,
Expand All @@ -89,20 +95,22 @@ export const cadastrappSetup = (action$, store) =>
type: "wfs"
}
}, true),
updateAdditionalLayer(
CADASTRAPP_VECTOR_LAYER_ID,
CADASTRAPP_OWNER,
'overlay',
{
id: CADASTRAPP_VECTOR_LAYER_ID,
features: [],
type: "vector",
name: "searchPoints",
visibility: true
}),
registerEventListener(MOUSE_EVENT, CONTROL_NAME), // Set map's mouse event trigger type
...(get(store.getState(), "mapInfo.enabled") ? [toggleMapInfoState(), hideMapinfoMarker()] : [])
]);
registerEventListener(MOUSE_EVENT, CONTROL_NAME) // Set map's mouse event trigger type
).concat(
Rx.Observable.of(
updateAdditionalLayer(
CADASTRAPP_VECTOR_LAYER_ID,
CADASTRAPP_OWNER,
'overlay',
{
id: CADASTRAPP_VECTOR_LAYER_ID,
features: [],
type: "vector",
name: "searchPoints",
visibility: true
})
)
).concat([...(mapInfoEnabled ? [toggleMapInfoState(), hideMapinfoMarker()] : [])]);
})
)
.concat(Rx.Observable.of(setupCompleted())) // required to sync the layer the first time (if closed/reopen)
Expand Down

0 comments on commit 01ff738

Please sign in to comment.