@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
package/lib/index.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {
|
|
9
|
+
Marker: true,
|
|
10
|
+
MarkerLayer: true
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "Marker", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _marker.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "MarkerLayer", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _markerLayer.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
var _marker = _interopRequireDefault(require("./marker"));
|
|
26
|
+
|
|
27
|
+
var _markerLayer = _interopRequireDefault(require("./marker-layer"));
|
|
28
|
+
|
|
29
|
+
require("./assets/iconfont/iconfont.js");
|
|
30
|
+
|
|
31
|
+
var _baseControl = require("./control/baseControl");
|
|
32
|
+
|
|
33
|
+
Object.keys(_baseControl).forEach(function (key) {
|
|
34
|
+
if (key === "default" || key === "__esModule") return;
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
36
|
+
if (key in exports && exports[key] === _baseControl[key]) return;
|
|
37
|
+
Object.defineProperty(exports, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function get() {
|
|
40
|
+
return _baseControl[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
var _logo = require("./control/logo");
|
|
46
|
+
|
|
47
|
+
Object.keys(_logo).forEach(function (key) {
|
|
48
|
+
if (key === "default" || key === "__esModule") return;
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
50
|
+
if (key in exports && exports[key] === _logo[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _logo[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _fullscreen = require("./control/fullscreen");
|
|
60
|
+
|
|
61
|
+
Object.keys(_fullscreen).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
64
|
+
if (key in exports && exports[key] === _fullscreen[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function get() {
|
|
68
|
+
return _fullscreen[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
var _exportImage = require("./control/exportImage");
|
|
74
|
+
|
|
75
|
+
Object.keys(_exportImage).forEach(function (key) {
|
|
76
|
+
if (key === "default" || key === "__esModule") return;
|
|
77
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
78
|
+
if (key in exports && exports[key] === _exportImage[key]) return;
|
|
79
|
+
Object.defineProperty(exports, key, {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function get() {
|
|
82
|
+
return _exportImage[key];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
var _geoLocate = require("./control/geoLocate");
|
|
88
|
+
|
|
89
|
+
Object.keys(_geoLocate).forEach(function (key) {
|
|
90
|
+
if (key === "default" || key === "__esModule") return;
|
|
91
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
92
|
+
if (key in exports && exports[key] === _geoLocate[key]) return;
|
|
93
|
+
Object.defineProperty(exports, key, {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function get() {
|
|
96
|
+
return _geoLocate[key];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
var _mapTheme = require("./control/mapTheme");
|
|
102
|
+
|
|
103
|
+
Object.keys(_mapTheme).forEach(function (key) {
|
|
104
|
+
if (key === "default" || key === "__esModule") return;
|
|
105
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
106
|
+
if (key in exports && exports[key] === _mapTheme[key]) return;
|
|
107
|
+
Object.defineProperty(exports, key, {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function get() {
|
|
110
|
+
return _mapTheme[key];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
var _layerSwitch = require("./control/layerSwitch");
|
|
116
|
+
|
|
117
|
+
Object.keys(_layerSwitch).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
120
|
+
if (key in exports && exports[key] === _layerSwitch[key]) return;
|
|
121
|
+
Object.defineProperty(exports, key, {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function get() {
|
|
124
|
+
return _layerSwitch[key];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
var _mouseLocation = require("./control/mouseLocation");
|
|
130
|
+
|
|
131
|
+
Object.keys(_mouseLocation).forEach(function (key) {
|
|
132
|
+
if (key === "default" || key === "__esModule") return;
|
|
133
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
134
|
+
if (key in exports && exports[key] === _mouseLocation[key]) return;
|
|
135
|
+
Object.defineProperty(exports, key, {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function get() {
|
|
138
|
+
return _mouseLocation[key];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
var _zoom = require("./control/zoom");
|
|
144
|
+
|
|
145
|
+
Object.keys(_zoom).forEach(function (key) {
|
|
146
|
+
if (key === "default" || key === "__esModule") return;
|
|
147
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
148
|
+
if (key in exports && exports[key] === _zoom[key]) return;
|
|
149
|
+
Object.defineProperty(exports, key, {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function get() {
|
|
152
|
+
return _zoom[key];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
var _scale = require("./control/scale");
|
|
158
|
+
|
|
159
|
+
Object.keys(_scale).forEach(function (key) {
|
|
160
|
+
if (key === "default" || key === "__esModule") return;
|
|
161
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
162
|
+
if (key in exports && exports[key] === _scale[key]) return;
|
|
163
|
+
Object.defineProperty(exports, key, {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function get() {
|
|
166
|
+
return _scale[key];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
var _popup = require("./popup/popup");
|
|
172
|
+
|
|
173
|
+
Object.keys(_popup).forEach(function (key) {
|
|
174
|
+
if (key === "default" || key === "__esModule") return;
|
|
175
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
176
|
+
if (key in exports && exports[key] === _popup[key]) return;
|
|
177
|
+
Object.defineProperty(exports, key, {
|
|
178
|
+
enumerable: true,
|
|
179
|
+
get: function get() {
|
|
180
|
+
return _popup[key];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
var _layerPopup = require("./popup/layerPopup");
|
|
186
|
+
|
|
187
|
+
Object.keys(_layerPopup).forEach(function (key) {
|
|
188
|
+
if (key === "default" || key === "__esModule") return;
|
|
189
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
190
|
+
if (key in exports && exports[key] === _layerPopup[key]) return;
|
|
191
|
+
Object.defineProperty(exports, key, {
|
|
192
|
+
enumerable: true,
|
|
193
|
+
get: function get() {
|
|
194
|
+
return _layerPopup[key];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
var _interface = require("./interface");
|
|
200
|
+
|
|
201
|
+
Object.keys(_interface).forEach(function (key) {
|
|
202
|
+
if (key === "default" || key === "__esModule") return;
|
|
203
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
204
|
+
if (key in exports && exports[key] === _interface[key]) return;
|
|
205
|
+
Object.defineProperty(exports, key, {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
get: function get() {
|
|
208
|
+
return _interface[key];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// 引入样式
|
|
214
|
+
function loadStyles(css, doc) {
|
|
215
|
+
var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
|
|
216
|
+
var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
|
|
217
|
+
|
|
218
|
+
if (isMiniAli || isWeChatMiniProgram) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!doc) doc = document;
|
|
223
|
+
|
|
224
|
+
if (!doc) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var head = doc.head || doc.getElementsByTagName('head')[0];
|
|
229
|
+
|
|
230
|
+
if (!head) {
|
|
231
|
+
head = doc.createElement('head');
|
|
232
|
+
var body = doc.body || doc.getElementsByTagName('body')[0];
|
|
233
|
+
|
|
234
|
+
if (body) {
|
|
235
|
+
body.parentNode.insertBefore(head, body);
|
|
236
|
+
} else {
|
|
237
|
+
doc.documentElement.appendChild(head);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
var style = doc.createElement('style');
|
|
242
|
+
style.type = 'text/css';
|
|
243
|
+
|
|
244
|
+
if (style.styleSheet) {
|
|
245
|
+
style.styleSheet.cssText = css;
|
|
246
|
+
} else {
|
|
247
|
+
style.appendChild(doc.createTextNode(css));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
head.appendChild(style);
|
|
251
|
+
return style;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
loadStyles(".l7-marker-container {\n position: absolute;\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n.l7-marker {\n position: absolute !important;\n top: 0;\n left: 0;\n z-index: 5;\n cursor: pointer;\n}\n.l7-marker-cluster {\n width: 40px;\n height: 40px;\n background-color: rgba(181, 226, 140, 0.6);\n background-clip: padding-box;\n border-radius: 20px;\n}\n.l7-marker-cluster div {\n width: 30px;\n height: 30px;\n margin-top: 5px;\n margin-left: 5px;\n font: 12px 'Helvetica Neue', Arial, Helvetica, sans-serif;\n text-align: center;\n background-color: rgba(110, 204, 57, 0.6);\n border-radius: 15px;\n}\n.l7-marker-cluster span {\n line-height: 30px;\n}\n.l7-touch .l7-control-attribution,\n.l7-touch .l7-control-layers,\n.l7-touch .l7-bar {\n -webkit-box-shadow: none;\n box-shadow: none;\n}\n.l7-touch .l7-control-layers,\n.l7-touch .l7-bar {\n background-clip: padding-box;\n border: 2px solid rgba(0, 0, 0, 0.2);\n}\n.mapboxgl-ctrl-logo,\n.amap-logo {\n display: none !important;\n}\n.l7-select-box {\n border: 3px dashed gray;\n border-radius: 2px;\n position: absolute;\n z-index: 1000;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.l7-control-container {\n font: 12px/1.5 'Helvetica Neue', Arial, Helvetica, sans-serif;\n}\n.l7-control-container .l7-control {\n position: relative;\n z-index: 800;\n float: left;\n clear: both;\n color: #595959;\n font-size: 12px;\n pointer-events: visiblePainted;\n /* IE 9-10 doesn't have auto */\n pointer-events: auto;\n}\n.l7-control-container .l7-control.l7-control--hide {\n display: none;\n}\n.l7-control-container .l7-top {\n top: 0;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n}\n.l7-control-container .l7-top .l7-control:not(.l7-control--hide) {\n margin-top: 8px;\n}\n.l7-control-container .l7-right {\n right: 0;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n}\n.l7-control-container .l7-right .l7-control:not(.l7-control--hide) {\n margin-right: 8px;\n}\n.l7-control-container .l7-bottom {\n bottom: 0;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n}\n.l7-control-container .l7-bottom .l7-control:not(.l7-control--hide) {\n margin-bottom: 8px;\n}\n.l7-control-container .l7-left {\n left: 0;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n z-index: 1000;\n pointer-events: none;\n}\n.l7-control-container .l7-left .l7-control:not(.l7-control--hide) {\n margin-left: 8px;\n}\n.l7-control-container .l7-center {\n position: absolute;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n}\n.l7-control-container .l7-center.l7-top,\n.l7-control-container .l7-center.l7-bottom {\n width: 100%;\n}\n.l7-control-container .l7-center.l7-left,\n.l7-control-container .l7-center.l7-right {\n height: 100%;\n}\n.l7-control-container .l7-center .l7-control {\n margin-right: 8px;\n margin-bottom: 8px;\n}\n.l7-control-container .l7-row {\n -webkit-box-orient: horizontal;\n -webkit-box-direction: normal;\n -ms-flex-direction: row;\n flex-direction: row;\n}\n.l7-control-container .l7-row.l7-top {\n -webkit-box-align: start;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n.l7-control-container .l7-row.l7-bottom {\n -webkit-box-align: end;\n -ms-flex-align: end;\n align-items: flex-end;\n}\n.l7-control-container .l7-column {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.l7-control-container .l7-column.l7-left {\n -webkit-box-align: start;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n.l7-control-container .l7-column.l7-right {\n -webkit-box-align: end;\n -ms-flex-align: end;\n align-items: flex-end;\n}\n.l7-button-control {\n min-width: 28px;\n height: 28px;\n background-color: #fff;\n border-width: 0;\n border-radius: 2px;\n outline: 0;\n cursor: pointer;\n -webkit-transition: all 0.2s;\n transition: all 0.2s;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: 0 6px;\n -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n line-height: 16px;\n}\n.l7-button-control .l7-iconfont {\n fill: #595959;\n color: #595959;\n width: 16px;\n height: 16px;\n}\n.l7-button-control.l7-button-control--row {\n padding: 0 16px 0 13px;\n}\n.l7-button-control.l7-button-control--row * + .l7-button-control__text {\n margin-left: 8px;\n}\n.l7-button-control.l7-button-control--column {\n height: 44px;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.l7-button-control.l7-button-control--column .l7-iconfont {\n margin-top: 3px;\n}\n.l7-button-control.l7-button-control--column .l7-button-control__text {\n margin-top: 3px;\n font-size: 10px;\n -webkit-transform: scale(0.83333);\n transform: scale(0.83333);\n}\n.l7-button-control:not(:disabled):hover {\n background-color: #f3f3f3;\n}\n.l7-button-control:not(:disabled):active {\n background-color: #f3f3f3;\n}\n.l7-button-control:disabled {\n background-color: #fafafa;\n color: #bdbdbd;\n cursor: not-allowed;\n}\n.l7-button-control:disabled .l7-iconfont {\n fill: #bdbdbd;\n color: #bdbdbd;\n}\n.l7-button-control:disabled:hover {\n background-color: #fafafa;\n}\n.l7-button-control:disabled:active {\n background-color: #fafafa;\n}\n.l7-popper {\n position: absolute;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n z-index: 5;\n color: #595959;\n}\n.l7-popper.l7-popper-hide {\n display: none;\n}\n.l7-popper .l7-popper-content {\n min-height: 28px;\n background: #fff;\n border-radius: 2px;\n -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n}\n.l7-popper .l7-popper-arrow {\n width: 0;\n height: 0;\n border-width: 4px;\n border-style: solid;\n border-top-color: transparent;\n border-bottom-color: transparent;\n border-left-color: transparent;\n border-right-color: transparent;\n -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n}\n.l7-popper.l7-popper-left {\n -webkit-box-orient: horizontal;\n -webkit-box-direction: normal;\n -ms-flex-direction: row;\n flex-direction: row;\n}\n.l7-popper.l7-popper-left .l7-popper-arrow {\n border-left-color: #fff;\n margin: 10px 0;\n}\n.l7-popper.l7-popper-right {\n -webkit-box-orient: horizontal;\n -webkit-box-direction: reverse;\n -ms-flex-direction: row-reverse;\n flex-direction: row-reverse;\n}\n.l7-popper.l7-popper-right .l7-popper-arrow {\n border-right-color: #fff;\n margin: 10px 0;\n}\n.l7-popper.l7-popper-top {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.l7-popper.l7-popper-top .l7-popper-arrow {\n border-top-color: #fff;\n margin: 0 10px;\n}\n.l7-popper.l7-popper-bottom {\n -webkit-box-orient: vertical;\n -webkit-box-direction: reverse;\n -ms-flex-direction: column-reverse;\n flex-direction: column-reverse;\n}\n.l7-popper.l7-popper-bottom .l7-popper-arrow {\n border-bottom-color: #fff;\n margin: 0 10px;\n}\n.l7-popper.l7-popper-start {\n -webkit-box-align: start;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n.l7-popper.l7-popper-end {\n -webkit-box-align: end;\n -ms-flex-align: end;\n align-items: flex-end;\n}\n.l7-select-control--normal {\n padding: 4px 0;\n}\n.l7-select-control--normal .l7-select-control-item {\n height: 24px;\n line-height: 24px;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: 0 16px;\n font-size: 12px;\n}\n.l7-select-control--normal .l7-select-control-item > * + * {\n margin-left: 6px;\n}\n.l7-select-control--normal .l7-select-control-item input[type='checkbox'] {\n height: 14px;\n width: 14px;\n}\n.l7-select-control--normal .l7-select-control-item:hover {\n background-color: #f3f3f3;\n}\n.l7-select-control--image {\n padding: 12px 12px 0 12px;\n width: 474px;\n height: 320px;\n overflow: auto;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n -webkit-box-align: start;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n.l7-select-control--image .l7-select-control-item {\n margin-right: 12px;\n border-radius: 2px;\n overflow: hidden;\n border: 1px solid #fff;\n -webkit-box-sizing: content-box;\n box-sizing: content-box;\n width: calc((100% - 36px) / 3);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n margin-bottom: 12px;\n position: relative;\n font-size: 12px;\n}\n.l7-select-control--image .l7-select-control-item img {\n width: 142px;\n height: 80px;\n}\n.l7-select-control--image .l7-select-control-item input[type='checkbox'] {\n position: absolute;\n right: 0;\n top: 0;\n}\n.l7-select-control--image .l7-select-control-item .l7-select-control-item-row {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n line-height: 26px;\n}\n.l7-select-control--image .l7-select-control-item .l7-select-control-item-row > * + * {\n margin-left: 8px;\n}\n.l7-select-control--image .l7-select-control-item.l7-select-control-item-active {\n border-color: #0370fe;\n}\n.l7-select-control--image .l7-select-control-item:nth-child(3n) {\n margin-right: 0;\n}\n.l7-select-control-item {\n cursor: pointer;\n}\n.l7-select-control-item input[type='checkbox'] {\n margin: 0;\n cursor: pointer;\n}\n.l7-select-control--multiple .l7-select-control-item:hover {\n background-color: transparent;\n}\n.l7-control-logo {\n width: 89px;\n height: 16px;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.l7-control-logo img {\n height: 100%;\n width: 100%;\n}\n.l7-control-logo .l7-control-logo-link {\n display: block;\n cursor: pointer;\n}\n.l7-control-logo .l7-control-logo-link img {\n cursor: pointer;\n}\n.l7-control-mouse-location {\n background-color: #fff;\n border-radius: 2px;\n -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n padding: 2px 4px;\n min-width: 130px;\n}\n.l7-control-zoom {\n -webkit-box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.15);\n border-radius: 2px;\n overflow: hidden;\n}\n.l7-control-zoom .l7-button-control {\n -webkit-box-shadow: 0 0 0;\n box-shadow: 0 0 0;\n border-radius: 0;\n font-size: 16px;\n}\n.l7-control-zoom .l7-button-control .l7-iconfont {\n width: 14px;\n height: 14px;\n}\n.l7-control-zoom .l7-button-control:first-child {\n border-bottom: 1px solid #f0f0f0;\n}\n.l7-control-scale {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.l7-control-scale .l7-control-scale-line {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: 2px 5px 1px;\n overflow: hidden;\n color: #595959;\n font-size: 10px;\n line-height: 1.1;\n white-space: nowrap;\n background: #fff;\n border: 2px solid #000;\n border-top: 0;\n -webkit-transition: width 0.1s;\n transition: width 0.1s;\n}\n.l7-control-scale .l7-control-scale-line + .l7-control-scale .l7-control-scale-line {\n margin-top: -2px;\n border-top: 2px solid #777;\n border-bottom: none;\n}\n.l7-right .l7-control-scale {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: end;\n -ms-flex-align: end;\n align-items: flex-end;\n}\n.l7-right .l7-control-scale .l7-control-scale-line {\n text-align: right;\n}\n.l7-popup {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 5;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n pointer-events: none;\n will-change: transform;\n}\n.l7-popup.l7-popup-hide {\n display: none;\n}\n.l7-popup .l7-popup-content {\n position: relative;\n padding: 16px;\n background: #fff;\n border-radius: 3px;\n -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);\n pointer-events: auto;\n font-size: 14px;\n}\n.l7-popup .l7-popup-content .l7-popup-content__title {\n font-weight: bold;\n margin-bottom: 8px;\n}\n.l7-popup .l7-popup-content .l7-popup-close-button {\n position: absolute;\n top: 0;\n right: 0;\n width: 18px;\n height: 18px;\n line-height: 18px;\n text-align: center;\n padding: 0;\n background-color: transparent;\n border: 0;\n border-radius: 0 3px 0 0;\n cursor: pointer;\n font-size: 14px;\n}\n.l7-popup .l7-popup-tip {\n z-index: 1;\n width: 0;\n height: 0;\n border: 10px solid transparent;\n}\n.l7-popup.l7-popup-anchor-bottom,\n.l7-popup.l7-popup-anchor-bottom-left,\n.l7-popup.l7-popup-anchor-bottom-right {\n -webkit-box-orient: vertical;\n -webkit-box-direction: reverse;\n -ms-flex-direction: column-reverse;\n flex-direction: column-reverse;\n}\n.l7-popup.l7-popup-anchor-top,\n.l7-popup.l7-popup-anchor-top-left,\n.l7-popup.l7-popup-anchor-top-right {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n.l7-popup.l7-popup-anchor-left {\n -webkit-box-orient: horizontal;\n -webkit-box-direction: normal;\n -ms-flex-direction: row;\n flex-direction: row;\n}\n.l7-popup.l7-popup-anchor-right {\n -webkit-box-orient: horizontal;\n -webkit-box-direction: reverse;\n -ms-flex-direction: row-reverse;\n flex-direction: row-reverse;\n}\n.l7-popup-anchor-top .l7-popup-tip {\n -webkit-align-self: center;\n -ms-flex-item-align: center;\n align-self: center;\n border-top: none;\n border-bottom-color: #fff;\n}\n.l7-popup-anchor-top-left .l7-popup-tip {\n -webkit-align-self: flex-start;\n -ms-flex-item-align: start;\n align-self: flex-start;\n border-top: none;\n border-bottom-color: #fff;\n border-left: none;\n}\n.l7-popup-anchor-top-right .l7-popup-tip {\n -webkit-align-self: flex-end;\n -ms-flex-item-align: end;\n align-self: flex-end;\n border-top: none;\n border-right: none;\n border-bottom-color: #fff;\n}\n.l7-popup-anchor-bottom .l7-popup-tip {\n -webkit-align-self: center;\n -ms-flex-item-align: center;\n align-self: center;\n border-top-color: #fff;\n border-bottom: none;\n}\n.l7-popup-anchor-bottom-left .l7-popup-tip {\n -webkit-align-self: flex-start;\n -ms-flex-item-align: start;\n align-self: flex-start;\n border-top-color: #fff;\n border-bottom: none;\n border-left: none;\n}\n.l7-popup-anchor-bottom-right .l7-popup-tip {\n -webkit-align-self: flex-end;\n -ms-flex-item-align: end;\n align-self: flex-end;\n border-top-color: #fff;\n border-right: none;\n border-bottom: none;\n}\n.l7-popup-anchor-left .l7-popup-tip {\n -webkit-align-self: center;\n -ms-flex-item-align: center;\n align-self: center;\n border-right-color: #fff;\n border-left: none;\n}\n.l7-popup-anchor-right .l7-popup-tip {\n -webkit-align-self: center;\n -ms-flex-item-align: center;\n align-self: center;\n border-right: none;\n border-left-color: #fff;\n}\n.l7-popup-anchor-top-left .l7-popup-content {\n border-top-left-radius: 0;\n}\n.l7-popup-anchor-top-right .l7-popup-content {\n border-top-right-radius: 0;\n}\n.l7-popup-anchor-bottom-left .l7-popup-content {\n border-bottom-left-radius: 0;\n}\n.l7-popup-anchor-bottom-right .l7-popup-content {\n border-bottom-right-radius: 0;\n}\n.l7-popup-track-pointer {\n display: none;\n}\n.l7-popup-track-pointer * {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n pointer-events: none;\n}\n.l7-map:hover .l7-popup-track-pointer {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n.l7-map:active .l7-popup-track-pointer {\n display: none;\n}\n.l7-layer-popup__row {\n font-size: 12px;\n}\n.l7-layer-popup__row + .l7-layer-popup__row {\n margin-top: 4px;\n}\n");
|
package/lib/interface.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _l7Core = require("@antv/l7-core");
|
|
27
|
+
|
|
28
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
30
|
+
var _eventemitter = require("eventemitter3");
|
|
31
|
+
|
|
32
|
+
var _lodash = require("lodash");
|
|
33
|
+
|
|
34
|
+
var _supercluster = _interopRequireDefault(require("supercluster/dist/supercluster"));
|
|
35
|
+
|
|
36
|
+
var _marker = _interopRequireDefault(require("./marker"));
|
|
37
|
+
|
|
38
|
+
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); }; }
|
|
39
|
+
|
|
40
|
+
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; } }
|
|
41
|
+
|
|
42
|
+
var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
43
|
+
(0, _inherits2.default)(MarkerLayer, _EventEmitter);
|
|
44
|
+
|
|
45
|
+
var _super = _createSuper(MarkerLayer);
|
|
46
|
+
|
|
47
|
+
function MarkerLayer(option) {
|
|
48
|
+
var _this$markerLayerOpti;
|
|
49
|
+
|
|
50
|
+
var _this;
|
|
51
|
+
|
|
52
|
+
(0, _classCallCheck2.default)(this, MarkerLayer);
|
|
53
|
+
_this = _super.call(this);
|
|
54
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "markers", []);
|
|
55
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "points", []);
|
|
56
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clusterMarkers", []);
|
|
57
|
+
_this.markerLayerOption = (0, _lodash.merge)(_this.getDefault(), option);
|
|
58
|
+
(0, _l7Utils.bindAll)(['update'], (0, _assertThisInitialized2.default)(_this));
|
|
59
|
+
_this.zoom = ((_this$markerLayerOpti = _this.markerLayerOption.clusterOption) === null || _this$markerLayerOpti === void 0 ? void 0 : _this$markerLayerOpti.zoom) || -99;
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
(0, _createClass2.default)(MarkerLayer, [{
|
|
64
|
+
key: "getDefault",
|
|
65
|
+
value: function getDefault() {
|
|
66
|
+
return {
|
|
67
|
+
cluster: false,
|
|
68
|
+
clusterOption: {
|
|
69
|
+
radius: 80,
|
|
70
|
+
maxZoom: 20,
|
|
71
|
+
minZoom: 0,
|
|
72
|
+
zoom: -99,
|
|
73
|
+
style: {},
|
|
74
|
+
className: ''
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
} // 执行scene.addMarkerLayer时调用
|
|
78
|
+
|
|
79
|
+
}, {
|
|
80
|
+
key: "addTo",
|
|
81
|
+
value: function addTo(scene) {
|
|
82
|
+
// this.remove();
|
|
83
|
+
this.scene = scene;
|
|
84
|
+
this.mapsService = scene.get(_l7Core.TYPES.IMapService);
|
|
85
|
+
|
|
86
|
+
if (this.markerLayerOption.cluster) {
|
|
87
|
+
this.initCluster();
|
|
88
|
+
this.update(); // 地图视野变化时,重新计算视野内的聚合点。
|
|
89
|
+
|
|
90
|
+
this.mapsService.on('camerachange', this.update); // amap1.x 更新事件
|
|
91
|
+
|
|
92
|
+
this.mapsService.on('viewchange', this.update); // amap2.0 更新事件
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.mapsService.on('camerachange', this.setContainerSize.bind(this)); // amap1.x 更新事件
|
|
96
|
+
|
|
97
|
+
this.mapsService.on('viewchange', this.setContainerSize.bind(this)); // amap2.0 更新事件
|
|
98
|
+
|
|
99
|
+
this.addMarkers();
|
|
100
|
+
return this;
|
|
101
|
+
} // 设置容器大小
|
|
102
|
+
|
|
103
|
+
}, {
|
|
104
|
+
key: "setContainerSize",
|
|
105
|
+
value: function setContainerSize() {
|
|
106
|
+
if (!this.mapsService) return;
|
|
107
|
+
var container = this.mapsService.getContainer();
|
|
108
|
+
this.containerSize = {
|
|
109
|
+
containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
|
|
110
|
+
containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
|
|
111
|
+
bounds: this.mapsService.getBounds()
|
|
112
|
+
};
|
|
113
|
+
} // 获取容器尺寸
|
|
114
|
+
|
|
115
|
+
}, {
|
|
116
|
+
key: "getContainerSize",
|
|
117
|
+
value: function getContainerSize() {
|
|
118
|
+
return this.containerSize;
|
|
119
|
+
} // 在图层添加单个marker
|
|
120
|
+
|
|
121
|
+
}, {
|
|
122
|
+
key: "addMarker",
|
|
123
|
+
value: function addMarker(marker) {
|
|
124
|
+
var cluster = this.markerLayerOption.cluster;
|
|
125
|
+
marker.getMarkerLayerContainerSize = this.getContainerSize.bind(this);
|
|
126
|
+
|
|
127
|
+
if (cluster) {
|
|
128
|
+
this.addPoint(marker, this.markers.length);
|
|
129
|
+
|
|
130
|
+
if (this.mapsService) {
|
|
131
|
+
// 在新增 marker 的时候需要更新聚合信息(哪怕此时的 zoom 没有发生变化)
|
|
132
|
+
var zoom = this.mapsService.getZoom();
|
|
133
|
+
var bbox = this.mapsService.getBounds();
|
|
134
|
+
this.bbox = (0, _l7Utils.padBounds)(bbox, 0.5);
|
|
135
|
+
this.zoom = Math.floor(zoom);
|
|
136
|
+
this.getClusterMarker(this.bbox, this.zoom);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.markers.push(marker);
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "removeMarker",
|
|
144
|
+
value: function removeMarker(marker) {
|
|
145
|
+
this.markers.indexOf(marker);
|
|
146
|
+
var markerIndex = this.markers.indexOf(marker);
|
|
147
|
+
|
|
148
|
+
if (markerIndex > -1) {
|
|
149
|
+
this.markers.splice(markerIndex, 1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 隐藏 marker 在每个 marker 上单独修改属性而不是在 markerContainer 上修改(在 markerContainer 修改会有用户在场景加载完之前调用失败的问题)
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
}, {
|
|
157
|
+
key: "hide",
|
|
158
|
+
value: function hide() {
|
|
159
|
+
this.markers.map(function (m) {
|
|
160
|
+
m.getElement().style.opacity = '0';
|
|
161
|
+
});
|
|
162
|
+
this.clusterMarkers.map(function (m) {
|
|
163
|
+
m.getElement().style.opacity = '0';
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 显示 marker
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
}, {
|
|
171
|
+
key: "show",
|
|
172
|
+
value: function show() {
|
|
173
|
+
this.markers.map(function (m) {
|
|
174
|
+
m.getElement().style.opacity = '1';
|
|
175
|
+
});
|
|
176
|
+
this.clusterMarkers.map(function (m) {
|
|
177
|
+
m.getElement().style.opacity = '1';
|
|
178
|
+
});
|
|
179
|
+
} // 返回当下的markers数据,有聚合图时返回聚合的marker列表,否则返回原始maerker列表
|
|
180
|
+
|
|
181
|
+
}, {
|
|
182
|
+
key: "getMarkers",
|
|
183
|
+
value: function getMarkers() {
|
|
184
|
+
var cluster = this.markerLayerOption.cluster;
|
|
185
|
+
return cluster ? this.clusterMarkers : this.markers;
|
|
186
|
+
} // 批量添加marker到scene
|
|
187
|
+
|
|
188
|
+
}, {
|
|
189
|
+
key: "addMarkers",
|
|
190
|
+
value: function addMarkers() {
|
|
191
|
+
var _this2 = this;
|
|
192
|
+
|
|
193
|
+
this.getMarkers().forEach(function (marker) {
|
|
194
|
+
marker.addTo(_this2.scene);
|
|
195
|
+
});
|
|
196
|
+
} // 清除图层里的marker
|
|
197
|
+
|
|
198
|
+
}, {
|
|
199
|
+
key: "clear",
|
|
200
|
+
value: function clear() {
|
|
201
|
+
this.markers.forEach(function (marker) {
|
|
202
|
+
marker.remove();
|
|
203
|
+
});
|
|
204
|
+
this.clusterMarkers.forEach(function (clusterMarker) {
|
|
205
|
+
clusterMarker.remove();
|
|
206
|
+
});
|
|
207
|
+
this.markers = [];
|
|
208
|
+
this.points = [];
|
|
209
|
+
this.clusterMarkers = [];
|
|
210
|
+
}
|
|
211
|
+
}, {
|
|
212
|
+
key: "destroy",
|
|
213
|
+
value: function destroy() {
|
|
214
|
+
this.clear();
|
|
215
|
+
this.removeAllListeners();
|
|
216
|
+
this.mapsService.off('camerachange', this.update);
|
|
217
|
+
this.mapsService.off('viewchange', this.update);
|
|
218
|
+
this.mapsService.off('camerachange', this.setContainerSize.bind(this));
|
|
219
|
+
this.mapsService.off('viewchange', this.setContainerSize.bind(this));
|
|
220
|
+
} // 将marker数据保存在point中
|
|
221
|
+
|
|
222
|
+
}, {
|
|
223
|
+
key: "addPoint",
|
|
224
|
+
value: function addPoint(marker, id) {
|
|
225
|
+
var _marker$getLnglat = marker.getLnglat(),
|
|
226
|
+
lng = _marker$getLnglat.lng,
|
|
227
|
+
lat = _marker$getLnglat.lat;
|
|
228
|
+
|
|
229
|
+
var feature = {
|
|
230
|
+
geometry: {
|
|
231
|
+
type: 'Point',
|
|
232
|
+
coordinates: [lng, lat]
|
|
233
|
+
},
|
|
234
|
+
properties: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, marker.getExtData()), {}, {
|
|
235
|
+
marker_id: id
|
|
236
|
+
})
|
|
237
|
+
};
|
|
238
|
+
this.points.push(feature);
|
|
239
|
+
|
|
240
|
+
if (this.clusterIndex) {
|
|
241
|
+
// 在新增点的时候需要更新 cluster 的数据
|
|
242
|
+
this.clusterIndex.load(this.points);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
key: "initCluster",
|
|
247
|
+
value: function initCluster() {
|
|
248
|
+
if (!this.markerLayerOption.cluster) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
var _this$markerLayerOpti2 = this.markerLayerOption.clusterOption,
|
|
253
|
+
radius = _this$markerLayerOpti2.radius,
|
|
254
|
+
_this$markerLayerOpti3 = _this$markerLayerOpti2.minZoom,
|
|
255
|
+
minZoom = _this$markerLayerOpti3 === void 0 ? 0 : _this$markerLayerOpti3,
|
|
256
|
+
maxZoom = _this$markerLayerOpti2.maxZoom;
|
|
257
|
+
this.clusterIndex = new _supercluster.default({
|
|
258
|
+
radius: radius,
|
|
259
|
+
minZoom: minZoom,
|
|
260
|
+
maxZoom: maxZoom
|
|
261
|
+
}); // @ts-ignore
|
|
262
|
+
|
|
263
|
+
this.clusterIndex.load(this.points);
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "getClusterMarker",
|
|
267
|
+
value: function getClusterMarker(viewBounds, zoom) {
|
|
268
|
+
var _this3 = this;
|
|
269
|
+
|
|
270
|
+
var viewBBox = viewBounds[0].concat(viewBounds[1]);
|
|
271
|
+
var clusterPoint = this.clusterIndex.getClusters(viewBBox, zoom);
|
|
272
|
+
this.clusterMarkers.forEach(function (marker) {
|
|
273
|
+
marker.remove();
|
|
274
|
+
});
|
|
275
|
+
this.clusterMarkers = [];
|
|
276
|
+
clusterPoint.forEach(function (feature) {
|
|
277
|
+
var _feature$properties;
|
|
278
|
+
|
|
279
|
+
var _this3$markerLayerOpt = _this3.markerLayerOption.clusterOption,
|
|
280
|
+
field = _this3$markerLayerOpt.field,
|
|
281
|
+
method = _this3$markerLayerOpt.method; // 处理聚合数据
|
|
282
|
+
|
|
283
|
+
if ((_feature$properties = feature.properties) !== null && _feature$properties !== void 0 && _feature$properties.cluster_id) {
|
|
284
|
+
var _feature$properties2;
|
|
285
|
+
|
|
286
|
+
var clusterData = _this3.getLeaves((_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2.cluster_id);
|
|
287
|
+
|
|
288
|
+
feature.properties.clusterData = clusterData;
|
|
289
|
+
|
|
290
|
+
if (field && method) {
|
|
291
|
+
var columnData = clusterData === null || clusterData === void 0 ? void 0 : clusterData.map(function (item) {
|
|
292
|
+
var data = (0, _defineProperty2.default)({}, field, item.properties[field]);
|
|
293
|
+
return data;
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
var column = _l7Utils.Satistics.getColumn(columnData, field);
|
|
297
|
+
|
|
298
|
+
var stat = _l7Utils.Satistics.getSatByColumn(method, column);
|
|
299
|
+
|
|
300
|
+
var fieldName = 'point_' + method;
|
|
301
|
+
feature.properties[fieldName] = stat.toFixed(2);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
var marker = _this3.clusterMarker(feature);
|
|
306
|
+
|
|
307
|
+
_this3.clusterMarkers.push(marker);
|
|
308
|
+
|
|
309
|
+
marker.addTo(_this3.scene);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}, {
|
|
313
|
+
key: "getLeaves",
|
|
314
|
+
value: function getLeaves(clusterId) {
|
|
315
|
+
var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
|
316
|
+
var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
317
|
+
|
|
318
|
+
if (!clusterId) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return this.clusterIndex.getLeaves(clusterId, limit, offset);
|
|
323
|
+
}
|
|
324
|
+
}, {
|
|
325
|
+
key: "clusterMarker",
|
|
326
|
+
value: function clusterMarker(feature) {
|
|
327
|
+
var clusterOption = this.markerLayerOption.clusterOption;
|
|
328
|
+
var _ref = clusterOption,
|
|
329
|
+
_ref$element = _ref.element,
|
|
330
|
+
element = _ref$element === void 0 ? this.generateElement.bind(this) : _ref$element;
|
|
331
|
+
var marker = new _marker.default({
|
|
332
|
+
element: element(feature)
|
|
333
|
+
}).setLnglat({
|
|
334
|
+
lng: feature.geometry.coordinates[0],
|
|
335
|
+
lat: feature.geometry.coordinates[1]
|
|
336
|
+
});
|
|
337
|
+
return marker;
|
|
338
|
+
}
|
|
339
|
+
}, {
|
|
340
|
+
key: "normalMarker",
|
|
341
|
+
value: function normalMarker(feature) {
|
|
342
|
+
var marker_id = feature.properties.marker_id;
|
|
343
|
+
return this.markers[marker_id];
|
|
344
|
+
}
|
|
345
|
+
}, {
|
|
346
|
+
key: "update",
|
|
347
|
+
value: function update() {
|
|
348
|
+
if (!this.mapsService) return; // 当图层中无marker时,无需更新
|
|
349
|
+
|
|
350
|
+
if (this.markers.length === 0) return;
|
|
351
|
+
var zoom = this.mapsService.getZoom();
|
|
352
|
+
var bbox = this.mapsService.getBounds();
|
|
353
|
+
|
|
354
|
+
if (!this.bbox || Math.abs(zoom - this.zoom) >= 1 || !(0, _l7Utils.boundsContains)(this.bbox, bbox)) {
|
|
355
|
+
this.bbox = (0, _l7Utils.padBounds)(bbox, 0.5);
|
|
356
|
+
this.zoom = Math.floor(zoom);
|
|
357
|
+
this.getClusterMarker(this.bbox, this.zoom);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}, {
|
|
361
|
+
key: "generateElement",
|
|
362
|
+
value: function generateElement(feature) {
|
|
363
|
+
var el = _l7Utils.DOM.create('div', 'l7-marker-cluster');
|
|
364
|
+
|
|
365
|
+
var label = _l7Utils.DOM.create('div', '', el);
|
|
366
|
+
|
|
367
|
+
var span = _l7Utils.DOM.create('span', '', label);
|
|
368
|
+
|
|
369
|
+
var _this$markerLayerOpti4 = this.markerLayerOption.clusterOption,
|
|
370
|
+
field = _this$markerLayerOpti4.field,
|
|
371
|
+
method = _this$markerLayerOpti4.method;
|
|
372
|
+
feature.properties.point_count = feature.properties.point_count || 1;
|
|
373
|
+
var text = field && method ? feature.properties['point_' + method] || feature.properties[field] : feature.properties.point_count;
|
|
374
|
+
span.textContent = text;
|
|
375
|
+
return el;
|
|
376
|
+
}
|
|
377
|
+
}]);
|
|
378
|
+
return MarkerLayer;
|
|
379
|
+
}(_eventemitter.EventEmitter);
|
|
380
|
+
|
|
381
|
+
exports.default = MarkerLayer;
|