diff --git a/packages/biz/src/boxSelectTree/index.md b/packages/biz/src/boxSelectTree/index.md index 614355f..2feff2c 100644 --- a/packages/biz/src/boxSelectTree/index.md +++ b/packages/biz/src/boxSelectTree/index.md @@ -43,7 +43,6 @@ group: | checkedTags | 选中的标签值 | string[] | [] | - | | footer | 盒子树底部渲染(需要内容撑开) | ReactNode、string | - | - | | tagFootRender | 标签看板底部自定义 | ReactNode、string | - | - | - | onResetTags | 标签重置 | () => void | [] | - | | onTagExpand | 标签展开 | (e: any) => void | [] | - | | onTabChange | tab切换监听 | function: (e) => void | - | - | diff --git a/packages/map/es/MapBox.js b/packages/map/es/MapBox.js deleted file mode 100644 index 244f3dd..0000000 --- a/packages/map/es/MapBox.js +++ /dev/null @@ -1,195 +0,0 @@ -function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } -var _excluded = ["style", "children", "height", "width", "draw", "markerData", "sluterData", "popUpInfo", "showPopUp", "toolsBarOpen", "showMarker", "showCluster", "clusterProps", "interactiveLayerIds", "buttonList", "onMarkerClick", "onPopUpClose", "customMarkerRender", "onLoad", "onDrawCreate", "onDrawUpdate", "onDrawDelete", "onToolClick"]; -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } -function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } -function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } -function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } -function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } -function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } -function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } -function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } -function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } -function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } -function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } -import 'mapbox-gl/dist/mapbox-gl.css'; -import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'; -import React, { forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react'; -import Map from 'react-map-gl'; -import classnames from 'classnames'; -import { merge } from '@zhst/func'; -import Tools from "./components/tools"; -import DrawControl from "./components/drawControl"; -import { defaultMapConfig } from "./utils/constants"; -import "./index.less"; -import mapboxDrawStyle from "./utils/drawStyle"; -import Marker from "./components/marker"; -import PopUp from "./components/popup"; -import Cluster from "./components/clusters/Clusters"; -import { clusterLayer } from "./components/clusters/layers"; -var componentName = 'zhst-map'; -var MapBox = /*#__PURE__*/forwardRef(function (props, ref) { - var _ref = props || {}, - _ref$style = _ref.style, - style = _ref$style === void 0 ? {} : _ref$style, - children = _ref.children, - _ref$height = _ref.height, - height = _ref$height === void 0 ? 600 : _ref$height, - _ref$width = _ref.width, - width = _ref$width === void 0 ? '100%' : _ref$width, - draw = _ref.draw, - _ref$markerData = _ref.markerData, - markerData = _ref$markerData === void 0 ? [] : _ref$markerData, - _ref$sluterData = _ref.sluterData, - sluterData = _ref$sluterData === void 0 ? [] : _ref$sluterData, - _ref$popUpInfo = _ref.popUpInfo, - popUpInfo = _ref$popUpInfo === void 0 ? { - longitude: 0, - latitude: 0 - } : _ref$popUpInfo, - showPopUp = _ref.showPopUp, - toolsBarOpen = _ref.toolsBarOpen, - _ref$showMarker = _ref.showMarker, - showMarker = _ref$showMarker === void 0 ? true : _ref$showMarker, - _ref$showCluster = _ref.showCluster, - showCluster = _ref$showCluster === void 0 ? false : _ref$showCluster, - clusterProps = _ref.clusterProps, - _ref$interactiveLayer = _ref.interactiveLayerIds, - interactiveLayerIds = _ref$interactiveLayer === void 0 ? [] : _ref$interactiveLayer, - _ref$buttonList = _ref.buttonList, - buttonList = _ref$buttonList === void 0 ? [{ - label: '圆形框选', - key: 'circle', - icon: 'icon-yuan', - onClick: function onClick() { - var _drawControlRef$curre, _drawControlRef$curre2; - return (_drawControlRef$curre = drawControlRef.current) === null || _drawControlRef$curre === void 0 || (_drawControlRef$curre = _drawControlRef$curre.drawer) === null || _drawControlRef$curre === void 0 || (_drawControlRef$curre2 = _drawControlRef$curre.changeMode) === null || _drawControlRef$curre2 === void 0 ? void 0 : _drawControlRef$curre2.call(_drawControlRef$curre, 'simple_select'); - } - }, { - label: '矩形框选', - key: 'rect', - icon: 'icon-fang', - onClick: function onClick() { - var _drawControlRef$curre3, _drawControlRef$curre4; - return (_drawControlRef$curre3 = drawControlRef.current) === null || _drawControlRef$curre3 === void 0 || (_drawControlRef$curre3 = _drawControlRef$curre3.drawer) === null || _drawControlRef$curre3 === void 0 || (_drawControlRef$curre4 = _drawControlRef$curre3.changeMode) === null || _drawControlRef$curre4 === void 0 ? void 0 : _drawControlRef$curre4.call(_drawControlRef$curre3, 'draw_rect'); - }, - popoverProps: { - placement: 'bottom', - content: '自定义内容' - } - }, { - label: '多边形框选', - key: 'more', - icon: 'icon-duobianxing', - onClick: function onClick() { - var _drawControlRef$curre5, _drawControlRef$curre6; - return (_drawControlRef$curre5 = drawControlRef.current) === null || _drawControlRef$curre5 === void 0 || (_drawControlRef$curre5 = _drawControlRef$curre5.drawer) === null || _drawControlRef$curre5 === void 0 || (_drawControlRef$curre6 = _drawControlRef$curre5.changeMode) === null || _drawControlRef$curre6 === void 0 ? void 0 : _drawControlRef$curre6.call(_drawControlRef$curre5, 'draw_polygon'); - } - }, { - label: '路径框选', - key: 'path', - icon: 'icon-lujingkuangxuannor', - onClick: function onClick() { - var _drawControlRef$curre7, _drawControlRef$curre8; - return (_drawControlRef$curre7 = drawControlRef.current) === null || _drawControlRef$curre7 === void 0 || (_drawControlRef$curre7 = _drawControlRef$curre7.drawer) === null || _drawControlRef$curre7 === void 0 || (_drawControlRef$curre8 = _drawControlRef$curre7.changeMode) === null || _drawControlRef$curre8 === void 0 ? void 0 : _drawControlRef$curre8.call(_drawControlRef$curre7, 'draw_line_string'); - } - }, { - label: '测距', - key: 'path', - icon: 'icon-ceju', - onClick: function onClick() { - var _drawControlRef$curre9, _drawControlRef$curre10; - return (_drawControlRef$curre9 = drawControlRef.current) === null || _drawControlRef$curre9 === void 0 || (_drawControlRef$curre9 = _drawControlRef$curre9.drawer) === null || _drawControlRef$curre9 === void 0 || (_drawControlRef$curre10 = _drawControlRef$curre9.changeMode) === null || _drawControlRef$curre10 === void 0 ? void 0 : _drawControlRef$curre10.call(_drawControlRef$curre9, 'draw_line_string'); - } - }, { - label: '清除', - key: 'clear', - icon: 'icon-gongjuxiangguanbi', - onClick: function onClick() { - var _drawControlRef$curre11; - return (_drawControlRef$curre11 = drawControlRef.current) === null || _drawControlRef$curre11 === void 0 || (_drawControlRef$curre11 = _drawControlRef$curre11.drawer) === null || _drawControlRef$curre11 === void 0 ? void 0 : _drawControlRef$curre11.deleteAll(); - } - }] : _ref$buttonList, - onMarkerClick = _ref.onMarkerClick, - onPopUpClose = _ref.onPopUpClose, - customMarkerRender = _ref.customMarkerRender, - onLoad = _ref.onLoad, - onDrawCreate = _ref.onDrawCreate, - onDrawUpdate = _ref.onDrawUpdate, - onDrawDelete = _ref.onDrawDelete, - onToolClick = _ref.onToolClick, - others = _objectWithoutProperties(_ref, _excluded); - var mapRef = useRef(null); - var drawControlRef = useRef(null); - - // 默认绘制配置 - var _useState = useState({ - displayControlsDefault: false, - position: 'top-left', - styles: mapboxDrawStyle, - // Select which mapbox-gl-draw control buttons to add to the map. - // @ts-ignore - controls: false, - // The user does not have to click the polygon control button first. - defaultMode: 'draw_polygon' - }), - _useState2 = _slicedToArray(_useState, 1), - drawConfig = _useState2[0]; - var initMarker = useMemo(function () { - return markerData.map(function (_item) { - return /*#__PURE__*/React.createElement(Marker, _extends({ - customMarkerRender: customMarkerRender, - onMarkerClick: onMarkerClick - }, _item)); - }); - }, [markerData]); - useImperativeHandle(ref, function () { - var _drawControlRef$curre12; - return { - mapRef: mapRef.current, - drawer: (_drawControlRef$curre12 = drawControlRef.current) === null || _drawControlRef$curre12 === void 0 ? void 0 : _drawControlRef$curre12.drawer - }; - }); - return ( - /*#__PURE__*/ - //@ts-ignore - React.createElement("div", { - className: classnames("".concat(componentName)) - }, /*#__PURE__*/React.createElement(Tools, { - open: toolsBarOpen, - buttonList: buttonList, - onToolClick: onToolClick - }), /*#__PURE__*/React.createElement(Map, _extends({ - ref: mapRef, - onLoad: onLoad, - style: _objectSpread({ - width: width, - height: height - }, style), - interactiveLayerIds: [clusterLayer.id].concat(_toConsumableArray(interactiveLayerIds)) - }, merge(defaultMapConfig, others)), showMarker && initMarker, showPopUp && popUpInfo && /*#__PURE__*/React.createElement(PopUp, _extends({ - onClose: onPopUpClose - }, popUpInfo)), showCluster && !showMarker && /*#__PURE__*/React.createElement(Cluster, _extends({ - type: "geojson", - cluster: true, - clusterMaxZoom: 14, - clusterRadius: 50, - data: sluterData - }, clusterProps)), draw && /*#__PURE__*/React.createElement(DrawControl, _extends({ - ref: drawControlRef, - onCreate: onDrawCreate, - onUpdate: onDrawUpdate, - onDelete: onDrawDelete, - onSelectionChange: function onSelectionChange(e) { - return console.log('e', e); - } - }, drawConfig)), children)) - ); -}); -export default MapBox; \ No newline at end of file diff --git a/packages/map/es/index.js b/packages/map/es/index.js index 8d9edea..1ff428f 100644 --- a/packages/map/es/index.js +++ b/packages/map/es/index.js @@ -1,2 +1,3 @@ -export { default as MapBox } from "./MapBox"; -export * from 'react-map-gl'; \ No newline at end of file +export { default as MapBox } from "./mapBox"; +export * from 'react-map-gl'; +export * from "./utils"; \ No newline at end of file diff --git a/packages/map/es/index.less b/packages/map/es/index.less deleted file mode 100644 index 3369b02..0000000 --- a/packages/map/es/index.less +++ /dev/null @@ -1,9 +0,0 @@ -.zhst-map { - position: relative; - width: auto; - height: auto; - - .mapboxgl-ctrl-logo { - display: none; - } -} diff --git a/packages/map/src/changelog/index.md b/packages/map/src/changelog/index.md new file mode 100644 index 0000000..d8f714b --- /dev/null +++ b/packages/map/src/changelog/index.md @@ -0,0 +1,7 @@ +--- +title: 版本更新日志 +order: 2 +toc: content +--- + + diff --git a/packages/map/src/demo/basic.tsx b/packages/map/src/demo/basic.tsx index 5667d42..9628dd8 100644 --- a/packages/map/src/demo/basic.tsx +++ b/packages/map/src/demo/basic.tsx @@ -120,18 +120,13 @@ const demo = () => { showCluster={showCluster} // popUpInfo={popupInfo} onPopUpClose={e => setPopupInfo(null)} - onMarkerClick={(e, status, data) => { + onMarkerCheck={(e, status, data) => { setMarkerData(pre => pre.map(item => { if (item.id === data.id) { item.checked = !data?.checked } return item })) - // setPopupInfo({ - // longitude: data?.longitude, - // latitude: data?.latitude, - // content: '测试' - // }) }} onZoomEnd={map => { let zoom = map.target.getZoom() // 画面层级,用来判断标签是否显示隐藏 diff --git a/packages/map/src/mapBox/MapBox.tsx b/packages/map/src/mapBox/MapBox.tsx index 74edddc..5ecab11 100644 --- a/packages/map/src/mapBox/MapBox.tsx +++ b/packages/map/src/mapBox/MapBox.tsx @@ -45,7 +45,8 @@ export interface MapProps extends MapBoxProps { onDrawCreate?: (e: { features: object[], [key: string]: any }) => void onDrawUpdate?: (e: { features: object[], [key: string]: any }) => void onDrawDelete?: (e: { features: object[], [key: string]: any }) => void - onMarkerClick?: MarkerProps['onMarkerClick'] + onMarkerClick?: MarkerProps['onClick'] + onMarkerCheck?: MarkerProps['onCheck'] onPopUpClose?: (e: PopupEvent) => void; onToolClick?: ToolsProps['onToolClick'] } @@ -118,6 +119,7 @@ const MapBox = forwardRef((props, ref) => { } ], onMarkerClick, + onMarkerCheck, onPopUpClose, customMarkerRender, onLoad, @@ -148,7 +150,8 @@ const MapBox = forwardRef((props, ref) => { return markerData.map((_item) => ( )) diff --git a/packages/map/src/marker/demo/basic.tsx b/packages/map/src/marker/demo/basic.tsx index 0cc2ae4..8d1ce94 100644 --- a/packages/map/src/marker/demo/basic.tsx +++ b/packages/map/src/marker/demo/basic.tsx @@ -61,10 +61,17 @@ const demo = () => { ref={mapRef} width='100%' height='800px' + showToolBar={false} markerData={markerData || []} showMarker={showMarker} - onMarkerClick={(e, status, data) => { + onMarkerCheck={(e, status, data) => { console.log('marker', data) + setMarkerData(pre => pre.map(item => { + if (item.id === data.id) { + item.checked = !data?.checked + } + return item + })) }} > diff --git a/packages/map/src/utils/index.md b/packages/map/src/utils/index.md index e69de29..9ac813f 100644 --- a/packages/map/src/utils/index.md +++ b/packages/map/src/utils/index.md @@ -0,0 +1,26 @@ +--- +category: Components +subtitle: utils +title: utils 工具库 +toc: content +group: + title: 其它 + order: 4 +--- + + +## getPointByShape + +获取图形中的点位,一般用来圈选使用 + +```js +import { getPointByShape } from '@zhst/map' +``` + +## getDistancesByStringLine + +通过绘制的线段获取每段线的距离,和总长度,默认单位为km + +```js +import { getDistancesByStringLine } from '@zhst/map' +```