my-openlayer 2.2.0 → 2.3.1
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/MyOl.js +1 -6
- package/core/ConfigManager.d.ts +88 -11
- package/core/ConfigManager.js +93 -16
- package/core/Line.d.ts +4 -85
- package/core/Line.js +52 -451
- package/core/MapBaseLayers.d.ts +1 -0
- package/core/MapBaseLayers.js +49 -37
- package/core/MapTools.d.ts +51 -0
- package/core/MapTools.js +112 -20
- package/core/Point.js +14 -12
- package/core/Polygon.d.ts +0 -7
- package/core/Polygon.js +20 -48
- package/core/RiverLayerManager.d.ts +93 -0
- package/core/RiverLayerManager.js +342 -0
- package/core/VueTemplatePoint.js +2 -4
- package/index.d.ts +3 -1
- package/index.js +1 -0
- package/package.json +1 -1
- package/types.d.ts +0 -6
package/MyOl.js
CHANGED
|
@@ -404,12 +404,7 @@ class MyOl {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
// 默认配置
|
|
407
|
-
MyOl.DefaultOptions =
|
|
408
|
-
layers: undefined,
|
|
409
|
-
zoom: 10,
|
|
410
|
-
center: [119.81, 29.969],
|
|
411
|
-
extent: undefined
|
|
412
|
-
};
|
|
407
|
+
MyOl.DefaultOptions = ConfigManager.DEFAULT_MYOL_OPTIONS;
|
|
413
408
|
// 坐标系配置
|
|
414
409
|
MyOl.PROJECTIONS = {
|
|
415
410
|
CGCS2000: "EPSG:4490",
|
package/core/ConfigManager.d.ts
CHANGED
|
@@ -7,21 +7,33 @@ export declare class ConfigManager {
|
|
|
7
7
|
* 默认点位配置
|
|
8
8
|
*/
|
|
9
9
|
static readonly DEFAULT_POINT_OPTIONS: {
|
|
10
|
-
strokeColor: string;
|
|
11
|
-
strokeWidth: number;
|
|
12
|
-
fillColor: string;
|
|
13
|
-
opacity: number;
|
|
14
10
|
visible: boolean;
|
|
15
|
-
layerName: string;
|
|
16
11
|
zIndex: number;
|
|
17
12
|
};
|
|
13
|
+
static readonly DEFAULT_POINT_TEXT_OPTIONS: {
|
|
14
|
+
textFont: string;
|
|
15
|
+
textFillColor: string;
|
|
16
|
+
textStrokeColor: string;
|
|
17
|
+
textStrokeWidth: number;
|
|
18
|
+
textOffsetY: number;
|
|
19
|
+
};
|
|
20
|
+
static readonly DEFAULT_POINT_ICON_SCALE = 1;
|
|
21
|
+
static readonly DEFAULT_CLUSTER_OPTIONS: {
|
|
22
|
+
distance: number;
|
|
23
|
+
minDistance: number;
|
|
24
|
+
zIndex: number;
|
|
25
|
+
};
|
|
26
|
+
static readonly DEFAULT_DOM_POINT_OVERLAY_OPTIONS: {
|
|
27
|
+
readonly positioning: "center-center";
|
|
28
|
+
readonly stopEvent: false;
|
|
29
|
+
};
|
|
18
30
|
/**
|
|
19
31
|
* 默认线配置
|
|
20
32
|
*/
|
|
21
33
|
static readonly DEFAULT_LINE_OPTIONS: {
|
|
34
|
+
type: string;
|
|
22
35
|
strokeColor: string;
|
|
23
36
|
strokeWidth: number;
|
|
24
|
-
opacity: number;
|
|
25
37
|
visible: boolean;
|
|
26
38
|
layerName: string;
|
|
27
39
|
zIndex: number;
|
|
@@ -30,13 +42,21 @@ export declare class ConfigManager {
|
|
|
30
42
|
* 默认面配置
|
|
31
43
|
*/
|
|
32
44
|
static readonly DEFAULT_POLYGON_OPTIONS: {
|
|
45
|
+
zIndex: number;
|
|
46
|
+
visible: boolean;
|
|
33
47
|
strokeColor: string;
|
|
34
48
|
strokeWidth: number;
|
|
35
49
|
fillColor: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
textFont: string;
|
|
51
|
+
textFillColor: string;
|
|
52
|
+
textStrokeColor: string;
|
|
53
|
+
textStrokeWidth: number;
|
|
54
|
+
};
|
|
55
|
+
static readonly DEFAULT_POLYGON_COLOR_MAP: {
|
|
56
|
+
'0': string;
|
|
57
|
+
'1': string;
|
|
58
|
+
'2': string;
|
|
59
|
+
'3': string;
|
|
40
60
|
};
|
|
41
61
|
/**
|
|
42
62
|
* 默认图片图层配置
|
|
@@ -55,7 +75,6 @@ export declare class ConfigManager {
|
|
|
55
75
|
opacity: number;
|
|
56
76
|
visible: boolean;
|
|
57
77
|
layerName: string;
|
|
58
|
-
zIndex: number;
|
|
59
78
|
};
|
|
60
79
|
/**
|
|
61
80
|
* 默认文本配置
|
|
@@ -66,6 +85,64 @@ export declare class ConfigManager {
|
|
|
66
85
|
textStrokeColor: string;
|
|
67
86
|
textStrokeWidth: number;
|
|
68
87
|
};
|
|
88
|
+
static readonly DEFAULT_HEATMAP_OPTIONS: {
|
|
89
|
+
blur: number;
|
|
90
|
+
radius: number;
|
|
91
|
+
zIndex: number;
|
|
92
|
+
opacity: number;
|
|
93
|
+
};
|
|
94
|
+
static readonly DEFAULT_HEATMAP_VALUE_KEY = "value";
|
|
95
|
+
static readonly TIANDITU_CONFIG: {
|
|
96
|
+
readonly BASE_URL: "//t{0-7}.tianditu.gov.cn/DataServer";
|
|
97
|
+
readonly PROJECTION: "EPSG:4326";
|
|
98
|
+
readonly DEFAULT_ZINDEX: 9;
|
|
99
|
+
readonly ANNOTATION_ZINDEX_OFFSET: 10;
|
|
100
|
+
};
|
|
101
|
+
static readonly DEFAULT_MAP_LAYERS_OPTIONS: {
|
|
102
|
+
zIndex: 9;
|
|
103
|
+
annotation: boolean;
|
|
104
|
+
mapClip: boolean;
|
|
105
|
+
mapClipData: undefined;
|
|
106
|
+
};
|
|
107
|
+
static readonly DEFAULT_MYOL_OPTIONS: {
|
|
108
|
+
layers: undefined;
|
|
109
|
+
zoom: number;
|
|
110
|
+
center: number[];
|
|
111
|
+
extent: undefined;
|
|
112
|
+
};
|
|
113
|
+
static readonly DEFAULT_VUE_TEMPLATE_POINT_OPTIONS: {
|
|
114
|
+
readonly positioning: "center-center";
|
|
115
|
+
readonly stopEvent: false;
|
|
116
|
+
readonly visible: true;
|
|
117
|
+
readonly zIndex: 1;
|
|
118
|
+
};
|
|
119
|
+
static readonly DEFAULT_RIVER_LEVEL_WIDTH_MAP: {
|
|
120
|
+
1: number;
|
|
121
|
+
2: number;
|
|
122
|
+
3: number;
|
|
123
|
+
4: number;
|
|
124
|
+
5: number;
|
|
125
|
+
};
|
|
126
|
+
static readonly DEFAULT_RIVER_LAYERS_BY_ZOOM_OPTIONS: {
|
|
127
|
+
type: string;
|
|
128
|
+
levelCount: number;
|
|
129
|
+
zoomOffset: number;
|
|
130
|
+
strokeColor: string;
|
|
131
|
+
strokeWidth: number;
|
|
132
|
+
visible: boolean;
|
|
133
|
+
zIndex: number;
|
|
134
|
+
layerName: string;
|
|
135
|
+
removeExisting: boolean;
|
|
136
|
+
};
|
|
137
|
+
static readonly DEFAULT_RIVER_WIDTH_BY_LEVEL_OPTIONS: {
|
|
138
|
+
type: string;
|
|
139
|
+
layerName: string;
|
|
140
|
+
strokeColor: string;
|
|
141
|
+
strokeWidth: number;
|
|
142
|
+
visible: boolean;
|
|
143
|
+
zIndex: number;
|
|
144
|
+
removeExisting: boolean;
|
|
145
|
+
};
|
|
69
146
|
/**
|
|
70
147
|
* 合并配置选项
|
|
71
148
|
* @param defaultOptions 默认配置
|
package/core/ConfigManager.js
CHANGED
|
@@ -51,36 +51,56 @@ export class ConfigManager {
|
|
|
51
51
|
* 默认点位配置
|
|
52
52
|
*/
|
|
53
53
|
ConfigManager.DEFAULT_POINT_OPTIONS = {
|
|
54
|
-
strokeColor: '#409EFF',
|
|
55
|
-
strokeWidth: 2,
|
|
56
|
-
fillColor: 'rgba(64, 158, 255, 0.3)',
|
|
57
|
-
opacity: 1,
|
|
58
54
|
visible: true,
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
zIndex: 21
|
|
56
|
+
};
|
|
57
|
+
ConfigManager.DEFAULT_POINT_TEXT_OPTIONS = {
|
|
58
|
+
textFont: '12px Calibri,sans-serif',
|
|
59
|
+
textFillColor: '#FFF',
|
|
60
|
+
textStrokeColor: '#000',
|
|
61
|
+
textStrokeWidth: 3,
|
|
62
|
+
textOffsetY: 20
|
|
63
|
+
};
|
|
64
|
+
ConfigManager.DEFAULT_POINT_ICON_SCALE = 1;
|
|
65
|
+
ConfigManager.DEFAULT_CLUSTER_OPTIONS = {
|
|
66
|
+
distance: 40,
|
|
67
|
+
minDistance: 0,
|
|
68
|
+
zIndex: 21
|
|
69
|
+
};
|
|
70
|
+
ConfigManager.DEFAULT_DOM_POINT_OVERLAY_OPTIONS = {
|
|
71
|
+
positioning: 'center-center',
|
|
72
|
+
stopEvent: false
|
|
61
73
|
};
|
|
62
74
|
/**
|
|
63
75
|
* 默认线配置
|
|
64
76
|
*/
|
|
65
77
|
ConfigManager.DEFAULT_LINE_OPTIONS = {
|
|
66
|
-
|
|
78
|
+
type: 'line',
|
|
79
|
+
strokeColor: 'rgba(3, 122, 255, 1)',
|
|
67
80
|
strokeWidth: 2,
|
|
68
|
-
opacity: 1,
|
|
69
81
|
visible: true,
|
|
70
82
|
layerName: 'lineLayer',
|
|
71
|
-
zIndex:
|
|
83
|
+
zIndex: 15
|
|
72
84
|
};
|
|
73
85
|
/**
|
|
74
86
|
* 默认面配置
|
|
75
87
|
*/
|
|
76
88
|
ConfigManager.DEFAULT_POLYGON_OPTIONS = {
|
|
89
|
+
zIndex: 11,
|
|
90
|
+
visible: true,
|
|
77
91
|
strokeColor: '#EBEEF5',
|
|
78
92
|
strokeWidth: 2,
|
|
79
|
-
fillColor: 'rgba(255, 255, 255, 0
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
fillColor: 'rgba(255, 255, 255, 0)',
|
|
94
|
+
textFont: '14px Calibri,sans-serif',
|
|
95
|
+
textFillColor: '#FFF',
|
|
96
|
+
textStrokeColor: '#409EFF',
|
|
97
|
+
textStrokeWidth: 2
|
|
98
|
+
};
|
|
99
|
+
ConfigManager.DEFAULT_POLYGON_COLOR_MAP = {
|
|
100
|
+
'0': 'rgba(255, 0, 0, 0.6)',
|
|
101
|
+
'1': 'rgba(245, 154, 35, 0.6)',
|
|
102
|
+
'2': 'rgba(255, 238, 0, 0.6)',
|
|
103
|
+
'3': 'rgba(1, 111, 255, 0.6)'
|
|
84
104
|
};
|
|
85
105
|
/**
|
|
86
106
|
* 默认图片图层配置
|
|
@@ -98,8 +118,7 @@ ConfigManager.DEFAULT_MASK_OPTIONS = {
|
|
|
98
118
|
fillColor: 'rgba(0, 0, 0, 0.5)',
|
|
99
119
|
opacity: 1,
|
|
100
120
|
visible: true,
|
|
101
|
-
layerName: 'maskLayer'
|
|
102
|
-
zIndex: 12
|
|
121
|
+
layerName: 'maskLayer'
|
|
103
122
|
};
|
|
104
123
|
/**
|
|
105
124
|
* 默认文本配置
|
|
@@ -110,3 +129,61 @@ ConfigManager.DEFAULT_TEXT_OPTIONS = {
|
|
|
110
129
|
textStrokeColor: '#409EFF',
|
|
111
130
|
textStrokeWidth: 2
|
|
112
131
|
};
|
|
132
|
+
ConfigManager.DEFAULT_HEATMAP_OPTIONS = {
|
|
133
|
+
blur: 15,
|
|
134
|
+
radius: 10,
|
|
135
|
+
zIndex: 11,
|
|
136
|
+
opacity: 1
|
|
137
|
+
};
|
|
138
|
+
ConfigManager.DEFAULT_HEATMAP_VALUE_KEY = 'value';
|
|
139
|
+
ConfigManager.TIANDITU_CONFIG = {
|
|
140
|
+
BASE_URL: '//t{0-7}.tianditu.gov.cn/DataServer',
|
|
141
|
+
PROJECTION: 'EPSG:4326',
|
|
142
|
+
DEFAULT_ZINDEX: 9,
|
|
143
|
+
ANNOTATION_ZINDEX_OFFSET: 10
|
|
144
|
+
};
|
|
145
|
+
ConfigManager.DEFAULT_MAP_LAYERS_OPTIONS = {
|
|
146
|
+
zIndex: ConfigManager.TIANDITU_CONFIG.DEFAULT_ZINDEX,
|
|
147
|
+
annotation: false,
|
|
148
|
+
mapClip: false,
|
|
149
|
+
mapClipData: undefined
|
|
150
|
+
};
|
|
151
|
+
ConfigManager.DEFAULT_MYOL_OPTIONS = {
|
|
152
|
+
layers: undefined,
|
|
153
|
+
zoom: 10,
|
|
154
|
+
center: [119.81, 29.969],
|
|
155
|
+
extent: undefined
|
|
156
|
+
};
|
|
157
|
+
ConfigManager.DEFAULT_VUE_TEMPLATE_POINT_OPTIONS = {
|
|
158
|
+
positioning: 'center-center',
|
|
159
|
+
stopEvent: false,
|
|
160
|
+
visible: true,
|
|
161
|
+
zIndex: 1
|
|
162
|
+
};
|
|
163
|
+
ConfigManager.DEFAULT_RIVER_LEVEL_WIDTH_MAP = {
|
|
164
|
+
1: 2,
|
|
165
|
+
2: 1,
|
|
166
|
+
3: 0.5,
|
|
167
|
+
4: 0.5,
|
|
168
|
+
5: 0.5
|
|
169
|
+
};
|
|
170
|
+
ConfigManager.DEFAULT_RIVER_LAYERS_BY_ZOOM_OPTIONS = {
|
|
171
|
+
type: 'river',
|
|
172
|
+
levelCount: 5,
|
|
173
|
+
zoomOffset: 8,
|
|
174
|
+
strokeColor: 'rgb(0,113,255)',
|
|
175
|
+
strokeWidth: 3,
|
|
176
|
+
visible: true,
|
|
177
|
+
zIndex: 15,
|
|
178
|
+
layerName: 'riverLayer',
|
|
179
|
+
removeExisting: false
|
|
180
|
+
};
|
|
181
|
+
ConfigManager.DEFAULT_RIVER_WIDTH_BY_LEVEL_OPTIONS = {
|
|
182
|
+
type: 'river',
|
|
183
|
+
layerName: 'river',
|
|
184
|
+
strokeColor: 'rgba(3, 122, 255, 1)',
|
|
185
|
+
strokeWidth: 2,
|
|
186
|
+
visible: true,
|
|
187
|
+
zIndex: 15,
|
|
188
|
+
removeExisting: false
|
|
189
|
+
};
|
package/core/Line.d.ts
CHANGED
|
@@ -2,28 +2,9 @@ import Map from "ol/Map";
|
|
|
2
2
|
import VectorSource from "ol/source/Vector";
|
|
3
3
|
import VectorLayer from "ol/layer/Vector";
|
|
4
4
|
import { LineOptions, MapJSONData } from "../types";
|
|
5
|
-
/**
|
|
6
|
-
* 河流级别宽度映射配置
|
|
7
|
-
*/
|
|
8
|
-
interface RiverLevelWidthMap {
|
|
9
|
-
[level: number]: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 河流图层配置选项
|
|
13
|
-
*/
|
|
14
|
-
interface RiverLayerOptions extends LineOptions {
|
|
15
|
-
/** 河流级别数量,默认为5 */
|
|
16
|
-
levelCount?: number;
|
|
17
|
-
/** 缩放级别偏移量,默认为8 */
|
|
18
|
-
zoomOffset?: number;
|
|
19
|
-
/** 河流级别宽度映射 */
|
|
20
|
-
levelWidthMap?: RiverLevelWidthMap;
|
|
21
|
-
/** 是否删除同名图层 */
|
|
22
|
-
removeExisting?: boolean;
|
|
23
|
-
}
|
|
24
5
|
/**
|
|
25
6
|
* 线要素管理类
|
|
26
|
-
*
|
|
7
|
+
* 用于在地图上添加和管理线要素
|
|
27
8
|
*
|
|
28
9
|
* @example
|
|
29
10
|
* ```typescript
|
|
@@ -38,14 +19,9 @@ interface RiverLayerOptions extends LineOptions {
|
|
|
38
19
|
export default class Line {
|
|
39
20
|
/** OpenLayers 地图实例 */
|
|
40
21
|
private readonly map;
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
private riverLayerList;
|
|
45
|
-
/** 河流图层显示状态 */
|
|
46
|
-
private riverLayerShow;
|
|
47
|
-
/** 默认河流级别宽度映射 */
|
|
48
|
-
private readonly defaultLevelWidthMap;
|
|
22
|
+
private mergeDefaultOptions;
|
|
23
|
+
private createStyleFunction;
|
|
24
|
+
private createLayer;
|
|
49
25
|
/**
|
|
50
26
|
* 构造函数
|
|
51
27
|
* @param map OpenLayers地图实例
|
|
@@ -65,66 +41,9 @@ export default class Line {
|
|
|
65
41
|
* @returns 创建的矢量图层
|
|
66
42
|
*/
|
|
67
43
|
addLineByUrl(url: string, options?: LineOptions): VectorLayer<VectorSource>;
|
|
68
|
-
/**
|
|
69
|
-
* 添加分级河流图层,根据缩放级别显示不同级别的河流
|
|
70
|
-
* @param fyRiverJson 河流 GeoJSON 数据
|
|
71
|
-
* @param options 河流图层配置选项
|
|
72
|
-
* @throws {Error} 当数据格式无效时抛出错误
|
|
73
|
-
*/
|
|
74
|
-
addRiverLayersByZoom(fyRiverJson: MapJSONData, options?: RiverLayerOptions): void;
|
|
75
|
-
/**
|
|
76
|
-
* 从URL添加分级河流图层,根据缩放级别显示不同级别的河流
|
|
77
|
-
* @param url 河流数据URL
|
|
78
|
-
* @param options 河流图层配置选项
|
|
79
|
-
* @throws {Error} 当数据格式无效时抛出错误
|
|
80
|
-
*/
|
|
81
|
-
addRiverLayersByZoomByUrl(url: string, options?: RiverLayerOptions): void;
|
|
82
|
-
/**
|
|
83
|
-
* 显示或隐藏河流图层
|
|
84
|
-
* @param show 是否显示河流图层
|
|
85
|
-
*/
|
|
86
|
-
showRiverLayer(show: boolean): void;
|
|
87
|
-
/**
|
|
88
|
-
* 根据缩放级别显示对应的河流图层
|
|
89
|
-
* 缩放级别越高,显示的河流级别越详细
|
|
90
|
-
*/
|
|
91
|
-
showRiverLayerByZoom(): void;
|
|
92
|
-
/**
|
|
93
|
-
* 添加按级别显示不同宽度的河流图层
|
|
94
|
-
* @param data 河流 GeoJSON 数据
|
|
95
|
-
* @param options 河流图层配置选项
|
|
96
|
-
* @returns 创建的河流图层
|
|
97
|
-
*/
|
|
98
|
-
addRiverWidthByLevel(data: MapJSONData, options?: RiverLayerOptions): VectorLayer<VectorSource>;
|
|
99
|
-
/**
|
|
100
|
-
* 从URL添加按级别显示不同宽度的河流图层
|
|
101
|
-
* @param url 河流数据URL
|
|
102
|
-
* @param options 河流图层配置选项
|
|
103
|
-
* @returns 创建的河流图层
|
|
104
|
-
*/
|
|
105
|
-
addRiverWidthByLevelByUrl(url: string, options?: RiverLayerOptions): VectorLayer<VectorSource>;
|
|
106
44
|
/**
|
|
107
45
|
* 移除线图层
|
|
108
46
|
* @param layerName 图层名称
|
|
109
47
|
*/
|
|
110
48
|
removeLineLayer(layerName: string): void;
|
|
111
|
-
/**
|
|
112
|
-
* 清除所有河流图层
|
|
113
|
-
*/
|
|
114
|
-
clearRiverLayers(): void;
|
|
115
|
-
/**
|
|
116
|
-
* 获取河流图层显示状态
|
|
117
|
-
* @returns 河流图层是否显示
|
|
118
|
-
*/
|
|
119
|
-
getRiverLayerVisibility(): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* 获取河流图层列表
|
|
122
|
-
* @returns 河流图层数组的副本
|
|
123
|
-
*/
|
|
124
|
-
getRiverLayers(): VectorLayer<VectorSource>[];
|
|
125
|
-
/**
|
|
126
|
-
* 销毁线管理器,清理所有资源
|
|
127
|
-
*/
|
|
128
|
-
destroy(): void;
|
|
129
49
|
}
|
|
130
|
-
export {};
|