start layer dropdown

This commit is contained in:
Bavo Vanderghote 2020-07-22 15:45:26 +02:00
commit 6c7e09b8c8
2 changed files with 20 additions and 9 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,11 @@ 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";
<<<<<<< HEAD
import {Basemap, BaseLayers} from "./Logic/Basemap"; import {Basemap, BaseLayers} from "./Logic/Basemap";
=======
import {BaseLayers, Basemap} from "./Logic/Basemap";
>>>>>>> 084a1d0c499c2d747ac5441aa8a6ce74f49ecf09
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 +16,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 +24,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,6 +331,7 @@ 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")
<<<<<<< HEAD
// --------------- Setting up basemap dropdown -------- // --------------- Setting up basemap dropdown --------
let baseLayerOptions = []; let baseLayerOptions = [];
@ -347,3 +345,5 @@ console.log(bm.CurrentLayer.data);
new DropDown(`label`, baseLayerOptions, bm.CurrentLayer).AttachTo("filter__selection"); new DropDown(`label`, baseLayerOptions, bm.CurrentLayer).AttachTo("filter__selection");
=======
>>>>>>> 084a1d0c499c2d747ac5441aa8a6ce74f49ecf09