From 759946600c9d8fb3effa7ea1e9825ff29fbdcbcf Mon Sep 17 00:00:00 2001 From: a-dutremble <106082983+a-dutremble@users.noreply.github.com> Date: Thu, 6 Jul 2023 18:18:06 +0200 Subject: [PATCH] refactor(example): add color interaction in SourceStreamWFS3D --- examples/source_stream_wfs_3d.html | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/source_stream_wfs_3d.html b/examples/source_stream_wfs_3d.html index caba39e13a..7bb8c11ba4 100644 --- a/examples/source_stream_wfs_3d.html +++ b/examples/source_stream_wfs_3d.html @@ -127,7 +127,8 @@ view.addLayer(lyonTclBusLayer); function colorBuildings(properties) { - if (properties.usage_1 === 'RĂ©sidentiel') { + if (!properties.selected) { + if (properties.usage_1 === 'RĂ©sidentiel') { return color.set(0xFDFDFF); } else if (properties.usage_1 === 'Annexe') { return color.set(0xC6C5B9); @@ -138,6 +139,9 @@ } else if (properties.usage_1 === 'Sportif') { return color.set(0x546A7B); } + } else { + return color.set(0xFFFF00); + } return color.set(0x555555); } @@ -222,16 +226,21 @@ function picking(event) { if(view.controls.isPaused) { var htmlInfo = document.getElementById('info'); - var intersects = view.pickObjectsAt(event, 3, 'WFS Building'); var properties; var info; - var batchId; + var intersects; + var intersects = view.pickGeometryAt(event, 3, 'WFS Building'); + var layer = view.getLayerById('WFS Building'); + htmlInfo.innerHTML = ' '; - - if (intersects.length) { - batchId = intersects[0].object.geometry.attributes.batchId.array[intersects[0].face.a]; - properties = intersects[0].object.feature.geometries[batchId].properties; + if (layer.selectedGeometry) { + layer.selectedGeometry.geometry.properties.selected = false; + } + if (intersects) { + properties = intersects.geometry.properties; + layer.selectedGeometry = intersects; + intersects.geometry.properties.selected = true; Object.keys(properties).map(function (objectKey) { var value = properties[objectKey]; @@ -243,7 +252,10 @@ } } }); - } + } + layer.redrawFeature(intersects); + layer.redrawFeature(layer.selectedGeometry); + view.notifyChange(layer); } }