From f5b2ba6a062d60d4460f47b897e1bd4988d40da9 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 18 Sep 2020 12:00:38 +0200 Subject: [PATCH] Fix the broken initial location --- Logic/FilteredLayer.ts | 9 +++++++-- Logic/UIEventSource.ts | 10 ++++++---- State.ts | 9 +++++---- index.ts | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Logic/FilteredLayer.ts b/Logic/FilteredLayer.ts index acc72d2..ba994b9 100644 --- a/Logic/FilteredLayer.ts +++ b/Logic/FilteredLayer.ts @@ -257,9 +257,14 @@ export class FilteredLayer { // We monky-patch the feature element with an update-style feature.updateStyle = () => { if (layer.setIcon) { - const icon = self._style(feature.properties).icon; + const style = self._style(feature.properties); + const icon = style.icon; if (icon.iconUrl) { - layer.setIcon(L.icon(icon)) + if (icon.iconUrl.startsWith("$circle")) { + // pass + } else { + layer.setIcon(L.icon(icon)) + } } } else { self._geolayer.setStyle(function (featureX) { diff --git a/Logic/UIEventSource.ts b/Logic/UIEventSource.ts index 20df0ed..58eb8c1 100644 --- a/Logic/UIEventSource.ts +++ b/Logic/UIEventSource.ts @@ -77,13 +77,15 @@ export class UIEventSource{ } - public syncWith(otherSource: UIEventSource) : UIEventSource{ + public syncWith(otherSource: UIEventSource, reverseOverride = false): UIEventSource { this.addCallback((latest) => otherSource.setData(latest)); const self = this; otherSource.addCallback((latest) => self.setData(latest)); - if(this.data === undefined){ - this.setData(otherSource.data); - }else{ + if (reverseOverride && otherSource.data !== undefined) { + this.setData(otherSource.data); + } else if (this.data === undefined) { + this.setData(otherSource.data); + } else { otherSource.setData(this.data); } return this; diff --git a/State.ts b/State.ts index 5be3ca5..52a9ddf 100644 --- a/State.ts +++ b/State.ts @@ -134,12 +134,13 @@ export class State { }) } - this.zoom = asFloat(QueryParameters.GetQueryParameter("z", "" + layoutToUse.startzoom) - .syncWith(LocalStorageSource.Get("zoom"))); + this.zoom = asFloat( + QueryParameters.GetQueryParameter("z", "" + layoutToUse.startzoom) + .syncWith(LocalStorageSource.Get("zoom"), true)); this.lat = asFloat(QueryParameters.GetQueryParameter("lat", "" + layoutToUse.startLat) - .syncWith(LocalStorageSource.Get("lat"))); + .syncWith(LocalStorageSource.Get("lat"), true)); this.lon = asFloat(QueryParameters.GetQueryParameter("lon", "" + layoutToUse.startLon) - .syncWith(LocalStorageSource.Get("lon"))); + .syncWith(LocalStorageSource.Get("lon"), true)); this.locationControl = new UIEventSource<{ lat: number, lon: number, zoom: number }>({ diff --git a/index.ts b/index.ts index 28f7dbb..acfd944 100644 --- a/index.ts +++ b/index.ts @@ -36,7 +36,7 @@ if (location.hostname === "localhost" || location.hostname === "127.0.0.1") { // ----------------- SELECT THE RIGHT QUESTSET ----------------- -let defaultLayout = "bookcases" +let defaultLayout = "buurtnatuur" const path = window.location.pathname.split("/").slice(-1)[0]; if (path !== "index.html" && path !== "") {