You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.
Skip To ContentArcGIS for DevelopersSign In Dashboard

Unsupported browser

You are using a browser that is not supported. JavaScript API works on the latest versions of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. Use one of these browsers and provide your feedback through GeoNet, the Esri Community.

  • {}
  • Firefox
  • Safari
  • undefined

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to use the search widget to search multiple Layer Sources based on given fields. The search widget provides the capability to search features in Layers or geocode locations with a Locator. By default, the Search widget sets the view on the Search result. The level of detail (LOD) at the center of the view depends on the data source, with higher quality data sources returning extents closer to the feature obtained from the search.

To use multiple sources with the search widget, you must set the widget's sources property.

// Setting sources property of the search widget to use two layer sources.
var searchWidget = new Search({
  view: view,
  allPlaceholder: "District or Senator",
  sources: [
      layer: featureLayerDistricts,
      searchFields: ["DISTRICTID"],
      displayField: "DISTRICTID",
      exactMatch: false,
      outFields: ["DISTRICTID", "NAME", "PARTY"],
      name: "Congressional Districts",
      placeholder: "example: 3708"
      layer: featureLayerSenators,
      searchFields: ["Name", "Party"],
      suggestionTemplate: "{Name}, Party: {Party}",
      exactMatch: false,
      outFields: ["*"],
      placeholder: "example: Casey",
      name: "Senators",
      zoomScale: 500000,
      resultSymbol: {
        type: "picture-marker", // autocasts as new PictureMarkerSymbol()
        url: "images/senate.png",
        height: 36,
        width: 36

Sample search results