我正在使用带有Leaflet的v3(v 1.0.2)并且需要捕获viewreset事件,但它没有被触发.
this.map.on("viewreset", () => console.log("VIEW RESET"));
还有其他人有这个问题吗?例如,我能够捕捉到zoomend事件.
另外,在新版本的Leaflet中操纵svg-layers上的位置等也有点痛苦……但这是另一个故事.
JSFidlle显示问题http://leafletjs.com/reference-1.0.2.html
解决方法:
根据:https://github.com/Leaflet/Leaflet/issues/4837
in 1.0, layers will have to rely on both zoom (zoom change) and viewreset (full reset of a layer). This was necessary to implement flyTo and other arbitrary animations.
并在:https://github.com/Leaflet/Leaflet/pull/3278
remove viewreset event and depend solely on zoom event in layers instead
因此,在缩放时不再触发viewreset事件.