首页 > 解决方案 > 无法在 React 中使用 MapControl 删除 react-leaflet Map

问题描述

我使用 MapControl 在 Leaflet 地图中创建了地图图例。一切正常,但是当我尝试删除 Map 组件时,我Uncaught TypeError: Cannot read property 'remove' of undefined MapControl.js. 有谁知道如何解决它?

下面是代码框中的示例 - 5 秒后,我删除了地图并更改了内容。 https://codesandbox.io/s/how-to-add-a-legend-to-the-map-using-react-leaflet-forked-if0q4?file=/src/Map.js

标签: javascriptreactjsleafletreact-leaflet

解决方案


推荐阅读