0

In using ArcGIS's ClassBreaksRenderer, I've made use of setMaxInclusive(false) to allow the breaks to not include the maximum value. This works fine when using the renderer object itself (such as in a Feature Layer). However, when I convert the ClassBreaksRenderer to JSON using the toJson function, it does not change the resulting JSON object. I'm using the renderer in a dynamic layer (setting it through LayerDrawingOptions), and when I do that it is being treated as if that property were not set, which affects the resulting image. Looking at the network traffic, I see that it's sending the JSON for the renderer. I've included sample code below based on the ArcGIS renderer_class_breaks sample to give an idea of what I'm talking about.

My question is: is there a way to get JSON for a renderer that includes a reference to the isMaxInclusive property, or that behaves in the same way? Or is this just something that was not implemented in JSON?

<!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>Class Breaks Renderer</title>

    <link rel="stylesheet" href="https://js.arcgis.com/3.19/esri/css/esri.css">
    <style>
      html, body, #map{
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
    <script src="https://js.arcgis.com/3.19/"></script>
    <script>
      var map;
      require([
        "esri/map", "esri/layers/FeatureLayer",
        "esri/InfoTemplate", "esri/symbols/SimpleFillSymbol", 
        "esri/renderers/ClassBreaksRenderer",
        "esri/Color", "dojo/dom-style", "dojo/domReady!"
      ], function(
        Map, FeatureLayer,
        InfoTemplate, SimpleFillSymbol, 
        ClassBreaksRenderer,
        Color, domStyle
      ) {
        map = new Map("map", {
          basemap: "streets",
          center: [-98.215, 38.382],
          zoom: 7,
          slider: false
        });

        var symbol = new SimpleFillSymbol();
        symbol.setColor(new Color([150, 150, 150, 0.5]));

        var renderer = new ClassBreaksRenderer(symbol, "POP07_SQMI");
        renderer.addBreak(0, 25, new SimpleFillSymbol().setColor(new Color([56, 168, 0, 0.5])));
        renderer.addBreak(25, 63.4, new SimpleFillSymbol().setColor(new Color([139, 209, 0, 0.5])));
        renderer.addBreak(63.4, 175, new SimpleFillSymbol().setColor(new Color([255, 255, 0, 0.5])));
        renderer.addBreak(175, 400, new SimpleFillSymbol().setColor(new Color([255, 128, 0, 0.5])));
        renderer.addBreak(400, Infinity, new SimpleFillSymbol().setColor(new Color([255, 0, 0, 0.5])));

        // Running with setMaxInclusive(false) turns the block just above the red wichita to yellow
        // Running without it sets it to green
        renderer.setMaxInclusive(false);

        // Neither setting for maxInclusive affects the output of renderer.toJson()
        console.log('renderer.toJson()', renderer.toJson());

        var infoTemplate = new InfoTemplate("${NAME}", "${*}");
        var featureLayer = new FeatureLayer("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3", {
          mode: FeatureLayer.MODE_SNAPSHOT,
          outFields: ["*"],
          infoTemplate: infoTemplate
        });

        featureLayer.setDefinitionExpression("STATE_NAME = 'Kansas'");
        featureLayer.setRenderer(renderer);
        map.addLayer(featureLayer);
      });
    </script>
  </head>

  <body>
    <div id="map"></div>
  </body>

</html>

1 Answer 1

1

it appears that you've caught something that just wasn't implemented in JSON. i can reproduce the same behavior in version 4.2 of the API and i've notified the development team of the problem.

http://jsbin.com/mimizociju/1/edit?html,output

is there a specific use case that makes it totally infeasible to workaround the issue in your own client code?

4
  • I have a workaround in place now that changes the renderer values to compensate.
    – Dante617
    Jan 27, 2017 at 15:03
  • glad to hear it. thanks for taking the time to file the report (and close the loop). Jan 27, 2017 at 21:29
  • Would definitely still like it if the JSON had a similar property, though.
    – Dante617
    Jan 27, 2017 at 21:51
  • me too. I'll update this thread if/when I get more info. Jan 28, 2017 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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