Hi,
I have added different features layer on map and have a working code to highlight the feature layer once user click on the map (I am using hitTest on mouse click event). But I am trying to do the same (highlight feature layer) once user searched an address and that address falls on one of feature layer. I am not able to make it work.
Here is my code snippet
search.on("search-complete", function(event)
{
//take lat and long from Esri search if geometry type is point or polygon
let lat, longt;
if(event.results[0].results[0].feature.geometry.type == 'point') {
lat = event.results[0].results[0].feature.geometry.latitude;
longt = event.results[0].results[0].feature.geometry.longitude;
} else if(event.results[0].results[0].feature.geometry.type == 'polygon') {
lat = event.results[0].results[0].feature.geometry.centroid.latitude;
longt = event.results[0].results[0].feature.geometry.centroid.longitude;
}
let pointVar = new Point({
latitude:lat,
longitude:longt
});
view.hitTest(pointVar).then(function(response)
{//alert("test");
console.log(response);
if (response && response.results.length > 0 && response.results[0].graphic && response.results[0].graphic != undefined && response.results[0].graphic.attributes != undefined ) {
let graphic = response.results[0].graphic;
view.whenLayerView(graphic.layer).then(function(lyrView){
if (highlightSelect) {
highlightSelect.remove();
}
highlightSelect = lyrView.highlight(graphic);
});
}
});
});