@antv/l7-component 2.18.0 → 2.18.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.
Files changed (114) hide show
  1. package/package.json +6 -6
  2. package/es/assets/iconfont/iconfont.js +0 -46
  3. package/es/constants/index.d.ts +0 -60
  4. package/es/constants/index.js +0 -60
  5. package/es/control/baseControl/buttonControl.d.ts +0 -59
  6. package/es/control/baseControl/buttonControl.js +0 -177
  7. package/es/control/baseControl/control.d.ts +0 -112
  8. package/es/control/baseControl/control.js +0 -302
  9. package/es/control/baseControl/index.d.ts +0 -4
  10. package/es/control/baseControl/index.js +0 -4
  11. package/es/control/baseControl/popperControl.d.ts +0 -26
  12. package/es/control/baseControl/popperControl.js +0 -120
  13. package/es/control/baseControl/selectControl.d.ts +0 -46
  14. package/es/control/baseControl/selectControl.js +0 -204
  15. package/es/control/exportImage.d.ts +0 -18
  16. package/es/control/exportImage.js +0 -159
  17. package/es/control/fullscreen.d.ts +0 -19
  18. package/es/control/fullscreen.js +0 -119
  19. package/es/control/geoLocate.d.ts +0 -16
  20. package/es/control/geoLocate.js +0 -107
  21. package/es/control/layerSwitch.d.ts +0 -19
  22. package/es/control/layerSwitch.js +0 -141
  23. package/es/control/logo.d.ts +0 -13
  24. package/es/control/logo.js +0 -75
  25. package/es/control/mapTheme.d.ts +0 -10
  26. package/es/control/mapTheme.js +0 -110
  27. package/es/control/mouseLocation.d.ts +0 -15
  28. package/es/control/mouseLocation.js +0 -83
  29. package/es/control/scale.d.ts +0 -34
  30. package/es/control/scale.js +0 -149
  31. package/es/control/zoom.d.ts +0 -38
  32. package/es/control/zoom.js +0 -132
  33. package/es/css/button.less +0 -70
  34. package/es/css/control.less +0 -71
  35. package/es/css/index.css +0 -594
  36. package/es/css/index.less +0 -12
  37. package/es/css/l7.less +0 -62
  38. package/es/css/layerPopup.less +0 -8
  39. package/es/css/logo.less +0 -18
  40. package/es/css/mouseLocation.less +0 -9
  41. package/es/css/popper.less +0 -64
  42. package/es/css/popup.less +0 -185
  43. package/es/css/scale.less +0 -34
  44. package/es/css/select.less +0 -86
  45. package/es/css/variables.less +0 -30
  46. package/es/css/zoom.less +0 -29
  47. package/es/images/layers.png +0 -0
  48. package/es/images/layers.svg +0 -1
  49. package/es/images/logo.png +0 -0
  50. package/es/images/quanping.svg +0 -12
  51. package/es/index.d.ts +0 -18
  52. package/es/index.js +0 -49
  53. package/es/interface.d.ts +0 -18
  54. package/es/interface.js +0 -1
  55. package/es/marker-layer.d.ts +0 -54
  56. package/es/marker-layer.js +0 -343
  57. package/es/marker.d.ts +0 -55
  58. package/es/marker.js +0 -410
  59. package/es/popup/layerPopup.d.ts +0 -86
  60. package/es/popup/layerPopup.js +0 -312
  61. package/es/popup/popup.d.ts +0 -139
  62. package/es/popup/popup.js +0 -567
  63. package/es/utils/anchor.d.ts +0 -22
  64. package/es/utils/anchor.js +0 -31
  65. package/es/utils/icon.d.ts +0 -1
  66. package/es/utils/icon.js +0 -9
  67. package/es/utils/popper.d.ts +0 -75
  68. package/es/utils/popper.js +0 -259
  69. package/es/utils/screenfull.d.ts +0 -2
  70. package/es/utils/screenfull.js +0 -128
  71. package/lib/assets/iconfont/iconfont.js +0 -48
  72. package/lib/constants/index.js +0 -68
  73. package/lib/control/baseControl/buttonControl.js +0 -183
  74. package/lib/control/baseControl/control.js +0 -314
  75. package/lib/control/baseControl/index.js +0 -39
  76. package/lib/control/baseControl/popperControl.js +0 -126
  77. package/lib/control/baseControl/selectControl.js +0 -210
  78. package/lib/control/exportImage.js +0 -165
  79. package/lib/control/fullscreen.js +0 -125
  80. package/lib/control/geoLocate.js +0 -113
  81. package/lib/control/layerSwitch.js +0 -147
  82. package/lib/control/logo.js +0 -81
  83. package/lib/control/mapTheme.js +0 -116
  84. package/lib/control/mouseLocation.js +0 -89
  85. package/lib/control/scale.js +0 -155
  86. package/lib/control/zoom.js +0 -138
  87. package/lib/css/button.less +0 -70
  88. package/lib/css/control.less +0 -71
  89. package/lib/css/index.css +0 -594
  90. package/lib/css/index.less +0 -12
  91. package/lib/css/l7.less +0 -62
  92. package/lib/css/layerPopup.less +0 -8
  93. package/lib/css/logo.less +0 -18
  94. package/lib/css/mouseLocation.less +0 -9
  95. package/lib/css/popper.less +0 -64
  96. package/lib/css/popup.less +0 -185
  97. package/lib/css/scale.less +0 -34
  98. package/lib/css/select.less +0 -86
  99. package/lib/css/variables.less +0 -30
  100. package/lib/css/zoom.less +0 -29
  101. package/lib/images/layers.png +0 -0
  102. package/lib/images/layers.svg +0 -1
  103. package/lib/images/logo.png +0 -0
  104. package/lib/images/quanping.svg +0 -12
  105. package/lib/index.js +0 -169
  106. package/lib/interface.js +0 -5
  107. package/lib/marker-layer.js +0 -349
  108. package/lib/marker.js +0 -417
  109. package/lib/popup/layerPopup.js +0 -317
  110. package/lib/popup/popup.js +0 -573
  111. package/lib/utils/anchor.js +0 -40
  112. package/lib/utils/icon.js +0 -16
  113. package/lib/utils/popper.js +0 -263
  114. package/lib/utils/screenfull.js +0 -136
@@ -1,312 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
- import _get from "@babel/runtime/helpers/esm/get";
6
- import _inherits from "@babel/runtime/helpers/esm/inherits";
7
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
- 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; } }
12
- import { DOM, lodashUtil } from '@antv/l7-utils';
13
- // import { Container } from 'inversify';
14
- import Popup from "./popup";
15
- var get = lodashUtil.get;
16
- export { LayerPopup };
17
- var LayerPopup = /*#__PURE__*/function (_Popup) {
18
- _inherits(LayerPopup, _Popup);
19
- var _super = _createSuper(LayerPopup);
20
- function LayerPopup() {
21
- var _this;
22
- _classCallCheck(this, LayerPopup);
23
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
- args[_key] = arguments[_key];
25
- }
26
- _this = _super.call.apply(_super, [this].concat(args));
27
- /**
28
- * 用于保存图层对应的事件回调以及配置信息
29
- * @protected
30
- */
31
- _defineProperty(_assertThisInitialized(_this), "layerConfigMap", new WeakMap());
32
- return _this;
33
- }
34
- _createClass(LayerPopup, [{
35
- key: "layerConfigItems",
36
- get:
37
- /**
38
- * 当期正在展示的图层以及对应元素 id 的信息
39
- * @protected
40
- */
41
-
42
- function get() {
43
- var _ref;
44
- var _this$popupOption = this.popupOption,
45
- config = _this$popupOption.config,
46
- items = _this$popupOption.items;
47
- return (_ref = config !== null && config !== void 0 ? config : items) !== null && _ref !== void 0 ? _ref : [];
48
- }
49
- }, {
50
- key: "addTo",
51
- value: function addTo(scene) {
52
- _get(_getPrototypeOf(LayerPopup.prototype), "addTo", this).call(this, scene);
53
- this.bindLayerEvent();
54
- this.hide();
55
- return this;
56
- }
57
- }, {
58
- key: "remove",
59
- value: function remove() {
60
- _get(_getPrototypeOf(LayerPopup.prototype), "remove", this).call(this);
61
- this.unbindLayerEvent();
62
- return this;
63
- }
64
- }, {
65
- key: "setOptions",
66
- value: function setOptions(option) {
67
- this.unbindLayerEvent();
68
- _get(_getPrototypeOf(LayerPopup.prototype), "setOptions", this).call(this, option);
69
- this.bindLayerEvent();
70
- return this;
71
- }
72
- }, {
73
- key: "getDefault",
74
- value: function getDefault(option) {
75
- var isClickTrigger = option.trigger === 'click';
76
- return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(LayerPopup.prototype), "getDefault", this).call(this, option)), {}, {
77
- trigger: 'hover',
78
- followCursor: !isClickTrigger,
79
- lngLat: {
80
- lng: 0,
81
- lat: 0
82
- },
83
- offsets: [0, 10],
84
- closeButton: false,
85
- closeOnClick: false,
86
- autoClose: false,
87
- closeOnEsc: false
88
- });
89
- }
90
-
91
- /**
92
- * 绑定对应的图层事件
93
- * @protected
94
- */
95
- }, {
96
- key: "bindLayerEvent",
97
- value: function bindLayerEvent() {
98
- var _this2 = this;
99
- var trigger = this.popupOption.trigger;
100
- this.layerConfigItems.forEach(function (configItem) {
101
- var _layer$getSource;
102
- var layer = _this2.getLayerByConfig(configItem);
103
- if (!layer) {
104
- return;
105
- }
106
- var layerInfo = _objectSpread({}, configItem);
107
- if (trigger === 'hover') {
108
- var onMouseMove = _this2.onLayerMouseMove.bind(_this2, layer);
109
- var onMouseOut = _this2.onLayerMouseOut.bind(_this2, layer);
110
- layerInfo.onMouseMove = onMouseMove;
111
- layerInfo.onMouseOut = onMouseOut;
112
- layer === null || layer === void 0 ? void 0 : layer.on('mousemove', onMouseMove);
113
- layer === null || layer === void 0 ? void 0 : layer.on('mouseout', onMouseOut);
114
- } else {
115
- var onClick = _this2.onLayerClick.bind(_this2, layer);
116
- layerInfo.onClick = onClick;
117
- layer === null || layer === void 0 ? void 0 : layer.on('click', onClick);
118
- }
119
- var source = layer === null || layer === void 0 ? void 0 : (_layer$getSource = layer.getSource) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.call(layer);
120
- var onSourceUpdate = _this2.onSourceUpdate.bind(_this2, layer);
121
- source === null || source === void 0 ? void 0 : source.on('update', onSourceUpdate);
122
- layerInfo.onSourceUpdate = onSourceUpdate;
123
- _this2.layerConfigMap.set(layer, layerInfo);
124
- });
125
- }
126
-
127
- /**
128
- * 解绑对应的图层事件
129
- * @protected
130
- */
131
- }, {
132
- key: "unbindLayerEvent",
133
- value: function unbindLayerEvent() {
134
- var _this3 = this;
135
- this.layerConfigItems.forEach(function (configItem) {
136
- var layer = _this3.getLayerByConfig(configItem);
137
- var layerInfo = layer && _this3.layerConfigMap.get(layer);
138
- if (!layerInfo) {
139
- return;
140
- }
141
- var onMouseMove = layerInfo.onMouseMove,
142
- onMouseOut = layerInfo.onMouseOut,
143
- onClick = layerInfo.onClick,
144
- onSourceUpdate = layerInfo.onSourceUpdate;
145
- if (onMouseMove) {
146
- layer.off('mousemove', onMouseMove);
147
- }
148
- if (onMouseOut) {
149
- layer.off('mouseout', onMouseOut);
150
- }
151
- if (onClick) {
152
- layer.off('click', onClick);
153
- }
154
- if (onSourceUpdate) {
155
- var _layer$getSource2;
156
- layer === null || layer === void 0 ? void 0 : (_layer$getSource2 = layer.getSource()) === null || _layer$getSource2 === void 0 ? void 0 : _layer$getSource2.off('update', onSourceUpdate);
157
- }
158
- });
159
- }
160
- }, {
161
- key: "onLayerMouseMove",
162
- value: function onLayerMouseMove(layer, e) {
163
- if (!this.isSameFeature(layer, e.featureId)) {
164
- var _this$getLayerInfoFra = this.getLayerInfoFrag(layer, e),
165
- title = _this$getLayerInfoFra.title,
166
- content = _this$getLayerInfoFra.content;
167
- this.setDOMContent(content);
168
- this.setTitle(title);
169
- this.displayFeatureInfo = {
170
- layer: layer,
171
- featureId: e.featureId
172
- };
173
- this.show();
174
- }
175
- }
176
-
177
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
178
- }, {
179
- key: "onLayerMouseOut",
180
- value: function onLayerMouseOut(layer, e) {
181
- this.displayFeatureInfo = undefined;
182
- if (this.isShow) {
183
- this.hide();
184
- }
185
- }
186
- }, {
187
- key: "onLayerClick",
188
- value: function onLayerClick(layer, e) {
189
- if (this.isShow && this.isSameFeature(layer, e.featureId)) {
190
- this.hide();
191
- } else {
192
- var _this$getLayerInfoFra2 = this.getLayerInfoFrag(layer, e),
193
- title = _this$getLayerInfoFra2.title,
194
- content = _this$getLayerInfoFra2.content;
195
- this.setDOMContent(content);
196
- this.setLnglat(e.lngLat);
197
- this.setTitle(title);
198
- this.displayFeatureInfo = {
199
- layer: layer,
200
- featureId: e.featureId
201
- };
202
- this.show();
203
- }
204
- }
205
- }, {
206
- key: "onSourceUpdate",
207
- value: function onSourceUpdate(layer) {
208
- this.hide();
209
- this.displayFeatureInfo = undefined;
210
- }
211
-
212
- /**
213
- * 通过当前图层和对应选中的元素获取气泡展示的 HTML 内容
214
- * @param layer
215
- * @param e
216
- * @protected
217
- */
218
- }, {
219
- key: "getLayerInfoFrag",
220
- value: function getLayerInfoFrag(layer, e) {
221
- var layerInfo = this.layerConfigMap.get(layer);
222
- var titleFrag;
223
- var contentFrag = document.createDocumentFragment();
224
- if (layerInfo) {
225
- var _feature = e.feature;
226
- if (_feature.type === 'Feature' && 'properties' in _feature && 'geometry' in _feature) {
227
- _feature = _feature.properties;
228
- }
229
- var title = layerInfo.title,
230
- fields = layerInfo.fields,
231
- customContent = layerInfo.customContent;
232
- if (title) {
233
- titleFrag = document.createDocumentFragment();
234
- var titleElement = title instanceof Function ? title(_feature) : title;
235
- DOM.appendElementType(titleFrag, titleElement);
236
- }
237
- if (customContent) {
238
- var content = customContent instanceof Function ? customContent(_feature) : customContent;
239
- DOM.appendElementType(contentFrag, content);
240
- } else if (fields !== null && fields !== void 0 && fields.length) {
241
- fields === null || fields === void 0 ? void 0 : fields.forEach(function (fieldConfig) {
242
- var _ref3, _ref4;
243
- var _ref2 = typeof fieldConfig === 'string' ?
244
- // tslint:disable-next-line:no-object-literal-type-assertion
245
- {
246
- field: fieldConfig
247
- } : fieldConfig,
248
- field = _ref2.field,
249
- formatField = _ref2.formatField,
250
- formatValue = _ref2.formatValue,
251
- getValue = _ref2.getValue;
252
- var row = DOM.create('div', 'l7-layer-popup__row');
253
- var value = getValue ? getValue(e.feature) : get(_feature, field);
254
- var fieldElement = (_ref3 = formatField instanceof Function ? formatField(field, _feature) : formatField) !== null && _ref3 !== void 0 ? _ref3 : field;
255
- var valueElement = (_ref4 = formatValue instanceof Function ? formatValue(value, _feature) : formatValue) !== null && _ref4 !== void 0 ? _ref4 : value;
256
- var fieldSpan = DOM.create('span', 'l7-layer-popup__key', row);
257
- DOM.appendElementType(fieldSpan, fieldElement);
258
- DOM.appendElementType(fieldSpan, document.createTextNode(':'));
259
- var valueSpan = DOM.create('span', 'l7-layer-popup__value', row);
260
-
261
- // 当 value 中每项元素均为基础数据类型时,用逗号隔开
262
- if (Array.isArray(valueElement) && valueElement.every(function (item) {
263
- return !(item instanceof Object);
264
- })) {
265
- valueElement = valueElement.map(function (item) {
266
- return String(item);
267
- }).join(',');
268
- }
269
- DOM.appendElementType(valueSpan, valueElement);
270
- contentFrag.appendChild(row);
271
- });
272
- }
273
- }
274
- return {
275
- title: titleFrag,
276
- content: contentFrag
277
- };
278
- }
279
-
280
- /**
281
- * 通过 Layer 配置访问到真实的 Layer 实例
282
- * @param configItem
283
- * @protected
284
- */
285
- }, {
286
- key: "getLayerByConfig",
287
- value: function getLayerByConfig(configItem) {
288
- var layer = configItem.layer;
289
- if (layer instanceof Object) {
290
- return layer;
291
- }
292
- if (typeof layer === 'string') {
293
- return this.layerService.getLayer(layer) || this.layerService.getLayerByName(layer);
294
- }
295
- }
296
-
297
- /**
298
- * 判断当前展示的 Feature 是否和上一次查看的一致
299
- * @param layer
300
- * @param featureId
301
- * @protected
302
- */
303
- }, {
304
- key: "isSameFeature",
305
- value: function isSameFeature(layer, featureId) {
306
- var displayFeatureInfo = this.displayFeatureInfo;
307
- return displayFeatureInfo && layer === displayFeatureInfo.layer && featureId === displayFeatureInfo.featureId;
308
- }
309
- }]);
310
- return LayerPopup;
311
- }(Popup);
312
- export { LayerPopup as default };
@@ -1,139 +0,0 @@
1
- import { ILayerService, ILngLat, IMapService, IPopup, IPopupOption, ISceneService } from '@antv/l7-core';
2
- import { DOM } from '@antv/l7-utils';
3
- import { EventEmitter } from 'eventemitter3';
4
- import { Container } from 'inversify';
5
- type ElementType = DOM.ElementType;
6
- export { Popup };
7
- export default class Popup<O extends IPopupOption = IPopupOption> extends EventEmitter implements IPopup {
8
- /**
9
- * 配置
10
- * @protected
11
- */
12
- protected popupOption: O;
13
- protected mapsService: IMapService;
14
- protected sceneService: ISceneService;
15
- protected layerService: ILayerService;
16
- protected scene: Container;
17
- /**
18
- * 关闭按钮对应的 DOM
19
- * @protected
20
- */
21
- protected closeButton?: HTMLElement | SVGElement;
22
- /**
23
- * Popup 的总容器 DOM,包含 content 和 tip
24
- * @protected
25
- */
26
- protected container: HTMLElement;
27
- /**
28
- * popup 气泡容器
29
- * @protected
30
- */
31
- protected content: HTMLElement;
32
- /**
33
- * popup 气泡标题
34
- * @protected
35
- */
36
- protected contentTitle?: HTMLElement;
37
- /**
38
- * popup 内容容器
39
- * @protected
40
- */
41
- protected contentPanel: HTMLElement;
42
- /**
43
- * 气泡箭头对应的 DOM
44
- * @protected
45
- */
46
- protected tip: HTMLElement;
47
- /**
48
- * 当前是否展示
49
- * @protected
50
- */
51
- protected isShow: boolean;
52
- protected get lngLat(): ILngLat;
53
- protected set lngLat(newLngLat: ILngLat);
54
- constructor(cfg?: Partial<O>);
55
- getIsShow(): boolean;
56
- addTo(scene: Container): this;
57
- remove(): this | undefined;
58
- /**
59
- * 获取 option 配置
60
- */
61
- getOptions(): O;
62
- setOptions(option: Partial<O>): this;
63
- open(): this;
64
- close(): this;
65
- show(): this | undefined;
66
- hide(): this | undefined;
67
- /**
68
- * 设置 HTML 内容
69
- * @param html
70
- */
71
- setHTML(html: ElementType): this;
72
- /**
73
- * 设置 Popup 展示文本
74
- * @param text
75
- */
76
- setText(text: string): this;
77
- setTitle(title?: ElementType): void;
78
- /**
79
- * 将地图自动平移到气泡位置
80
- */
81
- panToPopup(): this;
82
- setLngLat(lngLat: ILngLat | [number, number]): this;
83
- /**
84
- * 设置 Popup 所在经纬度
85
- * @param lngLat
86
- */
87
- setLnglat(lngLat: ILngLat | [number, number]): this;
88
- /**
89
- * 获取 Popup 所在经纬度
90
- */
91
- getLnglat(): ILngLat;
92
- /**
93
- * 设置 Popup 最大宽度
94
- * @param maxWidth
95
- */
96
- setMaxWidth(maxWidth: string): this;
97
- isOpen(): boolean;
98
- protected onMouseMove: (e: MouseEvent) => void;
99
- /**
100
- * 将经纬度转换成对应的像素偏移位置
101
- * @protected
102
- */
103
- protected updateLngLatPosition: () => void;
104
- protected getDefault(option: Partial<O>): O;
105
- /**
106
- * 设置 Popup 内容 HTML
107
- * @param element
108
- */
109
- protected setDOMContent(element: ElementType): this;
110
- /**
111
- * 绑定地图点击事件触发销毁 Popup
112
- * @protected
113
- */
114
- protected updateCloseOnClick(onlyClear?: boolean): void;
115
- protected updateCloseOnEsc(onlyClear?: boolean): void;
116
- protected updateFollowCursor(onlyClear?: boolean): void;
117
- protected onKeyDown: (e: KeyboardEvent) => void;
118
- /**
119
- * 创建 Popup 内容容器的 DOM (在每次 setHTML 或 setText 时都会被调用)
120
- * @protected
121
- */
122
- protected createContent(): void;
123
- protected onCloseButtonClick: (e: Event) => void;
124
- protected update: () => void;
125
- /**
126
- * 设置 Popup 相对于地图容器的 Position
127
- * @param left
128
- * @param top
129
- * @protected
130
- */
131
- protected setPopupPosition(left: number, top: number): void;
132
- /**
133
- * 检查当前传入 option 是否包含 keys 字段
134
- * @param option
135
- * @param keys
136
- * @protected
137
- */
138
- protected checkUpdateOption(option: Partial<O>, keys: Array<keyof O>): boolean;
139
- }