tianditu-v4-types
v0.0.7
Published
天地图类型定义
Readme
天地图类型定义
v4.0
TypeScript 类型定义包,提供天地图 Web JS API(如 T.Map、T.Marker)的完整 .d.ts。
适用于:
原本只能通过 <script src> 引入天地图 SDK
想在 TypeScript / Vue / React 中获得智能提示与类型检查
希望模块化方式使用 API
安装
npm install tianditu-v4-types -D
pnpm add tianditu-v4-types -D使用示例(模块化)
import type { Map, Point, Marker } from "tianditu-v4-types";
const map = new window.T.Map("app", { minZoom: 3 }) as Map;
map.centerAndZoom(new Point(116.39, 39.9), 12);
const m = new Marker(new Point(116.39, 39.9));
map.addLayer(m);业务侧配置
tsconfig.json
在项目的 src 目录下创建 types 文件夹,并在其中创建 tianditu.d.ts 文件:
// src/types/tianditu.d.ts
import 'tianditu-v4-types'
declare global {
interface Window {
T: typeof import('tianditu-v4-types').T
}
}⚠️ 注意
本包仅提供 TypeScript 类型,不包含任何 JS 功能。 你仍需要通过 引入天地图 SDK。
