1

Here is my code

else if(which == "abc"){  
        var d = (id).toString();  
        d = d.replace("abc", "");  
        query.where = "Name='" + d + "'";  
        console.info(query.where);  
        query.returnGeometry = true;  
        layerC.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {  
          thePoly = features[0].geometry;  
          theExtent = thePoly.getExtent().expand(1); //Zoom out slightly from the polygon's extent  
          map.setExtent(theExtent);  
        }); 

    }
     var text;
     var R = document.getElementById('abc').value;
     var rLyrToggle = dom.byId("rLyr");

     switch(Cpt) {
case "room1":
    on(rLyrToggle, "change", function() {
      building layer.visible = rLyrToggle.checked;

    });
    break;

default:
    text = "No room";
}

My check box does not show the layer upon checking layer is added to the map but I disable its visibilty , I want that when combox selected value is equal to the case 1 then the feature is visibile when user check the box

Vikash Pandey
  • 5,407
  • 6
  • 41
  • 42
Sarah Salar
  • 193
  • 1
  • 3
  • 14
  • Can you create a jsfiddle where we can reproduce same issue.. that will be a better way...however somewhere its fishy in switch case.. building layer.visible = rLyrToggle.checked; on this line... if you want a exact fix then add some more details or similar running environment.. – Vikash Pandey Apr 24 '17 at 05:57
  • Fishy? i have added layer to the map but sets its visibilty tot false .when combox value matches the case number it has that file so when user click the check box the said layer is visibile – Sarah Salar Apr 24 '17 at 06:25
  • or is there any example that user select the layer from dropdown button. it is cascading nested filtering – Sarah Salar Apr 24 '17 at 06:26
  • whatever you have conveyed in above msgs is it feasible to create a running sample similar to it.. – Vikash Pandey Apr 24 '17 at 06:31
  • i cannot create running sample :( – Sarah Salar Apr 24 '17 at 06:34
  • Its quite difficult to help if you don't want to help yourself.. let me try – Vikash Pandey Apr 24 '17 at 06:35
  • any idea about getting all values of the field instead of distinct value like esriRequest({ url: "http://localhost:6080/arcgis/rest/services/query?where=First_Name ='" + id.toString() + "'&outFields=Last_Name&returnGeometry=false&orderByFields=Last_Name&returnDistinctValues=true&f=json", content:{ f:'json' }, in this example query returns unique values i want to return all values – Sarah Salar Apr 24 '17 at 10:00
  • sure... we can do it.. – Vikash Pandey Apr 24 '17 at 10:09
  • how ? i tried with distinct values it returns few values . i want to populate with all values. – Sarah Salar Apr 24 '17 at 10:12
  • added an example/answer for finding all/partial value from a gis layer... – Vikash Pandey Apr 24 '17 at 12:25

1 Answers1

2

Well, to find all value(As mentioned in comments) from a GIS layer i Would suggest use queryTask instead of esriRequest-

Below is the working 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>Query State Info without Map</title>

    <script src="https://js.arcgis.com/3.20/"></script>
    <script>
      require([
        "dojo/dom", "dojo/on",
        "esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!"
      ], function (dom, on, Query, QueryTask) {

        var queryTask = new QueryTask("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");

        var query = new Query();
        query.returnGeometry = false;
        query.outFields = [
          "SQMI", "STATE_NAME", "STATE_FIPS", "SUB_REGION", "STATE_ABBR",
          "POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI", "HOUSEHOLDS",
          "MALES", "FEMALES", "WHITE", "BLACK", "AMERI_ES", "ASIAN", "OTHER",
          "HISPANIC", "AGE_UNDER5", "AGE_5_17", "AGE_18_21", "AGE_22_29",
          "AGE_30_39", "AGE_40_49", "AGE_50_64", "AGE_65_UP"
        ];

        on(dom.byId("execute"), "click", execute);
        on(dom.byId("findAll"), "click", findAll);

        function execute () {
          query.where = "";
          query.text = dom.byId("stateName").value;
          queryTask.execute(query, showResults);
        }
        
        function findAll () {
          query.where = "1=1";
          queryTask.execute(query, showResults);
        }

        function showResults (results) {
          var resultItems = [];
          var resultCount = results.features.length;
          for (var i = 0; i < resultCount; i++) {
            var featureAttributes = results.features[i].attributes;
            for (var attr in featureAttributes) {
              resultItems.push("<b>" + attr + ":</b>  " + featureAttributes[attr] + "<br>");
            }
            resultItems.push("<br>");
          }
          dom.byId("info").innerHTML = resultItems.join("");
        }
      });
    </script>
  </head>

  <body>
    US state name :
    <input type="text" id="stateName" value="California">
    <input id="execute" type="button" value="Get Details">
     OR
    <input id="findAll" type="button" value="Find All">
    <br />
    <br />
    <div id="info" style="padding:5px; margin:5px; background-color:#eee;">
    </div>
  </body>
</html>

Hoping this will help you :)

Vikash Pandey
  • 5,407
  • 6
  • 41
  • 42