@antv/l7-component 2.9.34 → 2.9.36-alpha.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/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 +106 -0
- package/es/control/baseControl/control.js +301 -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/layerControl.d.ts +21 -0
- package/es/control/layerControl.js +172 -0
- package/es/control/logo.d.ts +10 -6
- package/es/control/logo.js +41 -11
- 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 +20 -10
- package/es/control/scale.js +77 -53
- package/es/control/zoom.d.ts +21 -10
- package/es/control/zoom.js +76 -49
- 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/logo.png +0 -0
- package/es/images/quanping.svg +12 -0
- package/es/index.d.ts +15 -8
- package/es/index.js +15 -9
- package/es/interface.d.ts +1 -20
- 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/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 +333 -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/layerControl.js +182 -0
- package/lib/control/logo.js +50 -23
- package/lib/control/mapTheme.js +151 -0
- package/lib/control/mouseLocation.js +120 -0
- package/lib/control/scale.js +82 -62
- package/lib/control/zoom.js +78 -59
- 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/logo.png +0 -0
- package/lib/images/quanping.svg +12 -0
- package/lib/index.js +165 -50
- package/lib/popup/layerPopup.js +317 -0
- package/lib/popup/popup.js +651 -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 +8 -5
- package/es/control/BaseControl.d.ts +0 -27
- package/es/control/BaseControl.js +0 -134
- package/es/control/layer.d.ts +0 -38
- package/es/control/layer.js +0 -340
- package/es/css/l7.css +0 -502
- package/es/popup.d.ts +0 -35
- package/es/popup.js +0 -300
- package/lib/control/BaseControl.js +0 -160
- package/lib/control/layer.js +0 -362
- package/lib/css/l7.css +0 -502
- package/lib/popup.js +0 -317
package/lib/popup.js
DELETED
|
@@ -1,317 +0,0 @@
|
|
|
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 = 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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
|
-
var _l7Core = require("@antv/l7-core");
|
|
25
|
-
|
|
26
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
27
|
-
|
|
28
|
-
var _eventemitter = require("eventemitter3");
|
|
29
|
-
|
|
30
|
-
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); }; }
|
|
31
|
-
|
|
32
|
-
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; } }
|
|
33
|
-
|
|
34
|
-
/** colse event */
|
|
35
|
-
var Popup = /*#__PURE__*/function (_EventEmitter) {
|
|
36
|
-
(0, _inherits2.default)(Popup, _EventEmitter);
|
|
37
|
-
|
|
38
|
-
var _super = _createSuper(Popup);
|
|
39
|
-
|
|
40
|
-
function Popup(cfg) {
|
|
41
|
-
var _this;
|
|
42
|
-
|
|
43
|
-
(0, _classCallCheck2.default)(this, Popup);
|
|
44
|
-
_this = _super.call(this);
|
|
45
|
-
_this.popupOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getdefault()), cfg);
|
|
46
|
-
(0, _l7Utils.bindAll)(['update', 'onClickClose', 'remove'], (0, _assertThisInitialized2.default)(_this));
|
|
47
|
-
return _this;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
(0, _createClass2.default)(Popup, [{
|
|
51
|
-
key: "addTo",
|
|
52
|
-
value: function addTo(scene) {
|
|
53
|
-
var _this2 = this;
|
|
54
|
-
|
|
55
|
-
this.mapsService = scene.get(_l7Core.TYPES.IMapService);
|
|
56
|
-
this.sceneSerive = scene.get(_l7Core.TYPES.ISceneService);
|
|
57
|
-
this.mapsService.on('camerachange', this.update);
|
|
58
|
-
this.mapsService.on('viewchange', this.update);
|
|
59
|
-
this.scene = scene;
|
|
60
|
-
this.update();
|
|
61
|
-
|
|
62
|
-
if (this.popupOption.closeOnClick) {
|
|
63
|
-
this.timeoutInstance = setTimeout(function () {
|
|
64
|
-
_this2.mapsService.on('click', _this2.onClickClose);
|
|
65
|
-
}, 30);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
this.emit('open');
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "close",
|
|
73
|
-
value: function close() {
|
|
74
|
-
this.remove();
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "open",
|
|
78
|
-
value: function open() {
|
|
79
|
-
this.addTo(this.scene);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "setHTML",
|
|
83
|
-
value: function setHTML(html) {
|
|
84
|
-
var frag = window.document.createDocumentFragment();
|
|
85
|
-
var temp = window.document.createElement('body');
|
|
86
|
-
var child;
|
|
87
|
-
temp.innerHTML = html;
|
|
88
|
-
|
|
89
|
-
while (true) {
|
|
90
|
-
child = temp.firstChild;
|
|
91
|
-
|
|
92
|
-
if (!child) {
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
frag.appendChild(child);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return this.setDOMContent(frag);
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "setLnglat",
|
|
103
|
-
value: function setLnglat(lngLat) {
|
|
104
|
-
this.lngLat = lngLat;
|
|
105
|
-
|
|
106
|
-
if (Array.isArray(lngLat)) {
|
|
107
|
-
this.lngLat = {
|
|
108
|
-
lng: lngLat[0],
|
|
109
|
-
lat: lngLat[1]
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (this.mapsService) {
|
|
114
|
-
this.mapsService.on('camerachange', this.update);
|
|
115
|
-
this.mapsService.on('viewchange', this.update);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
this.update();
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: "getLnglat",
|
|
123
|
-
value: function getLnglat() {
|
|
124
|
-
return this.lngLat;
|
|
125
|
-
}
|
|
126
|
-
}, {
|
|
127
|
-
key: "setText",
|
|
128
|
-
value: function setText(text) {
|
|
129
|
-
return this.setDOMContent(window.document.createTextNode(text));
|
|
130
|
-
}
|
|
131
|
-
}, {
|
|
132
|
-
key: "setMaxWidth",
|
|
133
|
-
value: function setMaxWidth(maxWidth) {
|
|
134
|
-
this.popupOption.maxWidth = maxWidth;
|
|
135
|
-
this.update();
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
key: "setDOMContent",
|
|
140
|
-
value: function setDOMContent(htmlNode) {
|
|
141
|
-
this.createContent();
|
|
142
|
-
this.content.appendChild(htmlNode);
|
|
143
|
-
this.update();
|
|
144
|
-
return this;
|
|
145
|
-
} // 移除popup
|
|
146
|
-
|
|
147
|
-
}, {
|
|
148
|
-
key: "remove",
|
|
149
|
-
value: function remove() {
|
|
150
|
-
if (this.content) {
|
|
151
|
-
this.removeDom(this.content);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (this.container) {
|
|
155
|
-
this.removeDom(this.container); // @ts-ignore
|
|
156
|
-
|
|
157
|
-
delete this.container;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (this.mapsService) {
|
|
161
|
-
// TODO: mapbox AMap 事件同步
|
|
162
|
-
this.mapsService.off('camerachange', this.update);
|
|
163
|
-
this.mapsService.off('viewchange', this.update);
|
|
164
|
-
this.mapsService.off('click', this.onClickClose); // @ts-ignore
|
|
165
|
-
|
|
166
|
-
delete this.mapsService;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
clearTimeout(this.timeoutInstance);
|
|
170
|
-
this.emit('close');
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "isOpen",
|
|
175
|
-
value: function isOpen() {
|
|
176
|
-
return !!this.mapsService;
|
|
177
|
-
}
|
|
178
|
-
}, {
|
|
179
|
-
key: "createContent",
|
|
180
|
-
value: function createContent() {
|
|
181
|
-
if (this.content) {
|
|
182
|
-
_l7Utils.DOM.remove(this.content);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
this.content = _l7Utils.DOM.create('div', 'l7-popup-content', this.container);
|
|
186
|
-
|
|
187
|
-
if (this.popupOption.closeButton) {
|
|
188
|
-
this.closeButton = _l7Utils.DOM.create('button', 'l7-popup-close-button', this.content);
|
|
189
|
-
|
|
190
|
-
if (this.popupOption.closeButtonOffsets) {
|
|
191
|
-
// 关闭按钮的偏移
|
|
192
|
-
this.closeButton.style.right = this.popupOption.closeButtonOffsets[0] + 'px';
|
|
193
|
-
this.closeButton.style.top = this.popupOption.closeButtonOffsets[1] + 'px';
|
|
194
|
-
} // this.closeButton.type = 'button';
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this.closeButton.setAttribute('aria-label', 'Close popup');
|
|
198
|
-
this.closeButton.innerHTML = '×';
|
|
199
|
-
this.closeButton.addEventListener('click', this.onClickClose);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}, {
|
|
203
|
-
key: "creatDom",
|
|
204
|
-
value: function creatDom(tagName, className, container) {
|
|
205
|
-
var el = window.document.createElement(tagName);
|
|
206
|
-
|
|
207
|
-
if (className !== undefined) {
|
|
208
|
-
el.className = className;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (container) {
|
|
212
|
-
container.appendChild(el);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return el;
|
|
216
|
-
}
|
|
217
|
-
}, {
|
|
218
|
-
key: "removeDom",
|
|
219
|
-
value: function removeDom(node) {
|
|
220
|
-
if (node.parentNode) {
|
|
221
|
-
node.parentNode.removeChild(node);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}, {
|
|
225
|
-
key: "getdefault",
|
|
226
|
-
value: function getdefault() {
|
|
227
|
-
return {
|
|
228
|
-
closeButton: true,
|
|
229
|
-
closeOnClick: true,
|
|
230
|
-
maxWidth: '240px',
|
|
231
|
-
offsets: [0, 0],
|
|
232
|
-
anchor: _l7Utils.anchorType.BOTTOM,
|
|
233
|
-
className: '',
|
|
234
|
-
stopPropagation: true
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
}, {
|
|
238
|
-
key: "onClickClose",
|
|
239
|
-
value: function onClickClose(e) {
|
|
240
|
-
if (e.stopPropagation) {
|
|
241
|
-
e.stopPropagation();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
this.remove();
|
|
245
|
-
}
|
|
246
|
-
}, {
|
|
247
|
-
key: "update",
|
|
248
|
-
value: function update() {
|
|
249
|
-
var _this3 = this;
|
|
250
|
-
|
|
251
|
-
var hasPosition = this.lngLat;
|
|
252
|
-
var _this$popupOption = this.popupOption,
|
|
253
|
-
className = _this$popupOption.className,
|
|
254
|
-
maxWidth = _this$popupOption.maxWidth,
|
|
255
|
-
anchor = _this$popupOption.anchor;
|
|
256
|
-
|
|
257
|
-
if (!this.mapsService || !hasPosition || !this.content) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
var popupContainer = this.mapsService.getMarkerContainer();
|
|
262
|
-
|
|
263
|
-
if (!this.container && popupContainer) {
|
|
264
|
-
this.container = this.creatDom('div', 'l7-popup', popupContainer);
|
|
265
|
-
this.tip = this.creatDom('div', 'l7-popup-tip', this.container);
|
|
266
|
-
this.container.appendChild(this.content);
|
|
267
|
-
|
|
268
|
-
if (className) {
|
|
269
|
-
className.split(' ').forEach(function (name) {
|
|
270
|
-
return _this3.container.classList.add(name);
|
|
271
|
-
});
|
|
272
|
-
} // 高德地图需要阻止事件冒泡 // 测试mapbox 地图不需要添加
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
var stopPropagation = this.popupOption.stopPropagation;
|
|
276
|
-
|
|
277
|
-
if (stopPropagation) {
|
|
278
|
-
['mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'].forEach(function (type) {
|
|
279
|
-
_this3.container.addEventListener(type, function (e) {
|
|
280
|
-
e.stopPropagation();
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
this.container.style.whiteSpace = 'nowrap';
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (maxWidth && this.container.style.maxWidth !== maxWidth) {
|
|
289
|
-
this.container.style.maxWidth = maxWidth;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
this.updatePosition();
|
|
293
|
-
|
|
294
|
-
_l7Utils.DOM.setTransform(this.container, "".concat(_l7Utils.anchorTranslate[anchor]));
|
|
295
|
-
|
|
296
|
-
(0, _l7Utils.applyAnchorClass)(this.container, anchor, 'popup');
|
|
297
|
-
}
|
|
298
|
-
}, {
|
|
299
|
-
key: "updatePosition",
|
|
300
|
-
value: function updatePosition() {
|
|
301
|
-
if (!this.mapsService) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
var _this$lngLat = this.lngLat,
|
|
306
|
-
lng = _this$lngLat.lng,
|
|
307
|
-
lat = _this$lngLat.lat;
|
|
308
|
-
var offsets = this.popupOption.offsets;
|
|
309
|
-
var pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
310
|
-
this.container.style.left = pos.x + offsets[0] + 'px';
|
|
311
|
-
this.container.style.top = pos.y - offsets[1] + 'px';
|
|
312
|
-
}
|
|
313
|
-
}]);
|
|
314
|
-
return Popup;
|
|
315
|
-
}(_eventemitter.EventEmitter);
|
|
316
|
-
|
|
317
|
-
exports.default = Popup;
|