尝试使用react-leaflet 3.0.0版本来实现react-lealfet-draw。 它抛出一个错误 /node_modules/react-leaflet-draw/dist/esm/EditControl.js 尝试导入错误:“MapControl”未从“react-leaflet”导出。
import "./styles/leaflet.css";
import "leaflet/dist/leaflet.css";
import "leaflet-draw/dist/leaflet.draw.css";
import "leaflet-draw";
import L from "leaflet";
import "leaflet-splitmap";
import {MapConatiner, TileLayer} from 'react-leaflet';
import {EditControl} from 'react-leaflet-draw';
有没有办法用react-leaflet V3.0.0实现传单绘制功能?
您可以采取一种解决方法。
您可以使用react-leaflet版本,例如。 3.2.5,你可以在你的package.json上添加react-leaflet-draw v0.19.5,但是如果你这样设置,它会产生冲突。
解决方案是在react-leaflet-draw上的依赖项上添加“覆盖”以使用react-leaflet v^3.0.0并忽略v^2.0.0
"overrides": {
"react-leaflet-draw": {
"react-leaflet": "^3.0.0"
}
}