my-openlayer 0.1.8 → 0.1.9
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/dist/MyOl.d.ts +2 -2
- package/dist/MyOl.js +1 -1
- package/dist/core/MapTools.d.ts +7 -7
- package/dist/core/MapTools.js +11 -4
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/MyOl.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import Point from "./core/Point";
|
|
|
5
5
|
import Line from "./core/Line";
|
|
6
6
|
import MapBaseLayers from "./core/MapBaseLayers";
|
|
7
7
|
import MapTools from "./core/MapTools";
|
|
8
|
-
import { MapInitType } from './types';
|
|
8
|
+
import { MapInitType, EventType } from './types';
|
|
9
9
|
export default class MyOl {
|
|
10
10
|
map: Map;
|
|
11
11
|
private baseLayers;
|
|
@@ -63,5 +63,5 @@ export default class MyOl {
|
|
|
63
63
|
* @param clickType 点击类型
|
|
64
64
|
* @param callback 回调函数
|
|
65
65
|
*/
|
|
66
|
-
mapOnEvent(eventType:
|
|
66
|
+
mapOnEvent(eventType: EventType, callback: (feature?: any, e?: any) => void, clickType?: 'point' | 'line' | 'polygon' | undefined): void;
|
|
67
67
|
}
|
package/dist/MyOl.js
CHANGED
|
@@ -150,7 +150,7 @@ class MyOl {
|
|
|
150
150
|
* @param clickType 点击类型
|
|
151
151
|
* @param callback 回调函数
|
|
152
152
|
*/
|
|
153
|
-
mapOnEvent(eventType
|
|
153
|
+
mapOnEvent(eventType, callback, clickType) {
|
|
154
154
|
MapTools.mapOnEvent(this.map, eventType, callback, clickType);
|
|
155
155
|
}
|
|
156
156
|
}
|
package/dist/core/MapTools.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Map from "ol/Map";
|
|
2
|
-
import { MapJSONData } from "../types";
|
|
2
|
+
import { EventType, MapJSONData } from "../types";
|
|
3
3
|
import VectorLayer from "ol/layer/Vector";
|
|
4
4
|
import VectorSource from "ol/source/Vector";
|
|
5
5
|
import BaseLayer from "ol/layer/Base";
|
|
@@ -12,8 +12,8 @@ export default class MapTools {
|
|
|
12
12
|
* 根据名称获取图层
|
|
13
13
|
* @param layerName 图层名称
|
|
14
14
|
*/
|
|
15
|
-
getLayerByLayerName(layerName: string): (BaseLayer | VectorLayer<VectorSource<import("ol/geom").Geometry>> | ImageLayer<ImageSource>)[];
|
|
16
|
-
static getLayerByLayerName(map: Map, layerName: string): (BaseLayer | VectorLayer<VectorSource<import("ol/geom").Geometry>> | ImageLayer<ImageSource>)[];
|
|
15
|
+
getLayerByLayerName(layerName: string | string[]): (BaseLayer | VectorLayer<VectorSource<import("ol/geom").Geometry>> | ImageLayer<ImageSource>)[];
|
|
16
|
+
static getLayerByLayerName(map: Map, layerName: string | string[]): (BaseLayer | VectorLayer<VectorSource<import("ol/geom").Geometry>> | ImageLayer<ImageSource>)[];
|
|
17
17
|
/**
|
|
18
18
|
* 设置地图裁剪
|
|
19
19
|
*/
|
|
@@ -22,13 +22,13 @@ export default class MapTools {
|
|
|
22
22
|
* 移除图层
|
|
23
23
|
* @param layerName 图层名称
|
|
24
24
|
*/
|
|
25
|
-
removeLayer(layerName: string): void;
|
|
25
|
+
removeLayer(layerName: string | string[]): void;
|
|
26
26
|
/**
|
|
27
27
|
* 移除图层
|
|
28
28
|
* @param map 地图对象
|
|
29
29
|
* @param layerName 图层名称
|
|
30
30
|
*/
|
|
31
|
-
static removeLayer(map: Map, layerName: string): void;
|
|
31
|
+
static removeLayer(map: Map, layerName: string | string[]): void;
|
|
32
32
|
setLayerVisible(layerName: string, visible: boolean): void;
|
|
33
33
|
/**
|
|
34
34
|
* 设置图层可见性
|
|
@@ -37,7 +37,7 @@ export default class MapTools {
|
|
|
37
37
|
* @param visible 是否可见
|
|
38
38
|
*/
|
|
39
39
|
static setLayerVisible: (map: Map, layerName: string, visible: boolean) => void;
|
|
40
|
-
mapOnEvent(eventType:
|
|
40
|
+
mapOnEvent(eventType: EventType, callback: (feature?: any, e?: any) => void, clickType?: 'point' | 'line' | 'polygon' | undefined): void;
|
|
41
41
|
/**
|
|
42
42
|
* 地图监听事件
|
|
43
43
|
* @param map
|
|
@@ -45,5 +45,5 @@ export default class MapTools {
|
|
|
45
45
|
* @param clickType 点击类型
|
|
46
46
|
* @param callback 回调函数
|
|
47
47
|
*/
|
|
48
|
-
static mapOnEvent(map: Map, eventType:
|
|
48
|
+
static mapOnEvent(map: Map, eventType: EventType, callback: (feature?: any, e?: any) => void, clickType?: 'point' | 'line' | 'polygon'): void;
|
|
49
49
|
}
|
package/dist/core/MapTools.js
CHANGED
|
@@ -21,9 +21,16 @@ class MapTools {
|
|
|
21
21
|
const targetLayer = [];
|
|
22
22
|
const layers = map.getLayers().getArray();
|
|
23
23
|
Object.keys(layers).forEach(function (key) {
|
|
24
|
-
const _layerName = layers[key]
|
|
25
|
-
if (
|
|
26
|
-
|
|
24
|
+
const _layerName = layers[key].get('layerName');
|
|
25
|
+
if (typeof layerName === "string") {
|
|
26
|
+
if (_layerName && _layerName === layerName) {
|
|
27
|
+
targetLayer.push(layers[key]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (_layerName && layerName.includes(_layerName)) {
|
|
32
|
+
targetLayer.push(layers[key]);
|
|
33
|
+
}
|
|
27
34
|
}
|
|
28
35
|
});
|
|
29
36
|
return targetLayer;
|
|
@@ -99,7 +106,7 @@ class MapTools {
|
|
|
99
106
|
* @param clickType 点击类型
|
|
100
107
|
* @param callback 回调函数
|
|
101
108
|
*/
|
|
102
|
-
static mapOnEvent(map, eventType
|
|
109
|
+
static mapOnEvent(map, eventType, callback, clickType) {
|
|
103
110
|
const clickTypeObj = {
|
|
104
111
|
point: ['point'],
|
|
105
112
|
line: ['line'],
|
package/dist/types.d.ts
CHANGED