Skip to content

Commit

Permalink
Rename visibility layer
Browse files Browse the repository at this point in the history
Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
  • Loading branch information
VijayanB committed Jan 31, 2023
1 parent 2175dd5 commit 1c0e433
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions public/components/layer_control_panel/layer_control_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
} from '../../model/layerRenderController';
import { MapState } from '../../model/mapState';
import { ConfigSchema } from '../../../common/config';
import {moveLayers, updateVisibility} from "../../model/map/layer_operations";
import {moveLayers, updateLayerVisibility} from "../../model/map/layer_operations";

interface MaplibreRef {
current: Maplibre | null;
Expand Down Expand Up @@ -290,7 +290,7 @@ export const LayerControlPanel = memo(
layer.visibility = LAYER_VISIBILITY.VISIBLE;
setLayerVisibility(new Map(layerVisibility.set(layer.id, true)));
}
updateVisibility(maplibreRef.current!, layer.id, layer.visibility);
updateLayerVisibility(maplibreRef.current!, layer.id, layer.visibility);
};

const onDeleteLayerIconClick = (layer: MapLayerSpecification) => {
Expand Down
5 changes: 1 addition & 4 deletions public/model/documentLayerFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
updateCircleLayer,
updateLineLayer,
updatePolygonLayer,
updateVisibility,
updateLayerVisibility,
} from './map/layer_operations';

interface MaplibreRef {
Expand Down Expand Up @@ -240,7 +240,4 @@ export const DocumentLayerFunctions = {
remove: (maplibreRef: MaplibreRef, layerConfig: DocumentLayerSpecification) => {
removeLayers(maplibreRef.current!, layerConfig.id, true);
},
hide: (maplibreRef: MaplibreRef, layerConfig: DocumentLayerSpecification) => {
updateVisibility(maplibreRef.current!, layerConfig.id, layerConfig.visibility);
},
};
4 changes: 2 additions & 2 deletions public/model/map/layer_operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
hasLayer, moveLayers, removeLayers,
updateCircleLayer,
updateLineLayer,
updatePolygonLayer, updateVisibility,
updatePolygonLayer, updateLayerVisibility,
} from './layer_operations';
import { Map as Maplibre } from 'maplibre-gl';
import { MockMaplibreMap } from './__mocks__/map';
Expand Down Expand Up @@ -366,7 +366,7 @@ describe('update visibility', function () {
const mockLayer2: MockLayer = new MockLayer('layer-11');
mockLayer1.setProperty('visibility', 'none');
const mockMap: MockMaplibreMap = new MockMaplibreMap([mockLayer1, mockLayer2]);
updateVisibility((mockMap as unknown) as Maplibre, 'layer-1', 'visible');
updateLayerVisibility((mockMap as unknown) as Maplibre, 'layer-1', 'visible');
expect(mockMap.getLayers().map((layer) => String(layer.getProperty('visibility')))).toEqual(
Array(2).fill('visible')
);
Expand Down
2 changes: 1 addition & 1 deletion public/model/map/layer_operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const removeLayers = (map: Maplibre, layerId: string, removeSource?: bool
}
};

export const updateVisibility = (map: Maplibre, layerId: string, visibility: string) => {
export const updateLayerVisibility = (map: Maplibre, layerId: string, visibility: string) => {
getLayers(map, layerId).forEach((layer) => {
map.setLayoutProperty(layer.id, 'visibility', visibility);
});
Expand Down

0 comments on commit 1c0e433

Please sign in to comment.