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

Refactor layer properties as own interface #225

Merged
merged 2 commits into from
Feb 4, 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
4 changes: 0 additions & 4 deletions public/model/customLayerFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ interface MaplibreRef {
current: Maplibre | null;
}

const getCurrentStyleLayers = (maplibreRef: MaplibreRef) => {
return maplibreRef.current?.getStyle().layers || [];
};

const updateLayerConfig = (layerConfig: CustomLayerSpecification, maplibreRef: MaplibreRef) => {
const maplibreInstance = maplibreRef.current;
if (maplibreInstance) {
Expand Down
24 changes: 10 additions & 14 deletions public/model/map/layer_operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ export const updateLayerVisibility = (map: Maplibre, layerId: string, visibility
});
};

export interface LineLayerSpecification {
// Common properties that every DashboardMap layer contains
interface Layer {
sourceId: string;
visibility: string;
color: string;
opacity: number;
width: number;
minZoom: number;
maxZoom: number;
}

export interface LineLayerSpecification extends Layer {
visibility: string;
color: string;
width: number;
}

export const addLineLayer = (
map: Maplibre,
specification: LineLayerSpecification,
Expand Down Expand Up @@ -90,16 +94,12 @@ export const updateLineLayer = (
return lineLayerId;
};

export interface CircleLayerSpecification {
sourceId: string;
export interface CircleLayerSpecification extends Layer {
visibility: string;
fillColor: string;
outlineColor: string;
radius: number;
opacity: number;
width: number;
minZoom: number;
maxZoom: number;
}

export const addCircleLayer = (
Expand Down Expand Up @@ -137,15 +137,11 @@ export const updateCircleLayer = (
return circleLayerId;
};

export interface PolygonLayerSpecification {
sourceId: string;
export interface PolygonLayerSpecification extends Layer {
visibility: string;
fillColor: string;
outlineColor: string;
opacity: number;
width: number;
minZoom: number;
maxZoom: number;
}

export const addPolygonLayer = (
Expand Down