@gis_victory/gismap 1.0.55 → 1.0.57

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/README.md CHANGED
@@ -1,5 +1,350 @@
1
- # Vue 3 + TypeScript + Vite
1
+ # @gis_victory/gismap 组件库
2
2
 
3
- This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
3
+ 一个基于 Vue 3 + TypeScript + Vite 开发的 GIS 地图组件库,提供丰富的地图交互功能和移动端适配。
4
4
 
5
- Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
5
+ ## 特性
6
+
7
+ - 📦 开箱即用的地图组件
8
+ - 🎨 支持多种地图样式和图层
9
+ - 📱 移动端适配
10
+ - 🔍 地图搜索功能
11
+ - 🎯 地图工具和控件
12
+ - 📍 标记和弹窗
13
+ - 📊 图例和数据可视化
14
+ - 🔄 地图切换和扩展
15
+
16
+ ## 安装
17
+
18
+ ```bash
19
+ npm install @gis_victory/gismap
20
+ # 或
21
+ yarn add @gis_victory/gismap
22
+ ```
23
+
24
+ ## 快速开始
25
+
26
+ ### 基础使用
27
+
28
+ ```vue
29
+ <template>
30
+ <MapContainer
31
+ :mapViewData="mapViewData"
32
+ :switchData="switchData"
33
+ :layerData="layerData"
34
+ :toolsData="toolsData"
35
+ :searchData="searchData"
36
+ @load="onMapLoad"
37
+ >
38
+ <!-- 自定义插槽内容 -->
39
+ <template #bottom-left>
40
+ <GisMapCompass />
41
+ </template>
42
+ </MapContainer>
43
+ </template>
44
+
45
+ <script setup lang="ts">
46
+ import { ref, reactive } from 'vue';
47
+ import { MapContainer, GisMapCompass, GSMap } from '@gis_victory/gismap';
48
+
49
+ const mapViewData = reactive({
50
+ zoom: 9,
51
+ center: [120.65677441301864, 29.745141743380103],
52
+ style: {
53
+ glyphs: "http://www.gisx.work/map-assets/fonts/{fontstack}/{range}.pbf",
54
+ },
55
+ icons: [
56
+ {
57
+ name: 'point',
58
+ label: "点",
59
+ url: 'assets/icons/point.png',
60
+ }
61
+ // 更多图标配置...
62
+ ]
63
+ });
64
+
65
+ const switchData = reactive({
66
+ layers: [{
67
+ name: "tdt-vec",
68
+ label: "标准地图",
69
+ iconName: "vector",
70
+ checked: true
71
+ }, {
72
+ name: "tdt-img",
73
+ label: "卫星影像",
74
+ iconName: "satellite",
75
+ checked: false
76
+ }],
77
+ extensions: [{
78
+ name: "tdt-cia",
79
+ label: "注记",
80
+ checked: true,
81
+ }]
82
+ });
83
+
84
+ const layerData = ref([]);
85
+ const toolsData = ref([]);
86
+ const searchData = ref([]);
87
+
88
+ const onMapLoad = (map: GSMap) => {
89
+ console.log('地图加载完成:', map);
90
+ // 地图操作逻辑...
91
+ };
92
+ </script>
93
+ ```
94
+
95
+ ## 组件列表
96
+
97
+ ### 核心组件
98
+
99
+ | 组件名 | 描述 | 示例 |
100
+ |-------|------|------|
101
+ | `MapContainer` | 地图容器,包含所有地图组件 | `<MapContainer :mapViewData="mapViewData" @load="onMapLoad" />` |
102
+ | `GisMapView` | 地图视图组件 | `<GisMapView :mapViewData="mapViewData" />` |
103
+ | `GisMapLayer` | 地图图层管理组件 | `<GisMapLayer :layerData="layerData" />` |
104
+ | `GisMapLegend` | 地图图例组件 | `<GisMapLegend />` |
105
+ | `GisMapTools` | 地图工具组件 | `<GisMapTools :toolsData="toolsData" />` |
106
+ | `GisMapSwitch` | 地图切换组件 | `<GisMapSwitch :switchData="switchData" />` |
107
+ | `GisMapSearch` | 地图搜索组件 | `<GisMapSearch :searchData="searchData" />` |
108
+
109
+ ### 工具组件
110
+
111
+ | 组件名 | 描述 | 示例 |
112
+ |-------|------|------|
113
+ | `GisMapCompass` | 地图指南针组件 | `<GisMapCompass />` |
114
+ | `GisMapPopupBar` | 弹窗工具栏组件 | `<GisMapPopupBar>` |
115
+ | `GisMapPopupBarItem` | 弹窗工具栏项组件 | `<GisMapPopupBarItem label="示例" />` |
116
+
117
+ ### 移动端组件
118
+
119
+ | 组件名 | 描述 | 示例 |
120
+ |-------|------|------|
121
+ | `MobileMapLayer` | 移动端地图图层组件 | `<MobileMapLayer>` |
122
+ | `MobileBaseLayerSwitch` | 移动端底图切换组件 | `<MobileBaseLayerSwitch :data="layersData" />` |
123
+
124
+ ## API 文档
125
+
126
+ ### MapContainer 组件
127
+
128
+ #### Props
129
+
130
+ | 属性名 | 类型 | 描述 | 默认值 |
131
+ |-------|------|------|--------|
132
+ | `mapViewData` | `Object` | 地图视图配置 | `{}` |
133
+ | `switchData` | `Object` | 地图切换配置 | `{}` |
134
+ | `layerData` | `Array` | 图层数据 | `[]` |
135
+ | `toolsData` | `Array` | 工具数据 | `[]` |
136
+ | `searchData` | `Array` | 搜索数据 | `[]` |
137
+
138
+ #### Events
139
+
140
+ | 事件名 | 参数 | 描述 |
141
+ |-------|------|------|
142
+ | `load` | `map: GSMap` | 地图加载完成事件 |
143
+
144
+ #### Slots
145
+
146
+ | 插槽名 | 描述 |
147
+ |-------|------|
148
+ | `bottom-left` | 地图左下角插槽 |
149
+ | `bottom-right` | 地图右下角插槽 |
150
+ | `top-left` | 地图左上角插槽 |
151
+ | `top-right` | 地图右上角插槽 |
152
+
153
+ ### GSMap 实例
154
+
155
+ #### 方法
156
+
157
+ | 方法名 | 参数 | 描述 |
158
+ |-------|------|------|
159
+ | `pubsub.on` | `event: string, callback: Function` | 订阅地图事件 |
160
+ | `pubsub.emit` | `event: string, data: any` | 发布地图事件 |
161
+ | `manager.templateManager.add` | `id: string, template: string` | 添加模板 |
162
+ | `manager.maskManager.add` | `data: string` | 添加遮罩 |
163
+
164
+ ## 配置项
165
+
166
+ ### mapViewData 配置
167
+
168
+ ```javascript
169
+ {
170
+ zoom: 9, // 初始缩放级别
171
+ center: [120.65677441301864, 29.745141743380103], // 初始中心点坐标
172
+ style: {
173
+ glyphs: "http://www.gisx.work/map-assets/fonts/{fontstack}/{range}.pbf", // 字体配置
174
+ },
175
+ icons: [ // 图标配置
176
+ {
177
+ name: 'point', // 图标名称
178
+ label: "点", // 图标标签
179
+ url: 'assets/icons/point.png', // 图标路径
180
+ }
181
+ ]
182
+ }
183
+ ```
184
+
185
+ ### switchData 配置
186
+
187
+ ```javascript
188
+ {
189
+ layers: [ // 底图配置
190
+ {
191
+ name: "tdt-vec", // 图层名称
192
+ label: "标准地图", // 图层标签
193
+ iconName: "vector", // 图标名称
194
+ checked: true // 是否默认选中
195
+ }
196
+ ],
197
+ extensions: [ // 扩展配置
198
+ {
199
+ name: "tdt-cia", // 扩展名称
200
+ label: "注记", // 扩展标签
201
+ checked: true, // 是否默认选中
202
+ config: { // 扩展配置
203
+ source: {
204
+ tiles: ["http://www.gisx.work/tiles/dem/{z}_{x}_{y}.webp"]
205
+ }
206
+ }
207
+ }
208
+ ]
209
+ }
210
+ ```
211
+
212
+ ## 示例
213
+
214
+ ### 完整示例
215
+
216
+ ```vue
217
+ <template>
218
+ <MapContainer
219
+ :mapViewData="mapViewData"
220
+ :switchData="switchData"
221
+ :layerData="layerData"
222
+ :toolsData="toolsData"
223
+ :searchData="searchData"
224
+ @load="onMapLoad"
225
+ >
226
+ <template #bottom-left>
227
+ <GisMapCompass />
228
+ </template>
229
+ <template #top-right>
230
+ <MobileMapLayer>
231
+ <MobileBaseLayerSwitch :data="switchData.layers" />
232
+ </MobileMapLayer>
233
+ </template>
234
+ </MapContainer>
235
+ </template>
236
+
237
+ <script setup lang="ts">
238
+ import { ref, reactive, onMounted } from 'vue';
239
+ import { MapContainer, GisMapCompass, GSMap, MobileMapLayer, MobileBaseLayerSwitch } from '@gis_victory/gismap';
240
+
241
+ const mapViewData = reactive({
242
+ zoom: 9,
243
+ center: [120.65677441301864, 29.745141743380103],
244
+ style: {
245
+ glyphs: "http://www.gisx.work/map-assets/fonts/{fontstack}/{range}.pbf",
246
+ },
247
+ icons: [
248
+ {
249
+ name: 'point',
250
+ label: "点",
251
+ url: 'assets/icons/point.png',
252
+ }
253
+ ]
254
+ });
255
+
256
+ const switchData = reactive({
257
+ layers: [{
258
+ name: "tdt-vec",
259
+ label: "标准地图",
260
+ iconName: "vector",
261
+ checked: true
262
+ }, {
263
+ name: "tdt-img",
264
+ label: "卫星影像",
265
+ iconName: "satellite",
266
+ checked: false
267
+ }],
268
+ extensions: [{
269
+ name: "tdt-cia",
270
+ label: "注记",
271
+ checked: true,
272
+ }]
273
+ });
274
+
275
+ const layerData = ref([]);
276
+ const toolsData = ref([]);
277
+ const searchData = ref([]);
278
+
279
+ let map: GSMap;
280
+ const onMapLoad = (_map: GSMap) => {
281
+ map = _map;
282
+ // 地图加载完成后的操作
283
+ map.pubsub.on('layer:click', ({ templateId, feature }: { templateId: string, feature: any }) => {
284
+ const template = map.manager?.templateManager?.renderHtml(templateId, feature.properties);
285
+ if (template) {
286
+ map.manager?.popupManager.show({
287
+ position: feature.geometry.coordinates,
288
+ html: template,
289
+ });
290
+ }
291
+ });
292
+ };
293
+
294
+ // 初始化数据
295
+ onMounted(() => {
296
+ // 这里可以加载图层数据、工具数据和搜索数据
297
+ });
298
+ </script>
299
+ ```
300
+
301
+ ## 开发指南
302
+
303
+ ### 本地开发
304
+
305
+ 1. 克隆仓库
306
+
307
+ ```bash
308
+ git clone <repository-url>
309
+ cd gismap
310
+ ```
311
+
312
+ 2. 安装依赖
313
+
314
+ ```bash
315
+ npm install
316
+ ```
317
+
318
+ 3. 启动开发服务器
319
+
320
+ ```bash
321
+ npm run dev
322
+ ```
323
+
324
+ 4. 构建生产版本
325
+
326
+ ```bash
327
+ npm run build
328
+ ```
329
+
330
+ ### 发布版本
331
+
332
+ ```bash
333
+ # 更新版本号
334
+ npm version patch
335
+ # 构建
336
+ npm run build
337
+ # 发布
338
+ npm publish
339
+ ```
340
+
341
+ ## 浏览器兼容性
342
+
343
+ - Chrome (最新版本)
344
+ - Firefox (最新版本)
345
+ - Safari (最新版本)
346
+ - Edge (最新版本)
347
+
348
+ ## 许可证
349
+
350
+ MIT
package/dist/index.es.js CHANGED
@@ -95176,6 +95176,10 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
95176
95176
  });
95177
95177
  break;
95178
95178
  }
95179
+ map2?.pubsub.emit(`switch:click`, {
95180
+ checked: item.checked,
95181
+ data: item
95182
+ });
95179
95183
  };
95180
95184
  onMounted(() => {
95181
95185
  props.data.layers.forEach((item) => {