Pass value of address variable into the search widget on a mapview ... have search auto execute?

271
4
Jump to solution
09-12-2018 08:43 AM
JohnRichardson
New Contributor III

Brand new to Javascript and the ArcGIS API .... so please forgive me if this is a simple question ... but how can I pass a value of an address variable into the search widget of a mapview and have the search execute automatically?

0 Kudos
1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

As Robert points out via the provided link, you should call the 'search' method:

 searchWidget = new Search({ 
    view:view,

    searchTerm: "1024 E 8th"
 });

 view.ui.add(searchWidget, "bottom-right");

view.when(()=>{

   searchWidget.search();

});

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor
JohnRichardson
New Contributor III

searchWidget = new Search({ //add the search widget to the map view
view:view
});
view.ui.add(searchWidget, "bottom-right");
addy = searchWidget.searchTerm = "1024 E 8th";
searchWidget(addy);

the above code will not execute the search for me ... it populates the search field in the widget, just does not run the search and zoom to result

0 Kudos
JohnGrayson
Esri Regular Contributor

As Robert points out via the provided link, you should call the 'search' method:

 searchWidget = new Search({ 
    view:view,

    searchTerm: "1024 E 8th"
 });

 view.ui.add(searchWidget, "bottom-right");

view.when(()=>{

   searchWidget.search();

});

JohnRichardson
New Contributor III

Yes!

Thank you all very much ... 

view.when(()=>{

   searchWidget.search();

});

The above bit of code did the trick!!

0 Kudos