@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
|
@@ -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/lib/popup/layerPopup.js
CHANGED
|
@@ -78,6 +78,21 @@ class LayerPopup extends _popup.default {
|
|
|
78
78
|
} = this.popupOption;
|
|
79
79
|
return (_ref = config !== null && config !== void 0 ? config : items) !== null && _ref !== void 0 ? _ref : [];
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 根据环境获取实际的触发事件
|
|
84
|
+
* 当 trigger 为 'click' 时,移动端使用 'touchend',PC 端使用 'click'
|
|
85
|
+
* @protected
|
|
86
|
+
*/
|
|
87
|
+
getActualTriggerEvent() {
|
|
88
|
+
const {
|
|
89
|
+
trigger
|
|
90
|
+
} = this.popupOption;
|
|
91
|
+
if (trigger === 'click') {
|
|
92
|
+
return (0, _l7Utils.isPC)() ? 'click' : 'touchend';
|
|
93
|
+
}
|
|
94
|
+
return trigger;
|
|
95
|
+
}
|
|
81
96
|
addTo(scene) {
|
|
82
97
|
super.addTo(scene);
|
|
83
98
|
this.bindLayerEvent();
|
|
@@ -105,7 +120,7 @@ class LayerPopup extends _popup.default {
|
|
|
105
120
|
return this;
|
|
106
121
|
}
|
|
107
122
|
getDefault(option) {
|
|
108
|
-
const isHoverTrigger = option.trigger
|
|
123
|
+
const isHoverTrigger = option.trigger === 'hover';
|
|
109
124
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, super.getDefault(option)), {}, {
|
|
110
125
|
trigger: 'hover',
|
|
111
126
|
followCursor: isHoverTrigger,
|
|
@@ -130,6 +145,7 @@ class LayerPopup extends _popup.default {
|
|
|
130
145
|
trigger,
|
|
131
146
|
closeOnClick
|
|
132
147
|
} = this.popupOption;
|
|
148
|
+
const actualTrigger = this.getActualTriggerEvent();
|
|
133
149
|
this.layerConfigItems.forEach(configItem => {
|
|
134
150
|
var _layer$getSource;
|
|
135
151
|
const layer = this.getLayerByConfig(configItem);
|
|
@@ -148,10 +164,10 @@ class LayerPopup extends _popup.default {
|
|
|
148
164
|
var _this$mapsService;
|
|
149
165
|
const onLayerClick = this.onLayerClick.bind(this, layer);
|
|
150
166
|
layerInfo.onClick = onLayerClick;
|
|
151
|
-
layer === null || layer === void 0 || layer.on(
|
|
167
|
+
layer === null || layer === void 0 || layer.on(actualTrigger, onLayerClick);
|
|
152
168
|
const mapContainer = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getMapContainer();
|
|
153
169
|
if (mapContainer && closeOnClick) {
|
|
154
|
-
mapContainer.addEventListener(
|
|
170
|
+
mapContainer.addEventListener(actualTrigger, this.onSceneClick);
|
|
155
171
|
}
|
|
156
172
|
}
|
|
157
173
|
const source = layer === null || layer === void 0 || (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
|
|
@@ -167,6 +183,7 @@ class LayerPopup extends _popup.default {
|
|
|
167
183
|
* @protected
|
|
168
184
|
*/
|
|
169
185
|
unbindLayerEvent() {
|
|
186
|
+
const actualTrigger = this.getActualTriggerEvent();
|
|
170
187
|
this.layerConfigItems.forEach(configItem => {
|
|
171
188
|
var _this$mapsService2;
|
|
172
189
|
const layer = this.getLayerByConfig(configItem);
|
|
@@ -187,7 +204,7 @@ class LayerPopup extends _popup.default {
|
|
|
187
204
|
layer.off('mouseout', onMouseOut);
|
|
188
205
|
}
|
|
189
206
|
if (onClick) {
|
|
190
|
-
layer.off(
|
|
207
|
+
layer.off(actualTrigger, onClick);
|
|
191
208
|
}
|
|
192
209
|
if (onSourceUpdate) {
|
|
193
210
|
var _layer$getSource2;
|
|
@@ -195,7 +212,7 @@ class LayerPopup extends _popup.default {
|
|
|
195
212
|
}
|
|
196
213
|
const mapContainer = (_this$mapsService2 = this.mapsService) === null || _this$mapsService2 === void 0 ? void 0 : _this$mapsService2.getMapContainer();
|
|
197
214
|
if (mapContainer) {
|
|
198
|
-
mapContainer.removeEventListener(
|
|
215
|
+
mapContainer.removeEventListener(actualTrigger, this.onSceneClick);
|
|
199
216
|
}
|
|
200
217
|
});
|
|
201
218
|
}
|
|
@@ -214,9 +231,7 @@ class LayerPopup extends _popup.default {
|
|
|
214
231
|
this.show();
|
|
215
232
|
}
|
|
216
233
|
}
|
|
217
|
-
|
|
218
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
219
|
-
onLayerMouseOut(layer, e) {
|
|
234
|
+
onLayerMouseOut(layer) {
|
|
220
235
|
this.setDisplayFeatureInfo(undefined);
|
|
221
236
|
if (this.isShow) {
|
|
222
237
|
this.hide();
|
package/lib/popup/popup.js
CHANGED
|
@@ -442,7 +442,6 @@ class Popup extends _eventemitter.EventEmitter {
|
|
|
442
442
|
isOpen() {
|
|
443
443
|
return !!this.mapsService;
|
|
444
444
|
}
|
|
445
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
446
445
|
getDefault(option) {
|
|
447
446
|
// tslint:disable-next-line:no-object-literal-type-assertion
|
|
448
447
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-component",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.1",
|
|
4
4
|
"description": "Component for L7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "https://github.com/orgs/antvis/people",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"@babel/runtime": "^7.7.7",
|
|
17
17
|
"eventemitter3": "^4.0.0",
|
|
18
18
|
"supercluster": "^7.0.0",
|
|
19
|
-
"@antv/l7-core": "2.23.
|
|
20
|
-
"@antv/l7-layers": "2.23.
|
|
21
|
-
"@antv/l7-utils": "2.23.
|
|
19
|
+
"@antv/l7-core": "2.23.1",
|
|
20
|
+
"@antv/l7-layers": "2.23.1",
|
|
21
|
+
"@antv/l7-utils": "2.23.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"less": "^4.1.3",
|
|
25
|
-
"@antv/l7-test-utils": "^2.23.
|
|
25
|
+
"@antv/l7-test-utils": "^2.23.1"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public",
|