@antv/l7-component 2.23.0 → 2.23.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/es/control/layerSwitch.js +5 -1
- package/es/index.js +150 -28
- package/es/popup/layerPopup.d.ts +8 -2
- package/es/popup/layerPopup.js +24 -9
- package/es/popup/popup.js +0 -1
- package/lib/control/layerSwitch.js +5 -1
- package/lib/index.js +150 -28
- package/lib/popup/layerPopup.d.ts +8 -2
- package/lib/popup/layerPopup.js +23 -8
- package/lib/popup/popup.js +0 -1
- package/package.json +5 -5
package/es/popup/layerPopup.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type LayerPopupConfigItem = {
|
|
|
17
17
|
export interface ILayerPopupOption extends IPopupOption {
|
|
18
18
|
config?: LayerPopupConfigItem[];
|
|
19
19
|
items?: LayerPopupConfigItem[];
|
|
20
|
-
trigger: 'hover' | 'click';
|
|
20
|
+
trigger: 'hover' | 'click' | 'touchend' | 'touchstart';
|
|
21
21
|
}
|
|
22
22
|
type LayerMapInfo = {
|
|
23
23
|
onMouseMove?: (layer: ILayer, e: any) => void;
|
|
@@ -45,6 +45,12 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
|
|
|
45
45
|
featureId: number;
|
|
46
46
|
};
|
|
47
47
|
protected get layerConfigItems(): LayerPopupConfigItem[];
|
|
48
|
+
/**
|
|
49
|
+
* 根据环境获取实际的触发事件
|
|
50
|
+
* 当 trigger 为 'click' 时,移动端使用 'touchend',PC 端使用 'click'
|
|
51
|
+
* @protected
|
|
52
|
+
*/
|
|
53
|
+
protected getActualTriggerEvent(): "hover" | "click" | "touchstart" | "touchend";
|
|
48
54
|
addTo(scene: L7Container): this;
|
|
49
55
|
remove(): this;
|
|
50
56
|
setOptions(option: Partial<ILayerPopupOption>): this;
|
|
@@ -60,7 +66,7 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
|
|
|
60
66
|
*/
|
|
61
67
|
protected unbindLayerEvent(): void;
|
|
62
68
|
protected onLayerMouseMove(layer: ILayer, e: any): void;
|
|
63
|
-
protected onLayerMouseOut(layer: ILayer
|
|
69
|
+
protected onLayerMouseOut(layer: ILayer): void;
|
|
64
70
|
protected onLayerClick: (layer: ILayer, e: any) => void;
|
|
65
71
|
protected onSceneClick: () => void;
|
|
66
72
|
protected onSourceUpdate(): void;
|
package/es/popup/layerPopup.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
-
import { DOM, lodashUtil } from '@antv/l7-utils';
|
|
3
|
+
import { DOM, isPC, lodashUtil } from '@antv/l7-utils';
|
|
4
4
|
import Popup from "./popup";
|
|
5
5
|
const {
|
|
6
6
|
get
|
|
@@ -72,6 +72,21 @@ export default class LayerPopup extends Popup {
|
|
|
72
72
|
} = this.popupOption;
|
|
73
73
|
return (_ref = config !== null && config !== void 0 ? config : items) !== null && _ref !== void 0 ? _ref : [];
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 根据环境获取实际的触发事件
|
|
78
|
+
* 当 trigger 为 'click' 时,移动端使用 'touchend',PC 端使用 'click'
|
|
79
|
+
* @protected
|
|
80
|
+
*/
|
|
81
|
+
getActualTriggerEvent() {
|
|
82
|
+
const {
|
|
83
|
+
trigger
|
|
84
|
+
} = this.popupOption;
|
|
85
|
+
if (trigger === 'click') {
|
|
86
|
+
return isPC() ? 'click' : 'touchend';
|
|
87
|
+
}
|
|
88
|
+
return trigger;
|
|
89
|
+
}
|
|
75
90
|
addTo(scene) {
|
|
76
91
|
super.addTo(scene);
|
|
77
92
|
this.bindLayerEvent();
|
|
@@ -99,7 +114,7 @@ export default class LayerPopup extends Popup {
|
|
|
99
114
|
return this;
|
|
100
115
|
}
|
|
101
116
|
getDefault(option) {
|
|
102
|
-
const isHoverTrigger = option.trigger
|
|
117
|
+
const isHoverTrigger = option.trigger === 'hover';
|
|
103
118
|
return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
|
|
104
119
|
trigger: 'hover',
|
|
105
120
|
followCursor: isHoverTrigger,
|
|
@@ -124,6 +139,7 @@ export default class LayerPopup extends Popup {
|
|
|
124
139
|
trigger,
|
|
125
140
|
closeOnClick
|
|
126
141
|
} = this.popupOption;
|
|
142
|
+
const actualTrigger = this.getActualTriggerEvent();
|
|
127
143
|
this.layerConfigItems.forEach(configItem => {
|
|
128
144
|
var _layer$getSource;
|
|
129
145
|
const layer = this.getLayerByConfig(configItem);
|
|
@@ -142,10 +158,10 @@ export default class LayerPopup extends Popup {
|
|
|
142
158
|
var _this$mapsService;
|
|
143
159
|
const onLayerClick = this.onLayerClick.bind(this, layer);
|
|
144
160
|
layerInfo.onClick = onLayerClick;
|
|
145
|
-
layer === null || layer === void 0 || layer.on(
|
|
161
|
+
layer === null || layer === void 0 || layer.on(actualTrigger, onLayerClick);
|
|
146
162
|
const mapContainer = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getMapContainer();
|
|
147
163
|
if (mapContainer && closeOnClick) {
|
|
148
|
-
mapContainer.addEventListener(
|
|
164
|
+
mapContainer.addEventListener(actualTrigger, this.onSceneClick);
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
const source = layer === null || layer === void 0 || (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
|
|
@@ -161,6 +177,7 @@ export default class LayerPopup extends Popup {
|
|
|
161
177
|
* @protected
|
|
162
178
|
*/
|
|
163
179
|
unbindLayerEvent() {
|
|
180
|
+
const actualTrigger = this.getActualTriggerEvent();
|
|
164
181
|
this.layerConfigItems.forEach(configItem => {
|
|
165
182
|
var _this$mapsService2;
|
|
166
183
|
const layer = this.getLayerByConfig(configItem);
|
|
@@ -181,7 +198,7 @@ export default class LayerPopup extends Popup {
|
|
|
181
198
|
layer.off('mouseout', onMouseOut);
|
|
182
199
|
}
|
|
183
200
|
if (onClick) {
|
|
184
|
-
layer.off(
|
|
201
|
+
layer.off(actualTrigger, onClick);
|
|
185
202
|
}
|
|
186
203
|
if (onSourceUpdate) {
|
|
187
204
|
var _layer$getSource2;
|
|
@@ -189,7 +206,7 @@ export default class LayerPopup extends Popup {
|
|
|
189
206
|
}
|
|
190
207
|
const mapContainer = (_this$mapsService2 = this.mapsService) === null || _this$mapsService2 === void 0 ? void 0 : _this$mapsService2.getMapContainer();
|
|
191
208
|
if (mapContainer) {
|
|
192
|
-
mapContainer.removeEventListener(
|
|
209
|
+
mapContainer.removeEventListener(actualTrigger, this.onSceneClick);
|
|
193
210
|
}
|
|
194
211
|
});
|
|
195
212
|
}
|
|
@@ -208,9 +225,7 @@ export default class LayerPopup extends Popup {
|
|
|
208
225
|
this.show();
|
|
209
226
|
}
|
|
210
227
|
}
|
|
211
|
-
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
213
|
-
onLayerMouseOut(layer, e) {
|
|
228
|
+
onLayerMouseOut(layer) {
|
|
214
229
|
this.setDisplayFeatureInfo(undefined);
|
|
215
230
|
if (this.isShow) {
|
|
216
231
|
this.hide();
|
package/es/popup/popup.js
CHANGED
|
@@ -436,7 +436,6 @@ export default class Popup extends EventEmitter {
|
|
|
436
436
|
isOpen() {
|
|
437
437
|
return !!this.mapsService;
|
|
438
438
|
}
|
|
439
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
440
439
|
getDefault(option) {
|
|
441
440
|
// tslint:disable-next-line:no-object-literal-type-assertion
|
|
442
441
|
return {
|
|
@@ -129,7 +129,11 @@ class LayerSwitch extends _selectControl.default {
|
|
|
129
129
|
// 如果是单选模式,则只显示第一个图层
|
|
130
130
|
handleSingleSelection() {
|
|
131
131
|
this.layers.forEach((layer, index) => {
|
|
132
|
-
index === 0
|
|
132
|
+
if (index === 0) {
|
|
133
|
+
layer.show();
|
|
134
|
+
} else {
|
|
135
|
+
layer.hide();
|
|
136
|
+
}
|
|
133
137
|
});
|
|
134
138
|
}
|
|
135
139
|
onAdd() {
|