1

Using the Esri JavaScript API I want to control the set.DefinitionExpression values based on a user controlled range slider.

The data is loaded from REST as ondemand using:

var POP_Total = new FeatureLayer("..../services/RPP_15/HEX_Confidence_Scores/MapServer/2", {
                  mode: FeatureLayer.MODE_ONDEMAND,
                  outFields: ["*"],
                  opacity: 0.5,
              });

I set a definition expression with:

POP_Total.setDefinitionExpression("POP_Total_Class >= 4 AND POP_Total_Class <= 5");

In the above case the returned values are hard coded to only display the values between 4 and 5. I wish to problematically change the values of the 4 and 5 with the values returned by the range slider.

The range slider is created with:

var sliderRules = new dijit.form.HorizontalRuleLabels({
                  minimum: 1,
                  maximum: 8,
                  labels: ["1", "2", "3", "4", "5", "6", "7", "8"],
                  labelStyle: "font-size:9px;color: #333",
                  style: "width:220px;height:30px;"
              }, "ruler");



              var rangeSlider = new dojox.form.HorizontalRangeSlider({
                  name: "rangeSlider",
                  value: [1, 8],
                  minimum: 1,
                  maximum: 8,
                  discreteValues: 8,
                  style: "width:220px;",
                  onChange: function (value) {
                      //alert('change occurred');
                  }
              }, "rangeSlider");

1 Answer 1

1
onChange: function (value) {
    var min = value[0];
    var max = value[1];
    var expression = "POP_Total_Class >= " + min + " AND POP_Total_Class <= " + max;
    POP_Total.setDefinitionExpression(expression);
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.