How do you set the Directions widget to default to "All" sources searchOptions?

2697
1
01-14-2016 11:53 PM
lasinh
by
New Contributor III

default  , the first sources in the list  is selected. how to select all sources in my code:

<!DOCTYPE html>

<html>

  <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>Directions Widget</title>

    <link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">

    <link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">

    <style>

      html, body, #map {

        height:100%;

        width:100%;

        margin:0;

        padding:0;

      }

      body {

        background-color:#FFF;

        overflow:hidden;

        font-family:"Trebuchet MS";

      }

    </style>

   

    <script src="http://js.arcgis.com/3.14/"></script>

    <script>

        require([

       "esri/map", "esri/tasks/locator", "esri/InfoTemplate", "esri/geometry/webMercatorUtils", "esri/dijit/Directions", "esri/dijit/Search", "esri/layers/FeatureLayer",

        "dojo/parser",

        "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"

      ], function (

         Map, Locator, InfoTemplate, webMercatorUtils, Directions, Search, FeatureLayer,

        parser

      ) {

          parser.parse();

          //all requests to route.arcgis.com will proxy to the proxyUrl defined in this object.   

          esriConfig.defaults.io.proxyUrl = "/proxy/";

          var map = new Map("map", {

              basemap: "gray",

              center: [-97, 38], // lon, lat

              zoom: 5

          });

          directionTimDuong = new Directions({

              map: map,

              autoSolve: false,

              dragging: false,

              showClearButton: true,

              maxStops: 5,

              showReverseStopsButton: true,

              //  showTravelModesOption: true,

              mapClickActive: true,

              routeTaskUrl: "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route",

              searchOptions: {

                  sources: [

                        {

                            featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServe..."),

                            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

                        },

                            {

                                featureLayer: new FeatureLayer("http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_Senators/FeatureServer/0"),

                                searchFields: ["Name"],

                                displayField: "Name",

                                exactMatch: false,

                                name: "Senator",

                                outFields: ["*"],

                                placeholder: "Senator name",

                                maxResults: 6,

                                maxSuggestions: 6,

                                //Create an InfoTemplate

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

                                enableSuggestions: true,

                                minCharacters: 0

                            }

                        ]

              }

          }, "dir");

                   

          directionTimDuong.startup();

      });

    </script>

  </head>

  <body class="claro">

    <div data-dojo-type="dijit/layout/BorderContainer"

         data-dojo-props="design:'headline', gutters:false"

         style="width:100%;height:100%;">

      <div data-dojo-type="dijit/layout/ContentPane"

           data-dojo-props="region:'right'"

           style="width:250px;">

       

        <div id="dir"></div>

      </div>

      <div id="map"

           data-dojo-type="dijit/layout/ContentPane"

           data-dojo-props="region:'center'">

      </div>

    </div>

  </body>

</html>

0 Kudos
1 Reply
AmritKumar1
New Contributor

Hi,

Use the code mentioned in the following link:

https://github.com/amritkumar90/Directions-widget-with-searchOptions/blob/master/

Make necessary modifications as required. Hope this helps!

--Amrit

0 Kudos