AnsweredAssumed Answered

Search widget not providing additional Suggestions ie wildcards

Question asked by jonah84 on Dec 31, 2015
Latest reply on Aug 18, 2017 by dd_fadhilah

I am very new to Javascript and am trying to use the "Search multiple sources" example within the sanbox. I have added a service I would like to search by the plat name however it is not providing me a drop down list like in the example provided.

 

Below is the example. Has anyone come up with a solution to this or am I just overlooking something. Thanks

 

<!DOCTYPE html>
<html dir="ltr">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
   <title>ArcGIS API for JavaScript | Search widget with multiple sources</title>
   <link rel="stylesheet" href="https://js.arcgis.com/3.15/dijit/themes/claro/claro.css">
   <link rel="stylesheet" href="https://js.arcgis.com/3.15/esri/css/esri.css">
   <style>
      html,
      body,
      #map {
         height: 100%;
         width: 100%;
         margin: 0;
         padding: 0;
      }
      #search {
         display: block;
         position: absolute;
         z-index: 2;
         top: 20px;
         left: 74px;
      }
   </style>

   </script>
<script src="https://js.arcgis.com/3.15/"></script>
   <script>
      require([
        "esri/map", "esri/dijit/Search", "esri/layers/FeatureLayer", "esri/InfoTemplate", "dojo/domReady!"
      ], function (Map, Search, FeatureLayer, InfoTemplate) {
         var map = new Map("map", {
            basemap: "gray",
            center: [-97, 38], // lon, lat
            zoom: 5
         });

         var s = new Search({
            enableButtonMode: true, //this enables the search widget to display as a single button
            enableLabel: false,
            enableInfoWindow: true,
            showInfoWindowOnSelect: false,
            map: map
         }, "search");

         var sources = s.get("sources");

         //Push the sources used to search, by default the ArcGIS Online World geocoder is included. In addition there is a feature layer of US congressional districts. The districts search is set up to find the "DISTRICTID". Also, a feature layer of senator information is set up to find based on the senator name.

         sources.push({
            featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServer/0"),
            searchFields: ["DISTRICTID"],
            displayField: "DISTRICTID",
            exactMatch: false,
            outFields: ["DISTRICTID", "NAME", "PARTY"],
            name: "Congressional Districts",
            placeholder: "3708",
            maxResults: 6,
            maxSuggestions: 6,

            //Create an InfoTemplate and include three fields
            infoTemplate: new InfoTemplate("Congressional District", "District ID: ${DISTRICTID}</br>Name: ${NAME}</br>Party Affiliation: ${PARTY}"),
            enableSuggestions: true,
            minCharacters: 0
         });

         sources.push({
            featureLayer: new FeatureLayer("http://********************/arcgis/rest/services/Apps/SubstationAsBuilts/MapServer/0"),
            searchFields: ["PlatLog.ProName"],
            displayField: "PlatLog.ProName",
            exactMatch: false,
            name: "PlatLog.ProName",
            outFields: ["*"],
            placeholder: "PlatLog.ProName",
            maxResults: 6,
            maxSuggestions: 6,

            //Create an InfoTemplate

            infoTemplate: new InfoTemplate("Senator information", "Name: ${PlatLog.ProName}</br>State: ${PlatLog.ProName}</br>Party Affiliation: ${PlatLog.ProName}</br>Phone No: ${PlatLog.ProName}<br><a href=${Web_Page} target=_blank ;'>Website</a>"),
           
            enableSuggestions: true,
            minCharacters: 0
         });

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

         s.startup();

      });
   </script>
</head>

<body>
   <div id="search"></div>
   <div id="map"></div>
</body>

</html>

Outcomes