From a3185f2d13c7df9f0959b9558a1915df35fa75ce Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 3 Dec 2021 01:29:09 +0100 Subject: [PATCH] Move SPlit-points to seperate layer; fix rendering bug on minimaps --- Customizations/AllKnownLayers.ts | 2 +- Models/ThemeConfig/PointRenderingConfig.ts | 2 +- UI/Popup/SplitRoadWizard.ts | 37 ++++++++-------------- assets/layers/split_point/split_point.json | 20 ++++++++++++ 4 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 assets/layers/split_point/split_point.json diff --git a/Customizations/AllKnownLayers.ts b/Customizations/AllKnownLayers.ts index 8e00fef45..b85b2dccd 100644 --- a/Customizations/AllKnownLayers.ts +++ b/Customizations/AllKnownLayers.ts @@ -20,7 +20,7 @@ export default class AllKnownLayers { public static added_by_default: string[] = ["gps_location", "gps_location_history", "home_location", "gps_track",] - public static no_include: string[] = ["conflation", "left_right_style"] + public static no_include: string[] = ["conflation", "left_right_style", "split_point"] /** * Layer IDs of layers which have special properties through built-in hooks */ diff --git a/Models/ThemeConfig/PointRenderingConfig.ts b/Models/ThemeConfig/PointRenderingConfig.ts index 38ece18fc..a60bc10a5 100644 --- a/Models/ThemeConfig/PointRenderingConfig.ts +++ b/Models/ThemeConfig/PointRenderingConfig.ts @@ -217,7 +217,7 @@ export default class PointRenderingConfig extends WithContextLoader { }else if(icon === undefined){ htmlEl = label }else if(label === undefined){ - htmlEl = iconAndBadges + htmlEl = new Combine([iconAndBadges]).SetStyle("flex flex-col") }else { htmlEl = new Combine([iconAndBadges, label]).SetStyle("flex flex-col") } diff --git a/UI/Popup/SplitRoadWizard.ts b/UI/Popup/SplitRoadWizard.ts index 7a534ca8b..71c4c1fec 100644 --- a/UI/Popup/SplitRoadWizard.ts +++ b/UI/Popup/SplitRoadWizard.ts @@ -16,19 +16,10 @@ import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeature import ShowDataMultiLayer from "../ShowDataLayer/ShowDataMultiLayer"; import LayerConfig from "../../Models/ThemeConfig/LayerConfig"; import {BBox} from "../../Logic/BBox"; - +import * as split_point from "../../assets/layers/split_point/split_point.json" export default class SplitRoadWizard extends Toggle { - private static splitLayerStyling = new LayerConfig({ - id: "splitpositions", - source: {osmTags: "_cutposition=yes"}, - mapRendering: [ - { - location: ["point", "centroid"], - icon: {render: "circle:white;./assets/svg/scissors.svg"}, - iconSize: {render: "30,30,center"} - } - ], - }, "(BUILTIN) SplitRoadWizard.ts", true) + // @ts-ignore + private static splitLayerStyling = new LayerConfig(split_point, "(BUILTIN) SplitRoadWizard.ts", true) public dialogIsOpened: UIEventSource @@ -68,14 +59,6 @@ export default class SplitRoadWizard extends Toggle { // Define how a cut is displayed on the map // Datalayer displaying the road and the cut points (if any) - new ShowDataLayer({ - features: new StaticFeatureSource(splitPoints, true), - leafletMap: miniMap.leafletMap, - zoomToFeatures: false, - enablePopups: false, - layerToShow: SplitRoadWizard.splitLayerStyling, - }) - new ShowDataMultiLayer({ features: new StaticFeatureSource([roadElement], false), layers: State.state.filteredLayers, @@ -84,6 +67,16 @@ export default class SplitRoadWizard extends Toggle { zoomToFeatures: true, allElements: State.state.allElements, }) + + new ShowDataLayer({ + features: new StaticFeatureSource(splitPoints, true), + leafletMap: miniMap.leafletMap, + zoomToFeatures: false, + enablePopups: false, + layerToShow: SplitRoadWizard.splitLayerStyling, + }) + + /** * Handles a click on the overleaf map. @@ -109,10 +102,8 @@ export default class SplitRoadWizard extends Toggle { const pointOnRoad = GeoOperations.nearestPoint(roadElement, coordinates); // pointOnRoad is a geojson // Update point properties to let it match the layer - pointOnRoad.properties._cutposition = "yes"; + pointOnRoad.properties["_split_point"] = "yes"; - // let the state remember the point, to be able to retrieve it later by id - State.state.allElements.addOrGetElement(pointOnRoad); // Add it to the list of all points and notify observers splitPoints.data.push({feature: pointOnRoad, freshness: new Date()}); // show the point on the data layer diff --git a/assets/layers/split_point/split_point.json b/assets/layers/split_point/split_point.json new file mode 100644 index 000000000..d7c971986 --- /dev/null +++ b/assets/layers/split_point/split_point.json @@ -0,0 +1,20 @@ +{ + "id": "split_point", + "description": "Layer rendering the little scissors for the minimap in the 'splitRoadWizard'", + "minzoom": 1, + "source": { + "osmTags": "_split_point=yes" + }, + "name": "Split point", + "title": "Split point", + "mapRendering": [ + { + "location": [ + "point", + "centroid" + ], + "icon": "circle:white;./assets/svg/scissors.svg", + "iconSize": "30,30,center" + } + ] +} \ No newline at end of file