Discover the Search widget

24481
65
03-06-2015 05:59 PM
MattDriscoll
Esri Contributor

There’s a new way to easily search your mapping data.

The ArcGIS JavaScript API’s new Search dijit precedes the Geocoder dijit (now deprecated). It’s been re-imagined, renamed and redesigned to provide a single searching and suggestion experience. It allows you to search across multiple Locator and Feature Layer services from a simple interface.

Whereas the Geocoder dijit’s intention was for searching only Locator tasks, the Search dijit was designed to handle multiple types of “sources,” including Locator tasks, Feature Layers and potentially more. The user interface has also been improved to handle searching one more of these sources. With the Search dijit, you can search or get suggestions from all the defined sources or a single source.

Much of the same functionality found in the Geocoder widget is also present in the Search dijit, but many new features have been added and redesigned for a better user and developer experience. As a developer, it should be easier for you to configure the Search widget and less code to write in order to handle common searching tasks. The icons for the widget use a font, so properties like the color or size can easily be modified.

New Features include:

  • Ability to search and get suggestions from Feature Layers
  • Automatically add Feature Layers from a map to the widget
  • Display additional search results to a user in the popup as “more results”
  • Highlight a result with a symbol
  • Label a result with a text symbol.
  • Results for suggestions and searches are separated and have different events
  • Optional button-mode to expand or collapse the search interface from a single button
  • Easily set an InfoTemplate to display custom popup information for a result
  • Individual placeholders for each search source... and more

Have fun exploring the demos or implementing it in your app.

65 Replies
DaveHighness
Occasional Contributor II

I tried sorting the feature layer on the name but that didn't change anything. What it does is sort the suggestions alphabetically so if the item you are looking for is down the list beyond the maxSuggestions amount then it doesn't show up in the suggestion list. That makes sense. I think we'll need to do is cull our layer to remove unnecessary places.

I still think it would be nice to have the option of doing a suggestion query similar to "LIKE 'SANTA%'" rather than with the double wildcard. Thanks for the help.

deleted-user-0W0-oLHxDjCX
New Contributor III

I Agree with David Coley​ suggestions with middle match are a little confusing. Have you found out a solution to this issue?

Ezequias

0 Kudos
DavidColey
Frequent Contributor

Not sure what you mean by 'middle match'. My question a while back was about the info template.  We've added a function that gets our domains' coded value descriptions and applies to the any domained fields

0 Kudos
DavidColey
Frequent Contributor

Hi Matt-

Has anyone solved how to return and display the description instead of the code for coded domain fields?  For example, I am passing a defined popup template var as the value for the infoTemplate constructor option:

sources.push({
        featureLayer: petitions,
        searchFields: petFlds,//["PetitionID"],
        displayField: "PetitionID",
        exactMatch: false,
        outFields: petFlds,
        name: "Petition ID",
        placeholder: "CPA-2013-C",
        maxResults: 6,
        maxSuggestions: 6,
        
        //Create an InfoTemplate and include three fields
        infoTemplate: plyPetitions,
        enableSuggestions: true,
        minCharacters: 0
    });

So in this case the infoTemaplate option is pointing to my popupTemplate as infoTemplates do not by default read domain descriptions.  If I have to configure an infoTemplate to handle domain descriptions I can but was hoping not to have to-

Thanks

David

0 Kudos
CemAkkus2
New Contributor II

Hi Matt,

This is a great post! I am trying to change the zoom scale when the search zooms into a returned result. I found zoomScale property but that is activated when the result does not have an associated scale. Am I missing something in the API documentation or is there another work around?

Thank you very much,

Cem

heatherstudley
New Contributor

Is there a way to format the search results so they appear by category in the search bar?  I'm wanting to emulate the search widget from ArcGIS Online's apps where they are separated by field in the search results drop-down so if a user types in "1000" it'll show parcels containing that number in one group and addresses containing it in another.

0 Kudos
GoranTozievski
New Contributor

I have implemented the Search in the MapTour template.Works like it should, but i need to catch the event that push the results so i can put them in the MapTour points..Here is an example

ScreenHunter_03 Apr. 15 11.52.jpg

So in short words i need the Search Result to be put in the point searched in the Template.So when the search is made the result should change the picture for the searched result.I im missing only the Search event that push the graphic on map.Regards

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Goran,

  So are you just looking for the search-results event?

Search | API Reference | ArcGIS API for JavaScript

GoranTozievski
New Contributor

For now yes ... Today i will try to pass the searcResult to the MapTour.. Thanks for the answer.

0 Kudos
deleted-user-0W0-oLHxDjCX
New Contributor III

Could you give me some information about if its possible to make an exact suggestion (without taking middle elements of my search criteria)?

I.E: If I type 12

I would like to have suggestions like this

1256848

1289684984

1256468

12

Instead of

565465412335

65985512

01205565

What event is used to make this suggestions?

Could you give me some advice?

0 Kudos