AnsweredAssumed Answered

search widget from multiple sources

Question asked by Henseki on Aug 6, 2017
Latest reply on Sep 19, 2018 by namoraj96

Hi All,

 

my search widget uses both geocoding service and two feature sources. However, I m having trouble having , it highlights the ESRI geocoder as the first source of search instead of ALL.

 

How do I make the ALL the default search so it searches all sources. Thanks in advance

 

// Add the layer to the map
  var trailsLayer = new FeatureLayer({
  });
 
  map.add(trailsLayer); // Optionally add layer to map

 

 

   // Add the layer to the map
  var trailsLayerr = new FeatureLayer({
  });
 
  map.add(trailsLayerr); // Optionally add layer to map
 
  var view = new MapView({
    container: "viewDiv"
    map: map,
   zoom: 17,
center: [0.46564130, 51.736810] // longitude, latitude
  });
 
  // Search
 
  var search = new Search({
    view: view
  });
  search.defaultSource.withinViewEnabled = true; // Limit search to visible map area only
  view.ui.add(search, "top-right"); // Add to the map

  // Add the trailheads as a search source

 
   

 

 

  search.sources.push({
    featureLayer: trailsLayer,
     searchFields: ["Postcode", "UPRN", "ADDRESS" ],
  displayField: "ADDRESS",
  exactMatch: false,
  outFields: ["*"],
   resultGraphicEnabled: true,
    name: "ADDRESS",
  placeholder: "example:  CM2 0HU",
    popupTemplate: { // autocasts as new popupTemplate()
        title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}",
        overwriteActions: true
     
      }
  });

 

 

  search.sources.push({
    featureLayer: trailsLayerr,
     searchFields: ["Postcode", "UPRN", "ADDRESS" ],
  displayField: "ADDRESS",
  exactMatch: false,
  outFields: ["*"],
   resultGraphicEnabled: true,
    name: "Postcode",
  placeholder: "example:  CM2 0HU",
    popupTemplate: { // autocasts as new popupTemplate()
        title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}",
        overwriteActions: true
     
      }
  });
 
 
 
   

 
 
 
 
 
 
 
 
 

});</script>
</head>
<body>
  <div id="viewDiv"></div>
</body>

Outcomes