Skip to content

Commit

Permalink
refactor(example): add color interaction in SourceStreamWFS3D
Browse files Browse the repository at this point in the history
  • Loading branch information
a-dutremble committed Jul 7, 2023
1 parent e41e0d3 commit 7599466
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions examples/source_stream_wfs_3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -138,6 +139,9 @@
} else if (properties.usage_1 === 'Sportif') {
return color.set(0x546A7B);
}
} else {
return color.set(0xFFFF00);
}

return color.set(0x555555);
}
Expand Down Expand Up @@ -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];
Expand All @@ -243,7 +252,10 @@
}
}
});
}
}
layer.redrawFeature(intersects);
layer.redrawFeature(layer.selectedGeometry);
view.notifyChange(layer);
}
}

Expand Down

0 comments on commit 7599466

Please sign in to comment.