I don't think there's a really elegant way to do it, but you should be able to at least have the graphic appear highlighted on the right feature. There are multiple ways to define infoTemplates, popups etc, so I don't know if the way I go about it fits into what you have done or not. You may have all this established in your code already, but here's how I go about it:I like a large yellow circle with a transparency on it so it stands out. I define my symbol at beginning, along with my popup, which I use in my map definition.
highlightMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,255,0]), 2),
new Color([255,255,0,0.5]));
var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,200,0]), 2), new Color([255,255,0,0.30])) ,
markerSymbol: highlightMarkerSymbol
}, dojo.create("div"));
map = new Map("mapDiv", {
basemap: "topo",
center: [-92.593, 38.5],
infoWindow:popup,
sliderPosition: "top-left",
sliderStyle: "large",
zoom: 7
});
I'm not using a featurelayer, I'm just defining the infoTemplate in the results handler of my Identify Task. Since I'm clicking on the map, and I have my infoWindow defined as popup in my map constructor, this is giving me my highlight symbol automatically without explicitly telling it to 'draw a graphic'. This example looks a little different because I have my Identify set as deferred with 'promise/all' so I had to also manage which layer my identify was coming from
var formatResults = arrayUtils.map(results, function(result){
var feature = result.feature;
var layerName = result.layerName;
feature.attributes.layerName = result.layerName;
feature.setInfoTemplate(generateInfoTemplate);
generateInfoTemplate.setTitle("Layer Information");//don't need a graphic, it's drawing from the infoWindow:popup in the map constructor
return feature;
});
if (formatResults.length === 0) {
map.infoWindow.clearFeatures();
} else {
map.infoWindow.setFeatures(formatResults);
map.infoWindow.show(idPoint);
}
{/CODE]
When I'm outside the map, in my grid, the items in that list aren't aware they are associated with a graphic, they're just data. But the data includes the objectID, so I'm running a query to get back to what the corresponding graphic is. This is a function that needs to work from one of two grids I have, so there's extra lines and incoming parameters here:
//highlights the feature when the user selects from the grid
function highlightFeatureFromGrid(event, dGrid, qTask) {
app.map.graphics.clear();
app.map.infoWindow.hide();
var row = dGrid.row(event);
var query = new Query();
var objid = [row.data.objectid];
query.where = "OBJECTID = " + objid;
query.returnGeometry = true;
query.outFields = ["*"];
query.outSpatialReference = spatialReference;
qTask.execute(query, function (results) {
var feature = results.features[0];//should only be on feature by that id in that layer
var graphic;
if (results.displayFieldName == 'VENDORID'){
feature.setInfoTemplate(venInfoTemplate);
}else {
feature.setInfoTemplate(offSatInfoTemplate);
}
app.map.centerAndZoom(feature.geometry, 12);
graphic = new Graphic(feature.geometry, highlightMarkerSymbol,feature.attributes, feature.infoTemplate);
app.map.graphics.add(graphic);
app.map.infoWindow.setContent(feature.getContent());
app.map.infoWindow.setTitle(feature.getTitle());
app.map.infoWindow.show(feature.geometry);
});
}
Assuming that gfx in your example is an esri Graphic and not something else, you ought to be able to just construct and draw a new Graphic over the top using the parameters of the existing one.
It ain't elegant, but it works.