Hello!
I'd like to know how to check if a feature is already highlighted.
I added a highlight for features on mousehover. But the highlight keeps flashing off and on if you move the mouse within a feature.
I think this is because I remove the highlight on every mouse move, without checking if a feature is already highlighted first. I've tried to build in a check for this, but it doesn't work yet. Which is why I'd like to know how to check for this.
Any help would be much appreciated!
Code (V4.24):
view.when(() => {
let highlight = null;
view.on("pointer-move", evt => {
view.hitTest(evt).then(response => {
if (response.results.length > 0) {
if (highlight) {
highlight.remove();
}
let graphic = response.results[0].graphic;
view.whenLayerView(graphic.layer).then(function(layerView){
highlight = layerView.highlight(graphic);
});
}
else{
if (highlight) {
highlight.remove();
}
}
});
});
});