Thank you John for the reply. After using ScreenPoint to hiTest() it works only if searched location is visible on screen window. I have set zoom level to 15, so if I searched an address that's not visible on viewable screen then it doesn't work.
Here is my updated code
var search = new Search({
view: view,
//container:"searchDiv",
popupEnabled: false,
resultGraphicEnabled: false,
enableHighlight: false,
//allPlaceholder:'#rn:msg:CUSTOM_MSG_MAP_SEARCH_PLACEHOLDER#',
sources: [customSearchSource, cityOwnedParcelSearch, waterTreatmentPlanSearch, waterProductionWellSearch, sampleStationSearch],
includeDefaultSources: false,
maxResults: 8,
maxSuggestions: 8,
});
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
});
//selectedGraphic.geometry = webMercatorUtils.geographicToWebMercator(pointVar);
view.hitTest(view.toScreen(pointVar)).then(function(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;
if (highlightSelect) {
highlightSelect.remove();
}
view.whenLayerView(graphic.layer).then(function(lyrView){
highlightSelect = lyrView.highlight(graphic);
});
}
});
search.clear();
});