Skip to content

Commit

Permalink
Add separate opacity control for MapGuide Base Layers. This setting w…
Browse files Browse the repository at this point in the history
…as previously lumped together with the main MG dynamic overlay

Fixes #1426
  • Loading branch information
jumpinjackie committed Apr 21, 2023
1 parent 42cde4d commit 44386d7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/api/layer-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Geometry from 'ol/geom/Geometry';
import UrlTile from 'ol/source/UrlTile';
import { LoadFunction as TileLoadFunction } from 'ol/Tile';
import { MapGuideMockMode } from '../components/mapguide-debug-context';
import { BLANK_GIF_DATA_URI, LAYER_ID_BASE, LAYER_ID_MG_BASE, LAYER_ID_MG_SEL_OVERLAY } from '../constants';
import { BLANK_GIF_DATA_URI, LAYER_ID_BASE, LAYER_ID_MG_BASE, LAYER_ID_MG_DYNAMIC_OVERLAY, LAYER_ID_MG_SEL_OVERLAY } from '../constants';
import { OLImageLayer, OLTileLayer } from './ol-types';
import { IGenericSubjectMapLayer } from '../actions/defs';
import { GenericLayerSetOL } from './generic-layer-set';
Expand Down Expand Up @@ -321,14 +321,19 @@ export class MgLayerSetOL implements ILayerSetOL {
}
}

if (LAYER_ID_MG_DYNAMIC_OVERLAY in trans) {
const opacity = restrictToRange(trans[LAYER_ID_MG_DYNAMIC_OVERLAY], 0, 1.0);
this.overlay.setOpacity(opacity);
} else {
this.overlay.setOpacity(1.0);
}

if (LAYER_ID_MG_BASE in trans) {
const opacity = restrictToRange(trans[LAYER_ID_MG_BASE], 0, 1.0);
this.overlay.setOpacity(opacity);
for (const group of this.mgTiledLayers) {
group.setOpacity(opacity);
}
} else {
this.overlay.setOpacity(1.0);
for (const group of this.mgTiledLayers) {
group.setOpacity(1.0);
}
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const FUSION_REDLINE_NAME = "Redline";

export const LAYER_ID_BASE = "LAYER_ID_BASE";
export const LAYER_ID_MG_BASE = "LAYER_ID_MG_BASE";
/**
* @since 0.14.8
*/
export const LAYER_ID_MG_DYNAMIC_OVERLAY = "LAYER_ID_MG_DYNAMIC_OVERLAY";
export const LAYER_ID_MG_SEL_OVERLAY = "LAYER_ID_MG_SEL_OVERLAY";

export const BLANK_GIF_DATA_URI = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
20 changes: 18 additions & 2 deletions src/containers/viewer-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Slider, HTMLSelect } from '@blueprintjs/core';
import { useActiveMapName, useViewerFeatureTooltipsEnabled, useConfiguredManualFeatureTooltips, useViewerSizeUnits, useViewerLocale, useActiveMapExternalBaseLayers, useViewerIsStateless, useViewerSelectCanDragPan } from './hooks';
import { setManualFeatureTooltipsEnabled, setFeatureTooltipsEnabled, setLayerTransparency, setViewSizeUnits, enableSelectDragPan } from '../actions/map';
import { useActiveMapLayerTransparency, useActiveMapState } from './hooks-mapguide';
import { LAYER_ID_BASE, LAYER_ID_MG_BASE, LAYER_ID_MG_SEL_OVERLAY } from '../constants';
import { LAYER_ID_BASE, LAYER_ID_MG_BASE, LAYER_ID_MG_DYNAMIC_OVERLAY, LAYER_ID_MG_SEL_OVERLAY } from '../constants';
import { useReduxDispatch } from "../components/map-providers/context";
import { isRuntimeMap } from "../utils/type-guards";

Expand Down Expand Up @@ -42,6 +42,9 @@ export const ViewerOptions = () => {
const onBaseOpacityChanged = (value: number) => {
onMgLayerOpacityChanged(mapName, LAYER_ID_BASE, value);
};
const onMgDynamicOverlayOpacityChanged = (value: number) => {
onMgLayerOpacityChanged(mapName, LAYER_ID_MG_DYNAMIC_OVERLAY, value);
}
const onMgOpacityChanged = (value: number) => {
onMgLayerOpacityChanged(mapName, LAYER_ID_MG_BASE, value);
};
Expand All @@ -64,20 +67,27 @@ export const ViewerOptions = () => {
let opBase = 1.0;
let opMgBase = 1.0;
let opMgSelOverlay = 1.0;
let opMgDynamicOverlay = 1.0;
if (layerTransparency) {
if (LAYER_ID_BASE in layerTransparency) {
opBase = layerTransparency[LAYER_ID_BASE];
}
if (LAYER_ID_MG_BASE in layerTransparency) {
opMgBase = layerTransparency[LAYER_ID_MG_BASE];
}
if (LAYER_ID_MG_DYNAMIC_OVERLAY in layerTransparency) {
opMgDynamicOverlay = layerTransparency[LAYER_ID_MG_DYNAMIC_OVERLAY];
}
if (LAYER_ID_MG_SEL_OVERLAY in layerTransparency) {
opMgSelOverlay = layerTransparency[LAYER_ID_MG_SEL_OVERLAY];
}
}
let hasMgBaseLayers = false;
let isStateless = stateless;
if (!map) {
isStateless = true;
} else {
hasMgBaseLayers = (map.FiniteDisplayScale?.length ?? 0) > 0;
}
return <div className="component-viewer-options">
<h5>{tr("VIEWER_OPTIONS", locale)}</h5>
Expand Down Expand Up @@ -113,10 +123,16 @@ export const ViewerOptions = () => {
</label>;
}
})()}
{hasMgBaseLayers && <label className="bp3-label noselect">
{tr("LAYER_ID_MG_BASE_LAYERS", locale)}
<div style={{ paddingLeft: 8, paddingRight: 8 }}>
<Slider min={0} max={1.0} stepSize={0.01} value={opMgBase} onChange={onMgOpacityChanged} />
</div>
</label>}
<label className="bp3-label noselect">
{map ? tr("LAYER_ID_MG_BASE", locale) : tr("LAYER_ID_SUBJECT", locale)}
<div style={{ paddingLeft: 8, paddingRight: 8 }}>
<Slider min={0} max={1.0} stepSize={0.01} value={opMgBase} onChange={onMgOpacityChanged} />
<Slider min={0} max={1.0} stepSize={0.01} value={opMgDynamicOverlay} onChange={onMgDynamicOverlayOpacityChanged} />
</div>
</label>
{!isStateless && <label className="bp3-label noselect">
Expand Down
1 change: 1 addition & 0 deletions src/strings/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const STRINGS_EN: ILocalizedMessages = {
"LAYER_ID_MG_BASE": "MapGuide Map",
"LAYER_ID_SUBJECT": "Subject Layer",
"LAYER_ID_MG_SEL_OVERLAY": "MapGuide Selection Overlay",
"LAYER_ID_MG_BASE_LAYERS": "MapGuide Base Layers",
"UNKNOWN_WIDGET": "This button references an unknown or unsupported widget: {widget}",
"UNKNOWN_COMMAND_REFERENCE": "This button references an unknown command or unsupported: {command}",
"INIT": "Initializing",
Expand Down
1 change: 1 addition & 0 deletions src/strings/msgdef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface ILocalizedMessages {
LAYER_ID_MG_BASE: string;
LAYER_ID_SUBJECT: string;
LAYER_ID_MG_SEL_OVERLAY: string;
LAYER_ID_MG_BASE_LAYERS: string;
UNKNOWN_WIDGET: string;
UNKNOWN_COMMAND_REFERENCE: string;
INIT: string;
Expand Down
1 change: 1 addition & 0 deletions viewer/strings/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"LAYER_ID_BASE": "Grundschicht",
"LAYER_ID_MG_BASE": "MapGuide Karte",
"LAYER_ID_MG_SEL_OVERLAY": "MapGuide Selection Overlay",
"LAYER_ID_MG_BASE_LAYERS": "MapGuide-Basislayer",
"UNKNOWN_WIDGET": "Diese Schaltfläche verweist auf einen unbekannten oder nicht unterstützten Widget: {widget}",
"UNKNOWN_COMMAND_REFERENCE": "Diese Schaltfläche verweist auf einen unbekannten Befehl oder nicht unterstützt: {command}",
"INIT": "Initialisierung",
Expand Down

0 comments on commit 44386d7

Please sign in to comment.