First working version of split road functionality

This commit is contained in:
Pieter Vander Vennet 2021-07-18 21:37:14 +02:00
parent 61f2ebf9ba
commit 248ea78b17
11 changed files with 88 additions and 66 deletions

View file

@ -23,7 +23,7 @@ export default class ShowDataLayer {
layoutToUse: UIEventSource<LayoutConfig>,
enablePopups = true,
zoomToFeatures = false,
name?:string) {
name?: string) {
this._leafletMap = leafletMap;
this._enablePopups = enablePopups;
this._features = features;
@ -130,6 +130,7 @@ export default class ShowDataLayer {
})
});
}
private postProcessFeature(feature, leafletLayer: L.Layer) {
const layer: LayerConfig = this._layerDict[feature._matching_layer_id];
if (layer === undefined) {
@ -157,7 +158,7 @@ export default class ShowDataLayer {
leafletLayer.on("popupopen", () => {
State.state.selectedElement.setData(feature)
if (infobox === undefined) {
const tags = State.state.allElements.getEventSourceById(feature.properties.id);
infobox = new FeatureInfoBox(tags, layer);
@ -172,7 +173,7 @@ export default class ShowDataLayer {
infobox.AttachTo(id)
infobox.Activate();
infobox.Activate();
});
const self = this;
State.state.selectedElement.addCallbackAndRunD(selected => {
@ -185,11 +186,13 @@ export default class ShowDataLayer {
if (selected.properties.id === feature.properties.id) {
// A small sanity check to prevent infinite loops:
if (selected.geometry.type === feature.geometry.type // 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
&& feature.id === feature.properties.id // the feature might have as id 'node/-1' and as 'feature.properties.id' = 'the newly assigned id'. That is no good too
) {
&& feature.id === feature.properties.id // the feature might have as id 'node/-1' and as 'feature.properties.id' = 'the newly assigned id'. That is no good too
) {
leafletLayer.openPopup()
}
if(feature.id !== feature.properties.id){
console.log("Not opening the popup for", feature)
}
}
})