@anov/gis-skills-cli 0.0.0-stage → 0.3.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.
- package/CHANGELOG.md +618 -0
- package/INSTALL.md +478 -0
- package/LICENSE +15 -0
- package/README.md +148 -2
- package/RELEASING.md +160 -0
- package/bin/anov-gis-skills.mjs +408 -0
- package/lib/mcp-config.mjs +273 -0
- package/package.json +42 -4
- package/skills/anovgis-analysis/SKILL.md +585 -0
- package/skills/anovgis-effects/SKILL.md +260 -0
- package/skills/anovgis-imagery-terrain/SKILL.md +505 -0
- package/skills/anovgis-layers/SKILL.md +627 -0
- package/skills/anovgis-materials/SKILL.md +635 -0
- package/skills/anovgis-models-3dtiles/SKILL.md +448 -0
- package/skills/anovgis-pitfalls/SKILL.md +561 -0
- package/skills/anovgis-popup-widget/SKILL.md +474 -0
- package/skills/anovgis-primitives/SKILL.md +482 -0
- package/skills/anovgis-vector-graphics/SKILL.md +602 -0
- package/skills/anovgis-viewer/SKILL.md +618 -0
- package/skills/using-anovgis/DEMO-MAP.md +64 -0
- package/skills/using-anovgis/DEMO-SKILL-MAP.md +248 -0
- package/skills/using-anovgis/DOMAINS.md +183 -0
- package/skills/using-anovgis/REFERENCE.md +114 -0
- package/skills/using-anovgis/SKILL.md +392 -0
- package/skills/using-anovgis/templates/README.md +154 -0
- package/skills/using-anovgis/templates/combo1-vue3-vite.md +295 -0
- package/skills/using-anovgis/templates/combo2-vue2-cli.md +119 -0
- package/skills/using-anovgis/templates/combo3-html-cdn.md +107 -0
- package/skills/using-anovgis/templates/combo4-vanilla-webpack.md +91 -0
- package/skills/using-anovgis/templates/wizard-profiles.md +105 -0
- package/vendor/cesiumjs-skills/LICENSE +201 -0
- package/vendor/cesiumjs-skills/NOTICE +18 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-3d-tiles/SKILL.md +465 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-camera/SKILL.md +500 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-core-utilities/SKILL.md +403 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/REFERENCE.md +397 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/SKILL.md +351 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/01-diffuse-tint.js +38 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/02-texture-swap.js +42 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/03-feature-id-tileset.js +29 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/04-translucent-override.js +37 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/05-vertex-displacement.js +49 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/06-metadata-ramp.js +34 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/07-voxel-shader.js +27 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/README.md +19 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/_sandcastle-template.html +9 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-entities/SKILL.md +389 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-imagery/SKILL.md +471 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-interaction/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-materials-shaders/SKILL.md +292 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-models-particles/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-primitives/SKILL.md +537 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-spatial-math/SKILL.md +358 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-terrain-environment/SKILL.md +401 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-time-properties/SKILL.md +353 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-viewer-setup/SKILL.md +434 -0
- package/vendor/cesiumjs-skills/skills/using-cesiumjs-skills/SKILL.md +35 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
> 本文件是 `skills/using-anovgis/SKILL.md` 的子文件 —— 模板组合 1(Vue 3 + Vite + 推荐控件 + 天地图 + 内网本地 SDK(默认组合))。
|
|
2
|
+
> 由 using-anovgis 路由进入,不要被别的 skill 直接引用。
|
|
3
|
+
|
|
4
|
+
#### 组合 1:Vue 3 + Vite + 推荐控件 + 天地图 + 内网本地 SDK ⭐ 推荐(默认)
|
|
5
|
+
|
|
6
|
+
> ⚠️ **v0.2.10 重写**:实测发现真正 bug 只有 1 个——`baseLayer: ANOVGIS.ImageryType.TDT` 触发 `_layerIndex on string 'tdt'` 错。删 baseLayer 行就够(对齐官方 `anov-gis-demo-vue3-main` 模板——官方根本不传 baseLayer)。**v0.2.9 关于 vite 7 必须升 vite 8 的判断是错的,撤销**(实测 vite 7 + 裸 @anov/gis + 不传 baseLayer,playwright 零报错)。
|
|
7
|
+
>
|
|
8
|
+
> ⚠️ **v0.2.12**:版本号跟齐官方 `anov-gis-demo-vue3-main` 模板(vite 8 + vue 3.5.43 + plugin-vue 6.0.9)。vite 7 / vite 8 实测都能跑(见 v0.2.10 定论),选官方版本号是为了与团队现存 Vue 3 项目保持一致,减少版本认知负担。
|
|
9
|
+
|
|
10
|
+
**`package.json`**(v0.2.12 跟齐官方 `anov-gis-demo-vue3-main`):
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"name": "anov-gis-vue3-starter",
|
|
14
|
+
"version": "1.0.0",
|
|
15
|
+
"private": true,
|
|
16
|
+
"type": "module",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"build": "vite build",
|
|
20
|
+
"preview": "vite preview"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@anov/gis": "^1.8.6",
|
|
24
|
+
"vue": "^3.5.43"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
28
|
+
"vite": "^8.3.0",
|
|
29
|
+
"vite-plugin-static-copy": "^4.1.1"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**`vite.config.ts`**(v0.2.7.3 跟齐官方 `anov-gis-demo-vue3-main` 模板,**移除 `optimizeDeps.exclude`**):
|
|
35
|
+
```ts
|
|
36
|
+
import { fileURLToPath, URL } from 'node:url'
|
|
37
|
+
import { defineConfig } from 'vite'
|
|
38
|
+
import vue from '@vitejs/plugin-vue'
|
|
39
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
|
40
|
+
|
|
41
|
+
// anov-gis Vue 3 + Vite 8 最简配置
|
|
42
|
+
// 完全对齐官方 anov-gis-demo-vue3-main 模板
|
|
43
|
+
// SDK v1.8.6 + Cesium 1.143
|
|
44
|
+
export default defineConfig({
|
|
45
|
+
plugins: [
|
|
46
|
+
vue(),
|
|
47
|
+
viteStaticCopy({
|
|
48
|
+
targets: [{
|
|
49
|
+
src: 'node_modules/@anov/gis/dist/resources/**/*',
|
|
50
|
+
dest: 'anov-gis-sdk',
|
|
51
|
+
rename: { stripBase: 5 },
|
|
52
|
+
}],
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
resolve: {
|
|
56
|
+
alias: {
|
|
57
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> **v0.2.7.3 修订**:playwright 实测官方模板(vite 8.3.0 + vue 3.5.43,无 `exclude`)**零报错**运行。v0.2.7.2 的 `optimizeDeps.exclude` 是绕路(避开 esbuild 预构建撞名),但官方模板本身用 vite 8 预构建也能跑。撞名的两个 `function Yi(` 在不同嵌套层级(实测 -62 vs -56),不会在同一 scope shadow。
|
|
64
|
+
|
|
65
|
+
> **v0.2.10 修订(定论)**:v0.2.9 的「vite 7 必须升 vite 8」是**误诊**——`exclude` 确实会引入 `does not provide an export named 'default'`(UMD 无 default),但**什么 optimizeDeps 配置都不需要**:v0.2.10 playwright 实测 vite 7 + 裸 @anov/gis + 不传 baseLayer **零报错**。真正的 bug 只有 `baseLayer: ANOVGIS.ImageryType.TDT`(字符串 `'tdt'` 被塞进图层集合,v0.2.9 看到的 P10 撞名错其实也是它——`queueReprojectionCommands` 打在字符串上)。删 baseLayer 行即可,vite 7 / vite 8 都行。
|
|
66
|
+
|
|
67
|
+
> **v0.2.12**:默认模板版本号回到官方 vite 8(`vite ^8.3.0` / `vue ^3.5.43` / `@vitejs/plugin-vue ^6.0.9`)。**不是**因为 vite 7 不能跑(v0.2.10 已实测 vite 7 零报错),而是从 0 创建项目统一用官方版本号,与团队现存 Vue 3 项目保持一致。
|
|
68
|
+
|
|
69
|
+
**`index.html`**:
|
|
70
|
+
```html
|
|
71
|
+
<!DOCTYPE html>
|
|
72
|
+
<html lang="zh-CN">
|
|
73
|
+
<head>
|
|
74
|
+
<meta charset="UTF-8">
|
|
75
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
76
|
+
<title>anov-gis Vue3 Starter</title>
|
|
77
|
+
</head>
|
|
78
|
+
<body>
|
|
79
|
+
<div id="app"></div>
|
|
80
|
+
<script type="module" src="/src/main.ts"></script>
|
|
81
|
+
</body>
|
|
82
|
+
</html>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**`src/main.ts`**:
|
|
86
|
+
```ts
|
|
87
|
+
import { createApp } from 'vue'
|
|
88
|
+
import App from './App.vue'
|
|
89
|
+
import ANOVGIS from '@anov/gis'
|
|
90
|
+
import '@anov/gis/dist/index.css'
|
|
91
|
+
|
|
92
|
+
// ⚠️ 必须在 new Viewer 之前(CDN/UMD 也遵守同一规则)
|
|
93
|
+
// 用 import.meta.env.BASE_URL 让 dev (/) / build (./) 都能正确解析 anov-gis-sdk 路径
|
|
94
|
+
ANOVGIS.setBaseUrl(import.meta.env.BASE_URL + 'anov-gis-sdk/')
|
|
95
|
+
|
|
96
|
+
createApp(App).mount('#app')
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**`src/App.vue`**(v0.2.9 修订:删 `baseLayer: ANOVGIS.ImageryType.TDT`,对齐官方模板):
|
|
100
|
+
```vue
|
|
101
|
+
<script setup lang="ts">
|
|
102
|
+
// ⚠️ viewer 必须模块级 let — 严禁 ref()/reactive()(避免每帧 setter 风暴)
|
|
103
|
+
let viewer: any = null
|
|
104
|
+
|
|
105
|
+
onMounted(() => {
|
|
106
|
+
// 不要传 baseLayer: ANOVGIS.ImageryType.*(SDK v1.8.6 内部 new ImageryLayer('TDT')
|
|
107
|
+
// 会报 "Cannot create property '_layerIndex' on string 'tdt'")
|
|
108
|
+
// 要加底图就用 viewer.imageryLayers.addImageryProvider()(构造后模式)
|
|
109
|
+
viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
110
|
+
contextOptions: { id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true } },
|
|
111
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
112
|
+
// 标准 demo 不需要时间轴/CZML 相关控件
|
|
113
|
+
timeline: false,
|
|
114
|
+
animation: false,
|
|
115
|
+
// 顶部控件(默认全开 — 与 anovgis-pitfalls § P-v0.2.4 一致)
|
|
116
|
+
baseLayerPicker: true,
|
|
117
|
+
fullscreenButton: true,
|
|
118
|
+
homeButton: true,
|
|
119
|
+
sceneModePicker: true,
|
|
120
|
+
navigationHelpButton: true,
|
|
121
|
+
// 信息栏
|
|
122
|
+
showMapInfo: true,
|
|
123
|
+
copyRight: false,
|
|
124
|
+
showFPS: false,
|
|
125
|
+
drillPick: false,
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
onBeforeUnmount(() => {
|
|
130
|
+
viewer?.destroy()
|
|
131
|
+
viewer = null
|
|
132
|
+
})
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<template>
|
|
136
|
+
<div id="cesiumContainer" style="width:100vw;height:100vh"></div>
|
|
137
|
+
</template>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**`src/globalConfig.ts`**(key / 服务地址):
|
|
141
|
+
```ts
|
|
142
|
+
// ⚠️ v0.2.7 硬编码:默认用 ANOV-GIS 官方 demo key(SDK examples/src/mixins/mixin.js 公开测试 key)
|
|
143
|
+
// 正式部署再替换为团队在 https://console.tianditu.gov.cn 申请的 key
|
|
144
|
+
export const globalConfig = {
|
|
145
|
+
tdtKey: 'b832b9764939cbb0919148c548b669ba',
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**运行**:
|
|
150
|
+
```bash
|
|
151
|
+
npm install
|
|
152
|
+
npm run dev
|
|
153
|
+
# 打开 http://localhost:5173
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**避坑(与本模板对照的常见错)**:
|
|
157
|
+
|
|
158
|
+
| 错误做法 | 后果 | 对应陷阱 |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `vite-plugin-static-copy@^1.0.0` + 没 `"type":"module"` | ESM 报错 | **P9** |
|
|
161
|
+
| vite **7/8** + 裸 `@anov/gis` + 构造时传 `baseLayer` | `_layerIndex on string 'tdt'` / `queueReprojectionCommands` 错(v0.2.9 曾误诊为 vite 预构建) | **删 baseLayer(v0.2.10 定论,vite 7 / 8 实测均零报错)** |
|
|
162
|
+
| `optimizeDeps.exclude:['@anov/gis']` | UMD 无 default 导出,浏览器 `import ANOVGIS` 报 `does not provide an export named 'default'` | **v0.2.7.2 已撤销——不需要任何 optimizeDeps 配置** |
|
|
163
|
+
| 用旧 SDK 示例 `anov-gis-demo-vue3` 的 vite `^4.x` + static-copy `^0.17.0` | 能跑但 `optimizeDeps` 等生态已落后 | 推荐升级 |
|
|
164
|
+
| `tdtKey: '替换为团队分配的 key'` 让用户去申请 | 增加摩擦 | 默认用 demo key |
|
|
165
|
+
| 加 `@anov/vite-plugins` 协调包(hainan 风格) | 单 hello earth 项目过重,引入 `layout-designer` 服务 + 额外依赖 `@anov/cic-standard-sdk` | v0.2.7.2 移除,纯 vue+vite 即可 |
|
|
166
|
+
| `baseLayer: ANOVGIS.ImageryType.TDT`(构造时传底图类型) | SDK v1.8.6 内部 `new ImageryLayer('TDT')` 报 `_layerIndex on string 'tdt'` | v0.2.9 修复(删 baseLayer,构造后用 `viewer.imageryLayers.addImageryProvider`) |
|
|
167
|
+
| 仅 curl/grep 验证 vite 启动就 commit "修复" | 实际运行时跑 playwright 才发现有错 | **P11(验证后才能说修复)** |
|
|
168
|
+
|
|
169
|
+
**验证命令**(跑通后**必跑**——不要只 curl 就 commit):
|
|
170
|
+
```python
|
|
171
|
+
# playwright 端到端验证(不要省略!)
|
|
172
|
+
from playwright.sync_api import sync_playwright
|
|
173
|
+
with sync_playwright() as p:
|
|
174
|
+
browser = p.chromium.launch()
|
|
175
|
+
page = browser.new_page()
|
|
176
|
+
errors = []
|
|
177
|
+
page.on('pageerror', lambda e: errors.append(e.message))
|
|
178
|
+
page.on('console', lambda m: errors.append(m.text) if m.type == 'error' else None)
|
|
179
|
+
page.goto('http://localhost:5173/', wait_until='networkidle', timeout=30000)
|
|
180
|
+
import time; time.sleep(5)
|
|
181
|
+
print(f'errors: {len(errors)}')
|
|
182
|
+
for e in errors[:5]: print(f' - {e[:200]}')
|
|
183
|
+
has_canvas = page.evaluate("!!document.querySelector('canvas')")
|
|
184
|
+
print(f'canvas: {has_canvas}')
|
|
185
|
+
browser.close()
|
|
186
|
+
# 期望:errors: 0, canvas: True
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 变体:ESM 模块方式(`import` 引入,适合 webpack / vite / rollup)
|
|
195
|
+
|
|
196
|
+
### B. ESM 模块方式(`import` 引入)适合 webpack / vite / rollup。
|
|
197
|
+
|
|
198
|
+
```js
|
|
199
|
+
// 来源: README.md L179-188
|
|
200
|
+
import '@anov/gis/dist/index.css';
|
|
201
|
+
import ANOVGIS from '@anov/gis';
|
|
202
|
+
ANOVGIS.setBaseUrl('/anov-gis-sdk/resources/');
|
|
203
|
+
const viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
204
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
205
|
+
// ⚠️ 不要传 baseLayer(v0.2.10 实测 v1.8.6 会报 _layerIndex on string 错)——底图构造后 addImageryProvider
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### D. Vue 3 + Vite 模板用 `vite-plugin-static-copy` 拷贝 Cesium 静态资源,AMD 报错用 webpack `IgnorePlugin` 兜底(`./punycode`/`./IPv6`/`./SecondLevelDomains`),模板 [anov-gis-vite](https://github.com/948033145/anov-gis-vite)。
|
|
213
|
+
|
|
214
|
+
> 完整骨架见上方「§ NPM 引入」末尾 Vite 配置 + App.vue 示例。
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
// 来源: README.md L201 + cesium_1_143_umd_webpack_amd_error.md
|
|
218
|
+
import { defineConfig } from 'vite';
|
|
219
|
+
import vue from '@vitejs/plugin-vue';
|
|
220
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
221
|
+
export default defineConfig({
|
|
222
|
+
plugins: [vue(), viteStaticCopy({
|
|
223
|
+
targets: [{ src: 'node_modules/@anov/gis/dist/resources/*', dest: 'anov-gis-sdk/resources' }],
|
|
224
|
+
})],
|
|
225
|
+
build: { target: 'esnext' },
|
|
226
|
+
define: { CESIUM_BASE_URL: JSON.stringify('/anov-gis-sdk/resources/') },
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
```vue
|
|
231
|
+
<script setup lang="ts">
|
|
232
|
+
// 来源: src/index.js L89-135(baseUrl 推断逻辑)
|
|
233
|
+
import { onMounted, onBeforeUnmount } from 'vue';
|
|
234
|
+
import ANOVGIS from '@anov/gis'; import '@anov/gis/dist/index.css';
|
|
235
|
+
let viewer: any;
|
|
236
|
+
onMounted(() => { viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
237
|
+
contextOptions: { id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true } },
|
|
238
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
239
|
+
}); });
|
|
240
|
+
onBeforeUnmount(() => viewer && viewer.destroy());
|
|
241
|
+
</script>
|
|
242
|
+
<template><div id="cesiumContainer" style="width:100%;height:100vh"></div></template>
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 变体:Vue 骨架 —— ❌ 错误 vs ✅ 正确
|
|
248
|
+
|
|
249
|
+
铁律 1「3D 大对象严禁进响应式」的具体对照(来自 `using-anovgis` § 框架集成 3 条铁律):
|
|
250
|
+
|
|
251
|
+
**正确骨架(Vue 3 Composition API + Vite)**:
|
|
252
|
+
|
|
253
|
+
```vue
|
|
254
|
+
<!-- src/App.vue -->
|
|
255
|
+
<script setup>
|
|
256
|
+
import { onMounted, onBeforeUnmount } from 'vue'
|
|
257
|
+
import ANOVGIS from '@anov/gis'
|
|
258
|
+
|
|
259
|
+
let viewer = null // 模块级 let,绝不放 ref()/reactive()
|
|
260
|
+
|
|
261
|
+
onMounted(() => {
|
|
262
|
+
const Cesium = window.Cesium // 唯一推荐写法
|
|
263
|
+
viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
264
|
+
baseLayerPicker: false, infoBox: false, selectionIndicator: false,
|
|
265
|
+
geocoder: false, animation: false, timeline: false,
|
|
266
|
+
contextOptions: { id: 'cesiumCanvas' },
|
|
267
|
+
})
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
onBeforeUnmount(() => {
|
|
271
|
+
viewer?.destroy()
|
|
272
|
+
viewer = null
|
|
273
|
+
})
|
|
274
|
+
</script>
|
|
275
|
+
|
|
276
|
+
<template>
|
|
277
|
+
<div id="cesiumContainer" style="width:100vw;height:100vh"></div>
|
|
278
|
+
</template>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**错误骨架(会导致主线程卡死)**:
|
|
282
|
+
|
|
283
|
+
```vue
|
|
284
|
+
<!-- ❌ 严禁 -->
|
|
285
|
+
<script setup>
|
|
286
|
+
import { ref } from 'vue'
|
|
287
|
+
import ANOVGIS from '@anov/gis'
|
|
288
|
+
|
|
289
|
+
// ❌ viewer 进了 ref,每帧 setter 触发响应式风暴
|
|
290
|
+
const viewer = ref(null)
|
|
291
|
+
onMounted(() => {
|
|
292
|
+
viewer.value = new ANOVGIS.Viewer('cesiumContainer', {})
|
|
293
|
+
})
|
|
294
|
+
</script>
|
|
295
|
+
```
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
> 本文件是 `skills/using-anovgis/SKILL.md` 的子文件 —— 模板组合 2(Vue 2 + Vue CLI + 推荐控件 + 天地图 + 内网本地 SDK)。
|
|
2
|
+
> 由 using-anovgis 路由进入,不要被别的 skill 直接引用。
|
|
3
|
+
|
|
4
|
+
#### 组合 2:Vue 2 + Vue CLI + 推荐控件 + 天地图 + 内网本地 SDK
|
|
5
|
+
|
|
6
|
+
**`package.json`**:
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"name": "anov-gis-vue2-starter",
|
|
10
|
+
"version": "1.0.0",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"serve": "vue-cli-service serve",
|
|
13
|
+
"build": "vue-cli-service build"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@anov/gis": "^1.8.6",
|
|
17
|
+
"vue": "^2.7.16"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@vue/cli-service": "^5.0.0",
|
|
21
|
+
"copy-webpack-plugin": "^12.0.0",
|
|
22
|
+
"vue-template-compiler": "^2.7.16"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**`vue.config.js`**:
|
|
28
|
+
```js
|
|
29
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
30
|
+
module.exports = {
|
|
31
|
+
publicPath: '/',
|
|
32
|
+
configureWebpack: {
|
|
33
|
+
plugins: [
|
|
34
|
+
new CopyWebpackPlugin({
|
|
35
|
+
patterns: [{
|
|
36
|
+
from: 'node_modules/@anov/gis/dist/resources',
|
|
37
|
+
to: 'public/anov-gis-sdk/resources'
|
|
38
|
+
}]
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**`src/main.js`**:
|
|
46
|
+
```js
|
|
47
|
+
import Vue from 'vue';
|
|
48
|
+
import App from './App.vue';
|
|
49
|
+
import ANOVGIS from '@anov/gis';
|
|
50
|
+
import '@anov/gis/dist/index.css';
|
|
51
|
+
|
|
52
|
+
ANOVGIS.setBaseUrl('/anov-gis-sdk/resources/');
|
|
53
|
+
|
|
54
|
+
Vue.config.productionTip = false;
|
|
55
|
+
new Vue({ render: (h) => h(App) }).$mount('#app');
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**`src/App.vue`**:
|
|
59
|
+
```vue
|
|
60
|
+
<template>
|
|
61
|
+
<div id="cesiumContainer" style="width:100vw;height:100vh"></div>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script>
|
|
65
|
+
import ANOVGIS from '@anov/gis';
|
|
66
|
+
|
|
67
|
+
export default {
|
|
68
|
+
name: 'App',
|
|
69
|
+
mounted() {
|
|
70
|
+
this.viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
71
|
+
// ⚠️ 不要传 baseLayer: ANOVGIS.ImageryType.*(SDK v1.8.6 报 "_layerIndex on string 'tdt'")——底图构造后用 addImageryProvider
|
|
72
|
+
contextOptions: { id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true } },
|
|
73
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
74
|
+
timeline: true, animation: true,
|
|
75
|
+
baseLayerPicker: true, fullscreenButton: true,
|
|
76
|
+
homeButton: true, sceneModePicker: true, navigationHelpButton: true,
|
|
77
|
+
showMapInfo: true,
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
beforeDestroy() {
|
|
81
|
+
this.viewer && this.viewer.destroy();
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
</script>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 变体:Vue 2 + vue-cli 配置与 Options API 写法
|
|
93
|
+
|
|
94
|
+
### C. Vue 2 + vue-cli 模板用 `copy-webpack-plugin` 拷贝 `node_modules/@anov/gis/dist/resources` 到 `public/anov-gis-sdk/resources`,模板仓库 [anov-gis-vue2](https://github.com/948033145/anov-gis-vue2)。
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
// 来源: README.md L200 + vue.config.js 模板约定
|
|
98
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
99
|
+
module.exports = {
|
|
100
|
+
publicPath: '/',
|
|
101
|
+
configureWebpack: { plugins: [new CopyWebpackPlugin({
|
|
102
|
+
patterns: [{ from: 'node_modules/@anov/gis/dist/resources', to: 'public/anov-gis-sdk/resources' }],
|
|
103
|
+
})] },
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
// 来源: examples/.../basemap/tdtSatelliteImage.html L28-66
|
|
109
|
+
export default {
|
|
110
|
+
mounted() {
|
|
111
|
+
window.viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
112
|
+
contextOptions: { id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true } },
|
|
113
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
beforeUnmount() { window.viewer && window.viewer.destroy(); },
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
> 本文件是 `skills/using-anovgis/SKILL.md` 的子文件 —— 模板组合 3(纯 HTML + UMD CDN + 极简控件 + 天地图 + 公网)。
|
|
2
|
+
> 由 using-anovgis 路由进入,不要被别的 skill 直接引用。
|
|
3
|
+
|
|
4
|
+
## CDN 引入(前置)
|
|
5
|
+
|
|
6
|
+
```html
|
|
7
|
+
<!DOCTYPE html>
|
|
8
|
+
<html lang="zh-CN">
|
|
9
|
+
<head>
|
|
10
|
+
<meta charset="UTF-8">
|
|
11
|
+
<title>@anov/gis Demo</title>
|
|
12
|
+
<script src="https://unpkg.com/@anov/gis@1.7.7/dist/index.js"></script>
|
|
13
|
+
<link rel="stylesheet" href="https://unpkg.com/@anov/gis@1.7.7/dist/index.css">
|
|
14
|
+
<!-- ⚠️ 1.8.4 尚未发布到公共 CDN,使用 1.7.7 替代。本地 SDK 升级到 1.8.x 后请改用 npm 引入。-->
|
|
15
|
+
<style>
|
|
16
|
+
html, body, #cesiumContainer { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="cesiumContainer"></div>
|
|
21
|
+
<script>
|
|
22
|
+
// ⚠️ 必须在 new Viewer 之前调用
|
|
23
|
+
ANOVGIS.setBaseUrl('https://unpkg.com/@anov/gis@1.7.7/dist/resources/');
|
|
24
|
+
window.viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
25
|
+
contextOptions: {
|
|
26
|
+
id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true },
|
|
27
|
+
showRenderLoopErrors: false,
|
|
28
|
+
},
|
|
29
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
30
|
+
baseLayerPicker: true, fullscreenButton: true, homeButton: true,
|
|
31
|
+
sceneModePicker: true, navigationHelpButton: true,
|
|
32
|
+
copyRight: false, showMapInfo: true,
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> ⚠️ 必须通过 HTTP 服务打开(不能直接 `file://`),否则 Cesium 静态资源加载失败。
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
#### 组合 3:HTML + UMD CDN + 极简 + 天地图 + 公网
|
|
43
|
+
|
|
44
|
+
**`index.html`**(单文件,零构建):
|
|
45
|
+
```html
|
|
46
|
+
<!DOCTYPE html>
|
|
47
|
+
<html lang="zh-CN">
|
|
48
|
+
<head>
|
|
49
|
+
<meta charset="UTF-8">
|
|
50
|
+
<title>anov-gis Quick Demo</title>
|
|
51
|
+
<script src="https://unpkg.com/@anov/gis@1.8.6/dist/index.js"></script>
|
|
52
|
+
<link rel="stylesheet" href="https://unpkg.com/@anov/gis@1.8.6/dist/index.css">
|
|
53
|
+
<style>
|
|
54
|
+
html, body, #cesiumContainer { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
|
|
55
|
+
</style>
|
|
56
|
+
</head>
|
|
57
|
+
<body>
|
|
58
|
+
<div id="cesiumContainer"></div>
|
|
59
|
+
<script>
|
|
60
|
+
ANOVGIS.setBaseUrl('https://unpkg.com/@anov/gis@1.8.6/dist/resources/');
|
|
61
|
+
window.viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
62
|
+
// ⚠️ 不要传 baseLayer: ANOVGIS.ImageryType.*(SDK v1.8.6 报 "_layerIndex on string 'tdt'")——底图构造后用 addImageryProvider
|
|
63
|
+
contextOptions: { id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true } },
|
|
64
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
65
|
+
// 极简 profile:全 false
|
|
66
|
+
timeline: false, animation: false,
|
|
67
|
+
baseLayerPicker: false, fullscreenButton: false,
|
|
68
|
+
homeButton: false, sceneModePicker: false, navigationHelpButton: false,
|
|
69
|
+
showMapInfo: false, copyRight: false, showFPS: false, drillPick: false,
|
|
70
|
+
});
|
|
71
|
+
</script>
|
|
72
|
+
</body>
|
|
73
|
+
</html>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**运行**:
|
|
77
|
+
```bash
|
|
78
|
+
npx http-server -p 8080
|
|
79
|
+
# 打开 http://localhost:8080/
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 变体:UMD 全局方式(`<script>` 引入,适合快速验证 / 无构建工具)
|
|
88
|
+
|
|
89
|
+
### A. UMD 全局方式(`<script>` 引入)适合快速验证 / 无构建工具。`@anov/gis` 挂到全局 `ANOVGIS`。
|
|
90
|
+
```html
|
|
91
|
+
<!-- 来源: README.md L156-160 -->
|
|
92
|
+
<script src="./anov-gis-sdk/index.js"></script>
|
|
93
|
+
<link rel="stylesheet" href="./anov-gis-sdk/index.css">
|
|
94
|
+
<script src="./anov-gis-sdk/applyfn.js"></script><!-- 业务级 API,可选 -->
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
// 来源: examples/.../basemap/tdtSatelliteImage.html L49-66
|
|
99
|
+
window.viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
100
|
+
contextOptions: { id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true }, showRenderLoopErrors: false },
|
|
101
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
102
|
+
baseLayerPicker: true, fullscreenButton: true, homeButton: true,
|
|
103
|
+
sceneModePicker: true, navigationHelpButton: true, copyRight: false, showMapInfo: true,
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
> CDN 1.7.7 仍可用,1.8.x 需改 NPM。
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
> 本文件是 `skills/using-anovgis/SKILL.md` 的子文件 —— 模板组合 4(Vanilla JS + webpack 5 + 完整控件 + ArcGIS + 内网)。
|
|
2
|
+
> 由 using-anovgis 路由进入,不要被别的 skill 直接引用。
|
|
3
|
+
|
|
4
|
+
#### 组合 4:Vanilla JS + webpack + 完整 + ArcGIS + 内网
|
|
5
|
+
|
|
6
|
+
**`package.json`**:
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"name": "anov-gis-webpack-starter",
|
|
10
|
+
"version": "1.0.0",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "webpack serve --mode development",
|
|
13
|
+
"build": "webpack --mode production"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": { "@anov/gis": "^1.8.6" },
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"copy-webpack-plugin": "^12.0.0",
|
|
18
|
+
"html-webpack-plugin": "^5.5.0",
|
|
19
|
+
"webpack": "^5.90.0",
|
|
20
|
+
"webpack-cli": "^5.1.0",
|
|
21
|
+
"webpack-dev-server": "^5.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**`webpack.config.js`**(含 AMD 报错兜底):
|
|
27
|
+
```js
|
|
28
|
+
const path = require('path');
|
|
29
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
30
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
31
|
+
const webpack = require('webpack');
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
entry: './src/main.js',
|
|
35
|
+
output: {
|
|
36
|
+
path: path.resolve(__dirname, 'dist'),
|
|
37
|
+
filename: 'bundle.[contenthash].js',
|
|
38
|
+
publicPath: '/',
|
|
39
|
+
},
|
|
40
|
+
plugins: [
|
|
41
|
+
new HtmlWebpackPlugin({ template: './index.html' }),
|
|
42
|
+
new CopyWebpackPlugin({
|
|
43
|
+
patterns: [{
|
|
44
|
+
from: 'node_modules/@anov/gis/dist/resources',
|
|
45
|
+
to: 'anov-gis-sdk/resources'
|
|
46
|
+
}]
|
|
47
|
+
}),
|
|
48
|
+
// Cesium 1.143 UMD AMD 报错兜底(P4 陷阱)
|
|
49
|
+
new webpack.IgnorePlugin({
|
|
50
|
+
resourceRegExp: /^\.\/locale$/,
|
|
51
|
+
contextRegExp: /moment$/,
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**`src/main.js`**:
|
|
58
|
+
```js
|
|
59
|
+
import '@anov/gis/dist/index.css';
|
|
60
|
+
import ANOVGIS from '@anov/gis';
|
|
61
|
+
|
|
62
|
+
ANOVGIS.setBaseUrl('/anov-gis-sdk/resources/');
|
|
63
|
+
|
|
64
|
+
window.viewer = new ANOVGIS.Viewer('cesiumContainer', {
|
|
65
|
+
// ⚠️ 不要传 baseLayer(v0.2.10 实测 v1.8.6 会报 _layerIndex on string 错)——底图构造后 addImageryProvider
|
|
66
|
+
contextOptions: { id: 'cesiumCanvas', webgl: { preserveDrawingBuffer: true } },
|
|
67
|
+
geocoderType: ANOVGIS.GeocoderType.TIANDITU,
|
|
68
|
+
// 完整 profile
|
|
69
|
+
timeline: true, animation: true,
|
|
70
|
+
baseLayerPicker: true, fullscreenButton: true,
|
|
71
|
+
homeButton: true, sceneModePicker: true, navigationHelpButton: true,
|
|
72
|
+
showMapInfo: true, copyRight: true, showFPS: true, drillPick: true,
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**`index.html`**:
|
|
77
|
+
```html
|
|
78
|
+
<!DOCTYPE html>
|
|
79
|
+
<html lang="zh-CN">
|
|
80
|
+
<head>
|
|
81
|
+
<meta charset="UTF-8">
|
|
82
|
+
<title>anov-gis Webpack Starter</title>
|
|
83
|
+
</head>
|
|
84
|
+
<body>
|
|
85
|
+
<div id="cesiumContainer" style="width:100vw;height:100vh"></div>
|
|
86
|
+
</body>
|
|
87
|
+
</html>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|