AnsweredAssumed Answered

Search Widget on my own data

Question asked by SteveAdams on Oct 16, 2015
Latest reply on Oct 16, 2015 by khutchins-esristaff

I have started to make the journey from Flex to javascript.

I am really new at this so forgive me.

I can get my map layer to show up but

  just can't seem to get the search to look at my mapserver

ArcGIS API for JavaScript | Basic Search

 

<!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 | Basic Search</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;

      }

      #search {

         display: block;

         position: absolute;

         z-index: 2;

         top: 20px;

         left: 74px;

      }

   </style>

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

   <script>

       var map;

       require([

 

 

        "esri/map",

        "esri/dijit/Search",

        "dojo/domReady!"

 

 

      ], function (Map, Search) {

          var initExtent = new esri.geometry.Extent({ "xmin": -119.609356, "ymin": 36.780374, "xmax": -119.797153, "ymax": 36.895779, "spatialReference": { "wkid": 4326} });

          map = new esri.Map("map", { extent: initExtent });

          var MyMapLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://cusdmaps2012.cusd.com/arcgis/rest/services/flex/CUSD_MapFlex3/MapServer", {

 

 

          });

          map.addLayer(MyMapLayer);

 

 

          var s = new Search({

              enableButtonMode: true, //this enables the search widget to display as a single button

              enableLabel: false,

              enableInfoWindow: true,

              showInfoWindowOnSelect: false,

              map: MyMapLayer

          }, "search");

 

 

          var sources = [];

 

 

          sources.push({

              featureLayer: new FeatureLayer("http://cusdmaps2012.cusd.com/arcgis/rest/services/flex/CUSD_MapFlex3/MapServer/0"),

              searchFields: ["FULL_ADDRESS"],

              displayField: "FULL_ADDRESS",

              exactMatch: false,

              name: "test",

              outFields: ["*"],

              placeholder: "test",

              maxResults: 6,

              maxSuggestions: 6,

 

 

              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