This is sort-of a follow-up to my thread here:
https://community.esri.com/t5/arcgis-api-for-javascript-questions/querying-one-feature-layer-to-use-...
I'm now trying to do the opposite: I need to unselect/clear an already selected feature in a feature layer, using a query or anything else besides getting the Popup involved. I have looked through the 4.X API as well as some examples on this board, but can't find anything that works. In the API for FeatureLayerView.highlight there is a snippet that uses highlight.remove(), but every time I try to use it, my developer console tells me that the .remove() is not a function, which doesn't surprise me because there is no .remove function anywhere I can find in the API.
I am trying to do something like this. FYI the myVariable variable is something I've already retrieved earlier that will represent the feature that's been highlighted.
function unselectParcel()
{
var myQuery = myLayer.createQuery();
myQuery.where = "MyFieldName = '" + myVariable + "'";
myLayer.queryFeatures(myQuery).then(function(response)
{
myView.whenLayerView(myLayer).then(function(layerView)
{
var feature = response.features[0];
layerView.highlight.remove(feature.attributes["OBJECTID"]);
});
});
}
As I said, the .remove() does not work, and I've tried all kinds of different iterations of it, to no avail. I've also tried putting the queryFeatures inside of the whenLayerView and all kinds of other arrangements, but since my selecting-the-feature function works fine and all I want to do is the reverse of that, it seems like I should just be able to make a minor change to that selecting-the-feature code - right? I can't believe they have a "highlight" function but no "clear" or "un-highlight" function.