@antv/l7-component 2.9.21 → 2.9.23
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/control/BaseControl.js +5 -26
- package/es/control/layer.js +13 -28
- package/es/control/logo.js +3 -4
- package/es/control/scale.js +6 -11
- package/es/control/zoom.js +3 -12
- package/es/css/l7.css +502 -0
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +1 -0
- package/es/images/logo.png +0 -0
- package/es/index.js +10 -10
- package/es/interface.js +1 -2
- package/es/marker-layer.js +27 -27
- package/es/marker.js +21 -27
- package/es/popup.js +16 -34
- package/es/utils/anchor.js +1 -2
- package/lib/control/BaseControl.js +100 -163
- package/lib/control/layer.js +248 -347
- package/lib/control/logo.js +52 -77
- package/lib/control/scale.js +112 -165
- package/lib/control/zoom.js +95 -143
- package/lib/css/l7.css +502 -0
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +1 -0
- package/lib/images/logo.png +0 -0
- package/lib/index.js +53 -135
- package/lib/interface.js +17 -2
- package/lib/marker-layer.js +224 -330
- package/lib/marker.js +271 -404
- package/lib/popup.js +201 -309
- package/lib/utils/anchor.js +54 -37
- package/package.json +9 -9
- package/es/control/BaseControl.js.map +0 -1
- package/es/control/layer.js.map +0 -1
- package/es/control/logo.js.map +0 -1
- package/es/control/scale.js.map +0 -1
- package/es/control/zoom.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/interface.js.map +0 -1
- package/es/marker-layer.js.map +0 -1
- package/es/marker.js.map +0 -1
- package/es/popup.js.map +0 -1
- package/es/utils/anchor.js.map +0 -1
- package/lib/control/BaseControl.js.map +0 -1
- package/lib/control/layer.js.map +0 -1
- package/lib/control/logo.js.map +0 -1
- package/lib/control/scale.js.map +0 -1
- package/lib/control/zoom.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface.js.map +0 -1
- package/lib/marker-layer.js.map +0 -1
- package/lib/marker.js.map +0 -1
- package/lib/popup.js.map +0 -1
- package/lib/utils/anchor.js.map +0 -1
package/lib/marker.js
CHANGED
|
@@ -1,435 +1,302 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/marker.ts
|
|
20
|
+
var marker_exports = {};
|
|
21
|
+
__export(marker_exports, {
|
|
22
|
+
default: () => Marker
|
|
7
23
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
-
|
|
34
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
35
|
-
|
|
36
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
-
|
|
38
|
-
var Marker = function (_EventEmitter) {
|
|
39
|
-
(0, _inherits2.default)(Marker, _EventEmitter);
|
|
40
|
-
|
|
41
|
-
var _super = _createSuper(Marker);
|
|
42
|
-
|
|
43
|
-
function Marker(option) {
|
|
44
|
-
var _this;
|
|
45
|
-
|
|
46
|
-
(0, _classCallCheck2.default)(this, Marker);
|
|
47
|
-
_this = _super.call(this);
|
|
48
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "markerOption", void 0);
|
|
49
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "defaultMarker", void 0);
|
|
50
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "popup", void 0);
|
|
51
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapsService", void 0);
|
|
52
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sceneSerive", void 0);
|
|
53
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "lngLat", void 0);
|
|
54
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "scene", void 0);
|
|
55
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "added", false);
|
|
56
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventHandle", function (e) {
|
|
57
|
-
_this.emit(e.type, {
|
|
24
|
+
module.exports = __toCommonJS(marker_exports);
|
|
25
|
+
var import_l7_core = require("@antv/l7-core");
|
|
26
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
27
|
+
var import_eventemitter3 = require("eventemitter3");
|
|
28
|
+
var Marker = class extends import_eventemitter3.EventEmitter {
|
|
29
|
+
constructor(option) {
|
|
30
|
+
super();
|
|
31
|
+
this.added = false;
|
|
32
|
+
this.eventHandle = (e) => {
|
|
33
|
+
this.emit(e.type, {
|
|
58
34
|
target: e,
|
|
59
|
-
data:
|
|
60
|
-
lngLat:
|
|
35
|
+
data: this.markerOption.extData,
|
|
36
|
+
lngLat: this.lngLat
|
|
61
37
|
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
38
|
+
};
|
|
39
|
+
this.markerOption = {
|
|
40
|
+
...this.getDefault(),
|
|
41
|
+
...option
|
|
42
|
+
};
|
|
43
|
+
(0, import_l7_utils.bindAll)(["update", "onMove", "onUp", "addDragHandler", "onMapClick"], this);
|
|
44
|
+
this.init();
|
|
69
45
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
value: function remove() {
|
|
103
|
-
if (this.mapsService) {
|
|
104
|
-
this.mapsService.off('click', this.onMapClick);
|
|
105
|
-
this.mapsService.off('move', this.update);
|
|
106
|
-
this.mapsService.off('moveend', this.update);
|
|
107
|
-
this.mapsService.off('mousedown', this.addDragHandler);
|
|
108
|
-
this.mapsService.off('touchstart', this.addDragHandler);
|
|
109
|
-
this.mapsService.off('mouseup', this.onUp);
|
|
110
|
-
this.mapsService.off('touchend', this.onUp);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
this.unRegisterMarkerEvent();
|
|
114
|
-
this.removeAllListeners();
|
|
115
|
-
var element = this.markerOption.element;
|
|
116
|
-
|
|
117
|
-
if (element) {
|
|
118
|
-
_l7Utils.DOM.remove(element);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (this.popup) {
|
|
122
|
-
this.popup.remove();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return this;
|
|
46
|
+
getDefault() {
|
|
47
|
+
return {
|
|
48
|
+
element: void 0,
|
|
49
|
+
anchor: import_l7_utils.anchorType.BOTTOM,
|
|
50
|
+
offsets: [0, 0],
|
|
51
|
+
color: "#5B8FF9",
|
|
52
|
+
draggable: false
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
addTo(scene) {
|
|
56
|
+
this.scene = scene;
|
|
57
|
+
this.mapsService = scene.get(import_l7_core.TYPES.IMapService);
|
|
58
|
+
this.sceneSerive = scene.get(import_l7_core.TYPES.ISceneService);
|
|
59
|
+
const { element, draggable } = this.markerOption;
|
|
60
|
+
this.mapsService.getMarkerContainer().appendChild(element);
|
|
61
|
+
this.registerMarkerEvent(element);
|
|
62
|
+
this.mapsService.on("camerachange", this.update);
|
|
63
|
+
this.mapsService.on("viewchange", this.update);
|
|
64
|
+
this.update();
|
|
65
|
+
this.added = true;
|
|
66
|
+
this.emit("added");
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
remove() {
|
|
70
|
+
if (this.mapsService) {
|
|
71
|
+
this.mapsService.off("click", this.onMapClick);
|
|
72
|
+
this.mapsService.off("move", this.update);
|
|
73
|
+
this.mapsService.off("moveend", this.update);
|
|
74
|
+
this.mapsService.off("mousedown", this.addDragHandler);
|
|
75
|
+
this.mapsService.off("touchstart", this.addDragHandler);
|
|
76
|
+
this.mapsService.off("mouseup", this.onUp);
|
|
77
|
+
this.mapsService.off("touchend", this.onUp);
|
|
126
78
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (Array.isArray(lngLat)) {
|
|
133
|
-
this.lngLat = {
|
|
134
|
-
lng: lngLat[0],
|
|
135
|
-
lat: lngLat[1]
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (this.popup) {
|
|
140
|
-
this.popup.setLnglat(this.lngLat);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
this.update();
|
|
144
|
-
return this;
|
|
79
|
+
this.unRegisterMarkerEvent();
|
|
80
|
+
this.removeAllListeners();
|
|
81
|
+
const { element } = this.markerOption;
|
|
82
|
+
if (element) {
|
|
83
|
+
import_l7_utils.DOM.remove(element);
|
|
145
84
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
value: function getLnglat() {
|
|
149
|
-
return this.lngLat;
|
|
85
|
+
if (this.popup) {
|
|
86
|
+
this.popup.remove();
|
|
150
87
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
setLnglat(lngLat) {
|
|
91
|
+
this.lngLat = lngLat;
|
|
92
|
+
if (Array.isArray(lngLat)) {
|
|
93
|
+
this.lngLat = {
|
|
94
|
+
lng: lngLat[0],
|
|
95
|
+
lat: lngLat[1]
|
|
96
|
+
};
|
|
155
97
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
value: function setElement(el) {
|
|
159
|
-
var _this2 = this;
|
|
160
|
-
|
|
161
|
-
if (!this.added) {
|
|
162
|
-
this.once('added', function () {
|
|
163
|
-
_this2.setElement(el);
|
|
164
|
-
});
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
var element = this.markerOption.element;
|
|
169
|
-
|
|
170
|
-
if (element) {
|
|
171
|
-
_l7Utils.DOM.remove(element);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
this.markerOption.element = el;
|
|
175
|
-
this.init();
|
|
176
|
-
this.mapsService.getMarkerContainer().appendChild(el);
|
|
177
|
-
this.registerMarkerEvent(el);
|
|
178
|
-
this.update();
|
|
179
|
-
return this;
|
|
98
|
+
if (this.popup) {
|
|
99
|
+
this.popup.setLnglat(this.lngLat);
|
|
180
100
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (!popup) {
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (!popup.isOpen()) {
|
|
200
|
-
popup.addTo(this.scene);
|
|
201
|
-
}
|
|
202
|
-
|
|
101
|
+
this.update();
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
getLnglat() {
|
|
105
|
+
return this.lngLat;
|
|
106
|
+
}
|
|
107
|
+
getElement() {
|
|
108
|
+
return this.markerOption.element;
|
|
109
|
+
}
|
|
110
|
+
setElement(el) {
|
|
111
|
+
if (!this.added) {
|
|
112
|
+
this.once("added", () => {
|
|
113
|
+
this.setElement(el);
|
|
114
|
+
});
|
|
203
115
|
return this;
|
|
204
116
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
var _this4 = this;
|
|
209
|
-
|
|
210
|
-
if (!this.added) {
|
|
211
|
-
this.once('added', function () {
|
|
212
|
-
_this4.closePopup();
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
var popup = this.popup;
|
|
217
|
-
|
|
218
|
-
if (popup) {
|
|
219
|
-
popup.remove();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return this;
|
|
117
|
+
const { element } = this.markerOption;
|
|
118
|
+
if (element) {
|
|
119
|
+
import_l7_utils.DOM.remove(element);
|
|
223
120
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
121
|
+
this.markerOption.element = el;
|
|
122
|
+
this.init();
|
|
123
|
+
this.mapsService.getMarkerContainer().appendChild(el);
|
|
124
|
+
this.registerMarkerEvent(el);
|
|
125
|
+
this.update();
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
openPopup() {
|
|
129
|
+
if (!this.added) {
|
|
130
|
+
this.once("added", () => {
|
|
131
|
+
this.openPopup();
|
|
132
|
+
});
|
|
233
133
|
return this;
|
|
234
134
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
value: function togglePopup() {
|
|
238
|
-
var popup = this.popup;
|
|
239
|
-
|
|
240
|
-
if (!popup) {
|
|
241
|
-
return this;
|
|
242
|
-
} else if (popup.isOpen()) {
|
|
243
|
-
popup.remove();
|
|
244
|
-
} else {
|
|
245
|
-
popup.addTo(this.scene);
|
|
246
|
-
}
|
|
247
|
-
|
|
135
|
+
const popup = this.popup;
|
|
136
|
+
if (!popup) {
|
|
248
137
|
return this;
|
|
249
138
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
value: function getPopup() {
|
|
253
|
-
return this.popup;
|
|
139
|
+
if (!popup.isOpen()) {
|
|
140
|
+
popup.addTo(this.scene);
|
|
254
141
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
closePopup() {
|
|
145
|
+
if (!this.added) {
|
|
146
|
+
this.once("added", () => {
|
|
147
|
+
this.closePopup();
|
|
148
|
+
});
|
|
259
149
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
throw new Error('Method not implemented.');
|
|
150
|
+
const popup = this.popup;
|
|
151
|
+
if (popup) {
|
|
152
|
+
popup.remove();
|
|
264
153
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
setPopup(popup) {
|
|
157
|
+
this.popup = popup;
|
|
158
|
+
if (this.lngLat) {
|
|
159
|
+
this.popup.setLnglat(this.lngLat);
|
|
269
160
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
togglePopup() {
|
|
164
|
+
const popup = this.popup;
|
|
165
|
+
if (!popup) {
|
|
166
|
+
return this;
|
|
167
|
+
} else if (popup.isOpen()) {
|
|
168
|
+
popup.remove();
|
|
169
|
+
} else {
|
|
170
|
+
popup.addTo(this.scene);
|
|
274
171
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
getPopup() {
|
|
175
|
+
return this.popup;
|
|
176
|
+
}
|
|
177
|
+
getOffset() {
|
|
178
|
+
return this.markerOption.offsets;
|
|
179
|
+
}
|
|
180
|
+
setDraggable(draggable) {
|
|
181
|
+
throw new Error("Method not implemented.");
|
|
182
|
+
}
|
|
183
|
+
isDraggable() {
|
|
184
|
+
return this.markerOption.draggable;
|
|
185
|
+
}
|
|
186
|
+
getExtData() {
|
|
187
|
+
return this.markerOption.extData;
|
|
188
|
+
}
|
|
189
|
+
setExtData(data) {
|
|
190
|
+
this.markerOption.extData = data;
|
|
191
|
+
}
|
|
192
|
+
update() {
|
|
193
|
+
if (!this.mapsService) {
|
|
194
|
+
return;
|
|
279
195
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
element = _this$markerOption2.element,
|
|
289
|
-
anchor = _this$markerOption2.anchor;
|
|
290
|
-
this.updatePosition();
|
|
291
|
-
|
|
292
|
-
_l7Utils.DOM.setTransform(element, "".concat(_l7Utils.anchorTranslate[anchor]));
|
|
196
|
+
const { element, anchor } = this.markerOption;
|
|
197
|
+
this.updatePosition();
|
|
198
|
+
import_l7_utils.DOM.setTransform(element, `${import_l7_utils.anchorTranslate[anchor]}`);
|
|
199
|
+
}
|
|
200
|
+
onMapClick(e) {
|
|
201
|
+
const { element } = this.markerOption;
|
|
202
|
+
if (this.popup && element) {
|
|
203
|
+
this.togglePopup();
|
|
293
204
|
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (this.popup && element) {
|
|
300
|
-
this.togglePopup();
|
|
301
|
-
}
|
|
205
|
+
}
|
|
206
|
+
updatePosition() {
|
|
207
|
+
if (!this.mapsService) {
|
|
208
|
+
return;
|
|
302
209
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
210
|
+
const { element, offsets } = this.markerOption;
|
|
211
|
+
const { lng, lat } = this.lngLat;
|
|
212
|
+
const bounds = this.mapsService.getBounds();
|
|
213
|
+
const pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
214
|
+
if (element) {
|
|
215
|
+
element.style.display = "block";
|
|
216
|
+
element.style.whiteSpace = "nowrap";
|
|
217
|
+
const container = this.mapsService.getContainer();
|
|
218
|
+
let containerWidth = 0;
|
|
219
|
+
let containerHeight = 0;
|
|
220
|
+
if (container) {
|
|
221
|
+
containerWidth = container.scrollWidth;
|
|
222
|
+
containerHeight = container.scrollHeight;
|
|
308
223
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
var _this$lngLat = this.lngLat,
|
|
314
|
-
lng = _this$lngLat.lng,
|
|
315
|
-
lat = _this$lngLat.lat;
|
|
316
|
-
var bounds = this.mapsService.getBounds();
|
|
317
|
-
var pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
318
|
-
|
|
319
|
-
if (element) {
|
|
320
|
-
element.style.display = 'block';
|
|
321
|
-
element.style.whiteSpace = 'nowrap';
|
|
322
|
-
var container = this.mapsService.getContainer();
|
|
323
|
-
var containerWidth = 0;
|
|
324
|
-
var containerHeight = 0;
|
|
325
|
-
|
|
326
|
-
if (container) {
|
|
327
|
-
containerWidth = container.scrollWidth;
|
|
328
|
-
containerHeight = container.scrollHeight;
|
|
224
|
+
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
|
225
|
+
if (pos.x > containerWidth) {
|
|
226
|
+
const newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
|
|
227
|
+
pos.x = newPos.x;
|
|
329
228
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
|
|
334
|
-
pos.x = newPos.x;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (pos.x < 0) {
|
|
338
|
-
var _newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
|
|
339
|
-
|
|
340
|
-
pos.x = _newPos.x;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
|
|
345
|
-
element.style.display = 'none';
|
|
229
|
+
if (pos.x < 0) {
|
|
230
|
+
const newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
|
|
231
|
+
pos.x = newPos.x;
|
|
346
232
|
}
|
|
347
|
-
|
|
348
|
-
element.style.left = pos.x + offsets[0] + 'px';
|
|
349
|
-
element.style.top = pos.y - offsets[1] + 'px';
|
|
350
233
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
key: "init",
|
|
354
|
-
value: function init() {
|
|
355
|
-
var _this5 = this;
|
|
356
|
-
|
|
357
|
-
var element = this.markerOption.element;
|
|
358
|
-
var _this$markerOption4 = this.markerOption,
|
|
359
|
-
color = _this$markerOption4.color,
|
|
360
|
-
anchor = _this$markerOption4.anchor;
|
|
361
|
-
|
|
362
|
-
if (!element) {
|
|
363
|
-
this.defaultMarker = true;
|
|
364
|
-
element = _l7Utils.DOM.create('div');
|
|
365
|
-
this.markerOption.element = element;
|
|
366
|
-
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
367
|
-
svg.setAttributeNS(null, 'display', 'block');
|
|
368
|
-
svg.setAttributeNS(null, 'height', '48px');
|
|
369
|
-
svg.setAttributeNS(null, 'width', '48px');
|
|
370
|
-
svg.setAttributeNS(null, 'viewBox', '0 0 1024 1024');
|
|
371
|
-
var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
372
|
-
path.setAttributeNS(null, 'd', 'M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z');
|
|
373
|
-
path.setAttributeNS(null, 'fill', color);
|
|
374
|
-
svg.appendChild(path);
|
|
375
|
-
element.appendChild(svg);
|
|
234
|
+
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
|
|
235
|
+
element.style.display = "none";
|
|
376
236
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
Object.keys(this.markerOption.style || {}).forEach(function (key) {
|
|
381
|
-
var _this5$markerOption, _this5$markerOption2;
|
|
382
|
-
|
|
383
|
-
var value = ((_this5$markerOption = _this5.markerOption) === null || _this5$markerOption === void 0 ? void 0 : _this5$markerOption.style) && ((_this5$markerOption2 = _this5.markerOption) === null || _this5$markerOption2 === void 0 ? void 0 : _this5$markerOption2.style[key]);
|
|
384
|
-
|
|
385
|
-
if (element) {
|
|
386
|
-
element.style[key] = value;
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
element.addEventListener('click', function (e) {
|
|
390
|
-
_this5.onMapClick(e);
|
|
391
|
-
});
|
|
392
|
-
element.addEventListener('click', this.eventHandle);
|
|
393
|
-
(0, _l7Utils.applyAnchorClass)(element, anchor, 'marker');
|
|
394
|
-
}
|
|
395
|
-
}, {
|
|
396
|
-
key: "registerMarkerEvent",
|
|
397
|
-
value: function registerMarkerEvent(element) {
|
|
398
|
-
element.addEventListener('mousemove', this.eventHandle);
|
|
399
|
-
element.addEventListener('click', this.eventHandle);
|
|
400
|
-
element.addEventListener('mousedown', this.eventHandle);
|
|
401
|
-
element.addEventListener('mouseup', this.eventHandle);
|
|
402
|
-
element.addEventListener('dblclick', this.eventHandle);
|
|
403
|
-
element.addEventListener('contextmenu', this.eventHandle);
|
|
404
|
-
element.addEventListener('mouseover', this.eventHandle);
|
|
405
|
-
element.addEventListener('mouseout', this.eventHandle);
|
|
406
|
-
}
|
|
407
|
-
}, {
|
|
408
|
-
key: "unRegisterMarkerEvent",
|
|
409
|
-
value: function unRegisterMarkerEvent() {
|
|
410
|
-
var element = this.getElement();
|
|
411
|
-
element.removeEventListener('mousemove', this.eventHandle);
|
|
412
|
-
element.removeEventListener('click', this.eventHandle);
|
|
413
|
-
element.removeEventListener('mousedown', this.eventHandle);
|
|
414
|
-
element.removeEventListener('mouseup', this.eventHandle);
|
|
415
|
-
element.removeEventListener('dblclick', this.eventHandle);
|
|
416
|
-
element.removeEventListener('contextmenu', this.eventHandle);
|
|
417
|
-
element.removeEventListener('mouseover', this.eventHandle);
|
|
418
|
-
element.removeEventListener('mouseout', this.eventHandle);
|
|
237
|
+
element.style.left = pos.x + offsets[0] + "px";
|
|
238
|
+
element.style.top = pos.y - offsets[1] + "px";
|
|
419
239
|
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
240
|
+
}
|
|
241
|
+
init() {
|
|
242
|
+
let { element } = this.markerOption;
|
|
243
|
+
const { color, anchor } = this.markerOption;
|
|
244
|
+
if (!element) {
|
|
245
|
+
this.defaultMarker = true;
|
|
246
|
+
element = import_l7_utils.DOM.create("div");
|
|
247
|
+
this.markerOption.element = element;
|
|
248
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
249
|
+
svg.setAttributeNS(null, "display", "block");
|
|
250
|
+
svg.setAttributeNS(null, "height", "48px");
|
|
251
|
+
svg.setAttributeNS(null, "width", "48px");
|
|
252
|
+
svg.setAttributeNS(null, "viewBox", "0 0 1024 1024");
|
|
253
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
254
|
+
path.setAttributeNS(null, "d", "M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z");
|
|
255
|
+
path.setAttributeNS(null, "fill", color);
|
|
256
|
+
svg.appendChild(path);
|
|
257
|
+
element.appendChild(svg);
|
|
429
258
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
259
|
+
import_l7_utils.DOM.addClass(element, "l7-marker");
|
|
260
|
+
Object.keys(this.markerOption.style || {}).forEach((key) => {
|
|
261
|
+
var _a, _b;
|
|
262
|
+
const value = ((_a = this.markerOption) == null ? void 0 : _a.style) && ((_b = this.markerOption) == null ? void 0 : _b.style[key]);
|
|
263
|
+
if (element) {
|
|
264
|
+
element.style[key] = value;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
element.addEventListener("click", (e) => {
|
|
268
|
+
this.onMapClick(e);
|
|
269
|
+
});
|
|
270
|
+
element.addEventListener("click", this.eventHandle);
|
|
271
|
+
(0, import_l7_utils.applyAnchorClass)(element, anchor, "marker");
|
|
272
|
+
}
|
|
273
|
+
registerMarkerEvent(element) {
|
|
274
|
+
element.addEventListener("mousemove", this.eventHandle);
|
|
275
|
+
element.addEventListener("click", this.eventHandle);
|
|
276
|
+
element.addEventListener("mousedown", this.eventHandle);
|
|
277
|
+
element.addEventListener("mouseup", this.eventHandle);
|
|
278
|
+
element.addEventListener("dblclick", this.eventHandle);
|
|
279
|
+
element.addEventListener("contextmenu", this.eventHandle);
|
|
280
|
+
element.addEventListener("mouseover", this.eventHandle);
|
|
281
|
+
element.addEventListener("mouseout", this.eventHandle);
|
|
282
|
+
}
|
|
283
|
+
unRegisterMarkerEvent() {
|
|
284
|
+
const element = this.getElement();
|
|
285
|
+
element.removeEventListener("mousemove", this.eventHandle);
|
|
286
|
+
element.removeEventListener("click", this.eventHandle);
|
|
287
|
+
element.removeEventListener("mousedown", this.eventHandle);
|
|
288
|
+
element.removeEventListener("mouseup", this.eventHandle);
|
|
289
|
+
element.removeEventListener("dblclick", this.eventHandle);
|
|
290
|
+
element.removeEventListener("contextmenu", this.eventHandle);
|
|
291
|
+
element.removeEventListener("mouseover", this.eventHandle);
|
|
292
|
+
element.removeEventListener("mouseout", this.eventHandle);
|
|
293
|
+
}
|
|
294
|
+
addDragHandler(e) {
|
|
295
|
+
throw new Error("Method not implemented.");
|
|
296
|
+
}
|
|
297
|
+
onUp(e) {
|
|
298
|
+
throw new Error("Method not implemented.");
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
302
|
+
0 && (module.exports = {});
|