Select to view content in your preferred language

How can I Search without displaying map?

2823
9
Jump to solution
10-10-2019 06:24 PM
AnnCrystal
Emerging Contributor

Any way of performing search (search widget) without displaying a map?  Something like this "Find" sample:

Query data without a map | ArcGIS API for JavaScript 3.30 

When I remove the map, it didn't work. Please share your thoughts.

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

Gotcha. Ok, if I understand now, you are basically just wanting to do some geocoding. If you don't want to use a map, then you won't want to use the Search widget. As I see it, you could use the Locator Task for this.

https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#

However, I do want to point out that Geocoding is a sometimes free and sometimes pay service. If you use the ArcGIS World Geocoding Service in a pay manner, then please review the instructions here:

https://developers.arcgis.com/rest/geocode/api-reference/geocoding-free-vs-paid.htm

If you have your own service to consume, or will be using the free operations explained in the link above, then here is a working sample as a proof of concept to get you started.

https://codepen.io/noash/pen/XWWdpge

The 3x sample that you posted a link to above does querying on a feature layer, which would be a different workflow, but one that you could implement yourself with the Query and QueryTask at 4.x and the  logic of the CodePen sample.

Query | ArcGIS API for JavaScript 4.13 

QueryTask | ArcGIS API for JavaScript 4.13 

View solution in original post

9 Replies
Noah-Sager
Esri Regular Contributor

You could try just using the SearchViewModel

SearchViewModel | ArcGIS API for JavaScript 4.13 

And there's a similar 4x sample to that 3x sample that uses the Find Task

FindTask | ArcGIS API for JavaScript 4.13 

0 Kudos
AnnCrystal
Emerging Contributor

Basically my question is how to implement search with out a map being displayed like in that Query data without map sample. Any sample scripts?

0 Kudos
Noah-Sager
Esri Regular Contributor

Sorry, I'm not sure how to help here.

Is the goal to use the Search widget without a map? This widget requires a View, and the point of having a View is to view and interact with a map. I don't think that's possible to do.

Search | ArcGIS API for JavaScript 4.13 

Or is the goal to query features from a layer similar to the 3x sample?

You can implement the same logic with the Query and QueryTask at 4.x.

Query | ArcGIS API for JavaScript 4.13 

QueryTask | ArcGIS API for JavaScript 4.13 

Or is the goal to do some geocoding and get the results from search locations without a map? Then you could use the SearchViewModel's search() method.

SearchViewModel | ArcGIS API for JavaScript 4.13 

0 Kudos
AnnCrystal
Emerging Contributor

The goal is to do some geocoding and get the result with out a map i.e something which is done in this sample:

Query data without a map | ArcGIS API for JavaScript 3.30 

0 Kudos
Noah-Sager
Esri Regular Contributor

Gotcha. Ok, if I understand now, you are basically just wanting to do some geocoding. If you don't want to use a map, then you won't want to use the Search widget. As I see it, you could use the Locator Task for this.

https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#

However, I do want to point out that Geocoding is a sometimes free and sometimes pay service. If you use the ArcGIS World Geocoding Service in a pay manner, then please review the instructions here:

https://developers.arcgis.com/rest/geocode/api-reference/geocoding-free-vs-paid.htm

If you have your own service to consume, or will be using the free operations explained in the link above, then here is a working sample as a proof of concept to get you started.

https://codepen.io/noash/pen/XWWdpge

The 3x sample that you posted a link to above does querying on a feature layer, which would be a different workflow, but one that you could implement yourself with the Query and QueryTask at 4.x and the  logic of the CodePen sample.

Query | ArcGIS API for JavaScript 4.13 

QueryTask | ArcGIS API for JavaScript 4.13 

AnnCrystal
Emerging Contributor

Perfect- Thanks

0 Kudos
AnnCrystal
Emerging Contributor

Do I need to have map enabled, if I need to use this location result for intersecting on another feature layer and extract an attribute out of that layer? Any samples? 

0 Kudos
AamirIslam
New Contributor

@Noah-Sager 

 

Can you please provide an example for suggestLocations

Looking for an example like https://codepen.io/noash/pen/XWWdpge

I don't want a map but need character by character auto complete suggestions? Thanks.

 

0 Kudos