Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…geoview into develop
  • Loading branch information
MatthewMuehlhauserNRCan committed Nov 21, 2024
2 parents 81b33d0 + 70f0716 commit 8aed3da
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/geoview-core/src/geo/layer/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,10 @@ export class LayerApi {
// Create geocore layer configs and add
const geoCoreGeoviewLayerInstance = new GeoCore(this.getMapId(), this.mapViewer.getDisplayLanguage());
const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(uuid);
const addedLayers: (GeoViewLayerAddedResult | undefined)[] = [];
layers.forEach((geoviewLayerConfig) => {
// Redirect
this.addGeoviewLayer(geoviewLayerConfig);
addedLayers.push(this.addGeoviewLayer(geoviewLayerConfig));
});
}

Expand Down
39 changes: 38 additions & 1 deletion packages/geoview-core/src/geo/map/map-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,49 @@ export class MapViewer {
* @returns {Promise<[void, void]>}
*/
setLanguage(displayLanguage: TypeDisplayLanguage, resetLayer?: boolean | false): Promise<[void, void]> {
// If the language hasn't changed don't do anything
if (AppEventProcessor.getDisplayLanguage(this.mapId) === displayLanguage) return Promise.resolve([undefined, undefined]);
if (VALID_DISPLAY_LANGUAGE.includes(displayLanguage)) {
const promise = AppEventProcessor.setDisplayLanguage(this.mapId, displayLanguage);

// if flag is true, check if config support the layers change and apply
if (resetLayer) {
logger.logInfo('reset layers not implemented yet');
const re = /[\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12}/g;

const configs = this.layer.getLayerEntryConfigs();
const originalMapOrderedLayerInfo = MapEventProcessor.getMapOrderedLayerInfo(this.mapId);
// Need to wait for all refreshed GeoCore layers to be settles before trying to update
// the ordered layer info. Otherwise, the map doesn't update correctly
Promise.allSettled(
configs
.filter((config) => {
// Filter to just Geocore layers and not child layers
if (re.test(config.geoviewLayerConfig.geoviewLayerId) && config.parentLayerConfig === undefined) {
return config;
}
return false;
})
.map((config) => {
// Remove and add back in GeoCore Layers and return their promises
const uuid = config.geoviewLayerConfig.geoviewLayerId.match(re)![0];
this.layer.removeLayerUsingPath(config.layerPath);
return this.layer.addGeoviewLayerByGeoCoreUUID(uuid);
})
)
.then(() => {
// Can use the setMapOrderedLayerInfo to update the maps states, BUT
// still need to remove any children layers first that weren't in the original.
const newMapOrderedLayerInfo = MapEventProcessor.getMapOrderedLayerInfo(this.mapId);
const originalLayerPaths = originalMapOrderedLayerInfo.map((layer) => layer.layerPath);
const childLayersToRemove = newMapOrderedLayerInfo
.map((layer) => layer.layerPath)
.filter((path) => !originalLayerPaths.includes(path));
childLayersToRemove.forEach((childPath) => {
this.layer.removeLayerUsingPath(childPath);
});
MapEventProcessor.setMapOrderedLayerInfo(this.mapId, originalMapOrderedLayerInfo);
})
.catch((err) => logger.logError(err));
}

// Emit language changed event
Expand Down
6 changes: 6 additions & 0 deletions packages/geoview-core/src/ui/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ Hold viewer specific css not inside theme
.guideBox p img {
vertical-align: bottom;
}

/* Allow Table to move while the new rows/columns are rendering */
.MuiTableContainer-root {
contain: paint;
will-change: transform;
}

0 comments on commit 8aed3da

Please sign in to comment.