UX: attempt to fix #2394

This commit is contained in:
Pieter Vander Vennet 2025-05-04 02:37:57 +02:00
parent 4604fc62e5
commit 156493ef06
6 changed files with 31 additions and 25 deletions

View file

@ -277,7 +277,7 @@ class LineRenderingLayer {
updateNeededSrc.set(false)
}
})
features.features.addCallbackAndRunD(() => {
features.features.addCallbackAndRunD(async (feats) => {
console.log("New features!", this._layername, features.features.data.length)
updateNeededSrc.set(true)
})
@ -377,6 +377,7 @@ class LineRenderingLayer {
private async update(features: Feature[]) {
const map = this._map
await this.awaitStyleLoaded()
const src = <GeoJSONSource>map.getSource(this._layername)
{
// Add source to the map or update the feature source
@ -550,7 +551,7 @@ export default class ShowDataLayer {
options: ShowDataLayerOptions & {
layer: LayerConfig
drawMarkers?: true | boolean
drawLines?: true | boolean
drawLines?: true | boolean,
}
) {
this._options = options
@ -626,23 +627,20 @@ export default class ShowDataLayer {
}
private initDrawFeatures(map: MlMap) {
const { features, doShowLayer, fetchStore, selectedElement } = this._options
const { features, doShowLayer, fetchStore, selectedElement, layer, drawLines, drawMarkers } = this._options
let onClick = this._options.onClick
if (!onClick && selectedElement) {
onClick =
this._options.layer.title === undefined
? undefined
: (feature: Feature) => {
selectedElement?.setData(feature)
}
if (!onClick && selectedElement && layer.title !== undefined) {
onClick = (feature: Feature) => {
selectedElement?.setData(feature)
}
}
if (this._options.drawLines !== false) {
for (let i = 0; i < this._options.layer.lineRendering.length; i++) {
const lineRenderingConfig = this._options.layer.lineRendering[i]
if (drawLines !== false) {
for (let i = 0; i < layer.lineRendering.length; i++) {
const lineRenderingConfig = layer.lineRendering[i]
const l = new LineRenderingLayer(
map,
features,
"mapcomplete_" + this._options.layer.id + "_linerendering_" + i,
"mapcomplete_" + (this._options.prefix ?? "") + layer.id + "_linerendering_" + i,
lineRenderingConfig,
doShowLayer,
fetchStore,
@ -651,11 +649,11 @@ export default class ShowDataLayer {
this.onDestroy.push(l.destruct)
}
}
if (this._options.drawMarkers !== false) {
for (const pointRenderingConfig of this._options.layer.mapRendering) {
if (drawMarkers !== false) {
for (const pointRenderingConfig of layer.mapRendering) {
new PointRenderingLayer(
map,
this._options.layer,
layer,
features,
pointRenderingConfig,
this._options.metaTags,