Actually change basemap when the UIEVentsource is changed

This commit is contained in:
Pieter Vander Vennet 2020-07-22 15:17:29 +02:00
parent db9ac0eaf0
commit 084a1d0c49
2 changed files with 13 additions and 10 deletions

View file

@ -50,6 +50,7 @@ export class Basemap {
public Location: UIEventSource<{ zoom: number, lat: number, lon: number }>; public Location: UIEventSource<{ zoom: number, lat: number, lon: number }>;
public LastClickLocation: UIEventSource<{ lat: number, lon: number }> = new UIEventSource<{ lat: number, lon: number }>(undefined) public LastClickLocation: UIEventSource<{ lat: number, lon: number }> = new UIEventSource<{ lat: number, lon: number }>(undefined)
private _previousLayer : L.tileLayer= undefined;
public CurrentLayer: UIEventSource<{ public CurrentLayer: UIEventSource<{
name: string, name: string,
layer: L.tileLayer layer: L.tileLayer
@ -66,6 +67,8 @@ export class Basemap {
zoom: location.data.zoom, zoom: location.data.zoom,
layers: [BaseLayers.defaultLayer], layers: [BaseLayers.defaultLayer],
}); });
this.map.attributionControl.setPrefix( this.map.attributionControl.setPrefix(
extraAttribution.Render() + " | <a href='https://osm.org'>OpenStreetMap</a>"); extraAttribution.Render() + " | <a href='https://osm.org'>OpenStreetMap</a>");
this.Location = location; this.Location = location;
@ -81,6 +84,14 @@ export class Basemap {
location.ping(); location.ping();
}); });
this.CurrentLayer.addCallback((layer:{layer: L.tileLayer}) => {
if(self._previousLayer !== undefined){
self.map.removeLayer(self._previousLayer);
}
self._previousLayer = layer.layer;
self.map.addLayer(layer.layer);
});
this.map.on("click", function (e) { this.map.on("click", function (e) {
self.LastClickLocation.setData({lat: e.latlng.lat, lon: e.latlng.lng}) self.LastClickLocation.setData({lat: e.latlng.lat, lon: e.latlng.lng})
}); });

View file

@ -3,7 +3,7 @@ import {Changes} from "./Logic/Changes";
import {ElementStorage} from "./Logic/ElementStorage"; import {ElementStorage} from "./Logic/ElementStorage";
import {UIEventSource} from "./UI/UIEventSource"; import {UIEventSource} from "./UI/UIEventSource";
import {UserBadge} from "./UI/UserBadge"; import {UserBadge} from "./UI/UserBadge";
import {Basemap} from "./Logic/Basemap"; import {BaseLayers, Basemap} from "./Logic/Basemap";
import {PendingChanges} from "./UI/PendingChanges"; import {PendingChanges} from "./UI/PendingChanges";
import {CenterMessageBox} from "./UI/CenterMessageBox"; import {CenterMessageBox} from "./UI/CenterMessageBox";
import {Helpers} from "./Helpers"; import {Helpers} from "./Helpers";
@ -12,7 +12,6 @@ import {FilteredLayer} from "./Logic/FilteredLayer";
import {LayerUpdater} from "./Logic/LayerUpdater"; import {LayerUpdater} from "./Logic/LayerUpdater";
import {UIElement} from "./UI/UIElement"; import {UIElement} from "./UI/UIElement";
import {FullScreenMessageBoxHandler} from "./UI/FullScreenMessageBoxHandler"; import {FullScreenMessageBoxHandler} from "./UI/FullScreenMessageBoxHandler";
import {Overpass} from "./Logic/Overpass";
import {FeatureInfoBox} from "./UI/FeatureInfoBox"; import {FeatureInfoBox} from "./UI/FeatureInfoBox";
import {GeoLocationHandler} from "./Logic/GeoLocationHandler"; import {GeoLocationHandler} from "./Logic/GeoLocationHandler";
import {StrayClickHandler} from "./Logic/StrayClickHandler"; import {StrayClickHandler} from "./Logic/StrayClickHandler";
@ -21,18 +20,12 @@ import {VariableUiElement} from "./UI/Base/VariableUIElement";
import {SearchAndGo} from "./UI/SearchAndGo"; import {SearchAndGo} from "./UI/SearchAndGo";
import {CollapseButton} from "./UI/Base/CollapseButton"; import {CollapseButton} from "./UI/Base/CollapseButton";
import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; import {AllKnownLayouts} from "./Customizations/AllKnownLayouts";
import { All } from "./Customizations/Layouts/All";
import {CheckBox} from "./UI/Base/CheckBox"; import {CheckBox} from "./UI/Base/CheckBox";
import { DrinkingWater } from "./Customizations/Layers/DrinkingWater";
import Translations from "./UI/i18n/Translations"; import Translations from "./UI/i18n/Translations";
import Translation from "./UI/i18n/Translation";
import Locale from "./UI/i18n/Locale"; import Locale from "./UI/i18n/Locale";
import {Layout, WelcomeMessage} from "./Customizations/Layout"; import {Layout, WelcomeMessage} from "./Customizations/Layout";
import {DropDown} from "./UI/Input/DropDown"; import {DropDown} from "./UI/Input/DropDown";
import {FixedInputElement} from "./UI/Input/FixedInputElement";
import {FixedUiElement} from "./UI/Base/FixedUiElement"; import {FixedUiElement} from "./UI/Base/FixedUiElement";
import ParkingType from "./Customizations/Questions/bike/ParkingType";
import { LayerDefinition } from "./Customizations/LayerDefinition";
import {LayerSelection} from "./UI/LayerSelection"; import {LayerSelection} from "./UI/LayerSelection";
import Combine from "./UI/Base/Combine"; import Combine from "./UI/Base/Combine";
@ -334,4 +327,3 @@ const openFilterButton = `
new CheckBox(new Combine([new LayerSelection(flayers), openFilterButton]), closedFilterButton).AttachTo("filter__selection") new CheckBox(new Combine([new LayerSelection(flayers), openFilterButton]), closedFilterButton).AttachTo("filter__selection")