diff --git a/packages/amap/src/marker-cluster/index.ts b/packages/amap/src/marker-cluster/index.ts index 3dc188b1..16a02597 100644 --- a/packages/amap/src/marker-cluster/index.ts +++ b/packages/amap/src/marker-cluster/index.ts @@ -1,2 +1,2 @@ -export { MarkerCluster } from './marker-cluster'; +export { default as MarkerCluster } from './marker-cluster'; export type { MarkerClusterProps } from './types'; diff --git a/packages/amap/src/marker-cluster/marker-cluster.tsx b/packages/amap/src/marker-cluster/marker-cluster.tsx index 7f53a07b..e928649f 100644 --- a/packages/amap/src/marker-cluster/marker-cluster.tsx +++ b/packages/amap/src/marker-cluster/marker-cluster.tsx @@ -108,3 +108,5 @@ const MarkerCluster = forwardRef(InternalCluster) as RefInternalCluster & { MarkerCluster.defaultProps = { zoomOnClick: true } + +export default MarkerCluster; diff --git a/packages/amap/src/marker/demo/demo-06/Business.tsx b/packages/amap/src/marker/demo/demo-06/Business.tsx deleted file mode 100644 index 800d884b..00000000 --- a/packages/amap/src/marker/demo/demo-06/Business.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React, { useContext } from 'react'; -import { Marker } from './Marker'; -import { MapService } from './useMapService'; - -export const Business: React.FC = () => { - const { list = [] } = useContext(MapService); - - return ( -
- {list.map((item, index) => { - return ( - - ) - })} -
- ) -} diff --git a/packages/amap/src/marker/demo/demo-06/Marker/index.less b/packages/amap/src/marker/demo/demo-06/Marker/index.less deleted file mode 100644 index 6e3d99b9..00000000 --- a/packages/amap/src/marker/demo/demo-06/Marker/index.less +++ /dev/null @@ -1,4 +0,0 @@ -.marker { - color: #f56a00; - background-color: #fde3cf; -} diff --git a/packages/amap/src/marker/demo/demo-06/Marker/index.tsx b/packages/amap/src/marker/demo/demo-06/Marker/index.tsx deleted file mode 100644 index 6c078201..00000000 --- a/packages/amap/src/marker/demo/demo-06/Marker/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { Avatar } from 'antd'; -import { AntDesignOutlined } from '@ant-design/icons'; -import { Marker as MapMarker } from '@pansy/react-amap'; -import { MarkerProps } from '@pansy/react-amap/es/marker/types'; -import styles from './index.less'; - -export const Marker: React.FC = (props) => { - console.log(props); - return ( - - } - /> - - ) -} diff --git a/packages/amap/src/marker/demo/demo-06/index.tsx b/packages/amap/src/marker/demo/demo-06/index.tsx deleted file mode 100644 index a4c23690..00000000 --- a/packages/amap/src/marker/demo/demo-06/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import { Map } from '@pansy/react-amap'; -import { Business } from './Business'; -import { useMapService, MapService } from './useMapService'; - -export default () => { - const mapService = useMapService(); - - return ( - -
- - - -
-
- ); -}; - diff --git a/packages/amap/src/marker/demo/demo-06/useMapService.ts b/packages/amap/src/marker/demo/demo-06/useMapService.ts deleted file mode 100644 index c8dc54b1..00000000 --- a/packages/amap/src/marker/demo/demo-06/useMapService.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { useState } from 'react'; -import { MarkerProps } from '@pansy/react-amap/es/marker/types'; -import { MapEventMap } from '@pansy/react-amap/es/map/types'; -import { getServiceToken } from './utils'; - -const randomLnglat = () => [ - 100 + Math.random() * 20, - 30 + Math.random() * 20 -]; - -const randomMarker = (len = 10) => ( - Array(len).fill(true).map((item, index) => ({ - position: randomLnglat(), - extData: index - })) -); - -export const useMapService = () => { - /** 标记点数据 */ - const [list, setList] = useState(randomMarker() as MarkerProps[]); - - const mapEventMap: MapEventMap = { - created: obj => { - console.log(obj); - }, - }; - - return { - list, - mapEventMap, - }; -}; - -export const MapService = getServiceToken(useMapService); diff --git a/packages/amap/src/marker/demo/demo-06/utils.ts b/packages/amap/src/marker/demo/demo-06/utils.ts deleted file mode 100644 index 1d286c21..00000000 --- a/packages/amap/src/marker/demo/demo-06/utils.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { createContext } from 'react'; - -/** - * 泛型约束,对注入数据的类型推断支持 - * - * @export - * @template T - * @param {(...args: any) => T} useFunc - * @param {(T | undefined)} [initialData=undefined] - * @returns - */ -export function getServiceToken( - useFunc: (...args: any) => T, - initialData: T | undefined = undefined, -) { - return createContext(initialData as T); -} - -export default getServiceToken; diff --git a/packages/amap/src/marker/index.md b/packages/amap/src/marker/index.md index 7d6f1119..6359d86e 100644 --- a/packages/amap/src/marker/index.md +++ b/packages/amap/src/marker/index.md @@ -41,10 +41,6 @@ group: -### 案例1 - - - ## API ### 动态属性 diff --git a/packages/amap/src/marker/marker.tsx b/packages/amap/src/marker/marker.tsx index 2120f2ee..05ab3762 100644 --- a/packages/amap/src/marker/marker.tsx +++ b/packages/amap/src/marker/marker.tsx @@ -1,12 +1,13 @@ -import React, { useRef, useEffect, useImperativeHandle } from 'react'; +import React, { forwardRef, useRef, useEffect, useImperativeHandle } from 'react'; import { usePortal } from '@pansy/use-portal'; import { useMap } from '../map'; import { usePropsReactive, isFun } from '../utils'; -import type { MarkerProps } from './types'; import { buildCreateOptions } from '../utils/control'; import { allProps, setterMap, converterMap } from './config'; -export const Marker = React.forwardRef>((props = {}, ref) => { +import type { MarkerProps } from './types'; + +export const Marker = forwardRef>((props = {}, ref) => { const { map, AMap } = useMap(); const { container, Portal } = usePortal(); const instanceObj = useRef(null);