Skip to content

Commit

Permalink
fix(CurveLine): Fix enableEditing props issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 27, 2020
1 parent 1d317a4 commit 2e92f2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions package.json
Expand Up @@ -48,7 +48,7 @@
"react-dom": ">=16.8.0"
},
"devDependencies": {
"@kkt/loader-less": "^5.5.1",
"@kkt/loader-less": "^5.6.1",
"@loadable/component": "^5.12.0",
"@types/classnames": "^2.2.7",
"@types/jest": "^24.0.23",
Expand All @@ -64,16 +64,15 @@
"classnames": "^2.2.6",
"compile-less-cli": "^1.3.0",
"cross-env": "^7.0.2",
"kkt": "^5.5.1",
"kkt": "^5.6.1",
"prismjs": "^1.19.0",
"raw-loader": "^3.1.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-markdown": "^4.3.1",
"react-router-dom": "^5.1.2",
"react-test-renderer": "^16.8.6",
"tsbb": "^1.5.2",
"typescript": "^3.8.3",
"tsbb": "^1.6.2",
"uiw": "^3.10.6"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/CurveLine/README.md
Expand Up @@ -15,7 +15,7 @@ import React, { useState } from 'react';
import { Map, CurveLine, APILoader } from '@uiw/react-baidu-map';

const Example = () => {
const [enableEditing, setEnableEditing] = useState(true);
const [enableEditing, setEnableEditing] = useState(false);
const [strokeOpacity, setStrokeOpacity] = useState(0.5);
function curveLineRef(props) {
if (props && props.curveLine) {
Expand Down Expand Up @@ -66,7 +66,7 @@ import { useRef, useEffect, useState } from 'react';
import { Map, APILoader, useMap, useCurveLine } from '@uiw/react-baidu-map';

const Example = () => {
const [enableEditing, setEnableEditing] = useState(true);
const [enableEditing, setEnableEditing] = useState(false);
const [strokeOpacity, setStrokeOpacity] = useState(0.9);
const divElm = useRef(null);
const { setContainer, map } = useMap({
Expand Down Expand Up @@ -143,7 +143,7 @@ ReactDOM.render(<Demo />, _mount_);
| strokeOpacity | 折线的透明度,取值范围0 - 1 | Number | - |
| strokeStyle | 折线的样式,solid或dashed | String | - |
| enableMassClear | 是否在调用map.clearOverlays清除此覆盖物,默认为true | Boolean | - |
| enableEditing | 是否启用线编辑,默认为false | Boolean | - |
| enableEditing | 是否启用线编辑,默认为false | Boolean | `false` |
| enableClicking | 是否响应点击事件,默认为true | Boolean | - |
| icons | 配置贴合折线的图标 | IconSequence[] | - |

Expand Down
8 changes: 4 additions & 4 deletions src/CurveLine/useCurveLine.tsx
Expand Up @@ -7,12 +7,12 @@ export interface UseCurveLine extends CurveLineProps {
}

export default (props = {} as UseCurveLine) => {
const { map, strokeColor, strokeWeight, strokeOpacity, strokeStyle, enableMassClear, enableEditing, enableClicking, icons, } = props;
const { map, strokeColor, strokeWeight, strokeOpacity, strokeStyle, enableMassClear, enableEditing = false, enableClicking, icons, } = props;
const [curveLine, setCurveLine] = useState<BMapLib.CurveLine>();
const libSDK = window.BMapLib;
const [bMapLib, setBMapLib] = useState<typeof BMapLib>(libSDK);
const [loadMapLib, setLoadBMapLib] = useState(false || !!libSDK);
const opts = { strokeColor, strokeWeight, strokeOpacity, strokeStyle, enableMassClear, enableClicking, icons, }
const opts = { strokeColor, strokeWeight, strokeOpacity, strokeStyle, enableMassClear, enableEditing, enableClicking, icons, }
useMemo(() => {
// 如果第一次加载,会执行下面的
if (map && bMapLib && !curveLine) {
Expand Down Expand Up @@ -52,15 +52,15 @@ export default (props = {} as UseCurveLine) => {

});
}
}, [map, loadMapLib, bMapLib, curveLine]);
}, [map, bMapLib, curveLine, loadMapLib, props.path, opts]);

const [path, setPath] = useState(props.path || []);
useEffect(() => {
if (curveLine && props.path && path && JSON.stringify(path) !== JSON.stringify(props.path)) {
const points = path.map((item) => new BMap.Point(item.lng, item.lat));
curveLine.setPath(points);
}
}, [curveLine, props.path]);
}, [curveLine, path, props.path]);

useVisiable(curveLine!, props);
useEventProperties<BMap.Polyline, UseCurveLine>(curveLine!, props, [
Expand Down

0 comments on commit 2e92f2d

Please sign in to comment.