I have been trying to implement this functionality myself without any luck. I am adding a county polygon layer that has 82 features in the layer. The features get generalized when they are loaded but not when the map is zoomed. The onZoomEnd event listener is getting called but the setMaxAllowableOffset for the feature layer is not getting recalculated. What am I missing here? Here is the code I am using.
var maxOffset = function maxOffset(map, pixelTolerance) {
return Math.floor(map.extent.getWidth() / map.width) * pixelTolerance;
};
var highlightCountyLayer = new esri.layers.FeatureLayer("countyURL", {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
maxAllowableOffset: maxOffset(map,1)
});
dojo.connect(highlightCountyLayer, "onLoad", function() {
dojo.connect(map, "onZoomEnd", function() {
console.log('onZoomEnd highlightCountyLayer')
highlightCountyLayer.setMaxAllowableOffset(maxOffset(map,1));
});
});
map.addLayer(highlightCountyLayer);