diff --git a/src/components/Legend/LegendIcon/demos/custom.tsx b/src/components/Legend/LegendIcon/demos/custom.tsx
new file mode 100644
index 00000000..af1da387
--- /dev/null
+++ b/src/components/Legend/LegendIcon/demos/custom.tsx
@@ -0,0 +1,17 @@
+import { LegendIcon } from '@antv/larkmap';
+import React from 'react';
+
+export default () => {
+ return (
+
+
,
+
![](https://gw.alipayobjects.com/zos/bmw-prod/e21321e0-8f4a-474f-a0ee-2176492bb824.svg)
,
+
![](https://gw.alipayobjects.com/zos/bmw-prod/7fb22e05-4488-4597-8e33-fc03716d2b0a.svg)
,
+ ]}
+ />
+
+ );
+};
diff --git a/src/components/Legend/LegendIcon/index.less b/src/components/Legend/LegendIcon/index.less
index 804ddc6d..461579f8 100644
--- a/src/components/Legend/LegendIcon/index.less
+++ b/src/components/Legend/LegendIcon/index.less
@@ -6,7 +6,7 @@
align-items: center;
line-height: 2;
- &__icon {
+ > *:first-child {
width: 16px;
height: 16px;
margin-right: 10px
diff --git a/src/components/Legend/LegendIcon/index.md b/src/components/Legend/LegendIcon/index.md
index fa402ce5..ae5cc7ba 100644
--- a/src/components/Legend/LegendIcon/index.md
+++ b/src/components/Legend/LegendIcon/index.md
@@ -21,8 +21,18 @@ nav:
+#### 自定义 icons
+
+
+
#### 在地图中展示
+
+#### LegendIcons
+
+```ts
+type LegendIcons = string | React.ReactElement;
+```
diff --git a/src/components/Legend/LegendIcon/index.tsx b/src/components/Legend/LegendIcon/index.tsx
index ea1f9b61..e8fb5e76 100644
--- a/src/components/Legend/LegendIcon/index.tsx
+++ b/src/components/Legend/LegendIcon/index.tsx
@@ -1,17 +1,26 @@
-import React from 'react';
import classnames from 'classnames';
-import type { LegendIconProps } from './types';
+import React from 'react';
import './index.less';
+import type { LegendIconProps, LegendIcons } from './types';
export const CLS_PREFIX = 'larkmap-legend-icon';
export const LegendIcon = (props: LegendIconProps) => {
const { labels, icons, className: cls, style } = props;
+
+ const renderIcon = (icon: LegendIcons) => {
+ if (React.isValidElement(icon)) {
+ return icon;
+ } else if (typeof icon === 'string') {
+ return
;
+ }
+ };
+
return (
{labels.map((item, index) => (
-
![]({icons[index]})
+ {renderIcon(icons[index])}
{item}
))}
diff --git a/src/components/Legend/LegendIcon/types.ts b/src/components/Legend/LegendIcon/types.ts
index a92a5cb2..885d585f 100644
--- a/src/components/Legend/LegendIcon/types.ts
+++ b/src/components/Legend/LegendIcon/types.ts
@@ -1,8 +1,10 @@
import type { CommonProps } from '../../../types/common';
+export type LegendIcons = string | React.ReactElement;
+
export interface LegendIconProps extends CommonProps {
/** 图例项名称 */
labels: string[];
/** 图例项图标 */
- icons: string[];
+ icons: LegendIcons[];
}