Skip to content

Commit

Permalink
fix(MapContextService): clone des cartes basé sur l'id plutôt que le …
Browse files Browse the repository at this point in the history
…nom de la couche (doublon)
  • Loading branch information
cboucheIGN committed Dec 18, 2024
1 parent c9f5a46 commit 8121dc5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const EXPORT_TILE_CONFIG = [
download: false,
artworkDirPath: 'artwork',
artworkFilePath: 'artwork/pictograms/document/document-download.svg',
detail: 'Détail (optionnel)'
detail: ''
}
];

Expand Down
13 changes: 11 additions & 2 deletions src/app/shared-map/services/map-context.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export class MapContextService {
}

// Ajouter une carte situation, clone de la map origine
createSituationMap(idClone: string, technicalName: string): Map {
createSituationMap(idClone: string, idLayer: string): Map {
// Rechercher la couche correspondant au technicalName
const selectedLayer = this.getLayerByTechnicalName(technicalName);
const selectedLayer = this.getLayerById(idLayer);

const layerCopy = new LayerGroup({
properties: {
Expand Down Expand Up @@ -357,4 +357,13 @@ export class MapContextService {
return allLayers.find((layer) => layer.get('technicalName') === technicalName) || null;
}

private getLayerById(id: string): any {
const allLayers = [
...MAP_BIODIVERISTE_LAYER_GROUP.getLayers().getArray(),
...MAP_PATRIMOINE_LAYER_GROUP.getLayers().getArray(),
];

return allLayers.find((layer) => layer.get('id') === id) || null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@ export class LayerInfoViewComponent implements OnChanges {

constructor() { }


ngOnChanges(changes: SimpleChanges): void {
this.prepareMap();
}

openTab(link: string) {
const windowReference: any = window;
windowReference.open(link, '_blank').focus();
}

private prepareMap() {
if (this.layer && this.displaySituationMap) {
this.map = this.layer.technicalName;
this.map = this.layer.id;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class ThematicTabsComponent implements OnInit {


updateMap(event: any) {
console.log('selectTab', event);
this.mapContextService.updateLayersVisibility(event);
}

Expand Down

0 comments on commit 8121dc5

Please sign in to comment.