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