Though I have accomplished the task at hand, i wish to find a more efficient way to do this. If esri have provided a way to highlight the first search result on performing a search, why is there no way to highlight the second, third ..etc result? Why do i have to manually create an anchor tag to do this?
If there is a simpler way to perform this kindly let me know!
My Current method:
I am currently retrieving all the results after the search is complete in the following function and storing it in a global variable:
search.on("search-results",function(search_results){
//access and store in global variable - allResults
}
For each of the data in allResults, I create a href link, [<span class='link' onclick='searchTreeNum("+counter+");return false;'>] I zoom in and popUp the infoTemplate manually. This is done in the following function , where counter represents the index in the allResults that it must generate the popup for :
function searchTreeNum(counter){
var feature = allResults[counter];
map.graphics.clear();
map.infoWindow.hide();
var gs = new GeometryService(geometryLayerUrl);
var bf = new BufferParameters();
var p = new Point(feature.geometry.x,feature.geometry.y,feature.geometry.spatialReference);
bf.geometries = [ feature.geometry ];
bf.distances = [ 5 ];
bf.unit = esri.tasks.GeometryService.UNIT_FEET;
bf.spatialReference = feature.geometry.spatialReference;
bf.outSpatialReference = map.spatialReference;
gs.buffer(bf, function(bufResults) {
var g = new Graphic(bufResults[0], pointType2, feature.attributes, "");
map.graphics.add(g);
var mp = webMercatorUtils.webMercatorToGeographic(p);
map.infoWindow.setTitle(title);
map.infoWindow.setContent(contentInfoWindow);
map.infoWindow.show(p,map.getInfoWindowAnchor(mp));
map.setExtent(bufResults[0].getExtent());
});
}