AnsweredAssumed Answered

API JS Search does not display the selected item in the search bar

Question asked by laurentdurufle on May 24, 2017
Latest reply on May 24, 2017 by laurentdurufle

API JS Search does not display, in the search bar, the item selected by the user (from the suggested list) while the effective search works perfectly and display on the map the item along with the popup window.

 

Do you have any idea what I am missing here?

 

Here is my code:

 

        var search = new Search({
            map: map,
            enableButtonMode: false,
            enableLabel: false,
            enableInfoWindow: true,
            showInfoWindowOnSelect: true,
            allPlaceholder: "Find PoP, Circuit, CLS, address"
            }, "SearchWidget");
                        
        var sources = search.get("sources");    //by default there is at least one source: 'ESRI world geocoder'

 

        //Amend some parameters of the default source geocoder (source[0])        
        sources[0].name = "Place (world geolocator)";
        sources[0].placeholder = "Find address or place";            
        
        //Push the sources used to search, by default the ArcGIS Online World geocoder is included. In addition we add other feature layers to search into.
        // Add layer PoP
        sources.push({
            featureLayer: new FeatureLayer(layerPoPsConfig.url),
            searchFields: ["PoP"],
            displayField: "PoP",
            exactMatch: false,
            outFields: ["*"],    
            name: "PoP",
            suggestionTemplate: "${PoP}, ${Country}",    //display in the suggestion menu
            placeholder: "Find PoP",            
            maxResults: 6,
            maxSuggestions: 6,

 

            //Create an InfoTemplate
            infoTemplate:  InfoTemplateLyrPoPs,
            enableSuggestions: true,
            enableSourcesMenu: true,
            enableSuggestionsMenu: true,
            minCharacters: 0,
            zoomScale: 10000000,            
        });   

 

        //Set the sources above to the search widget
        search.set("sources", sources);        
        search.startup();

Outcomes