Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DrawingManager在WebGL模式下不可用,有报错 #310

Open
sknightq opened this issue Jul 12, 2023 · 2 comments
Open

DrawingManager在WebGL模式下不可用,有报错 #310

sknightq opened this issue Jul 12, 2023 · 2 comments

Comments

@sknightq
Copy link

在WebGL模式下会报错
复现方式:用这个demo并开启webgl模式

  1. TypeError: Cannot read properties of undefined (reading 'offset')
    image
const { drawingManager } = useDrawingManager({
    map,
    isOpen: true, 
    enableDrawingTool: true,
    drawingToolOptions: {
      anchor: BMAP_ANCHOR_TOP_RIGHT, // 位置, 这个用WebGL开启会报 Cannot read properties of undefined (reading 'offset')错误,不传这个参数才能正常渲染,但是不能修改控件位置(只能用CSS修改)
      offset: new BMap.Size(5, 5), 
      drawingModes: ['circle', 'polygon'],
    },
    circleOptions: styleOptions, 
    polylineOptions: styleOptions, 
    polygonOptions: styleOptions, 
    rectangleOptions: styleOptions
  })
  1. 画圆时直接报错Uncaught TypeError: Cannot read properties of null (reading 'lng'),导致无法画圆
    image
@jaywcjlove
Copy link
Member

* 百度地图JavaScript API GL v1.0是一套由JavaScript语言编写的应用程序接口,可帮助您在网站中构建功能丰富、交互性强的地图应用,支持PC端和移动端基于浏览器的地图应用开发,且支持HTML5特性的地图开发。
* JavaScript API GL使用了WebGL对地图、覆盖物等进行渲染,支持3D视角展示地图。 GL版本接口基本向下兼容,迁移成本低。目前v1.0版本支持了基本的3D地图展示、基本地图控件和覆盖物。
*/
type?: 'webgl';

@sknightq 需要设置一下但是也不一定能解决问题,如果没有解决可以使用官方 React GL 组件 https://lbsyun.baidu.com/solutions/reactBmapDoc

https://uiwjs.github.io/react-baidu-map/#/api-loader?_id=props

@sknightq
Copy link
Author

@jaywcjlove 感谢回复,官方组件写得太烂了,不管是类型声明还是加载方式。目前解决方法就是不用webgl模式

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants