@tianditu/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -0
  3. package/dist/index.d.mts +662 -0
  4. package/dist/index.mjs +1617 -0
  5. package/package.json +53 -0
  6. package/types/base.d.ts +97 -0
  7. package/types/control/control.d.ts +55 -0
  8. package/types/control/copyright.d.ts +30 -0
  9. package/types/control/index.d.ts +6 -0
  10. package/types/control/mapType.d.ts +63 -0
  11. package/types/control/overviewMap.d.ts +64 -0
  12. package/types/control/scale.d.ts +17 -0
  13. package/types/control/zoom.d.ts +24 -0
  14. package/types/global.d.mts +2 -0
  15. package/types/index.d.ts +19 -0
  16. package/types/layer/gridlineLayer.d.ts +33 -0
  17. package/types/layer/index.d.ts +4 -0
  18. package/types/layer/tdt.d.ts +14 -0
  19. package/types/layer/tileLayer.d.ts +78 -0
  20. package/types/layer/wms.d.ts +24 -0
  21. package/types/map.d.ts +290 -0
  22. package/types/militarySymbols/base.d.ts +71 -0
  23. package/types/militarySymbols/control.d.ts +24 -0
  24. package/types/militarySymbols/entities.d.ts +547 -0
  25. package/types/militarySymbols/index.d.ts +4 -0
  26. package/types/militarySymbols/tools.d.ts +191 -0
  27. package/types/modular.d.ts +258 -0
  28. package/types/mousetool/circleTool.d.ts +32 -0
  29. package/types/mousetool/coordinatePickup.d.ts +28 -0
  30. package/types/mousetool/index.d.ts +8 -0
  31. package/types/mousetool/markTool.d.ts +40 -0
  32. package/types/mousetool/mousetool.d.ts +28 -0
  33. package/types/mousetool/paintBrushTool.d.ts +23 -0
  34. package/types/mousetool/polygonTool.d.ts +47 -0
  35. package/types/mousetool/polylineTool.d.ts +47 -0
  36. package/types/mousetool/rectangleTool.d.ts +28 -0
  37. package/types/overlay/circle.d.ts +67 -0
  38. package/types/overlay/cloudMarkerCollection.d.ts +50 -0
  39. package/types/overlay/contextMenu.d.ts +75 -0
  40. package/types/overlay/icon.d.ts +33 -0
  41. package/types/overlay/index.d.ts +13 -0
  42. package/types/overlay/infowindow.d.ts +59 -0
  43. package/types/overlay/label.d.ts +53 -0
  44. package/types/overlay/marker.d.ts +50 -0
  45. package/types/overlay/markerClusterer.d.ts +103 -0
  46. package/types/overlay/overlay.d.ts +109 -0
  47. package/types/overlay/polygon.d.ts +59 -0
  48. package/types/overlay/polyline.d.ts +47 -0
  49. package/types/overlay/rectangle.d.ts +57 -0
  50. package/types/overlay/svg.d.ts +19 -0
  51. package/types/service/administrativeDivision.d.ts +48 -0
  52. package/types/service/busLineSearch.d.ts +89 -0
  53. package/types/service/dataSources.d.ts +30 -0
  54. package/types/service/drivingRoute.d.ts +135 -0
  55. package/types/service/geocoder.d.ts +47 -0
  56. package/types/service/geolocation.d.ts +39 -0
  57. package/types/service/index.d.ts +9 -0
  58. package/types/service/localCity.d.ts +24 -0
  59. package/types/service/localSearch.d.ts +178 -0
  60. package/types/service/transitRoute.d.ts +132 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Demo Macro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @tianditu/core
2
+
3
+ ![npm version](https://img.shields.io/npm/v/@tianditu/core)
4
+ ![npm downloads](https://img.shields.io/npm/dw/@tianditu/core)
5
+ ![npm license](https://img.shields.io/npm/l/@tianditu/core)
6
+
7
+ > 天地图 JavaScript API 的框架无关内核,不绑定任何 UI 框架。
8
+ > 幂等的 SDK 加载器与地图会话、覆盖物/工具/图层/信息窗的生命周期编排,以及驱动 Vue 与 Web Components 两个适配层的组件定义层都汇聚于此——适配层因此保持轻薄,接入新框架只需写响应式胶水。
9
+
10
+ ## 特性
11
+
12
+ - 🔄 **幂等 SDK 加载器** — `loadTdt` 只拉取并执行一次官方脚本,预填组件包缓存规避加载竞态,并以哨兵检测补载缺失的包
13
+ - 🗺️ **地图会话** — `createMapSession` 按官方约定初始化地图并负责销毁;初始中心不传时回退北京,`locate` 支持三种定位方式:`"geolocation"` 浏览器定位、`"ip"` 官方 IP 定位、`"auto"` 前者优先浏览器失败回退 IP
14
+ - 🧩 **生命周期编排** — `mountOverlay`、`mountTool`、`mountTileLayer` 与 `createInfoWindow` 承担构造/挂载/同步/卸载,适配层保持轻薄
15
+ - 📑 **组件定义层** — `defs/` 下每组件一份框架无关定义(props 形状、SDK 构造、sync 与事件表),Vue 与 Web Components 适配层消费同一份
16
+ - 🔁 **Props 同步** — `createPropsSync` 把响应式 getter diff 成官方 setter 调用;`SyncDef` 声明 prop → setter 映射
17
+ - 📡 **事件桥** — `bindEventNames` 以统一的退订形状挂接/解绑 SDK 原生事件
18
+ - ⏳ **构造守卫** — `createWhenReady` 对 "is not a constructor" 时序错误重试,直至扩展组件包就绪
19
+ - 📑 **类型分发** — SDK 全局声明随包分发;import 本包即可在任意位置获得 `window.T` 类型
20
+
21
+ ## 安装
22
+
23
+ ```bash
24
+ # npm
25
+ $ npm install @tianditu/core
26
+
27
+ # yarn
28
+ $ yarn add @tianditu/core
29
+
30
+ # pnpm
31
+ $ pnpm add @tianditu/core
32
+ ```
33
+
34
+ ## 快速开始
35
+
36
+ ```typescript
37
+ import { createMapSession, loadTdt } from "@tianditu/core";
38
+
39
+ const session = await createMapSession(container, {
40
+ tk: "你的浏览器端密钥",
41
+ center: [116.404, 39.915],
42
+ zoom: 12,
43
+ });
44
+
45
+ session.destroy();
46
+ ```
47
+
48
+ 只加载 SDK 不建图时,也可使用导出的 `loadTdt({ tk })`。
49
+
50
+ ## API
51
+
52
+ - **loader** — `loadTdt` / `createWhenReady`
53
+ - **session** — `createMapSession` / `toLngLat` / `toLngLats` / `DEFAULT_CENTER`
54
+ - **编排** — `mountOverlay` / `mountTool` / `mountTileLayer` / `createInfoWindow` / `applyMapInteractions`
55
+ - **定义层** — `OverlayDef` / `ToolDef` / `ControlDef` / `LayerDef` 与各组件 `xxxDef` 常量
56
+ - **工具** — `createPropsSync` / `bindEventNames` / `compact`
57
+
58
+ 完整类型化 API 参考见[文档站](https://github.com/DemoMacro/tianditu/tree/main/docs)。
59
+
60
+ ## 相关包
61
+
62
+ - [@tianditu/vue](https://www.npmjs.com/package/@tianditu/vue) — Vue 3 组件适配层
63
+ - [@tianditu/web-components](https://www.npmjs.com/package/@tianditu/web-components) — Web Components 适配层
64
+ - [@tianditu/services](https://www.npmjs.com/package/@tianditu/services) — 类型化 REST 服务客户端
65
+
66
+ ## 许可
67
+
68
+ - [MIT](LICENSE) © [Demo Macro](https://www.demomacro.com/)