FeatureLayer.setMaxAllowableOffset doesn't seem to do anything

431
2
Jump to solution
02-02-2018 10:06 AM
BrettGreenfield__DNR_
Occasional Contributor II

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?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Brett,

   The Feature layer is already doing a generalization based on the extent because of.

AutoGeneralize:

Enable or disable the auto generalization of features from a non-editable layer in on-demand mode. When true, the layer uses the current map resolution as the maxAllowableOffset for all queries issued to the server. The default value is true. As of v2.7

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Brett,

   The Feature layer is already doing a generalization based on the extent because of.

AutoGeneralize:

Enable or disable the auto generalization of features from a non-editable layer in on-demand mode. When true, the layer uses the current map resolution as the maxAllowableOffset for all queries issued to the server. The default value is true. As of v2.7

View solution in original post

0 Kudos
BrettGreenfield__DNR_
Occasional Contributor II

Ah!  How obvious.  Thank you!

0 Kudos