Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUS-3919-Persist-BaseMap #260

Merged
merged 3 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@angular/platform-server": "^15.2.8",
"@angular/router": "^15.2.8",
"@auscope/angular-cesium": "^15.0.1",
"@auscope/portal-core-ui": "^3.0.4",
"@auscope/portal-core-ui": "^3.0.7",
"@csiro-geoanalytics/ng": "^2.5.0",
"@ng-bootstrap/ng-bootstrap": "^14.1.0",
"@ng-select/ng-select": "^10.0.4",
Expand Down
25 changes: 17 additions & 8 deletions src/app/menupanel/layerpanel/layerpanel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { UserStateService } from 'app/services/user/user-state.service';
import { Bookmark } from 'app/models/bookmark.model';
import { AuthService } from 'app/services/auth/auth.service';
import { LayerManagerService } from 'app/services/ui/layer-manager.service';
import { environment } from 'environments/environment';


// Filter modes available in the dropdown layer filter selector
Expand Down Expand Up @@ -121,14 +122,14 @@ export class LayerPanelComponent implements OnInit {
* "layerGroup" - an instance of this.layerGroups[key].value
*/
public isLayerGroupVisible(layerGroupValue): boolean {
if (layerGroupValue.expanded && layerGroupValue.loaded) {
for (const layer of layerGroupValue.loaded) {
if (layer.hide === false) {
return true;
}
}
if (layerGroupValue.expanded && layerGroupValue.loaded) {
for (const layer of layerGroupValue.loaded) {
if (layer.hide === false) {
return true;
}
}
return false;
}
return false;
}

/**
Expand All @@ -140,7 +141,7 @@ export class LayerPanelComponent implements OnInit {
// Re-order layers by index field provided index field is present (it won't be in older states)
const orderedLayerKeys: string[] = [];
for (const layer of Object.keys(layerStateObj)) {
if (layer.toLowerCase() !== 'map') {
if (layer.toLowerCase() !== 'map' && layer.toLowerCase() !== 'basemap') {
// Add layer at 'index' position of array, else just push
if (layerStateObj[layer].hasOwnProperty('index')) {
orderedLayerKeys[layerStateObj[layer].index] = layer;
Expand Down Expand Up @@ -177,6 +178,14 @@ export class LayerPanelComponent implements OnInit {
alert('The specified state could not be found, it may have been deleted or made private.');
}

// Set base map if "baseMap" key is present
if (layerStateObj.hasOwnProperty('baseMap')) {
const baseMap = environment.baseMapLayers.find(bm => bm.value === layerStateObj['baseMap']);
if (baseMap) {
this.csMapService.setBaseMapLayer(baseMap.viewValue);
}
}

// Load state layers in corresponding FilterPanels
setTimeout(() => {
this.loadFilterPanelLayersFromState(layerStateObj);
Expand Down
9 changes: 8 additions & 1 deletion src/app/services/user/user-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AuscopeApiService } from '../api/auscope-api.service';
import { CsMapService, ManageStateService } from '@auscope/portal-core-ui';
import { v4 as uuidv4 } from 'uuid';
import { HttpResponse } from '@angular/common/http';
import { environment } from 'environments/environment';


@Injectable()
Expand Down Expand Up @@ -155,9 +156,15 @@ export class UserStateService {
public addState(name: string, description: string, isPublic: boolean): Observable<any> {
const id = uuidv4();
const state = this.manageStateService.getState();
// Add the base map to the state
const baseMapImagery = this.csMapService.getViewer().baseLayerPicker.viewModel.selectedImagery;
const baseMap = environment.baseMapLayers.find(bm => bm.viewValue === baseMapImagery.name);
if (baseMap) {
state.baseMap = baseMap.value;
}
// Add the index position of each layer to the state object
for (const layerKey of Object.keys(state)) {
if (layerKey.toLowerCase() !== 'map') {
if (layerKey.toLowerCase() !== 'map' && layerKey.toLowerCase() !== 'basemap') {
const layerIndex = this.csMapService.getLayerIndex(layerKey);
state[layerKey].index = layerIndex;
}
Expand Down