AnsweredAssumed Answered

FeatureLayer.setMaxAllowableOffset doesn't seem to do anything

Question asked by bgfield on Feb 2, 2018
Latest reply on Feb 5, 2018 by bgfield

I've been experimenting with the maxAllowableOffset property to try to manage the load times of one of my feature services, except this method doesn't seem to do anything at all.  When I inspect the feature layer object in my developers console, I don't even see a "maxAllowableOffset" property.  If I run the javascript and look at the network requests I see "&maxAllowableOffset=x" in the query, where x ends up being the same regardless of what I enter for the maxAllowableOffset property when creating the feature layer object (x does change as you zoom in and out, though).


Just to be sure there wasn't something weird in my map I created a very basic sample map with one of ESRI's feature layers to test this.

 

<!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>Simple Map</title>
    <link rel="stylesheet" href="https://js.arcgis.com/3.23/esri/css/esri.css">
    <style>
      html, body, #map {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
    <script src="https://js.arcgis.com/3.23/"></script>
    <script>
      require(["esri/map", "esri/layers/FeatureLayer", "dojo/on", "dojo/parser", "dojo/domReady!"], function(Map, FeatureLayer, on, parser) {
      
          parser.parse();
      
        map = new Map("map", {
          basemap: "topo",
          center: [-95.45, 37.75],
          zoom: 5
        });
          
        featureLayer = new esri.layers.FeatureLayer("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/3", { maxAllowableOffset: 5000 });
          
          map.addLayer(featureLayer);
          
          function calcOffset() {
               console.log(map.extent.getWidth() / map.width);
               return (map.extent.getWidth() / map.width);
          };
          
          on(map, "zoom-end", function() {
               maxOffset = calcOffset();
               featureLayer.setMaxAllowableOffset(maxOffset);
          });
          
      });
    </script>
  </head>

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

 

Just for kicks, I also tried setting the maxAllowableOffset through the .setMaxAllowableOffset method instead of setting it when creating the feature layer object itself, and the results were the same.

 

Has anyone gotten this to work?

Outcomes