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

fix(landing): disable scale control for NZTM as it is wrong BM-394 #3101

Merged
merged 1 commit into from
Jan 25, 2024
Merged
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
28 changes: 24 additions & 4 deletions packages/landing/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
/** Ignore the location updates */
ignoreNextLocationUpdate = false;

controlScale?: maplibre.ScaleControl | null;
controlGeo?: maplibregl.GeolocateControl | null;

updateLocation = (): void => {
Expand Down Expand Up @@ -80,15 +81,34 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
this.map.removeControl(this.controlGeo);
}
}
/**
* Only show the scale on GoogleTMS
* As it does not work with the projection logic we are currently using
*/
ensureScaleControl(): void {
if (Config.map.debug['debug.screenshot']) return;
if (Config.map.tileMatrix === GoogleTms) {
if (this.controlScale != null) return;
this.controlScale = new maplibre.ScaleControl({});
this.map.addControl(this.controlScale, 'bottom-right');
} else {
if (this.controlScale == null) return;
this.map.removeControl(this.controlScale);
}
}

updateStyle = (): void => {
this.ensureGeoControl();
this.ensureScaleControl();
const tileGrid = getTileGrid(Config.map.tileMatrix.identifier);
const style = tileGrid.getStyle(Config.map.layerId, Config.map.style, undefined, Config.map.filter.date);
this.map.setStyle(style);

if (Config.map.tileMatrix !== GoogleTms) this.map.setMaxBounds([-179.9, -85, 179.9, 85]);
else this.map.setMaxBounds();
if (Config.map.tileMatrix !== GoogleTms) {
this.map.setMaxBounds([-179.9, -85, 179.9, 85]);
} else {
this.map.setMaxBounds();
}
// TODO check and only update when Config.map.layer changes.
this.forceUpdate();
};
Expand Down Expand Up @@ -169,8 +189,8 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
this.map.addControl(nav, 'top-left');
if (!Config.map.isDebug) this.map.addControl(new maplibre.FullscreenControl({ container: this.el }));

const scale = new maplibre.ScaleControl({});
this.map.addControl(scale, 'bottom-right');
this.controlScale = new maplibre.ScaleControl({});
this.map.addControl(this.controlScale, 'bottom-right');
}

this.map.on('render', this.onRender);
Expand Down
Loading