@antv/l7-component 2.21.0 → 2.21.2
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/assets/iconfont/iconfont.js +6 -6
- package/es/constants/index.js +2 -2
- package/es/control/baseControl/buttonControl.js +109 -144
- package/es/control/baseControl/control.js +212 -258
- package/es/control/baseControl/popperControl.js +67 -95
- package/es/control/baseControl/selectControl.js +132 -178
- package/es/control/exportImage.js +59 -142
- package/es/control/fullscreen.js +69 -100
- package/es/control/geoLocate.js +37 -84
- package/es/control/layerSwitch.js +111 -154
- package/es/control/logo.js +43 -69
- package/es/control/mapTheme.js +57 -98
- package/es/control/mouseLocation.js +37 -69
- package/es/control/scale.js +107 -135
- package/es/control/swipe.js +297 -393
- package/es/control/zoom.js +80 -112
- package/es/css/index.css +10 -7
- package/es/index.js +667 -1
- package/es/marker-layer.js +274 -326
- package/es/marker.d.ts +0 -2
- package/es/marker.js +394 -453
- package/es/popup/layerPopup.js +277 -321
- package/es/popup/popup.js +422 -482
- package/es/utils/anchor.js +6 -6
- package/es/utils/icon.js +4 -4
- package/es/utils/popper.js +180 -196
- package/es/utils/screenfull.js +29 -51
- package/lib/assets/iconfont/iconfont.js +6 -6
- package/lib/constants/index.d.ts +60 -0
- package/lib/constants/index.js +2 -2
- package/lib/control/baseControl/buttonControl.d.ts +60 -0
- package/lib/control/baseControl/buttonControl.js +110 -143
- package/lib/control/baseControl/control.d.ts +112 -0
- package/lib/control/baseControl/control.js +213 -257
- package/lib/control/baseControl/index.d.ts +4 -0
- package/lib/control/baseControl/index.js +5 -5
- package/lib/control/baseControl/popperControl.d.ts +28 -0
- package/lib/control/baseControl/popperControl.js +68 -94
- package/lib/control/baseControl/selectControl.d.ts +53 -0
- package/lib/control/baseControl/selectControl.js +133 -177
- package/lib/control/exportImage.d.ts +19 -0
- package/lib/control/exportImage.js +60 -141
- package/lib/control/fullscreen.d.ts +20 -0
- package/lib/control/fullscreen.js +70 -99
- package/lib/control/geoLocate.d.ts +17 -0
- package/lib/control/geoLocate.js +38 -83
- package/lib/control/layerSwitch.d.ts +27 -0
- package/lib/control/layerSwitch.js +112 -153
- package/lib/control/logo.d.ts +14 -0
- package/lib/control/logo.js +44 -69
- package/lib/control/mapTheme.d.ts +11 -0
- package/lib/control/mapTheme.js +58 -97
- package/lib/control/mouseLocation.d.ts +16 -0
- package/lib/control/mouseLocation.js +38 -68
- package/lib/control/scale.d.ts +35 -0
- package/lib/control/scale.js +108 -134
- package/lib/control/swipe.d.ts +66 -0
- package/lib/control/swipe.js +298 -392
- package/lib/control/zoom.d.ts +39 -0
- package/lib/control/zoom.js +81 -111
- package/lib/css/index.css +10 -7
- package/lib/index.d.ts +19 -0
- package/lib/index.js +683 -17
- package/lib/interface.d.ts +18 -0
- package/lib/marker-layer.d.ts +55 -0
- package/lib/marker-layer.js +276 -324
- package/lib/marker.d.ts +58 -0
- package/lib/marker.js +395 -452
- package/lib/popup/layerPopup.d.ts +99 -0
- package/lib/popup/layerPopup.js +278 -320
- package/lib/popup/popup.d.ts +142 -0
- package/lib/popup/popup.js +423 -481
- package/lib/utils/anchor.d.ts +22 -0
- package/lib/utils/anchor.js +6 -6
- package/lib/utils/icon.d.ts +1 -0
- package/lib/utils/icon.js +6 -5
- package/lib/utils/popper.d.ts +76 -0
- package/lib/utils/popper.js +184 -196
- package/lib/utils/screenfull.d.ts +2 -0
- package/lib/utils/screenfull.js +29 -52
- package/package.json +16 -20
- package/CHANGELOG.md +0 -325
- package/LICENSE.md +0 -21
package/lib/popup/layerPopup.js
CHANGED
|
@@ -6,368 +6,326 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.LayerPopup = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
10
|
var _l7Utils = require("@antv/l7-utils");
|
|
18
11
|
var _popup = _interopRequireDefault(require("./popup"));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
function LayerPopup() {
|
|
26
|
-
var _this;
|
|
27
|
-
(0, _classCallCheck2.default)(this, LayerPopup);
|
|
28
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
|
-
args[_key] = arguments[_key];
|
|
30
|
-
}
|
|
31
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
12
|
+
const {
|
|
13
|
+
get
|
|
14
|
+
} = _l7Utils.lodashUtil;
|
|
15
|
+
class LayerPopup extends _popup.default {
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
super(...args);
|
|
32
18
|
/**
|
|
33
19
|
* 用于统计当前帧当中,layer 被点击的次数
|
|
34
20
|
*/
|
|
35
|
-
(0, _defineProperty2.default)(
|
|
21
|
+
(0, _defineProperty2.default)(this, "layerClickCountByFrame", 0);
|
|
36
22
|
/**
|
|
37
23
|
* 用于保存图层对应的事件回调以及配置信息
|
|
38
24
|
* @protected
|
|
39
25
|
*/
|
|
40
|
-
(0, _defineProperty2.default)(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
(0, _defineProperty2.default)(this, "layerConfigMap", new WeakMap());
|
|
27
|
+
/**
|
|
28
|
+
* 当期正在展示的图层以及对应元素 id 的信息
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
31
|
+
(0, _defineProperty2.default)(this, "displayFeatureInfo", void 0);
|
|
32
|
+
(0, _defineProperty2.default)(this, "onLayerClick", (layer, e) => {
|
|
33
|
+
requestAnimationFrame(() => {
|
|
34
|
+
if (this.popupOption.closeOnClick) {
|
|
35
|
+
this.layerClickCountByFrame++;
|
|
45
36
|
}
|
|
46
|
-
if (
|
|
47
|
-
|
|
37
|
+
if (this.isShow && this.isSameFeature(layer, e.featureId)) {
|
|
38
|
+
this.hide();
|
|
48
39
|
} else {
|
|
49
|
-
|
|
50
|
-
title
|
|
51
|
-
content
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
const {
|
|
41
|
+
title,
|
|
42
|
+
content
|
|
43
|
+
} = this.getLayerInfoFrag(layer, e);
|
|
44
|
+
this.setDOMContent(content);
|
|
45
|
+
this.setLnglat(e.lngLat);
|
|
46
|
+
this.setTitle(title);
|
|
47
|
+
this.setDisplayFeatureInfo({
|
|
48
|
+
layer,
|
|
57
49
|
featureId: e.featureId
|
|
58
50
|
});
|
|
59
|
-
|
|
51
|
+
this.show();
|
|
60
52
|
}
|
|
61
53
|
});
|
|
62
54
|
});
|
|
63
|
-
(0, _defineProperty2.default)(
|
|
64
|
-
|
|
65
|
-
requestAnimationFrame(
|
|
66
|
-
if (!
|
|
67
|
-
|
|
55
|
+
(0, _defineProperty2.default)(this, "onSceneClick", () => {
|
|
56
|
+
this.layerClickCountByFrame = 0;
|
|
57
|
+
requestAnimationFrame(() => {
|
|
58
|
+
if (!this.layerClickCountByFrame) {
|
|
59
|
+
this.hide();
|
|
68
60
|
}
|
|
69
61
|
});
|
|
70
62
|
});
|
|
71
|
-
(0, _defineProperty2.default)(
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
(0, _defineProperty2.default)(this, "onLayerHide", () => {
|
|
64
|
+
this.hide();
|
|
65
|
+
this.setDisplayFeatureInfo(undefined);
|
|
74
66
|
});
|
|
75
67
|
/**
|
|
76
68
|
* 覆盖 Popup 中的默认的 closeOnClick 行为
|
|
77
69
|
*/
|
|
78
70
|
// tslint:disable-next-line:no-empty
|
|
79
|
-
(0, _defineProperty2.default)(
|
|
80
|
-
return _this;
|
|
71
|
+
(0, _defineProperty2.default)(this, "updateCloseOnClick", () => {});
|
|
81
72
|
}
|
|
82
|
-
(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
73
|
+
get layerConfigItems() {
|
|
74
|
+
var _ref;
|
|
75
|
+
const {
|
|
76
|
+
config,
|
|
77
|
+
items
|
|
78
|
+
} = this.popupOption;
|
|
79
|
+
return (_ref = config !== null && config !== void 0 ? config : items) !== null && _ref !== void 0 ? _ref : [];
|
|
80
|
+
}
|
|
81
|
+
addTo(scene) {
|
|
82
|
+
super.addTo(scene);
|
|
83
|
+
this.bindLayerEvent();
|
|
84
|
+
this.hide();
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
remove() {
|
|
88
|
+
super.remove();
|
|
89
|
+
this.unbindLayerEvent();
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
setOptions(option) {
|
|
93
|
+
this.unbindLayerEvent();
|
|
94
|
+
const newOption = (0, _objectSpread2.default)({}, option);
|
|
95
|
+
const trigger = newOption.trigger || this.popupOption.trigger;
|
|
96
|
+
const items = newOption.items || this.popupOption.items;
|
|
97
|
+
const isEmptyItems = (items === null || items === void 0 ? void 0 : items.length) === 0;
|
|
98
|
+
newOption.followCursor = trigger === 'hover' && !isEmptyItems;
|
|
99
|
+
const isShow = this.isShow;
|
|
100
|
+
super.setOptions(newOption);
|
|
101
|
+
this.bindLayerEvent();
|
|
102
|
+
if (isEmptyItems || !isShow) {
|
|
102
103
|
this.hide();
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "remove",
|
|
107
|
-
value: function remove() {
|
|
108
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "remove", this).call(this);
|
|
109
|
-
this.unbindLayerEvent();
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "setOptions",
|
|
114
|
-
value: function setOptions(option) {
|
|
115
|
-
this.unbindLayerEvent();
|
|
116
|
-
var newOption = (0, _objectSpread2.default)({}, option);
|
|
117
|
-
var trigger = newOption.trigger || this.popupOption.trigger;
|
|
118
|
-
var items = newOption.items || this.popupOption.items;
|
|
119
|
-
var isEmptyItems = (items === null || items === void 0 ? void 0 : items.length) === 0;
|
|
120
|
-
newOption.followCursor = trigger === 'hover' && !isEmptyItems;
|
|
121
|
-
var isShow = this.isShow;
|
|
122
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "setOptions", this).call(this, newOption);
|
|
123
|
-
this.bindLayerEvent();
|
|
124
|
-
if (isEmptyItems || !isShow) {
|
|
125
|
-
this.hide();
|
|
126
|
-
}
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "getDefault",
|
|
131
|
-
value: function getDefault(option) {
|
|
132
|
-
var isHoverTrigger = option.trigger === 'hover';
|
|
133
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "getDefault", this).call(this, option)), {}, {
|
|
134
|
-
trigger: 'hover',
|
|
135
|
-
followCursor: isHoverTrigger,
|
|
136
|
-
lngLat: {
|
|
137
|
-
lng: 0,
|
|
138
|
-
lat: 0
|
|
139
|
-
},
|
|
140
|
-
offsets: [0, 10],
|
|
141
|
-
closeButton: false,
|
|
142
|
-
closeOnClick: true,
|
|
143
|
-
autoClose: false,
|
|
144
|
-
closeOnEsc: false
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* 绑定对应的图层事件
|
|
150
|
-
* @protected
|
|
151
|
-
*/
|
|
152
|
-
}, {
|
|
153
|
-
key: "bindLayerEvent",
|
|
154
|
-
value: function bindLayerEvent() {
|
|
155
|
-
var _this2 = this;
|
|
156
|
-
var _this$popupOption2 = this.popupOption,
|
|
157
|
-
trigger = _this$popupOption2.trigger,
|
|
158
|
-
closeOnClick = _this$popupOption2.closeOnClick;
|
|
159
|
-
this.layerConfigItems.forEach(function (configItem) {
|
|
160
|
-
var _layer$getSource;
|
|
161
|
-
var layer = _this2.getLayerByConfig(configItem);
|
|
162
|
-
if (!layer) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
var layerInfo = (0, _objectSpread2.default)({}, configItem);
|
|
166
|
-
if (trigger === 'hover') {
|
|
167
|
-
var onMouseMove = _this2.onLayerMouseMove.bind(_this2, layer);
|
|
168
|
-
var onMouseOut = _this2.onLayerMouseOut.bind(_this2, layer);
|
|
169
|
-
layerInfo.onMouseMove = onMouseMove;
|
|
170
|
-
layerInfo.onMouseOut = onMouseOut;
|
|
171
|
-
layer === null || layer === void 0 || layer.on('mousemove', onMouseMove);
|
|
172
|
-
layer === null || layer === void 0 || layer.on('mouseout', onMouseOut);
|
|
173
|
-
} else {
|
|
174
|
-
var _this2$mapsService;
|
|
175
|
-
var onLayerClick = _this2.onLayerClick.bind(_this2, layer);
|
|
176
|
-
layerInfo.onClick = onLayerClick;
|
|
177
|
-
layer === null || layer === void 0 || layer.on('click', onLayerClick);
|
|
178
|
-
var mapContainer = (_this2$mapsService = _this2.mapsService) === null || _this2$mapsService === void 0 ? void 0 : _this2$mapsService.getMapContainer();
|
|
179
|
-
if (mapContainer && closeOnClick) {
|
|
180
|
-
mapContainer.addEventListener('click', _this2.onSceneClick);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
var source = layer === null || layer === void 0 || (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
|
|
184
|
-
var onSourceUpdate = _this2.onSourceUpdate.bind(_this2);
|
|
185
|
-
source === null || source === void 0 || source.on('update', onSourceUpdate);
|
|
186
|
-
layerInfo.onSourceUpdate = onSourceUpdate;
|
|
187
|
-
_this2.layerConfigMap.set(layer, layerInfo);
|
|
188
|
-
});
|
|
189
104
|
}
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
getDefault(option) {
|
|
108
|
+
const isHoverTrigger = option.trigger === 'hover';
|
|
109
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, super.getDefault(option)), {}, {
|
|
110
|
+
trigger: 'hover',
|
|
111
|
+
followCursor: isHoverTrigger,
|
|
112
|
+
lngLat: {
|
|
113
|
+
lng: 0,
|
|
114
|
+
lat: 0
|
|
115
|
+
},
|
|
116
|
+
offsets: [0, 10],
|
|
117
|
+
closeButton: false,
|
|
118
|
+
closeOnClick: true,
|
|
119
|
+
autoClose: false,
|
|
120
|
+
closeOnEsc: false
|
|
121
|
+
});
|
|
122
|
+
}
|
|
190
123
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
var mapContainer = (_this3$mapsService = _this3.mapsService) === null || _this3$mapsService === void 0 ? void 0 : _this3$mapsService.getMapContainer();
|
|
224
|
-
if (mapContainer) {
|
|
225
|
-
mapContainer.removeEventListener('click', _this3.onSceneClick);
|
|
124
|
+
/**
|
|
125
|
+
* 绑定对应的图层事件
|
|
126
|
+
* @protected
|
|
127
|
+
*/
|
|
128
|
+
bindLayerEvent() {
|
|
129
|
+
const {
|
|
130
|
+
trigger,
|
|
131
|
+
closeOnClick
|
|
132
|
+
} = this.popupOption;
|
|
133
|
+
this.layerConfigItems.forEach(configItem => {
|
|
134
|
+
var _layer$getSource;
|
|
135
|
+
const layer = this.getLayerByConfig(configItem);
|
|
136
|
+
if (!layer) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const layerInfo = (0, _objectSpread2.default)({}, configItem);
|
|
140
|
+
if (trigger === 'hover') {
|
|
141
|
+
const onMouseMove = this.onLayerMouseMove.bind(this, layer);
|
|
142
|
+
const onMouseOut = this.onLayerMouseOut.bind(this, layer);
|
|
143
|
+
layerInfo.onMouseMove = onMouseMove;
|
|
144
|
+
layerInfo.onMouseOut = onMouseOut;
|
|
145
|
+
layer === null || layer === void 0 || layer.on('mousemove', onMouseMove);
|
|
146
|
+
layer === null || layer === void 0 || layer.on('mouseout', onMouseOut);
|
|
147
|
+
} else {
|
|
148
|
+
var _this$mapsService;
|
|
149
|
+
const onLayerClick = this.onLayerClick.bind(this, layer);
|
|
150
|
+
layerInfo.onClick = onLayerClick;
|
|
151
|
+
layer === null || layer === void 0 || layer.on('click', onLayerClick);
|
|
152
|
+
const mapContainer = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getMapContainer();
|
|
153
|
+
if (mapContainer && closeOnClick) {
|
|
154
|
+
mapContainer.addEventListener('click', this.onSceneClick);
|
|
226
155
|
}
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}, {
|
|
230
|
-
key: "onLayerMouseMove",
|
|
231
|
-
value: function onLayerMouseMove(layer, e) {
|
|
232
|
-
if (!this.isSameFeature(layer, e.featureId)) {
|
|
233
|
-
var _this$getLayerInfoFra2 = this.getLayerInfoFrag(layer, e),
|
|
234
|
-
title = _this$getLayerInfoFra2.title,
|
|
235
|
-
content = _this$getLayerInfoFra2.content;
|
|
236
|
-
this.setDOMContent(content);
|
|
237
|
-
this.setTitle(title);
|
|
238
|
-
this.setDisplayFeatureInfo({
|
|
239
|
-
layer: layer,
|
|
240
|
-
featureId: e.featureId
|
|
241
|
-
});
|
|
242
|
-
this.show();
|
|
243
156
|
}
|
|
244
|
-
|
|
157
|
+
const source = layer === null || layer === void 0 || (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
|
|
158
|
+
const onSourceUpdate = this.onSourceUpdate.bind(this);
|
|
159
|
+
source === null || source === void 0 || source.on('update', onSourceUpdate);
|
|
160
|
+
layerInfo.onSourceUpdate = onSourceUpdate;
|
|
161
|
+
this.layerConfigMap.set(layer, layerInfo);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
245
164
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
165
|
+
/**
|
|
166
|
+
* 解绑对应的图层事件
|
|
167
|
+
* @protected
|
|
168
|
+
*/
|
|
169
|
+
unbindLayerEvent() {
|
|
170
|
+
this.layerConfigItems.forEach(configItem => {
|
|
171
|
+
var _this$mapsService2;
|
|
172
|
+
const layer = this.getLayerByConfig(configItem);
|
|
173
|
+
const layerInfo = layer && this.layerConfigMap.get(layer);
|
|
174
|
+
if (!layerInfo) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const {
|
|
178
|
+
onMouseMove,
|
|
179
|
+
onMouseOut,
|
|
180
|
+
onClick,
|
|
181
|
+
onSourceUpdate
|
|
182
|
+
} = layerInfo;
|
|
183
|
+
if (onMouseMove) {
|
|
184
|
+
layer.off('mousemove', onMouseMove);
|
|
253
185
|
}
|
|
186
|
+
if (onMouseOut) {
|
|
187
|
+
layer.off('mouseout', onMouseOut);
|
|
188
|
+
}
|
|
189
|
+
if (onClick) {
|
|
190
|
+
layer.off('click', onClick);
|
|
191
|
+
}
|
|
192
|
+
if (onSourceUpdate) {
|
|
193
|
+
var _layer$getSource2;
|
|
194
|
+
layer === null || layer === void 0 || (_layer$getSource2 = layer.getSource()) === null || _layer$getSource2 === void 0 || _layer$getSource2.off('update', onSourceUpdate);
|
|
195
|
+
}
|
|
196
|
+
const mapContainer = (_this$mapsService2 = this.mapsService) === null || _this$mapsService2 === void 0 ? void 0 : _this$mapsService2.getMapContainer();
|
|
197
|
+
if (mapContainer) {
|
|
198
|
+
mapContainer.removeEventListener('click', this.onSceneClick);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
onLayerMouseMove(layer, e) {
|
|
203
|
+
if (!this.isSameFeature(layer, e.featureId)) {
|
|
204
|
+
const {
|
|
205
|
+
title,
|
|
206
|
+
content
|
|
207
|
+
} = this.getLayerInfoFrag(layer, e);
|
|
208
|
+
this.setDOMContent(content);
|
|
209
|
+
this.setTitle(title);
|
|
210
|
+
this.setDisplayFeatureInfo({
|
|
211
|
+
layer,
|
|
212
|
+
featureId: e.featureId
|
|
213
|
+
});
|
|
214
|
+
this.show();
|
|
254
215
|
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
219
|
+
onLayerMouseOut(layer, e) {
|
|
220
|
+
this.setDisplayFeatureInfo(undefined);
|
|
221
|
+
if (this.isShow) {
|
|
258
222
|
this.hide();
|
|
259
|
-
this.setDisplayFeatureInfo(undefined);
|
|
260
223
|
}
|
|
224
|
+
}
|
|
225
|
+
onSourceUpdate() {
|
|
226
|
+
this.hide();
|
|
227
|
+
this.setDisplayFeatureInfo(undefined);
|
|
228
|
+
}
|
|
261
229
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
230
|
+
/**
|
|
231
|
+
* 通过当前图层和对应选中的元素获取气泡展示的 HTML 内容
|
|
232
|
+
* @param layer
|
|
233
|
+
* @param e
|
|
234
|
+
* @protected
|
|
235
|
+
*/
|
|
236
|
+
getLayerInfoFrag(layer, e) {
|
|
237
|
+
const layerInfo = this.layerConfigMap.get(layer);
|
|
238
|
+
let titleFrag;
|
|
239
|
+
const contentFrag = document.createDocumentFragment();
|
|
240
|
+
if (layerInfo) {
|
|
241
|
+
let feature = e.feature;
|
|
242
|
+
if (feature.type === 'Feature' && 'properties' in feature && 'geometry' in feature) {
|
|
243
|
+
feature = feature.properties;
|
|
244
|
+
}
|
|
245
|
+
const {
|
|
246
|
+
title,
|
|
247
|
+
fields,
|
|
248
|
+
customContent
|
|
249
|
+
} = layerInfo;
|
|
250
|
+
if (title) {
|
|
251
|
+
titleFrag = document.createDocumentFragment();
|
|
252
|
+
const titleElement = title instanceof Function ? title(feature) : title;
|
|
253
|
+
_l7Utils.DOM.appendElementType(titleFrag, titleElement);
|
|
254
|
+
}
|
|
255
|
+
if (customContent) {
|
|
256
|
+
const content = customContent instanceof Function ? customContent(feature) : customContent;
|
|
257
|
+
_l7Utils.DOM.appendElementType(contentFrag, content);
|
|
258
|
+
} else if (fields !== null && fields !== void 0 && fields.length) {
|
|
259
|
+
fields === null || fields === void 0 || fields.forEach(fieldConfig => {
|
|
260
|
+
var _ref2, _ref3;
|
|
261
|
+
const {
|
|
262
|
+
field,
|
|
263
|
+
formatField,
|
|
264
|
+
formatValue,
|
|
265
|
+
getValue
|
|
266
|
+
} = typeof fieldConfig === 'string' ?
|
|
267
|
+
// tslint:disable-next-line:no-object-literal-type-assertion
|
|
268
|
+
{
|
|
269
|
+
field: fieldConfig
|
|
270
|
+
} : fieldConfig;
|
|
271
|
+
const row = _l7Utils.DOM.create('div', 'l7-layer-popup__row');
|
|
272
|
+
const value = getValue ? getValue(e.feature) : get(feature, field);
|
|
273
|
+
const fieldElement = (_ref2 = formatField instanceof Function ? formatField(field, feature) : formatField) !== null && _ref2 !== void 0 ? _ref2 : field;
|
|
274
|
+
let valueElement = (_ref3 = formatValue instanceof Function ? formatValue(value, feature) : formatValue) !== null && _ref3 !== void 0 ? _ref3 : value;
|
|
275
|
+
const fieldSpan = _l7Utils.DOM.create('span', 'l7-layer-popup__key', row);
|
|
276
|
+
_l7Utils.DOM.appendElementType(fieldSpan, fieldElement);
|
|
277
|
+
_l7Utils.DOM.appendElementType(fieldSpan, document.createTextNode(':'));
|
|
278
|
+
const valueSpan = _l7Utils.DOM.create('span', 'l7-layer-popup__value', row);
|
|
310
279
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
_l7Utils.DOM.appendElementType(valueSpan, valueElement);
|
|
320
|
-
contentFrag.appendChild(row);
|
|
321
|
-
});
|
|
322
|
-
}
|
|
280
|
+
// 当 value 中每项元素均为基础数据类型时,用逗号隔开
|
|
281
|
+
if (Array.isArray(valueElement) && valueElement.every(item => !(item instanceof Object))) {
|
|
282
|
+
valueElement = valueElement.map(item => String(item)).join(',');
|
|
283
|
+
}
|
|
284
|
+
_l7Utils.DOM.appendElementType(valueSpan, valueElement);
|
|
285
|
+
contentFrag.appendChild(row);
|
|
286
|
+
});
|
|
323
287
|
}
|
|
324
|
-
return {
|
|
325
|
-
title: titleFrag,
|
|
326
|
-
content: contentFrag
|
|
327
|
-
};
|
|
328
288
|
}
|
|
289
|
+
return {
|
|
290
|
+
title: titleFrag,
|
|
291
|
+
content: contentFrag
|
|
292
|
+
};
|
|
293
|
+
}
|
|
329
294
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (typeof layer === 'string') {
|
|
343
|
-
return this.layerService.getLayer(layer) || this.layerService.getLayerByName(layer);
|
|
344
|
-
}
|
|
295
|
+
/**
|
|
296
|
+
* 通过 Layer 配置访问到真实的 Layer 实例
|
|
297
|
+
* @param configItem
|
|
298
|
+
* @protected
|
|
299
|
+
*/
|
|
300
|
+
getLayerByConfig(configItem) {
|
|
301
|
+
const layer = configItem.layer;
|
|
302
|
+
if (layer instanceof Object) {
|
|
303
|
+
return layer;
|
|
304
|
+
}
|
|
305
|
+
if (typeof layer === 'string') {
|
|
306
|
+
return this.layerService.getLayer(layer) || this.layerService.getLayerByName(layer);
|
|
345
307
|
}
|
|
308
|
+
}
|
|
346
309
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
310
|
+
/**
|
|
311
|
+
* 判断当前展示的 Feature 是否和上一次查看的一致
|
|
312
|
+
* @param layer
|
|
313
|
+
* @param featureId
|
|
314
|
+
* @protected
|
|
315
|
+
*/
|
|
316
|
+
isSameFeature(layer, featureId) {
|
|
317
|
+
const displayFeatureInfo = this.displayFeatureInfo;
|
|
318
|
+
return displayFeatureInfo && layer === displayFeatureInfo.layer && featureId === displayFeatureInfo.featureId;
|
|
319
|
+
}
|
|
320
|
+
setDisplayFeatureInfo(displayFeatureInfo) {
|
|
321
|
+
const oldDisplayFeatureInfo = this.displayFeatureInfo;
|
|
322
|
+
if (oldDisplayFeatureInfo) {
|
|
323
|
+
oldDisplayFeatureInfo.layer.off('hide', this.onLayerHide);
|
|
358
324
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
value: function setDisplayFeatureInfo(displayFeatureInfo) {
|
|
362
|
-
var oldDisplayFeatureInfo = this.displayFeatureInfo;
|
|
363
|
-
if (oldDisplayFeatureInfo) {
|
|
364
|
-
oldDisplayFeatureInfo.layer.off('hide', this.onLayerHide);
|
|
365
|
-
}
|
|
366
|
-
if (displayFeatureInfo) {
|
|
367
|
-
displayFeatureInfo.layer.on('hide', this.onLayerHide);
|
|
368
|
-
}
|
|
369
|
-
this.displayFeatureInfo = displayFeatureInfo;
|
|
325
|
+
if (displayFeatureInfo) {
|
|
326
|
+
displayFeatureInfo.layer.on('hide', this.onLayerHide);
|
|
370
327
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
328
|
+
this.displayFeatureInfo = displayFeatureInfo;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
exports.default = exports.LayerPopup = LayerPopup;
|