Obtain point object from Search widget results

1316
2
Jump to solution
12-13-2019 11:46 AM
AndrewL
Occasional Contributor II

I am migrating my application to the ArcGIS API for JS Version 4.13 from Version 3.15.

I would like to return a point so that I may use it in a query task.

My old code was: query.geometry = addressPoint;

I am not sure how to obtain this from using the Search widget:

var searchWidget = new Search({
  view: view,
  container: "searchWidget",
  popupEnabled: false
});

searchWidget.on('search-complete', function(result){
  console.log(result)

});

Thank you.

0 Kudos
1 Solution

Accepted Solutions
JoseBanuelos
Esri Contributor

Hello Andrew,

To access the point geometry with the callback function you have, it will be result.results[0].results[0].feature.geometry. 

Regards,

Jose

View solution in original post

2 Replies
JoseBanuelos
Esri Contributor

Hello Andrew,

To access the point geometry with the callback function you have, it will be result.results[0].results[0].feature.geometry. 

Regards,

Jose

AndrewL
Occasional Contributor II

Thanks Jose! That worked.

I was able to use DevTools to figure out how to retrieve the name as well since I need that too.

addressText = result.results[0].results[0].name