From 41ee3a7e58131f641456aeb3ff035d07102a857f Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 24 Jun 2021 02:34:13 +0200 Subject: [PATCH] Formatting --- UI/ShowDataLayer.ts | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/UI/ShowDataLayer.ts b/UI/ShowDataLayer.ts index cb48a10fb7..6aa8407c90 100644 --- a/UI/ShowDataLayer.ts +++ b/UI/ShowDataLayer.ts @@ -16,12 +16,12 @@ export default class ShowDataLayer { private readonly _leafletMap: UIEventSource; private _cleanCount = 0; private readonly _enablePopups: boolean; - private readonly _features : UIEventSource<{ feature: any, freshness: Date }[]> + private readonly _features: UIEventSource<{ feature: any, freshness: Date }[]> constructor(features: UIEventSource<{ feature: any, freshness: Date }[]>, leafletMap: UIEventSource, layoutToUse: UIEventSource, - enablePopups= true, + enablePopups = true, zoomToFeatures = false) { this._leafletMap = leafletMap; this._enablePopups = enablePopups; @@ -46,7 +46,7 @@ export default class ShowDataLayer { } const mp = leafletMap.data; - if(mp === undefined){ + if (mp === undefined) { return; } @@ -75,11 +75,11 @@ export default class ShowDataLayer { mp.addLayer(geoLayer) } - if(zoomToFeatures){ + if (zoomToFeatures) { mp.fitBounds(geoLayer.getBounds()) } - - + + State.state.selectedElement.ping(); } @@ -89,7 +89,6 @@ export default class ShowDataLayer { } - private createStyleFor(feature) { const tagsSource = State.state.allElements.addOrGetElement(feature); // Every object is tied to exactly one layer @@ -111,7 +110,7 @@ export default class ShowDataLayer { const style = layer.GenerateLeafletStyle(tagSource, !(layer.title === undefined && (layer.tagRenderings ?? []).length === 0)); const baseElement = style.icon.html; - if(!this._enablePopups){ + if (!this._enablePopups) { baseElement.SetStyle("cursor: initial !important") } return L.marker(latLng, { @@ -137,7 +136,7 @@ export default class ShowDataLayer { // or probably a map in the popup - no popups needed! return; } - + const popup = L.popup({ autoPan: true, closeOnEscapeKey: true, @@ -180,25 +179,25 @@ export default class ShowDataLayer { if (selected.properties.id === feature.properties.id) { // A small sanity check to prevent infinite loops: // If a feature is rendered both as way and as point, opening one popup might trigger the other to open, which might trigger the one to open again - if(selected.geometry.type === feature.geometry.type){ - leafletLayer.openPopup() + if (selected.geometry.type === feature.geometry.type) { + leafletLayer.openPopup() } - + } }) } private CreateGeojsonLayer(): L.Layer { - const self = this; - const data = { - type: "FeatureCollection", - features: [] - } - // @ts-ignore - return L.geoJSON(data, { - style: feature => self.createStyleFor(feature), - pointToLayer: (feature, latLng) => self.pointToLayer(feature, latLng), + const self = this; + const data = { + type: "FeatureCollection", + features: [] + } + // @ts-ignore + return L.geoJSON(data, { + style: feature => self.createStyleFor(feature), + pointToLayer: (feature, latLng) => self.pointToLayer(feature, latLng), onEachFeature: (feature, leafletLayer) => self.postProcessFeature(feature, leafletLayer) });