About search widget, does the map have to be published as a feature server rather than a map server in order to use the suggestion function?

2292
1
01-18-2016 06:33 PM
guangyupan
New Contributor

I use the code like this:

var search = new Search({
        sources: [{
            featureLayer = new FeatureLayer("http://localhost:6080/arcgis/rest/services//103Map111/MapServer/0 "),
            searchFields: ["LGA_NAME11"],
            displayField: "LGA_NAME11",
            exactMatch: false,
            name: "LGA_NAME11",
            outFields: ["*"],
            placeholder: "LGA_NAME",
            maxResults: 6,
            maxSuggestions: 6,

            //Create an InfoTemplate

            infoTemplate: new InfoTemplate("LGA_NAME11", "LGA_NAME11: ${LGA_NAME11}</br>Decile: ${Decile}</br>GP: ${LGA_GP}</br>Psyc: ${LGA_Psyc}</br>clinPsycol: ${LGA_clinPs}"),
           
            enableSuggestions: true,
            minCharacters: 0
      }],
        map: map
      }, "search");
   search.startup();

It is quite similar with the sample code for search. However, even if  it can search the right place but cannot show suggestion. I think there is something wrong with the published map. But I have no idea on how to fix it.

Tags (1)
0 Kudos
1 Reply
GirishYadav
Occasional Contributor

Guangyu,

Search dijit does support map/feature service feature layer. and according to ArcGIS JS API documentation:

"Suggestions are available if working with a 10.3 geocoding service that has suggest capability loaded or a 10.3 feature layer that supports pagination, i.e. supportsPagination = true"

Now, for pagination support check this out:

How do you enable the "Supports Pagination" on a layer at 10.3?

Hopefully this will help.

-Girish