@antv/l7-component 2.9.37-alpha.2 → 2.9.37-alpha.3
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 +53 -0
- package/es/constants/index.d.ts +60 -0
- package/es/constants/index.js +60 -0
- package/es/control/baseControl/buttonControl.d.ts +59 -0
- package/es/control/baseControl/buttonControl.js +191 -0
- package/es/control/baseControl/control.d.ts +113 -0
- package/es/control/baseControl/control.js +313 -0
- package/es/control/baseControl/index.d.ts +4 -0
- package/es/control/baseControl/index.js +4 -0
- package/es/control/baseControl/popperControl.d.ts +26 -0
- package/es/control/baseControl/popperControl.js +131 -0
- package/es/control/baseControl/selectControl.d.ts +46 -0
- package/es/control/baseControl/selectControl.js +232 -0
- package/es/control/exportImage.d.ts +18 -0
- package/es/control/exportImage.js +163 -0
- package/es/control/fullscreen.d.ts +19 -0
- package/es/control/fullscreen.js +151 -0
- package/es/control/geoLocate.d.ts +16 -0
- package/es/control/geoLocate.js +139 -0
- package/es/control/layerSwitch.d.ts +21 -0
- package/es/control/layerSwitch.js +193 -0
- package/es/control/logo.d.ts +13 -0
- package/es/control/logo.js +87 -0
- package/es/control/mapTheme.d.ts +10 -0
- package/es/control/mapTheme.js +135 -0
- package/es/control/mouseLocation.d.ts +15 -0
- package/es/control/mouseLocation.js +104 -0
- package/es/control/scale.d.ts +34 -0
- package/es/control/scale.js +172 -0
- package/es/control/zoom.d.ts +35 -0
- package/es/control/zoom.js +146 -0
- package/es/css/button.less +70 -0
- package/es/css/control.less +71 -0
- package/es/css/index.css +567 -0
- package/es/css/index.less +12 -0
- package/es/css/l7.less +60 -0
- package/es/css/layerPopup.less +8 -0
- package/es/css/logo.less +18 -0
- package/es/css/mouseLocation.less +9 -0
- package/es/css/popper.less +64 -0
- package/es/css/popup.less +169 -0
- package/es/css/scale.less +34 -0
- package/es/css/select.less +86 -0
- package/es/css/variables.less +28 -0
- package/es/css/zoom.less +21 -0
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +1 -0
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +12 -0
- package/es/index.d.ts +18 -0
- package/es/index.js +59 -0
- package/es/interface.d.ts +18 -0
- package/es/interface.js +1 -0
- package/es/marker-layer.d.ts +53 -0
- package/es/marker-layer.js +363 -0
- package/es/marker.d.ts +49 -0
- package/es/marker.js +434 -0
- package/es/popup/layerPopup.d.ts +78 -0
- package/es/popup/layerPopup.js +308 -0
- package/es/popup/popup.d.ts +147 -0
- package/es/popup/popup.js +636 -0
- package/es/utils/anchor.d.ts +22 -0
- package/es/utils/anchor.js +35 -0
- package/es/utils/icon.d.ts +1 -0
- package/es/utils/icon.js +9 -0
- package/es/utils/popper.d.ts +75 -0
- package/es/utils/popper.js +286 -0
- package/es/utils/screenfull.d.ts +2 -0
- package/es/utils/screenfull.js +157 -0
- package/lib/assets/iconfont/iconfont.js +55 -0
- package/lib/constants/index.js +68 -0
- package/lib/control/baseControl/buttonControl.js +207 -0
- package/lib/control/baseControl/control.js +340 -0
- package/lib/control/baseControl/index.js +57 -0
- package/lib/control/baseControl/popperControl.js +142 -0
- package/lib/control/baseControl/selectControl.js +253 -0
- package/lib/control/exportImage.js +177 -0
- package/lib/control/fullscreen.js +164 -0
- package/lib/control/geoLocate.js +154 -0
- package/lib/control/layerSwitch.js +203 -0
- package/lib/control/logo.js +105 -0
- package/lib/control/mapTheme.js +151 -0
- package/lib/control/mouseLocation.js +120 -0
- package/lib/control/scale.js +189 -0
- package/lib/control/zoom.js +162 -0
- package/lib/css/button.less +70 -0
- package/lib/css/control.less +71 -0
- package/lib/css/index.css +567 -0
- package/lib/css/index.less +12 -0
- package/lib/css/l7.less +60 -0
- package/lib/css/layerPopup.less +8 -0
- package/lib/css/logo.less +18 -0
- package/lib/css/mouseLocation.less +9 -0
- package/lib/css/popper.less +64 -0
- package/lib/css/popup.less +169 -0
- package/lib/css/scale.less +34 -0
- package/lib/css/select.less +86 -0
- package/lib/css/variables.less +28 -0
- package/lib/css/zoom.less +21 -0
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +1 -0
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +12 -0
- package/lib/index.js +254 -0
- package/lib/interface.js +5 -0
- package/lib/marker-layer.js +381 -0
- package/lib/marker.js +449 -0
- package/lib/popup/layerPopup.js +317 -0
- package/lib/popup/popup.js +651 -0
- package/lib/utils/anchor.js +45 -0
- package/lib/utils/icon.js +18 -0
- package/lib/utils/popper.js +297 -0
- package/lib/utils/screenfull.js +167 -0
- package/package.json +5 -5
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.LayerPopup = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
30
|
+
var _lodash = require("lodash");
|
|
31
|
+
|
|
32
|
+
var _popup = _interopRequireDefault(require("./popup"));
|
|
33
|
+
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
35
|
+
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
+
|
|
38
|
+
var LayerPopup = /*#__PURE__*/function (_Popup) {
|
|
39
|
+
(0, _inherits2.default)(LayerPopup, _Popup);
|
|
40
|
+
|
|
41
|
+
var _super = _createSuper(LayerPopup);
|
|
42
|
+
|
|
43
|
+
function LayerPopup() {
|
|
44
|
+
var _this;
|
|
45
|
+
|
|
46
|
+
(0, _classCallCheck2.default)(this, LayerPopup);
|
|
47
|
+
|
|
48
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49
|
+
args[_key] = arguments[_key];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
53
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "layerConfigMap", new WeakMap());
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
(0, _createClass2.default)(LayerPopup, [{
|
|
58
|
+
key: "addTo",
|
|
59
|
+
value: function addTo(scene) {
|
|
60
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "addTo", this).call(this, scene);
|
|
61
|
+
this.bindLayerEvent();
|
|
62
|
+
this.hide();
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "remove",
|
|
67
|
+
value: function remove() {
|
|
68
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "remove", this).call(this);
|
|
69
|
+
this.unbindLayerEvent();
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "setOptions",
|
|
74
|
+
value: function setOptions(option) {
|
|
75
|
+
this.unbindLayerEvent();
|
|
76
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "setOptions", this).call(this, option);
|
|
77
|
+
this.bindLayerEvent();
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getDefault",
|
|
82
|
+
value: function getDefault(option) {
|
|
83
|
+
var isClickTrigger = option.trigger === 'click';
|
|
84
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(LayerPopup.prototype), "getDefault", this).call(this, option)), {}, {
|
|
85
|
+
trigger: 'hover',
|
|
86
|
+
followCursor: !isClickTrigger,
|
|
87
|
+
lngLat: {
|
|
88
|
+
lng: 0,
|
|
89
|
+
lat: 0
|
|
90
|
+
},
|
|
91
|
+
offsets: [0, 10],
|
|
92
|
+
closeButton: false,
|
|
93
|
+
closeOnClick: false,
|
|
94
|
+
autoClose: false,
|
|
95
|
+
closeOnEsc: false
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 绑定对应的图层事件
|
|
100
|
+
* @protected
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
}, {
|
|
104
|
+
key: "bindLayerEvent",
|
|
105
|
+
value: function bindLayerEvent() {
|
|
106
|
+
var _this2 = this;
|
|
107
|
+
|
|
108
|
+
var _this$popupOption = this.popupOption,
|
|
109
|
+
config = _this$popupOption.config,
|
|
110
|
+
trigger = _this$popupOption.trigger;
|
|
111
|
+
config.forEach(function (configItem) {
|
|
112
|
+
var layer = _this2.getLayerByConfig(configItem);
|
|
113
|
+
|
|
114
|
+
if (!layer) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
var layerInfo = (0, _objectSpread2.default)({}, configItem);
|
|
119
|
+
|
|
120
|
+
if (trigger === 'hover') {
|
|
121
|
+
var onMouseMove = _this2.onLayerMouseMove.bind(_this2, layer);
|
|
122
|
+
|
|
123
|
+
var onMouseOut = _this2.onLayerMouseOut.bind(_this2, layer);
|
|
124
|
+
|
|
125
|
+
layerInfo.onMouseMove = onMouseMove;
|
|
126
|
+
layerInfo.onMouseOut = onMouseOut;
|
|
127
|
+
layer === null || layer === void 0 ? void 0 : layer.on('mousemove', onMouseMove);
|
|
128
|
+
layer === null || layer === void 0 ? void 0 : layer.on('mouseout', onMouseOut);
|
|
129
|
+
} else {
|
|
130
|
+
var onClick = _this2.onLayerClick.bind(_this2, layer);
|
|
131
|
+
|
|
132
|
+
layerInfo.onClick = onClick;
|
|
133
|
+
layer === null || layer === void 0 ? void 0 : layer.on('click', onClick);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var source = layer.getSource();
|
|
137
|
+
|
|
138
|
+
var onSourceUpdate = _this2.onSourceUpdate.bind(_this2, layer);
|
|
139
|
+
|
|
140
|
+
source === null || source === void 0 ? void 0 : source.on('update', onSourceUpdate);
|
|
141
|
+
layerInfo.onSourceUpdate = onSourceUpdate;
|
|
142
|
+
|
|
143
|
+
_this2.layerConfigMap.set(layer, layerInfo);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 解绑对应的图层事件
|
|
148
|
+
* @protected
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
}, {
|
|
152
|
+
key: "unbindLayerEvent",
|
|
153
|
+
value: function unbindLayerEvent() {
|
|
154
|
+
var _this3 = this;
|
|
155
|
+
|
|
156
|
+
var config = this.popupOption.config;
|
|
157
|
+
config.forEach(function (configItem) {
|
|
158
|
+
var layer = _this3.getLayerByConfig(configItem);
|
|
159
|
+
|
|
160
|
+
var layerInfo = layer && _this3.layerConfigMap.get(layer);
|
|
161
|
+
|
|
162
|
+
if (!layerInfo) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var onMouseMove = layerInfo.onMouseMove,
|
|
167
|
+
onMouseOut = layerInfo.onMouseOut,
|
|
168
|
+
onClick = layerInfo.onClick,
|
|
169
|
+
onSourceUpdate = layerInfo.onSourceUpdate;
|
|
170
|
+
|
|
171
|
+
if (onMouseMove) {
|
|
172
|
+
layer.off('mousemove', onMouseMove);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (onMouseOut) {
|
|
176
|
+
layer.off('mouseout', onMouseOut);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (onClick) {
|
|
180
|
+
layer.off('click', onClick);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (onSourceUpdate) {
|
|
184
|
+
var _layer$getSource;
|
|
185
|
+
|
|
186
|
+
layer === null || layer === void 0 ? void 0 : (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.off('update', onSourceUpdate);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "onLayerMouseMove",
|
|
192
|
+
value: function onLayerMouseMove(layer, e) {
|
|
193
|
+
if (!this.isSameFeature(layer, e.featureId)) {
|
|
194
|
+
var frag = this.getLayerInfoFrag(layer, e);
|
|
195
|
+
this.setDOMContent(frag);
|
|
196
|
+
this.displayFeatureInfo = {
|
|
197
|
+
layer: layer,
|
|
198
|
+
featureId: e.featureId
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!this.isShow) {
|
|
203
|
+
this.show();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}, {
|
|
207
|
+
key: "onLayerMouseOut",
|
|
208
|
+
value: function onLayerMouseOut(layer, e) {
|
|
209
|
+
this.displayFeatureInfo = undefined;
|
|
210
|
+
|
|
211
|
+
if (this.isShow) {
|
|
212
|
+
this.hide();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}, {
|
|
216
|
+
key: "onLayerClick",
|
|
217
|
+
value: function onLayerClick(layer, e) {
|
|
218
|
+
if (this.isShow && this.isSameFeature(layer, e.featureId)) {
|
|
219
|
+
this.hide();
|
|
220
|
+
} else {
|
|
221
|
+
var frag = this.getLayerInfoFrag(layer, e);
|
|
222
|
+
this.setDOMContent(frag);
|
|
223
|
+
this.setLnglat(e.lngLat);
|
|
224
|
+
this.show();
|
|
225
|
+
this.displayFeatureInfo = {
|
|
226
|
+
layer: layer,
|
|
227
|
+
featureId: e.featureId
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "onSourceUpdate",
|
|
233
|
+
value: function onSourceUpdate(layer) {
|
|
234
|
+
var _this$displayFeatureI;
|
|
235
|
+
|
|
236
|
+
if (((_this$displayFeatureI = this.displayFeatureInfo) === null || _this$displayFeatureI === void 0 ? void 0 : _this$displayFeatureI.layer) === layer) {
|
|
237
|
+
this.hide();
|
|
238
|
+
this.displayFeatureInfo = undefined;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* 通过当前图层和对应选中的元素获取气泡展示的 HTML 内容
|
|
243
|
+
* @param layer
|
|
244
|
+
* @param e
|
|
245
|
+
* @protected
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
}, {
|
|
249
|
+
key: "getLayerInfoFrag",
|
|
250
|
+
value: function getLayerInfoFrag(layer, e) {
|
|
251
|
+
var layerInfo = this.layerConfigMap.get(layer);
|
|
252
|
+
var frag = document.createDocumentFragment();
|
|
253
|
+
|
|
254
|
+
if (layerInfo) {
|
|
255
|
+
var _feature = e.feature;
|
|
256
|
+
|
|
257
|
+
if (_feature.type === 'Feature' && 'properties' in _feature && 'geometry' in _feature) {
|
|
258
|
+
_feature = _feature.properties;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
var fields = layerInfo.fields;
|
|
262
|
+
fields === null || fields === void 0 ? void 0 : fields.forEach(function (fieldConfig) {
|
|
263
|
+
var _ref = typeof fieldConfig === 'string' ? {
|
|
264
|
+
field: fieldConfig
|
|
265
|
+
} : fieldConfig,
|
|
266
|
+
field = _ref.field,
|
|
267
|
+
formatField = _ref.formatField,
|
|
268
|
+
formatValue = _ref.formatValue,
|
|
269
|
+
getValue = _ref.getValue;
|
|
270
|
+
|
|
271
|
+
var row = _l7Utils.DOM.create('div', 'l7-layer-popup__row');
|
|
272
|
+
|
|
273
|
+
var value = getValue ? getValue(e.feature) : (0, _lodash.get)(_feature, field);
|
|
274
|
+
row.innerHTML = "".concat(formatField ? formatField(field) : field, ": ").concat(formatValue ? formatValue(value) : value);
|
|
275
|
+
frag.appendChild(row);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return frag;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 通过 Layer 配置访问到真实的 Layer 实例
|
|
283
|
+
* @param config
|
|
284
|
+
* @protected
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
}, {
|
|
288
|
+
key: "getLayerByConfig",
|
|
289
|
+
value: function getLayerByConfig(config) {
|
|
290
|
+
var layer = config.layer;
|
|
291
|
+
|
|
292
|
+
if (layer instanceof Object) {
|
|
293
|
+
return layer;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (typeof layer === 'string') {
|
|
297
|
+
return this.layerService.getLayer(layer) || this.layerService.getLayerByName(layer);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* 判断当前展示的 Feature 是否和上一次查看的一致
|
|
302
|
+
* @param layer
|
|
303
|
+
* @param featureId
|
|
304
|
+
* @protected
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
}, {
|
|
308
|
+
key: "isSameFeature",
|
|
309
|
+
value: function isSameFeature(layer, featureId) {
|
|
310
|
+
var displayFeatureInfo = this.displayFeatureInfo;
|
|
311
|
+
return displayFeatureInfo && layer === displayFeatureInfo.layer && featureId === displayFeatureInfo.featureId;
|
|
312
|
+
}
|
|
313
|
+
}]);
|
|
314
|
+
return LayerPopup;
|
|
315
|
+
}(_popup.default);
|
|
316
|
+
|
|
317
|
+
exports.default = exports.LayerPopup = LayerPopup;
|