【发布时间】:2018-01-15 21:35:07
【问题描述】:
我想知道如何在 react-leaflet 地图组件上捕获 zoomstart 和 zoomend 事件。
我有一些自定义的非地理地图
<Map
center={this.getCalculatedCenterFromState()}
zoom={this.getCalculatedZoomFromState()}
minZoom={this.getCalculatedMinZoomFromState()}
maxZoom={2}
attributionControl={false}
doubleClickZoom={false}
zoomControl={false}
crs={this.mapService.getProjectionType()}
>
<ZoomControl position={'topright'} zoomInText={"<img src=" + this.mapService.getPlusIconPath() + " alt='plus' />"} zoomOutText={"<img src=" + this.mapService.getMinusIconPath() + " alt='minus' />"} />
<CategoryControl />
<Layers data={this.showPlanService.getJSONResponse()} />
</Map>
我需要根据缩放级别显示和隐藏一些组件。
【问题讨论】:
-
你试过
onZoomstart/onZoomend吗? -
@megamit 是的,兄弟,这是工作。我只是在处理程序方法中犯了一些错误(没有输出的 TODO 注释)但我确信有一些 alert() 方法。
标签: reactjs leaflet react-leaflet