uiwjs / react-baidu-map

基于 React 封装的百度地图组件,支持 React Hook,帮助你轻松的接入地图到 React 项目中。
https://uiwjs.github.io/react-baidu-map
MIT License
223 stars 22 forks source link

可否添加百度的第三方:鼠标绘制工具条库 #14

Closed amin168 closed 4 years ago

amin168 commented 4 years ago

http://lbsyun.baidu.com/index.php?title=jspopular3.0/guide/mouse2draw

http://lbsyun.baidu.com/index.php?title=jspopular3.0/openlibrary

demo:https://lbsyun.baidu.com/jsdemo.htm#f0_7

jaywcjlove commented 4 years ago

@amin168 你可以通过这个实例来添加第三方库

https://github.com/uiwjs/react-baidu-map/tree/master/src/CurveLine

通过 requireScript 方法懒加载第三方包。

https://github.com/uiwjs/react-baidu-map/blob/master/src/CurveLine/useCurveLine.tsx#L25-L31

方法 requireScript 已经导出。

import { requireScript } from '@uiw/react-baidu-map';

requireScript('//api.map.baidu.com/library/CurveLine/1.5/src/CurveLine.min.js')
.then(() => {
  if (window.BMapLib) {
    console.log(window.BMapLib);
  }
}).catch(() => {

});
jaywcjlove commented 4 years ago

@amin168 目前没有空去封装,如果你急,你可以根据实例 来个 PR 。

amin168 commented 4 years ago

@jaywcjlove 我先自己试着封装一下,到时来个PR

amin168 commented 4 years ago

@jaywcjlove 我尝试运行npm run doc:dev,但报了以下的错误,是缺少了什么组件吗。

我现在封装了一点,想测试一下

image

我发了一封邮件给你,想叫你拿个QQ或者WeChat的联系方式ヽ(ー_ー)ノ

jaywcjlove commented 4 years ago

@amin168 兼容windows环境变量要使用这个包 cross-env 环境变量只支持 Mac OS 和 Linux 系统。

jaywcjlove commented 4 years ago

@amin168 你试一试。