如何防止 dynamicMapLayer 在每次缩放或平移地图时刷新?

How do I prevent a dynamicMapLayer from refreshing on every zoom or pan of the map?

我正在使用传单 L.esri.dynamicMapLayer 在地图上显示大量多段线,并且向 ArcGIS Server 发出绘制它们的导出请求可能需要一段时间。如果用户快速进行多次缩放或平移,我可能会收到一堆待处理的导出请求,这也会阻止对 ArcGIS Server 的其他请求。除了最后一个外,所有这些导出请求都是无用的。

对于其他客户端层,我已经通过确保用户在自己刷新层之前停止缩放或平移至少 2 秒来控制刷新。我如何对 dynamicMapLayer 做同样的事情,我能否暂停或停止自动刷新并自行决定何时发出导出请求?

请注意,我们不能使用图块来获得更好的性能,因为图层必须保持动态的其他原因。

How do I prevent a dynamicMapLayer from refreshing on every zoom or pan of the map?

你不能。 It is designed that way.

除非 esri 人员重新设计它以创建 L.GridLayer 的子类而不是 L.ImageOverlay,否则几乎没有任何解决办法。

I'm already controlling the refresh by making sure the user has stopped zooming or panning for at least 2 second before refreshing the layers myself. How can I do the same for the dynamicMapLayer?

一个可怕的、丑陋的黑客。覆盖 private L.Esri.DynamicMapLayer._update 方法,使其成为先前方法的装饰器,例如类似于:

(function() {
  var previousProto = L.Esri.DynamicMapLayer.prototype;
  L.Esri.DynamicMapLayer.include({
    _update: function(){
       throttle(previousProto._update, 2000);
    }
  });
})();

它很丑陋,它违背了大多数良好的编码习惯(覆盖私有方法,eeeew),而且它可能会崩溃。

Note that we cannot use tiles for better performance, because of other reasons the layer must stay dynamic.

我不同意。 "tiles" 并不意味着 "static"。您可以轻松应用缓存清除,或使用 time dimension, or send all data to the client and let it slice it into vector tiles for quick rendering, or use something fancier like Carto(DB)'s Torque.

事实上,您的 Esri 工具不允许您轻松创建不同的切片集,或者不允许对不断变化的资源进行切片访问,或者不允许触发客户端数据失效,但这并不表示无法完成。