my-openlayer 2.4.2 → 2.4.3
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/AI_CONTEXT.md +147 -0
- package/CHANGELOG.md +53 -0
- package/README.md +156 -1502
- package/core/SelectHandler.d.ts +6 -0
- package/core/SelectHandler.js +27 -2
- package/docs/ConfigManager.md +40 -0
- package/docs/ErrorHandler.md +45 -0
- package/docs/EventManager.md +52 -0
- package/docs/Line.md +52 -0
- package/docs/MapBaseLayers.md +48 -0
- package/docs/MapTools.md +48 -0
- package/docs/MeasureHandler.md +47 -0
- package/docs/MyOl.md +62 -0
- package/docs/Point.md +58 -0
- package/docs/Polygon.md +65 -0
- package/docs/RiverLayerManager.md +59 -0
- package/docs/SelectHandler.md +59 -0
- package/docs/ValidationUtils.md +38 -0
- package/docs/VueTemplatePoint.md +85 -0
- package/package.json +4 -1
package/AI_CONTEXT.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# AI Context for my-openlayer
|
|
2
|
+
|
|
3
|
+
Use this context to understand how to use the `my-openlayer` library.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
`my-openlayer` is a modern map component library based on OpenLayers, designed for Web GIS applications. It provides a modular, TypeScript-ready wrapper around OpenLayers features.
|
|
8
|
+
|
|
9
|
+
- **Core Dependency**: `ol` (OpenLayers)
|
|
10
|
+
- **Key Features**: Map initialization, Tianditu (天地图) support, Point/Line/Polygon management, Event handling, Selection, Measurement, Vue component markers.
|
|
11
|
+
|
|
12
|
+
## Core Architecture
|
|
13
|
+
|
|
14
|
+
- **MyOl**: The main entry class. Initializes the map and provides access to sub-modules.
|
|
15
|
+
- **Modules** (Lazy loaded via getters):
|
|
16
|
+
- `MapBaseLayers`: Base map switching (Vector, Image, Terrain) and Annotation layers.
|
|
17
|
+
- `Point`: Point features, clusters, DOM markers.
|
|
18
|
+
- `Line`: Line features, river layers.
|
|
19
|
+
- `Polygon`: Polygon features, heatmaps, image layers, masks.
|
|
20
|
+
- `MapTools`: General tools (Zoom, Fit, Layer management).
|
|
21
|
+
- `MeasureHandler`: Distance and Area measurement.
|
|
22
|
+
- `SelectHandler`: Feature selection interaction.
|
|
23
|
+
- `EventManager`: Unified event listener management.
|
|
24
|
+
- **Utils**: `ConfigManager`, `ErrorHandler`, `ValidationUtils`.
|
|
25
|
+
|
|
26
|
+
## Quick Start (Minimal Example)
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import MyOl, { MapInitType } from 'my-openlayer';
|
|
30
|
+
|
|
31
|
+
// 1. Configuration
|
|
32
|
+
const config: MapInitType = {
|
|
33
|
+
target: 'map-container', // ID of the DIV
|
|
34
|
+
center: [119.81, 29.969], // [Longitude, Latitude]
|
|
35
|
+
zoom: 10,
|
|
36
|
+
token: 'YOUR_TIANDITU_TOKEN', // Required for Tianditu base maps
|
|
37
|
+
annotation: true // Show annotation layer by default
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// 2. Initialize
|
|
41
|
+
const map = new MyOl('map-container', config);
|
|
42
|
+
|
|
43
|
+
// 3. Access Modules & Add Features
|
|
44
|
+
map.getPoint().addPoint([{ lgtd: 119.81, lttd: 29.969, name: 'Demo' }], {
|
|
45
|
+
layerName: 'demo-layer',
|
|
46
|
+
img: 'marker.png'
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API Reference (Condensed)
|
|
51
|
+
|
|
52
|
+
### `MyOl` (Main Class)
|
|
53
|
+
- `constructor(id: string | HTMLElement, options?: MapInitType)`
|
|
54
|
+
- `getPoint()`: Returns `Point` instance.
|
|
55
|
+
- `getLine()`: Returns `Line` instance.
|
|
56
|
+
- `getPolygon()`: Returns `Polygon` instance.
|
|
57
|
+
- `getMapBaseLayers()`: Returns `MapBaseLayers` instance.
|
|
58
|
+
- `getTools()`: Returns `MapTools` instance.
|
|
59
|
+
- `getSelectHandler()`: Returns `SelectHandler` instance.
|
|
60
|
+
- `getEventManager()`: Returns `EventManager` instance.
|
|
61
|
+
- `locationAction(lon, lat, zoom, duration)`: Animate to location.
|
|
62
|
+
|
|
63
|
+
### `MapBaseLayers`
|
|
64
|
+
- `switchBaseLayer(type: 'vec_c' | 'img_c' | 'ter_c')`: Switch base map.
|
|
65
|
+
- `setAnnotationVisible(visible: boolean)`: Toggle text annotations.
|
|
66
|
+
- `addGeoServerLayer(url, layerName, options)`: Add WMS layer.
|
|
67
|
+
|
|
68
|
+
### `Point`
|
|
69
|
+
- `addPoint(data: PointData[], options: PointOptions)`: Add markers.
|
|
70
|
+
- `addClusterPoint(data, options)`: Add clustered markers.
|
|
71
|
+
- `addVueTemplatePoint(data, Component, options)`: Use Vue component as marker.
|
|
72
|
+
|
|
73
|
+
### `Line`
|
|
74
|
+
- `addLine(geoJson, options)`: Add lines from GeoJSON.
|
|
75
|
+
- `addLineByUrl(url, options)`: Load GeoJSON from URL.
|
|
76
|
+
|
|
77
|
+
### `Polygon`
|
|
78
|
+
- `addPolygon(geoJson, options)`: Add polygons.
|
|
79
|
+
- `addBorderPolygon(geoJson, options)`: Add boundary lines.
|
|
80
|
+
- `updateFeatureColor(layerName, colorMap, options)`: Update colors dynamically.
|
|
81
|
+
- `addHeatmap(data, options)`: Add heatmap.
|
|
82
|
+
|
|
83
|
+
### `SelectHandler`
|
|
84
|
+
- `enableSelect(mode: 'click'|'hover', options)`: Enable selection.
|
|
85
|
+
- `selectByIds(ids, options)`: Programmatic selection.
|
|
86
|
+
|
|
87
|
+
### `MeasureHandler`
|
|
88
|
+
- **Important**: Must be instantiated manually if not exposed via `MyOl`.
|
|
89
|
+
- `new MeasureHandler(map.map)`
|
|
90
|
+
- `start('LineString' | 'Polygon')`
|
|
91
|
+
- `end()`, `clean()`
|
|
92
|
+
|
|
93
|
+
## Key Type Definitions (TypeScript)
|
|
94
|
+
|
|
95
|
+
Use these interfaces to ensure type safety.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
export interface MapInitType {
|
|
99
|
+
layers?: LayerItem[] | { [key: string]: LayerItem[] };
|
|
100
|
+
zoom?: number;
|
|
101
|
+
center?: number[]; // [lon, lat]
|
|
102
|
+
minZoom?: number;
|
|
103
|
+
maxZoom?: number;
|
|
104
|
+
token?: string; // Tianditu Token
|
|
105
|
+
annotation?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface BaseOptions {
|
|
109
|
+
layerName?: string;
|
|
110
|
+
zIndex?: number;
|
|
111
|
+
visible?: boolean;
|
|
112
|
+
opacity?: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface PointOptions extends BaseOptions {
|
|
116
|
+
textKey?: string; // Property key for label text
|
|
117
|
+
img?: string; // Icon URL
|
|
118
|
+
scale?: number;
|
|
119
|
+
textFillColor?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface PointData {
|
|
123
|
+
lgtd: number;
|
|
124
|
+
lttd: number;
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface LineOptions extends BaseOptions {
|
|
129
|
+
strokeColor?: string;
|
|
130
|
+
strokeWidth?: number;
|
|
131
|
+
lineDash?: number[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface PolygonOptions extends BaseOptions {
|
|
135
|
+
fillColor?: string;
|
|
136
|
+
strokeColor?: string;
|
|
137
|
+
textKey?: string;
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Best Practices
|
|
142
|
+
|
|
143
|
+
1. **Use Modules**: Access functionality through `map.getPoint()`, `map.getLine()`, etc., rather than manipulating the `ol.Map` directly when possible.
|
|
144
|
+
2. **Layer Names**: Always provide a unique `layerName` in options to easily retrieve or remove layers later (`map.getTools().removeLayer('my-layer')`).
|
|
145
|
+
3. **Coordinate System**: The library defaults to `EPSG:4326` (WGS84) for input coordinates (lon/lat) and `CGCS2000` internally where applicable.
|
|
146
|
+
4. **Vue Integration**: Use `addVueTemplatePoint` for complex markers requiring interactivity or dynamic content.
|
|
147
|
+
5. **Event Handling**: Use `map.getEventManager().on('click', ...)` instead of native listeners for better management.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.4.3] - 2026-01-27
|
|
4
|
+
|
|
5
|
+
### ✨ Features
|
|
6
|
+
|
|
7
|
+
- 重构Polygon样式处理并添加示例组件
|
|
8
|
+
- **core:** 添加基于GeoJSON数据的地图定位功能
|
|
9
|
+
- **core:** 添加地图定位功能并重构点位相关方法
|
|
10
|
+
- **Point:** 添加闪烁点功能及示例
|
|
11
|
+
- **core:** 为Polygon添加layerName选项并调整图层添加逻辑
|
|
12
|
+
- **Point:** 添加setOneVisibleByProp方法控制点显示
|
|
13
|
+
- **Polygon:** 优化遮罩功能支持多几何图形处理
|
|
14
|
+
- **测量工具:** 添加测量距离和面积功能及工具栏样式
|
|
15
|
+
- **地图:** 添加自定义投影配置支持
|
|
16
|
+
- **日志管理:** 实现统一日志开关与级别控制
|
|
17
|
+
- **SelectHandler:** 新增要素选择处理器模块
|
|
18
|
+
- upgrade OpenLayers to v10.6.1 and update project to v2.0.0
|
|
19
|
+
- update MapBaseLayers to handle optional token and improve annotation layer management
|
|
20
|
+
- 重新添加已清理的App.vue文件,移除了所有敏感token信息
|
|
21
|
+
- 重构Vue模板点位功能并优化事件管理
|
|
22
|
+
- **Polygon:** 改进图像图层处理逻辑并添加更新功能
|
|
23
|
+
- 添加验证工具类并重构现有验证逻辑
|
|
24
|
+
- **地图工具:** 重构地图工具类并增强错误处理
|
|
25
|
+
- 重构类型系统并增强核心功能
|
|
26
|
+
|
|
27
|
+
### 🐛 Bug Fixes
|
|
28
|
+
|
|
29
|
+
- **core:** 改进Vue依赖检测逻辑并更新版本号
|
|
30
|
+
- **VueTemplatePoint:** 修复Vue3环境下pointData的类型定义
|
|
31
|
+
- **core:** 修正Line类中layerName属性设置错误
|
|
32
|
+
- resolve TypeScript build error in MapBaseLayers.ts
|
|
33
|
+
|
|
34
|
+
### ⚡ Performance
|
|
35
|
+
|
|
36
|
+
- **Polygon:** 优化GeoJSON解析性能,直接注入layerName
|
|
37
|
+
|
|
38
|
+
### ♻️ Refactor
|
|
39
|
+
|
|
40
|
+
- **MapBaseLayers:** 重构图层管理逻辑,优化代码结构和可维护性
|
|
41
|
+
- **ConfigManager:** 集中管理默认配置并移除无用接口
|
|
42
|
+
- **样式处理:** 统一处理自定义样式逻辑并修复代码格式
|
|
43
|
+
- 将nameKey重命名为textKey以提高语义清晰度
|
|
44
|
+
- 更新依赖项并优化类型导出结构
|
|
45
|
+
- **core:** 重构DomPoint和MapBaseLayers类,优化代码结构和功能
|
|
46
|
+
|
|
47
|
+
### 📝 Documentation
|
|
48
|
+
|
|
49
|
+
- 添加详细模块文档并更新发布配置
|
|
50
|
+
- update README with branch strategy and add migration guide
|
|
51
|
+
|
|
52
|
+
All notable changes to this project will be documented in this file.
|
|
53
|
+
|