forked from MapComplete/MapComplete
		
	Fix dynamically selecting the popup when changing the hash
This commit is contained in:
		
							parent
							
								
									162ab325f9
								
							
						
					
					
						commit
						df92bda151
					
				
					 2 changed files with 18 additions and 10 deletions
				
			
		| 
						 | 
					@ -90,12 +90,12 @@ export default class SelectedFeatureHandler {
 | 
				
			||||||
            if (feature === undefined) {
 | 
					            if (feature === undefined) {
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            const currentlySeleced = state.selectedElement.data
 | 
					            const currentlySelected = state.selectedElement.data
 | 
				
			||||||
            if (currentlySeleced === undefined) {
 | 
					            if (currentlySelected === undefined) {
 | 
				
			||||||
                state.selectedElement.setData(feature)
 | 
					                state.selectedElement.setData(feature)
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (currentlySeleced.properties?.id === feature.properties.id) {
 | 
					            if (currentlySelected.properties?.id === feature.properties.id) {
 | 
				
			||||||
                // We already have the right feature
 | 
					                // We already have the right feature
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -136,7 +136,7 @@ export default class ShowDataLayerImplementation {
 | 
				
			||||||
        if (this._leafletMap.data === undefined) {
 | 
					        if (this._leafletMap.data === undefined) {
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const v = this.leafletLayersPerId.get(selected.properties.id + selected.geometry.type)
 | 
					        const v = this.leafletLayersPerId.get(selected.properties.id)
 | 
				
			||||||
        if (v === undefined) {
 | 
					        if (v === undefined) {
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -335,7 +335,20 @@ export default class ShowDataLayerImplementation {
 | 
				
			||||||
            icon: L.divIcon(style),
 | 
					            icon: L.divIcon(style),
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Creates a function which, for the given feature, will open the featureInfoBox (and lazyly create it)
 | 
				
			||||||
 | 
					     * This function is cached
 | 
				
			||||||
 | 
					     * @param feature
 | 
				
			||||||
 | 
					     * @param key
 | 
				
			||||||
 | 
					     * @param layer
 | 
				
			||||||
 | 
					     * @private
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    private createActivateFunction(feature, key: string, layer: LayerConfig): (event) => void {
 | 
					    private createActivateFunction(feature, key: string, layer: LayerConfig): (event) => void {
 | 
				
			||||||
 | 
					        if (this.leafletLayersPerId.has(key)) {
 | 
				
			||||||
 | 
					            return this.leafletLayersPerId.get(key).activateFunc
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let infobox: ScrollableFullScreen = undefined
 | 
					        let infobox: ScrollableFullScreen = undefined
 | 
				
			||||||
        const self = this
 | 
					        const self = this
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -373,12 +386,7 @@ export default class ShowDataLayerImplementation {
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const key = feature.properties.id
 | 
					        const key = feature.properties.id
 | 
				
			||||||
        let activate: (event) => void
 | 
					        const activate = this.createActivateFunction(feature, key, layer)
 | 
				
			||||||
        if (this.leafletLayersPerId.has(key)) {
 | 
					 | 
				
			||||||
            activate = this.leafletLayersPerId.get(key).activateFunc
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            activate = this.createActivateFunction(feature, key, layer)
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // We also have to open on rightclick, doubleclick, ... as users sometimes do this. See #1219
 | 
					        // We also have to open on rightclick, doubleclick, ... as users sometimes do this. See #1219
 | 
				
			||||||
        leafletLayer.on({
 | 
					        leafletLayer.on({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue