How do I highlight a cluster with a feature query?

626
2
08-05-2020 04:42 AM
KDimitrov
New Contributor II

Hello,

I am trying to highlight a cluster by using the queryFeatures method on a GeoJSON layer, but only the children of the cluster are highlighted when I turn off the marker clustering.

I am using a Sketch widget to highlight only items in the selected area.

Can the clusters be highlighted instead of the children?

sketch.on("create", function(event) {

if (event.state === "complete") {

selectFeatures(event.graphic.geometry);

}

});

var highlight;
function selectFeatures(geometry){

// remove the first sketch shape if it exists
if(sketchLayer.graphics.items.length > 1){

var firstItem = sketchLayer.graphics.items[0];
sketchLayer.graphics.remove(firstItem);

}
// remove the current highlight if set
if(highlight){

highlight.remove();

}


// query
view.whenLayerView(layer).then(function(layerView){

var query = layer.createQuery();
query.geometry = geometry;
query.returnGeometry = true;
layer.queryFeatures(query).then(function(result){

highlight = layerView.highlight(result.features); // clusters are not highlighted here, only the children

});

});

}

0 Kudos
2 Replies
KDimitrov
New Contributor II

Anybody?

0 Kudos
FabricioBezerra
New Contributor II

I would love to know if that is possible too

0 Kudos