ym-gis-2d 1.0.49 → 1.0.51
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/API.md +789 -0
- package/README.md +33 -76
- package/assets/main.css +16 -3
- package/capabilities/index.d.ts +7 -0
- package/capabilities/index.d.ts.map +1 -1
- package/capabilities/index.js +1 -1
- package/capabilities/index.js.map +1 -1
- package/controls/ControlManager.js +1 -1
- package/controls/LegendControl.js +1 -1
- package/controls/MousePositionControl.js +1 -1
- package/controls/SwipeLayerControl.d.ts +4 -0
- package/controls/SwipeLayerControl.d.ts.map +1 -1
- package/controls/SwipeLayerControl.js +1 -1
- package/controls/SwipeLayerControl.js.map +1 -1
- package/conver/kml/geoJSONToKml.js +1 -1
- package/conver/kml/index.js +1 -1
- package/conver/kml/kmlToGeoJSON.js +1 -1
- package/entity/Feature.js +1 -1
- package/entity/GeometryType.js +1 -1
- package/entity/layer/supermap/ISuperMapLayerInfo.d.ts +31 -0
- package/entity/layer/supermap/ISuperMapLayerInfo.d.ts.map +1 -0
- package/entity/layer/supermap/ISuperMapLayerInfo.js +1 -0
- package/entity/layer/supermap/ISuperMapLayerInfo.js.map +1 -0
- package/entity/measure/AreaMeasureUnits.js +1 -1
- package/entity/measure/DistanceMeasureUnits.js +1 -1
- package/feature/FeatureManager.js +1 -1
- package/index.js +1 -1
- package/interaction/AreaMeasure.js +1 -1
- package/interaction/Difference.js +1 -1
- package/interaction/DistanceMeasure.js +1 -1
- package/interaction/Draw.js +1 -1
- package/interaction/InteractionManager.js +1 -1
- package/interaction/Modify.js +1 -1
- package/interaction/Repair.js +1 -1
- package/interaction/Select.js +1 -1
- package/interaction/Snap.js +1 -1
- package/interaction/Split.js +1 -1
- package/layers/ArcgisDynamicLayer.js +1 -1
- package/layers/ArcgisFeatureLayer.js +1 -1
- package/layers/ArcgisTileLayer.js +1 -1
- package/layers/ArcgisWMSLayer.js +1 -1
- package/layers/ArcgisWMTSLayer.js +1 -1
- package/layers/GeoserverVectorTile.js +1 -1
- package/layers/GeoserverWFSLayer.js +1 -1
- package/layers/GeoserverWMSLayer.js +1 -1
- package/layers/GeoserverWMTSLayer.js +1 -1
- package/layers/LayerManager.d.ts +6 -0
- package/layers/LayerManager.d.ts.map +1 -1
- package/layers/LayerManager.js +1 -1
- package/layers/LayerManager.js.map +1 -1
- package/layers/MapTileLayer.js +1 -1
- package/layers/SuperMapLayer.d.ts +18 -0
- package/layers/SuperMapLayer.d.ts.map +1 -0
- package/layers/SuperMapLayer.js +1 -0
- package/layers/SuperMapLayer.js.map +1 -0
- package/layers/TDTLayer.js +1 -1
- package/mapView/Map.d.ts.map +1 -1
- package/mapView/Map.js +1 -1
- package/mapView/Map.js.map +1 -1
- package/mapView/View.js +1 -1
- package/package.json +1 -1
- package/plot/Plot.js +1 -1
- package/plot/geometry/point/Point.js +1 -1
- package/plot/geometry/polygon/BasePolygon.js +1 -1
- package/plot/geometry/polygon/Circle.js +1 -1
- package/plot/geometry/polygon/Polygon.js +1 -1
- package/plot/geometry/polygon/RectAngle.js +1 -1
- package/plot/geometry/polyline/BaseLine.js +1 -1
- package/plot/geometry/polyline/Polyline.js +1 -1
- package/style/PointStyleFormat.js +1 -1
- package/style/PolygonStyleFormat.js +1 -1
- package/style/PolylineStyleFormat.js +1 -1
- package/style/StyleManager.js +1 -1
- package/style/common.js +1 -1
- package/style.css +1 -1
- package/utils/ArrayUtil.js +1 -1
- package/utils/AxiosUtil.js +1 -1
- package/utils/EsriUtil.js +1 -1
- package/utils/GeometryUtil.js +1 -1
- package/utils/LayerUtil.js +1 -1
- package/utils/RegisterProjUtil.js +1 -1
- package/utils/ResolutionUtil.js +1 -1
- package/utils/StringUtil.js +1 -1
- package/utils/StyleUtil.js +1 -1
- package/utils/SuperMapUtil.d.ts +21 -0
- package/utils/SuperMapUtil.d.ts.map +1 -0
- package/utils/SuperMapUtil.js +1 -0
- package/utils/SuperMapUtil.js.map +1 -0
- package/utils/UrlUtil.js +1 -1
- package/utils/XmlUtil.js +1 -1
- package/utils/format/CQL.js +1 -1
- package/utils/format/IsMatchCql.js +1 -1
- package/utils/gcj02Util.js +1 -1
- package/utils/plug/canvas/ImageCache.js +1 -1
- package/utils/plug/canvas/PinBuilder.js +1 -1
- package/utils/plug/canvas/PinIcon.js +1 -1
- package/utils/plug/canvas/writeTextToCanvas.js +1 -1
- package/utils/tasks/esri/Identify.js +1 -1
- package/utils/tasks/esri/Query.js +1 -1
- package/utils/tasks/esri/Task.js +1 -1
- package/utils/tasks/geoserver/QueryTask.js +1 -1
- package/utils/tasks/index.d.ts.map +1 -1
- package/utils/tasks/index.js +1 -1
- package/utils/tasks/index.js.map +1 -1
- package/ym-gis-2d.es.js +1 -1
- package/ym-gis-2d.umd.js +1 -1
package/API.md
ADDED
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
# ym-gis-2d API 文档
|
|
2
|
+
|
|
3
|
+
> 基于 [OpenLayers 9](https://openlayers.org/) 封装的二维 GIS 核心库,提供地图初始化、多源图层加载、空间查询、要素编辑与几何运算等能力。
|
|
4
|
+
> 当前版本:`1.0.49`
|
|
5
|
+
> npm 包名:`ym-gis-2d`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 目录
|
|
10
|
+
|
|
11
|
+
- [简介](#简介)
|
|
12
|
+
- [安装与依赖](#安装与依赖)
|
|
13
|
+
- [快速开始](#快速开始)
|
|
14
|
+
- [模块导入方式](#模块导入方式)
|
|
15
|
+
- [核心类 OLMap](#核心类-olmap)
|
|
16
|
+
- [图层配置 IMapService](#图层配置-imapservice)
|
|
17
|
+
- [支持的图层类型](#支持的图层类型)
|
|
18
|
+
- [要素管理 FeatureManager](#要素管理-featuremanager)
|
|
19
|
+
- [地图交互 Interaction](#地图交互-interaction)
|
|
20
|
+
- [地图控件 Control](#地图控件-control)
|
|
21
|
+
- [服务元数据 capabilities](#服务元数据-capabilities)
|
|
22
|
+
- [空间查询 tasks](#空间查询-tasks)
|
|
23
|
+
- [几何工具 GeometryUtil](#几何工具-geometryutil)
|
|
24
|
+
- [坐标系 RegisterProjUtil](#坐标系-registerprojutil)
|
|
25
|
+
- [KML 转换](#kml-转换)
|
|
26
|
+
- [类型定义 entity](#类型定义-entity)
|
|
27
|
+
- [完整示例](#完整示例)
|
|
28
|
+
- [注意事项](#注意事项)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 简介
|
|
33
|
+
|
|
34
|
+
`ym-gis-2d` 是对 OpenLayers 的业务封装,主要能力包括:
|
|
35
|
+
|
|
36
|
+
| 能力 | 说明 |
|
|
37
|
+
|------|------|
|
|
38
|
+
| 地图视图 | 默认 CGCS2000(EPSG:4490),支持中心点、范围、缩放级别等初始化 |
|
|
39
|
+
| 图层加载 | ArcGIS / GeoServer / 天地图 / XYZ 瓦片等多种服务 |
|
|
40
|
+
| 临时矢量层 | 点/线/面三套临时图层,用于绘制、选中、定位高亮 |
|
|
41
|
+
| 空间编辑 | 绘制、选择、修改、吸附、分割、挖除、修补等交互 |
|
|
42
|
+
| 空间查询 | 支持 ArcGIS 与 GeoServer 服务的属性/空间查询 |
|
|
43
|
+
| 几何运算 | WKT/GeoJSON 转换、缓冲、求交、合并、分割等 |
|
|
44
|
+
| 服务解析 | 自动读取 WMS/WMTS/WFS/ArcGIS MapServer 元数据 |
|
|
45
|
+
|
|
46
|
+
推荐与 UI 组件库 `ym-giswidget-2d` 配合使用,也可单独集成到 Vue / React / 原生 JS 项目。
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 安装与依赖
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install ym-gis-2d
|
|
54
|
+
# 或
|
|
55
|
+
pnpm add ym-gis-2d
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### peer 依赖
|
|
59
|
+
|
|
60
|
+
本包内部依赖以下库,请确保项目中版本兼容:
|
|
61
|
+
|
|
62
|
+
| 依赖 | 用途 |
|
|
63
|
+
|------|------|
|
|
64
|
+
| `ol` ^9.x | 地图渲染核心 |
|
|
65
|
+
| `axios` | HTTP 请求 |
|
|
66
|
+
| `proj4` | 坐标系转换 |
|
|
67
|
+
| `@turf/turf` | 部分几何运算 |
|
|
68
|
+
| `jsts` | 拓扑运算(分割、合并等) |
|
|
69
|
+
|
|
70
|
+
### 样式引入
|
|
71
|
+
|
|
72
|
+
地图组件会自动引入 OpenLayers 与包内样式,若样式未生效,请手动引入:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import 'ol/ol.css';
|
|
76
|
+
import 'ym-gis-2d/assets/main.css';
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 快速开始
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<div id="map" style="width: 100%; height: 500px;"></div>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import OLMap from 'ym-gis-2d/mapView/Map';
|
|
89
|
+
import type { IMapService } from 'ym-gis-2d/entity';
|
|
90
|
+
|
|
91
|
+
// 1. 创建地图(默认 EPSG:4490,中心合肥附近)
|
|
92
|
+
const map = new OLMap('map', {
|
|
93
|
+
projection: 4490,
|
|
94
|
+
center: [117.22, 31.82],
|
|
95
|
+
zoom: 10,
|
|
96
|
+
extent: [89.7, 26.7, 94.8, 29.8], // 可选:初始 fit 到范围
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// 2. 加载天地图矢量
|
|
100
|
+
const vecLayer: IMapService = {
|
|
101
|
+
id: 'tdt-vec',
|
|
102
|
+
title: '天地图矢量',
|
|
103
|
+
url: 'http://t0.tianditu.gov.cn/vec_c/wmts?tk=YOUR_TOKEN',
|
|
104
|
+
sublayers: ['vec'],
|
|
105
|
+
layerType: 'tdt-c',
|
|
106
|
+
opacity: 1,
|
|
107
|
+
mapIndex: 0,
|
|
108
|
+
checked: true,
|
|
109
|
+
thumbnail: '',
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
await map.addMapLayer(vecLayer);
|
|
113
|
+
|
|
114
|
+
// 3. 叠加 WKT 并定位
|
|
115
|
+
map.addWKT(
|
|
116
|
+
'POINT(91.1 29.6)',
|
|
117
|
+
'EPSG:4490',
|
|
118
|
+
'marker',
|
|
119
|
+
true,
|
|
120
|
+
{ name: '拉萨' },
|
|
121
|
+
{ color: '#f03437', opacity: 0.5, outlineColor: 'red', outlineWidth: 2 }
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 模块导入方式
|
|
128
|
+
|
|
129
|
+
包采用**子路径导入**(与源码目录结构一致),常用入口如下:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// 地图
|
|
133
|
+
import OLMap, { OlMapOptions, ChangeLayerEvent } from 'ym-gis-2d/mapView/Map';
|
|
134
|
+
import OLView from 'ym-gis-2d/mapView/View';
|
|
135
|
+
|
|
136
|
+
// 类型
|
|
137
|
+
import type { IMapService, IMapServiceTree, ILayerField } from 'ym-gis-2d/entity';
|
|
138
|
+
import Feature from 'ym-gis-2d/entity/Feature';
|
|
139
|
+
import type IStyle from 'ym-gis-2d/entity/style/IStyle';
|
|
140
|
+
|
|
141
|
+
// 要素 / 交互 / 工具
|
|
142
|
+
import FeatureManager from 'ym-gis-2d/feature/FeatureManager';
|
|
143
|
+
import Draw from 'ym-gis-2d/interaction/Draw';
|
|
144
|
+
import Select from 'ym-gis-2d/interaction/Select';
|
|
145
|
+
import { selectFeaturesByGeo } from 'ym-gis-2d/utils/tasks';
|
|
146
|
+
import { fromWKT, toWKT, getArea, getLength } from 'ym-gis-2d/utils/GeometryUtil';
|
|
147
|
+
import { getWmtsLayers, getWmsLayers } from 'ym-gis-2d/capabilities';
|
|
148
|
+
import { toKml, toGeoJSON } from 'ym-gis-2d/conver/kml';
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
> 根入口 `ym-gis-2d` 仅导出 `Map2D` 别名,实际项目请使用上述子路径。
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 核心类 OLMap
|
|
156
|
+
|
|
157
|
+
`OLMap` 继承自 `ol/Map`,是地图操作的中心入口。
|
|
158
|
+
|
|
159
|
+
### 构造函数
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
new OLMap(
|
|
163
|
+
element: string | HTMLElement,
|
|
164
|
+
options?: OlMapOptions,
|
|
165
|
+
view?: OLView
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### OlMapOptions
|
|
170
|
+
|
|
171
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
172
|
+
|------|------|--------|------|
|
|
173
|
+
| `projection` | `number` | `4490` | 坐标系 WKID,如 4490、4326 |
|
|
174
|
+
| `center` | `number[]` | `[117.22, 31.82]` | 地图中心 `[x, y]` |
|
|
175
|
+
| `extent` | `number[]` | - | 初始范围 `[xmin, ymin, xmax, ymax]`,设置后自动 fit |
|
|
176
|
+
| `zoom` | `number` | `10` | 初始缩放级别 |
|
|
177
|
+
| `minZoom` | `number` | `0` | 最小缩放 |
|
|
178
|
+
| `maxZoom` | `number` | `28` | 最大缩放 |
|
|
179
|
+
| `minResolution` | `number` | - | 最小分辨率 |
|
|
180
|
+
| `maxResolution` | `number` | - | 最大分辨率 |
|
|
181
|
+
| `constrainResolution` | `boolean` | `false` | 是否强制整数缩放级别 |
|
|
182
|
+
|
|
183
|
+
### 实例属性
|
|
184
|
+
|
|
185
|
+
| 属性 | 类型 | 说明 |
|
|
186
|
+
|------|------|------|
|
|
187
|
+
| `currentEditLayer` | `IMapService` | 当前编辑目标图层,配合 FeatureManager 使用 |
|
|
188
|
+
| `interactionManager` | `InteractionManager` | 交互管理器 |
|
|
189
|
+
| `controlManager` | `ControlManager` | 控件管理器 |
|
|
190
|
+
|
|
191
|
+
### 图层方法
|
|
192
|
+
|
|
193
|
+
| 方法 | 说明 |
|
|
194
|
+
|------|------|
|
|
195
|
+
| `addMapLayer(layerInfo)` | 按 `layerType` 异步创建并添加图层 |
|
|
196
|
+
| `addMapLayers(layerInfo[])` | 批量添加图层 |
|
|
197
|
+
| `addLayer(layer, fitLayer?)` | 直接添加 OpenLayers 图层 |
|
|
198
|
+
| `removeLayerById(id)` | 按 id 移除图层 |
|
|
199
|
+
| `removeLayerByIds(ids[])` | 批量移除 |
|
|
200
|
+
| `getLayerById(id)` | 按 id 查找图层 |
|
|
201
|
+
| `getLayerByLayerTag(layerTag)` | 按 layerTag 查找 |
|
|
202
|
+
| `getLayersByIds(ids[])` | 批量查找 |
|
|
203
|
+
| `fitLayer(layer)` | 缩放到图层范围 |
|
|
204
|
+
| `fitLayerById(id)` | 按 id 缩放 |
|
|
205
|
+
| `fitFilterByLayerTag(layerTag, filter, isSelected?, tag?)` | 查询并定位到过滤结果 |
|
|
206
|
+
| `refresh()` | 刷新地图渲染 |
|
|
207
|
+
|
|
208
|
+
### WKT / 定位方法
|
|
209
|
+
|
|
210
|
+
| 方法 | 说明 |
|
|
211
|
+
|------|------|
|
|
212
|
+
| `addWKT(wkt, proj, tag?, location?, properties?, style?)` | 添加 WKT 到临时图层 |
|
|
213
|
+
| `addWKTs(wkts[], proj, tag?, location?, style?, properties?)` | 批量添加 WKT |
|
|
214
|
+
| `locationWKT(wkt, proj?, ratio?, isFlash?)` | 定位到 WKT |
|
|
215
|
+
| `locationWKTs(wkts[], proj?, ratio?, isFlash?)` | 定位到多个 WKT |
|
|
216
|
+
| `locationGeometry(geometry, proj?, ratio?, isFlash?)` | 定位到 Geometry |
|
|
217
|
+
| `locationGeometrys(geometrys[], proj?, ratio?, isFlash?)` | 定位到多个 Geometry |
|
|
218
|
+
|
|
219
|
+
#### addWKT 参数示例
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
map.addWKT(
|
|
223
|
+
'POLYGON((117.0 31.0, 117.1 31.0, 117.1 31.1, 117.0 31.1, 117.0 31.0))',
|
|
224
|
+
'EPSG:4490',
|
|
225
|
+
'plot-001', // tag:用于后续按标签清除
|
|
226
|
+
true, // 是否自动定位
|
|
227
|
+
{ id: 1 }, // 属性
|
|
228
|
+
{
|
|
229
|
+
color: 'rgba(255,0,0,0.2)',
|
|
230
|
+
opacity: 0.2,
|
|
231
|
+
outlineColor: 'red',
|
|
232
|
+
outlineWidth: 2,
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 临时图层
|
|
238
|
+
|
|
239
|
+
| 方法 | 说明 |
|
|
240
|
+
|------|------|
|
|
241
|
+
| `getPointTempLayer()` | 临时点图层 |
|
|
242
|
+
| `getLineTempLayer()` | 临时线图层 |
|
|
243
|
+
| `getPolygonTempLayer()` | 临时面图层 |
|
|
244
|
+
| `getTempLayerByGeoType(geoType)` | 按几何类型获取临时层 |
|
|
245
|
+
| `getTempLayerById(id)` | 按 id 获取/创建临时层 |
|
|
246
|
+
| `sortTemLayer()` | 调整临时层叠放顺序 |
|
|
247
|
+
|
|
248
|
+
### 其他方法
|
|
249
|
+
|
|
250
|
+
| 方法 | 说明 |
|
|
251
|
+
|------|------|
|
|
252
|
+
| `getExtent()` | 获取当前视图范围 |
|
|
253
|
+
| `createOverlay(id, element?)` | 创建地图 Overlay |
|
|
254
|
+
| `resetViewProjection(projection)` | 切换视图坐标系,如 `'EPSG:4326'` |
|
|
255
|
+
| `getView()` | 返回扩展的 `OLView` 实例 |
|
|
256
|
+
|
|
257
|
+
### 图层变更事件
|
|
258
|
+
|
|
259
|
+
添加/移除图层时会派发 `ChangeLayerEvent`:
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
map.on('changelayer', (evt: ChangeLayerEvent) => {
|
|
263
|
+
console.log(evt.changetype); // 'add' | 'remove' | 'update'
|
|
264
|
+
console.log(evt.layerIds);
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 图层配置 IMapService
|
|
271
|
+
|
|
272
|
+
图层统一使用 `IMapService` 描述,核心字段如下:
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
interface IMapService {
|
|
276
|
+
id: string; // 唯一 id
|
|
277
|
+
title: string; // 显示名称
|
|
278
|
+
url?: string; // 服务地址
|
|
279
|
+
sublayers?: string[]; // 子图层名 / 图层索引
|
|
280
|
+
layerType?: string; // 服务类型(见下表)
|
|
281
|
+
layerTypeName?: string; // 类型名称
|
|
282
|
+
layerTag?: string; // 业务标识,用于查询/过滤
|
|
283
|
+
mapIndex?: number; // 图层层级(zIndex)
|
|
284
|
+
opacity?: number; // 透明度 0~1
|
|
285
|
+
geometryType?: number; // 1 点 / 2 线 / 3 面
|
|
286
|
+
editType?: boolean; // 是否可编辑
|
|
287
|
+
selectIndex?: string; // 空间查询图层名
|
|
288
|
+
tableName?: string; // 数据源表名
|
|
289
|
+
primaryKey?: string; // 主键字段
|
|
290
|
+
loadFilter?: string; // 加载过滤 CQL/SQL
|
|
291
|
+
minScale?: number; // 最小显示比例尺(-1 不限)
|
|
292
|
+
maxScale?: number; // 最大显示比例尺(-1 不限)
|
|
293
|
+
checked?: boolean; // 是否默认加载
|
|
294
|
+
thumbnail: string; // 缩略图路径
|
|
295
|
+
legend?: ILegend[]; // 自定义图例
|
|
296
|
+
showLegend?: boolean;
|
|
297
|
+
parentId?: string; // 目录树父节点
|
|
298
|
+
showIndex?: number; // 目录树排序
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## 支持的图层类型
|
|
305
|
+
|
|
306
|
+
通过 `map.addMapLayer()` 加载,`layerType` 取值如下:
|
|
307
|
+
|
|
308
|
+
| layerType | 说明 | url 示例 | sublayers |
|
|
309
|
+
|-----------|------|----------|-----------|
|
|
310
|
+
| `tdt-c` | 天地图 WMTS(4490) | `http://t0.tianditu.gov.cn/vec_c/wmts?tk=xxx` | `['vec']` / `['img']` / `['cva']` |
|
|
311
|
+
| `tile` | XYZ 瓦片 | `http://host/tile/{x}/{y}/{z}.png` | - |
|
|
312
|
+
| `geoserver-wms` | GeoServer WMS | `http://host/geoserver/wms` | `['workspace:layer']` |
|
|
313
|
+
| `geoserver-wmts` | GeoServer WMTS | `http://host/geoserver/gwc/service/wmts` | `['layer']` |
|
|
314
|
+
| `geoserver-wfs` | GeoServer WFS 矢量 | `http://host/geoserver/wfs` | `['workspace:layer']` |
|
|
315
|
+
| `geoserver-vector-tile` | GeoServer 矢量切片 | WMTS 地址 | `['layer']` |
|
|
316
|
+
| `arcgis-dynamic` | ArcGIS 动态地图 | MapServer 根地址 | 图层 id 字符串数组 |
|
|
317
|
+
| `arcgis-tile` | ArcGIS 切片 | MapServer 根地址 | - |
|
|
318
|
+
| `arcgis-feature` | ArcGIS 要素 | MapServer 根地址 | 图层 id 数组 |
|
|
319
|
+
| `arcgis-wms` | ArcGIS WMS | WMS 地址 | `['layer']` |
|
|
320
|
+
| `arcgis-wmts` | ArcGIS WMTS | WMTS 地址 | `['layer']` |
|
|
321
|
+
| `supermap-rest` | 超图 iServer REST 地图 | `http://host/iserver/services/map-xxx/rest/maps/mapName` 或 `.rjson` 地址 | 可选,url 为 maps 根地址时传地图名 |
|
|
322
|
+
|
|
323
|
+
### 天地图示例
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
await map.addMapLayer({
|
|
327
|
+
id: '001',
|
|
328
|
+
title: '天地图矢量',
|
|
329
|
+
url: 'http://t0.tianditu.gov.cn/vec_c/wmts?tk=YOUR_TOKEN',
|
|
330
|
+
sublayers: ['vec'],
|
|
331
|
+
layerType: 'tdt-c',
|
|
332
|
+
opacity: 1,
|
|
333
|
+
mapIndex: 0,
|
|
334
|
+
checked: true,
|
|
335
|
+
thumbnail: './img/vec.png',
|
|
336
|
+
});
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### GeoServer WMS 示例
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
await map.addMapLayer({
|
|
343
|
+
id: 'wms-001',
|
|
344
|
+
title: '市界',
|
|
345
|
+
url: 'http://192.168.1.185:8082/geoserver/qinghai/wms',
|
|
346
|
+
sublayers: ['qinghai_sheng_yy'],
|
|
347
|
+
layerType: 'geoserver-wms',
|
|
348
|
+
layerTag: 'boundary',
|
|
349
|
+
selectIndex: 'qinghai_sheng_yy',
|
|
350
|
+
geometryType: 3,
|
|
351
|
+
opacity: 1,
|
|
352
|
+
mapIndex: 4,
|
|
353
|
+
editType: true,
|
|
354
|
+
thumbnail: '',
|
|
355
|
+
});
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### XYZ 瓦片示例
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
await map.addMapLayer({
|
|
362
|
+
id: 'xyz-001',
|
|
363
|
+
title: '自定义影像',
|
|
364
|
+
url: 'http://host/vt/x={x}&y={y}&z={z}&scale=1.jpg',
|
|
365
|
+
layerType: 'tile',
|
|
366
|
+
opacity: 1,
|
|
367
|
+
mapIndex: 0,
|
|
368
|
+
thumbnail: '',
|
|
369
|
+
});
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
> XYZ 模板支持 OpenLayers 占位符:`{x}` `{y}` `{z}` `{-y}`(TMS Y 轴翻转)。
|
|
373
|
+
|
|
374
|
+
### 超图 iServer REST 地图示例
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
await map.addMapLayer({
|
|
378
|
+
id: 'supermap-001',
|
|
379
|
+
title: '通化子项目矢量',
|
|
380
|
+
url: 'http://10.3.50.13:8090/iserver/services/map-TongHua/rest/maps/通化子项目矢量@通化.rjson',
|
|
381
|
+
layerType: 'supermap-rest',
|
|
382
|
+
opacity: 1,
|
|
383
|
+
mapIndex: 0,
|
|
384
|
+
checked: true,
|
|
385
|
+
thumbnail: '',
|
|
386
|
+
});
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
> `url` 支持 `.rjson` / `.json` 后缀,或不带后缀的 `rest/maps/{mapName}` 地址。若 `url` 为 `rest/maps` 根地址,可通过 `sublayers: ['地图名']` 指定地图。
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## 要素管理 FeatureManager
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
import FeatureManager from 'ym-gis-2d/feature/FeatureManager';
|
|
397
|
+
|
|
398
|
+
const fm = new FeatureManager(map);
|
|
399
|
+
|
|
400
|
+
// 设置当前编辑图层
|
|
401
|
+
map.currentEditLayer = layerInfo;
|
|
402
|
+
|
|
403
|
+
// 获取可编辑要素
|
|
404
|
+
const editFeatures = fm.getEditFeatures();
|
|
405
|
+
const editFeaturesFiltered = fm.getEditFeatures('status', ['draft']);
|
|
406
|
+
|
|
407
|
+
// 获取选中要素
|
|
408
|
+
const selected = fm.getSelectedFeatures(); // 全部
|
|
409
|
+
const byLayer = fm.getSelectedFeatures('layer-id'); // 指定图层
|
|
410
|
+
|
|
411
|
+
// 闪烁高亮
|
|
412
|
+
fm.flashFeatures(features, 3);
|
|
413
|
+
fm.flashGeometrys([geometry], 3);
|
|
414
|
+
|
|
415
|
+
// 清除临时要素
|
|
416
|
+
fm.clearTempFeatures(); // 清除全部
|
|
417
|
+
fm.clearTempFeatures('tag'); // 按 tag 清除
|
|
418
|
+
|
|
419
|
+
// KML 导入
|
|
420
|
+
const features = await fm.kmlImport(kmlString);
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Feature 扩展属性
|
|
424
|
+
|
|
425
|
+
`ym-gis-2d/entity/Feature` 在 OpenLayers Feature 基础上扩展:
|
|
426
|
+
|
|
427
|
+
| 属性 | 类型 | 说明 |
|
|
428
|
+
|------|------|------|
|
|
429
|
+
| `isSelected` | `boolean` | 是否选中 |
|
|
430
|
+
| `fromType` | `'draw' \| 'import' \| 'cut' \| ...` | 来源类型 |
|
|
431
|
+
| `layerId` | `string` | 关联图层 id |
|
|
432
|
+
| `tag` | `string` | 业务标签 |
|
|
433
|
+
| `tempLayer` | `VectorLayer` | 所在临时图层 |
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## 地图交互 Interaction
|
|
438
|
+
|
|
439
|
+
所有交互通过 `map.interactionManager` 注册:
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
map.interactionManager.addInteraction('draw', drawInstance);
|
|
443
|
+
map.interactionManager.removeInteraction('draw');
|
|
444
|
+
map.interactionManager.getInteraction('draw');
|
|
445
|
+
map.interactionManager.removeAllInteractions();
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Draw — 绘制
|
|
449
|
+
|
|
450
|
+
```typescript
|
|
451
|
+
import Draw from 'ym-gis-2d/interaction/Draw';
|
|
452
|
+
import GeometryType from 'ym-gis-2d/entity/GeometryType';
|
|
453
|
+
|
|
454
|
+
const draw = new Draw(map, GeometryType.Polygon, {
|
|
455
|
+
style: { color: 'rgba(0,0,255,0.2)', outlineColor: 'blue', outlineWidth: 2 },
|
|
456
|
+
showTip: true,
|
|
457
|
+
tipText: '点击绘制多边形',
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
draw.on('drawEnd', (evt) => {
|
|
461
|
+
const feature = evt.feature;
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
map.interactionManager.addInteraction('draw', draw);
|
|
465
|
+
draw.setActive(true);
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
支持的 `GeometryType`:
|
|
469
|
+
|
|
470
|
+
| 常量 | 说明 |
|
|
471
|
+
|------|------|
|
|
472
|
+
| `Point` | 点 |
|
|
473
|
+
| `PolyLine` | 折线 |
|
|
474
|
+
| `Polygon` | 多边形 |
|
|
475
|
+
| `Rectangle` | 矩形 |
|
|
476
|
+
| `Circle` | 圆 |
|
|
477
|
+
| `Curve` | 曲线 |
|
|
478
|
+
| `Arrow` / `ArrowAttack` / `ArrowPincerlike` | 箭头类 |
|
|
479
|
+
| 等 | 见 `entity/GeometryType.ts` |
|
|
480
|
+
|
|
481
|
+
Draw 事件:`drawStart` `drawEnd` `drawAbort` `drawAddPoint` `drawMoving`
|
|
482
|
+
|
|
483
|
+
### Select — 选择 / 查询
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
import Select from 'ym-gis-2d/interaction/Select';
|
|
487
|
+
|
|
488
|
+
const select = new Select(map, {
|
|
489
|
+
pixelDistance: 5,
|
|
490
|
+
addTempLayer: true,
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
select.on('selected', (evt) => {
|
|
494
|
+
console.log(evt.features);
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
map.interactionManager.addInteraction('select', select);
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### 其他交互
|
|
501
|
+
|
|
502
|
+
| 类 | 导入路径 | 说明 |
|
|
503
|
+
|----|----------|------|
|
|
504
|
+
| `Modify` | `interaction/Modify` | 节点编辑 |
|
|
505
|
+
| `Snap` | `interaction/Snap` | 吸附 |
|
|
506
|
+
| `Split` | `interaction/Split` | 面分割 |
|
|
507
|
+
| `Difference` | `interaction/Difference` | 挖除/差集 |
|
|
508
|
+
| `Repair` | `interaction/Repair` | 面修补 |
|
|
509
|
+
| `AreaMeasure` | `interaction/AreaMeasure` | 面积量测 |
|
|
510
|
+
| `DistanceMeasure` | `interaction/DistanceMeasure` | 距离量测 |
|
|
511
|
+
|
|
512
|
+
量测单位配置见 `entity/measure/AreaMeasureUnits`、`DistanceMeasureUnits`。
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## 地图控件 Control
|
|
517
|
+
|
|
518
|
+
通过 `map.controlManager` 管理,用法与 `interactionManager` 类似。
|
|
519
|
+
|
|
520
|
+
| 类 | 导入路径 | 说明 |
|
|
521
|
+
|----|----------|------|
|
|
522
|
+
| `MousePositionControl` | `controls/MousePositionControl` | 鼠标坐标显示 |
|
|
523
|
+
| `LegendControl` | `controls/LegendControl` | 图例 |
|
|
524
|
+
| `SwipeLayerControl` | `controls/SwipeLayerControl` | 卷帘对比 |
|
|
525
|
+
|
|
526
|
+
```typescript
|
|
527
|
+
import MousePositionControl from 'ym-gis-2d/controls/MousePositionControl';
|
|
528
|
+
|
|
529
|
+
const mousePos = new MousePositionControl({
|
|
530
|
+
fractionDigits: 4,
|
|
531
|
+
showSpheroid: true,
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
map.controlManager.addControl('mousePosition', mousePos);
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
## 服务元数据 capabilities
|
|
540
|
+
|
|
541
|
+
用于管理后台解析服务能力、图层列表与字段信息:
|
|
542
|
+
|
|
543
|
+
```typescript
|
|
544
|
+
import {
|
|
545
|
+
getWmtsLayers,
|
|
546
|
+
getWmsLayers,
|
|
547
|
+
getWfLayers,
|
|
548
|
+
getArcgisDynamicLayers,
|
|
549
|
+
getArcgisDynamicLayerFields,
|
|
550
|
+
getWmsLayerFields,
|
|
551
|
+
getSourceLayerFields,
|
|
552
|
+
getDynamicLayerInfo,
|
|
553
|
+
getWMTSLayerCapabilities,
|
|
554
|
+
getWMSLayerCapabilities,
|
|
555
|
+
getWFSLayerCapabilities,
|
|
556
|
+
} from 'ym-gis-2d/capabilities';
|
|
557
|
+
|
|
558
|
+
// 获取 WMTS 图层列表
|
|
559
|
+
const layers = await getWmtsLayers('http://host/geoserver/gwc/service/wmts');
|
|
560
|
+
|
|
561
|
+
// 获取图层字段
|
|
562
|
+
const fields = await getSourceLayerFields(url, 'workspace:layer', 'geoserver-wfs');
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
## 空间查询 tasks
|
|
568
|
+
|
|
569
|
+
```typescript
|
|
570
|
+
import { selectFeaturesByGeo } from 'ym-gis-2d/utils/tasks';
|
|
571
|
+
|
|
572
|
+
const features = await selectFeaturesByGeo(
|
|
573
|
+
geometry, // 查询几何(可选)
|
|
574
|
+
'EPSG:4490', // 几何坐标系
|
|
575
|
+
serviceUrl,
|
|
576
|
+
layerName, // selectIndex / 图层名
|
|
577
|
+
'geoserver-wms', // 服务类型
|
|
578
|
+
"id=1", // 属性过滤(可选)
|
|
579
|
+
resolution // 当前地图分辨率(栅格 WMS 查询时使用)
|
|
580
|
+
);
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
支持的服务类型:`arcgis-dynamic`、`arcgis-feature`、`geoserver-wfs`、`geoserver-wms`、`geoserver-wmts`。
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## 几何工具 GeometryUtil
|
|
588
|
+
|
|
589
|
+
```typescript
|
|
590
|
+
import {
|
|
591
|
+
fromWKT, toWKT,
|
|
592
|
+
fromWKTs,
|
|
593
|
+
fromGeoJSON, toGeoJSON,
|
|
594
|
+
fromEsriJSON, toEsriJSON,
|
|
595
|
+
getArea, getLength,
|
|
596
|
+
bufferOp, bufferPixel,
|
|
597
|
+
contains, crosses, intersects, intersection,
|
|
598
|
+
union, unions, difference,
|
|
599
|
+
jstlSplit, splitLineByLine,
|
|
600
|
+
expandExtent,
|
|
601
|
+
polygonToLines,
|
|
602
|
+
getGeometryCenter,
|
|
603
|
+
isGeometryEmpty,
|
|
604
|
+
} from 'ym-gis-2d/utils/GeometryUtil';
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
常用示例:
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
const geom = fromWKT('POINT(117 31)', 'EPSG:4490', 'EPSG:4490');
|
|
611
|
+
const wkt = toWKT(geom);
|
|
612
|
+
const area = getArea(polygon, 'EPSG:4490', true); // 第三个参数:是否椭球面积
|
|
613
|
+
const len = getLength(line, 'EPSG:4490', true);
|
|
614
|
+
const merged = union(geom1, geom2);
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
---
|
|
618
|
+
|
|
619
|
+
## 坐标系 RegisterProjUtil
|
|
620
|
+
|
|
621
|
+
```typescript
|
|
622
|
+
import { registerProj, isSpheroid, getSpheroidProjection } from 'ym-gis-2d/utils/RegisterProjUtil';
|
|
623
|
+
|
|
624
|
+
// 注册坐标系(OLMap 构造时会自动注册 projection 选项)
|
|
625
|
+
registerProj('EPSG:4490');
|
|
626
|
+
registerProj('EPSG:4326');
|
|
627
|
+
|
|
628
|
+
// 判断是否大地坐标系
|
|
629
|
+
isSpheroid(projection);
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
### GCJ-02 转换
|
|
633
|
+
|
|
634
|
+
```typescript
|
|
635
|
+
import { gcj02towgs84, wgs84togcj02 } from 'ym-gis-2d/utils/gcj02Util';
|
|
636
|
+
const [lng, lat] = gcj02towgs84(116.404, 39.915);
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
## KML 转换
|
|
642
|
+
|
|
643
|
+
```typescript
|
|
644
|
+
import { toKml, toGeoJSON } from 'ym-gis-2d/conver/kml';
|
|
645
|
+
|
|
646
|
+
// GeoJSON → KML 字符串
|
|
647
|
+
const kml = toKml(geojson, options);
|
|
648
|
+
|
|
649
|
+
// KML → GeoJSON(支持字符串、URL、Blob、KMZ)
|
|
650
|
+
const geojson = await toGeoJSON(kmlString, null);
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
---
|
|
654
|
+
|
|
655
|
+
## 类型定义 entity
|
|
656
|
+
|
|
657
|
+
```typescript
|
|
658
|
+
import type {
|
|
659
|
+
IMapService,
|
|
660
|
+
IMapServiceTree,
|
|
661
|
+
IMapServiceQuery,
|
|
662
|
+
IMapServiceType,
|
|
663
|
+
ILayerField,
|
|
664
|
+
} from 'ym-gis-2d/entity';
|
|
665
|
+
|
|
666
|
+
import type IStyle from 'ym-gis-2d/entity/style/IStyle';
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
### IStyle 样式
|
|
670
|
+
|
|
671
|
+
```typescript
|
|
672
|
+
interface IStyle {
|
|
673
|
+
color?: string | number[]; // 填充色
|
|
674
|
+
opacity?: number; // 填充透明度
|
|
675
|
+
outlineColor?: string | number[];
|
|
676
|
+
outlineOpacity?: number;
|
|
677
|
+
outlineWidth?: number;
|
|
678
|
+
imgurl?: string; // 点图标
|
|
679
|
+
radius?: number; // 点半径(米)
|
|
680
|
+
scale?: number; // 图标缩放
|
|
681
|
+
rotation?: number; // 图标旋转
|
|
682
|
+
text?: string; // 标注文字
|
|
683
|
+
font?: IFont;
|
|
684
|
+
}
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
### 图层目录树
|
|
688
|
+
|
|
689
|
+
```typescript
|
|
690
|
+
import { mapServiceTreeTransform } from 'ym-gis-2d/utils/LayerUtil';
|
|
691
|
+
|
|
692
|
+
const tree: IMapServiceTree[] = mapServiceTreeTransform(flatLayerList);
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
---
|
|
696
|
+
|
|
697
|
+
## 完整示例
|
|
698
|
+
|
|
699
|
+
Vue 3 集成示例(参考 `comm-web` 项目):
|
|
700
|
+
|
|
701
|
+
```vue
|
|
702
|
+
<template>
|
|
703
|
+
<div id="map"></div>
|
|
704
|
+
</template>
|
|
705
|
+
|
|
706
|
+
<script setup lang="ts">
|
|
707
|
+
import { onMounted } from 'vue';
|
|
708
|
+
import OLMap from 'ym-gis-2d/mapView/Map';
|
|
709
|
+
import type { IMapService } from 'ym-gis-2d/entity';
|
|
710
|
+
import Draw from 'ym-gis-2d/interaction/Draw';
|
|
711
|
+
import GeometryType from 'ym-gis-2d/entity/GeometryType';
|
|
712
|
+
import FeatureManager from 'ym-gis-2d/feature/FeatureManager';
|
|
713
|
+
|
|
714
|
+
const layers: IMapService[] = [
|
|
715
|
+
{
|
|
716
|
+
id: 'vec',
|
|
717
|
+
title: '天地图矢量',
|
|
718
|
+
url: 'http://t0.tianditu.gov.cn/vec_c/wmts?tk=YOUR_TOKEN',
|
|
719
|
+
sublayers: ['vec'],
|
|
720
|
+
layerType: 'tdt-c',
|
|
721
|
+
mapIndex: 0,
|
|
722
|
+
opacity: 1,
|
|
723
|
+
checked: true,
|
|
724
|
+
thumbnail: '',
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
id: 'boundary',
|
|
728
|
+
title: '行政边界',
|
|
729
|
+
url: 'http://host/geoserver/wms',
|
|
730
|
+
sublayers: ['ws:boundary'],
|
|
731
|
+
layerType: 'geoserver-wms',
|
|
732
|
+
layerTag: 'boundary',
|
|
733
|
+
selectIndex: 'ws:boundary',
|
|
734
|
+
geometryType: 3,
|
|
735
|
+
editType: true,
|
|
736
|
+
mapIndex: 1,
|
|
737
|
+
opacity: 1,
|
|
738
|
+
thumbnail: '',
|
|
739
|
+
},
|
|
740
|
+
];
|
|
741
|
+
|
|
742
|
+
onMounted(async () => {
|
|
743
|
+
const map = new OLMap('map', {
|
|
744
|
+
projection: 4490,
|
|
745
|
+
extent: [89.7, 26.7, 94.8, 29.8],
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
for (const layer of layers) {
|
|
749
|
+
await map.addMapLayer(layer);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
map.currentEditLayer = layers[1];
|
|
753
|
+
|
|
754
|
+
const draw = new Draw(map, GeometryType.Polygon);
|
|
755
|
+
draw.on('drawEnd', () => {
|
|
756
|
+
const fm = new FeatureManager(map);
|
|
757
|
+
console.log(fm.getEditFeatures());
|
|
758
|
+
});
|
|
759
|
+
map.interactionManager.addInteraction('draw', draw);
|
|
760
|
+
});
|
|
761
|
+
</script>
|
|
762
|
+
|
|
763
|
+
<style>
|
|
764
|
+
#map { width: 100%; height: 100vh; }
|
|
765
|
+
</style>
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
---
|
|
769
|
+
|
|
770
|
+
## 注意事项
|
|
771
|
+
|
|
772
|
+
1. **坐标系**:默认 EPSG:4490(CGCS2000),与天地图 `tdt-c` 服务匹配;使用 WGS84 服务时需设置 `projection: 4326`。
|
|
773
|
+
2. **跨域**:WMS/WMTS/XYZ 服务需配置 CORS,或在开发环境使用代理。
|
|
774
|
+
3. **天地图 Token**:`tdt-c` 类型 URL 需携带有效 `tk` 参数。
|
|
775
|
+
4. **异步加载**:`addMapLayer` 为异步方法,WMS/WMTS 会先请求 GetCapabilities,请使用 `await` 或 `.then()`。
|
|
776
|
+
5. **临时图层**:绘制、选中、定位高亮均写入临时矢量层,不会直接修改服务端数据;持久化需自行对接后端。
|
|
777
|
+
6. **发布产物**:npm 包为编译后的 JS + `.d.ts` 声明文件,子路径导入方式与源码一致。
|
|
778
|
+
7. **UI 组件**:工具栏、图例、卷帘等 UI 在 `ym-giswidget-2d` 包中,本包仅提供 GIS 核心能力。
|
|
779
|
+
|
|
780
|
+
---
|
|
781
|
+
|
|
782
|
+
## 相关包
|
|
783
|
+
|
|
784
|
+
| 包名 | 说明 |
|
|
785
|
+
|------|------|
|
|
786
|
+
| `ym-giswidget-2d` | 二维 GIS UI 组件(工具栏、图例、量测、导入导出等) |
|
|
787
|
+
| `ol` | OpenLayers 官方库 |
|
|
788
|
+
|
|
789
|
+
如有问题,请联系包维护者或查阅 monorepo 内 `comm-web`、`gis-2d-docs` 示例项目。
|