快速上手
安装
按需选择组件包与服务包
本工具库是第三方封装,不是天地图官方产品。工具分为四个包,按需安装:
# Vue 3 组件(含 @tianditu/core)
$ pnpm add @tianditu/vue
# Web Components(含 @tianditu/core)
$ pnpm add @tianditu/web-components
# REST 服务客户端(独立,无地图运行时依赖)
$ pnpm add @tianditu/services
如何选择
| 需求 | 选择 |
|---|---|
| Vue 3 应用,声明式写法 | @tianditu/vue |
| 非框架页面,或跨框架复用 | @tianditu/web-components |
| 只调 REST 服务接口(搜索、地理编码、行政区、静态图等) | @tianditu/services |
| 自行编排 SDK 生命周期 | @tianditu/core(前两个包已内置依赖) |
前置要求
- 浏览器端密钥(tk)——地图与服务接口必需,见密钥(tk)
@tianditu/vue要求 Vue ≥ 3.3