@ant-design/maps

中文文档
1.0.8发布于 2023/11/27MITTypeScriptESM + CJS近 30 天下载 6.9万

maps

原始使用文档
文档目录8 节
  1. Case
  2. ✨ Features
  3. 📦 Installation
  4. 🔨 Usage
  5. 📜 Document & API
  6. 🤝 How to Contribute
  7. 📧 Contact us
  8. License

@ant-design/maps

A React geographic visualization component library, based on L7Plot.

npm npm GitHub stars npm License

Website • Quick Start • Gallery • FAQ • Blog

Case

✨ Features

  • Easy to use
  • TypeScript

📦 Installation

$ npm install @ant-design/maps

🔨 Usage

import React, { useState, useEffect } from 'react';
import { AreaMap } from '@ant-design/maps';

const DemoAreaMap = () => {
  const [data, setData] = useState({ type: 'FeatureCollection', features: [] });

  useEffect(() => {
    asyncFetch();
  }, []);

  const asyncFetch = () => {
    fetch('https://gw.alipayobjects.com/os/bmw-prod/d6da7ac1-8b4f-4a55-93ea-e81aa08f0cf3.json')
      .then((response) => response.json())
      .then((json) => setData(json))
      .catch((error) => {
        console.log('fetch data failed', error);
      });
  };
  const config = {
    map: {
      type: 'mapbox',
      style: 'blank',
      center: [120.19382669582967, 30.258134],
      zoom: 3,
      pitch: 0,
    },
    source: {
      data: data,
      parser: {
        type: 'geojson',
      },
    },
    autoFit: true,
    color: {
      field: 'adcode',
      value: ['rgb(239,243,255)', 'rgb(189,215,231)', 'rgb(107,174,214)', 'rgb(49,130,189)', 'rgb(8,81,156)'],
      scale: {
        type: 'quantile',
      },
    },
    style: {
      opacity: 1,
      stroke: 'rgb(93,112,146)',
      lineWidth: 0.6,
      lineOpacity: 1,
    },
    state: {
      active: true,
    },
    label: {
      visible: true,
      field: 'name',
      style: {
        fill: '#000',
        opacity: 0.8,
        fontSize: 10,
        stroke: '#fff',
        strokeWidth: 1.5,
        textAllowOverlap: false,
        padding: [5, 5],
      },
    },
    tooltip: {
      items: ['name', 'adcode'],
    },
    zoom: {
      position: 'bottomright',
    },
    legend: {
      position: 'bottomleft',
    },
  };

  return <AreaMap {...config} />;
};

export default DemoAreaMap;

📜 Document & API

See chart API for details. Common props:

PropertyDescriptionTypedefaultValue
onReadychart loaded callback(chart)=> void-
loadingloading statusboolean-
loadingTemplateloading templateReact.ReactElement-
errorTemplatecustom error template(e: Error) => React.ReactNode-
classNamecontainer classstring-
containerStylecontainer styleReact.CSSProperties-

🤝 How to Contribute

Your contributions are always welcome! Please Do have a look at the issues first.

📧 Contact us

DingTalk group number: 44788198 .

License

MIT

版本与发布记录

@ant-design/maps 共发布 17 个版本,首次发布于 2021/11/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.8latest2023/11/272 年前
1.0.72023/07/053 年前
1.0.62022/11/083 年前
1.0.52022/11/083 年前
1.0.42022/08/224 年前
1.0.32022/07/194 年前

其他发布通道:beta → 0.0.1-beta.3。

关于 @ant-design/maps 的常见问题

@ant-design/maps 是什么?

maps

如何安装 @ant-design/maps?

在项目目录运行 npm install @ant-design/maps,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.8.4)、react-dom(>=16.8.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ant-design/maps 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ant-design/maps 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ant-design/maps 可以商用吗?

@ant-design/maps 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ant-design/maps 的下载量有多少?

根据 npm 官方下载统计,@ant-design/maps 在 2026/10/06 – 2026/11/04 这 30 天内被下载 69,321 次,日均约 2,311 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ant-design/maps 还在维护吗?

最新版本 1.0.8 发布于 2023/11/27(2 年前);至今共发布 17 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/11/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。