Skip to content

Commit

Permalink
fix(landing): locate button does not work in nztm so disable it (#2140)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha authored Apr 5, 2022
1 parent 293a14b commit 957b612
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/landing/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
/** Ignore the location updates */
ignoreNextLocationUpdate = false;

controlGeo: maplibre.GeolocateControl | null;

updateLocation = (): void => {
if (this.ignoreNextLocationUpdate) {
this.ignoreNextLocationUpdate = false;
Expand Down Expand Up @@ -51,7 +53,23 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
this.map.fitBounds(bounds);
};

/**
* Only show the geocontrol on GoogleTMS
* As it does not work with the projection logic we are currently using
*/
ensureGeoControl(): void {
if (Config.map.tileMatrix === GoogleTms) {
if (this.controlGeo != null) return;
this.controlGeo = new maplibre.GeolocateControl({});
this.map.addControl(this.controlGeo);
} else {
if (this.controlGeo == null) return;
this.map.removeControl(this.controlGeo);
}
}

updateStyle = (): void => {
this.ensureGeoControl();
const tileGrid = getTileGrid(Config.map.tileMatrix.identifier);
const style = tileGrid.getStyle(Config.map.layerId, Config.map.style);
this.map.setStyle(style);
Expand Down Expand Up @@ -89,7 +107,6 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
const nav = new maplibre.NavigationControl({ visualizePitch: true });
this.map.addControl(nav, 'top-left');

this.map.addControl(new maplibre.GeolocateControl({}));
this.map.addControl(new maplibre.FullscreenControl({ container: this.el }));

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

0 comments on commit 957b612

Please sign in to comment.