Search Widget

169
3
Jump to solution
03-20-2020 09:47 AM
jaykapalczynski
Frequent Contributor

I have a search widget in my app.

After the search widget address is applied I have it run some code to return features within a certain distance.

This all works great....

// SEARCH WIDGET 
var searchWidget = new Search({
   view: view,
   popupEnabled: false
});
searchWidget.on("select-result", function () {
   searchRadius();
});

But what I want to do is pass the Search Widget an Address not manually enter it in the widget.

I want to read from a table and pass the individual addresses to the search widget and get the result from the code that have written.

Can I pass the searchWidget an address? If so an examples out there?

0 Kudos
1 Solution

Accepted Solutions
jaykapalczynski
Frequent Contributor
0 Kudos
3 Replies
jaykapalczynski
Frequent Contributor
0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Jay,

   In case that does not get you there, The method on the search widget is called search.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#search 

jaykapalczynski
Frequent Contributor

yea the answer for the link that I posted was the same

var searchWidget = new Search{view: view1})
function mySubmitFunction () {
  let element = document.getElementById("YourInputID")
  let address = element.value

  searchWidget.search(address).then((results) => {
     console.log("Search widget results :", results)
  })
})
0 Kudos