uiwjs/react-baidu-map

ref获取DrawingManager组件实例报错

liuaoin opened this issue · 5 comments

@liuaoin 不知道示例是如何写的,组件自己内部加载了 SDK,可能SDK不匹配

if (map && bMapLib && !bMapLib.DrawingManager) {
requireCss('//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css').then(() => {});
requireScript('//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js')
.then(() => {
if (window.BMapLib) {
const newMapLib = Object.assign(window.BMapLib, bMapLib);
setBMapLib(newMapLib);
const instance = new BMapLib.DrawingManager(map, opts);
setDrawingManager(instance);
}
})
.catch(() => {});
}
// 如果第一次加载,会执行下面的
if (!bMapLib && !loadMapLib) {
setLoadBMapLib(true);
requireCss('//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css').then(() => {});
requireScript('//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js')
.then(() => {
if (window.BMapLib) {
setBMapLib(window.BMapLib);
}
})
.catch(() => {});
}

image

image

@liuaoin 你更新 2.6.1 试一试

已修复,感谢