@antv/l7-map 2.17.11 → 2.18.0
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/camera.js +2 -1
- package/es/earthmap.js +2 -3
- package/es/geo/transform.js +1 -6
- package/es/handler/events/event.js +2 -1
- package/es/handler/events/map_mouse_event.js +2 -1
- package/es/handler/handler_inertia.js +2 -1
- package/es/handler/handler_manager.js +49 -64
- package/es/handler/shim/drag_pan.js +2 -7
- package/es/handler/shim/touch_zoom_rotate.js +2 -7
- package/es/hash.js +4 -4
- package/es/map.js +14 -29
- package/es/util.d.ts +3 -3
- package/es/util.js +10 -15
- package/es/utils/dom.js +23 -67
- package/es/utils/performance.js +1 -2
- package/lib/camera.js +12 -11
- package/lib/earthmap.js +2 -3
- package/lib/geo/transform.js +1 -6
- package/lib/handler/events/event.js +4 -2
- package/lib/handler/events/map_mouse_event.js +3 -2
- package/lib/handler/handler_inertia.js +8 -7
- package/lib/handler/handler_manager.js +51 -66
- package/lib/handler/shim/drag_pan.js +2 -7
- package/lib/handler/shim/touch_zoom_rotate.js +2 -7
- package/lib/hash.js +5 -4
- package/lib/map.js +15 -30
- package/lib/util.js +10 -15
- package/lib/utils/dom.js +23 -67
- package/lib/utils/performance.js +1 -2
- package/package.json +4 -4
package/es/camera.js
CHANGED
|
@@ -8,14 +8,15 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
8
8
|
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); }; }
|
|
9
9
|
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; } }
|
|
10
10
|
// @ts-ignore
|
|
11
|
+
import { lodashUtil } from '@antv/l7-utils';
|
|
11
12
|
import { EventEmitter } from 'eventemitter3';
|
|
12
|
-
import { merge } from 'lodash';
|
|
13
13
|
import LngLat from "./geo/lng_lat";
|
|
14
14
|
import LngLatBounds from "./geo/lng_lat_bounds";
|
|
15
15
|
import Point from "./geo/point";
|
|
16
16
|
import Transform from "./geo/transform";
|
|
17
17
|
import { Event } from "./handler/events/event";
|
|
18
18
|
import { clamp, ease as defaultEasing, extend, interpolate, now, pick, prefersReducedMotion, wrap } from "./util";
|
|
19
|
+
var merge = lodashUtil.merge;
|
|
19
20
|
var Camera = /*#__PURE__*/function (_EventEmitter) {
|
|
20
21
|
_inherits(Camera, _EventEmitter);
|
|
21
22
|
var _super = _createSuper(Camera);
|
package/es/earthmap.js
CHANGED
|
@@ -7,8 +7,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
8
|
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); }; }
|
|
9
9
|
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; } }
|
|
10
|
-
import { DOM } from '@antv/l7-utils';
|
|
11
|
-
import { merge } from 'lodash';
|
|
10
|
+
import { DOM, lodashUtil } from '@antv/l7-utils';
|
|
12
11
|
import Camera from "./camera";
|
|
13
12
|
function loadStyles(css, doc) {
|
|
14
13
|
var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
|
|
@@ -51,7 +50,7 @@ import { PerformanceUtils } from "./utils/performance";
|
|
|
51
50
|
import TaskQueue from "./utils/task_queue";
|
|
52
51
|
var defaultMinZoom = -2;
|
|
53
52
|
var defaultMaxZoom = 22;
|
|
54
|
-
|
|
53
|
+
var merge = lodashUtil.merge;
|
|
55
54
|
// the default values, but also the valid range
|
|
56
55
|
var defaultMinPitch = 0;
|
|
57
56
|
var defaultMaxPitch = 60;
|
package/es/geo/transform.js
CHANGED
|
@@ -4,7 +4,6 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
4
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
6
|
// @ts-ignore
|
|
7
|
-
import { isMini } from '@antv/l7-utils';
|
|
8
7
|
import { mat2, mat4, vec4 } from 'gl-matrix';
|
|
9
8
|
import Point from "../geo/point";
|
|
10
9
|
import { clamp, interpolate, wrap } from "../util";
|
|
@@ -799,11 +798,7 @@ var Transform = /*#__PURE__*/function () {
|
|
|
799
798
|
var s = Math.max(sx || 0, sy || 0);
|
|
800
799
|
if (s) {
|
|
801
800
|
this.center = this.unproject(new Point(sx ? (maxX + minX) / 2 : point.x, sy ? (maxY + minY) / 2 : point.y));
|
|
802
|
-
|
|
803
|
-
this.zoom = Math.max(this.zoom, Math.max(-1, this.minZoom));
|
|
804
|
-
} else {
|
|
805
|
-
this.zoom += this.scaleZoom(s);
|
|
806
|
-
}
|
|
801
|
+
this.zoom += this.scaleZoom(s);
|
|
807
802
|
this.unmodified = unmodified;
|
|
808
803
|
this.constraining = false;
|
|
809
804
|
return;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
3
|
// tslint:disable-next-line:no-submodule-imports
|
|
4
|
-
import
|
|
4
|
+
import { lodashUtil } from '@antv/l7-utils';
|
|
5
|
+
var merge = lodashUtil.merge;
|
|
5
6
|
export var Event = /*#__PURE__*/_createClass(function Event(type) {
|
|
6
7
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7
8
|
_classCallCheck(this, Event);
|
|
@@ -7,9 +7,10 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
7
7
|
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; } }
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
// tslint:disable-next-line:no-submodule-imports
|
|
10
|
-
import
|
|
10
|
+
import { lodashUtil } from '@antv/l7-utils';
|
|
11
11
|
import DOM from "../../utils/dom";
|
|
12
12
|
import { Event } from "./event";
|
|
13
|
+
var merge = lodashUtil.merge;
|
|
13
14
|
var MapMouseEvent = /*#__PURE__*/function (_Event) {
|
|
14
15
|
_inherits(MapMouseEvent, _Event);
|
|
15
16
|
var _super = _createSuper(MapMouseEvent);
|
|
@@ -7,8 +7,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
7
7
|
import Point from "../geo/point";
|
|
8
8
|
|
|
9
9
|
// tslint:disable-next-line:no-submodule-imports
|
|
10
|
-
import
|
|
10
|
+
import { lodashUtil } from '@antv/l7-utils';
|
|
11
11
|
import { bezier, clamp, now } from "../util";
|
|
12
|
+
var merge = lodashUtil.merge;
|
|
12
13
|
var defaultInertiaOptions = {
|
|
13
14
|
linearity: 0.3,
|
|
14
15
|
easing: bezier(0, 0, 0.3, 1)
|
|
@@ -7,8 +7,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
7
7
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
// tslint:disable-next-line: no-submodule-imports
|
|
10
|
-
import {
|
|
11
|
-
import { merge } from 'lodash';
|
|
10
|
+
import { lodashUtil } from '@antv/l7-utils';
|
|
12
11
|
import Point from "../geo/point";
|
|
13
12
|
import DOM from "../utils/dom";
|
|
14
13
|
import BlockableMapEventHandler from "./blockable_map_event";
|
|
@@ -28,6 +27,7 @@ import TouchZoomRotateHandler from "./shim/touch_zoom_rotate";
|
|
|
28
27
|
import TapDragZoomHandler from "./tap/tap_drag_zoom";
|
|
29
28
|
import TapZoomHandler from "./tap/tap_zoom";
|
|
30
29
|
import { TouchPanHandler, TouchPitchHandler, TouchRotateHandler, TouchZoomHandler } from "./touch";
|
|
30
|
+
var merge = lodashUtil.merge;
|
|
31
31
|
var _isMoving = function isMoving(p) {
|
|
32
32
|
return p.zoom || p.drag || p.pitch || p.rotate;
|
|
33
33
|
};
|
|
@@ -139,67 +139,52 @@ var HandlerManager = /*#__PURE__*/function () {
|
|
|
139
139
|
this.addDefaultHandlers(options);
|
|
140
140
|
var el = this.el;
|
|
141
141
|
this.listeners = [];
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
_iterator2.f();
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
$window.document.addEventListener('touchstart', function (e) {
|
|
192
|
-
_this.handleEvent(e);
|
|
193
|
-
}, {});
|
|
194
|
-
$window.document.addEventListener('touchmove', function (e) {
|
|
195
|
-
_this.handleEvent(e);
|
|
196
|
-
}, {});
|
|
197
|
-
$window.document.addEventListener('touchend', function (e) {
|
|
198
|
-
_this.handleEvent(e);
|
|
199
|
-
}, {});
|
|
200
|
-
$window.document.addEventListener('touchcancel', function (e) {
|
|
201
|
-
_this.handleEvent(e);
|
|
202
|
-
}, {});
|
|
142
|
+
// l7 - mini
|
|
143
|
+
this.listeners = [
|
|
144
|
+
// Bind touchstart and touchmove with passive: false because, even though
|
|
145
|
+
// they only fire a map events and therefore could theoretically be
|
|
146
|
+
// passive, binding with passive: true causes iOS not to respect
|
|
147
|
+
// e.preventDefault() in _other_ handlers, even if they are non-passive
|
|
148
|
+
// (see https://bugs.webkit.org/show_bug.cgi?id=184251)
|
|
149
|
+
[el, 'touchstart', {
|
|
150
|
+
passive: false
|
|
151
|
+
}], [el, 'touchmove', {
|
|
152
|
+
passive: false
|
|
153
|
+
}], [el, 'touchend', undefined], [el, 'touchcancel', undefined], [el, 'mousedown', undefined], [el, 'mousemove', undefined], [el, 'mouseup', undefined],
|
|
154
|
+
// Bind window-level event listeners for move and up/end events. In the absence of
|
|
155
|
+
// the pointer capture API, which is not supported by all necessary platforms,
|
|
156
|
+
// window-level event listeners give us the best shot at capturing events that
|
|
157
|
+
// fall outside the map canvas element. Use `{capture: true}` for the move event
|
|
158
|
+
// to prevent map move events from being fired during a drag.
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
[window.document, 'mousemove', {
|
|
161
|
+
capture: true
|
|
162
|
+
}],
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
[window.document, 'mouseup', undefined], [el, 'mouseover', undefined], [el, 'mouseout', undefined], [el, 'dblclick', undefined], [el, 'click', undefined], [el, 'keydown', {
|
|
165
|
+
capture: false
|
|
166
|
+
}], [el, 'keyup', undefined], [el, 'wheel', {
|
|
167
|
+
passive: false
|
|
168
|
+
}], [el, 'contextmenu', undefined],
|
|
169
|
+
// @ts-ignore
|
|
170
|
+
[window, 'blur', undefined]];
|
|
171
|
+
var _iterator2 = _createForOfIteratorHelper(this.listeners),
|
|
172
|
+
_step2;
|
|
173
|
+
try {
|
|
174
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
175
|
+
var _step2$value = _slicedToArray(_step2.value, 3),
|
|
176
|
+
target = _step2$value[0],
|
|
177
|
+
type = _step2$value[1],
|
|
178
|
+
listenerOptions = _step2$value[2];
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
DOM.addEventListener(target, type,
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
target === window.document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
|
|
183
|
+
}
|
|
184
|
+
} catch (err) {
|
|
185
|
+
_iterator2.e(err);
|
|
186
|
+
} finally {
|
|
187
|
+
_iterator2.f();
|
|
203
188
|
}
|
|
204
189
|
}
|
|
205
190
|
_createClass(HandlerManager, [{
|
|
@@ -401,7 +386,7 @@ var HandlerManager = /*#__PURE__*/function () {
|
|
|
401
386
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
402
387
|
var t = _step6.value;
|
|
403
388
|
var target = t.target;
|
|
404
|
-
if (
|
|
389
|
+
if (this.el.contains(target)) {
|
|
405
390
|
mapTouches.push(t);
|
|
406
391
|
}
|
|
407
392
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import { isMini } from '@antv/l7-utils';
|
|
4
3
|
/**
|
|
5
4
|
* The `DragPanHandler` allows the user to pan the map by clicking and dragging
|
|
6
5
|
* the cursor.
|
|
@@ -41,9 +40,7 @@ var DragPanHandler = /*#__PURE__*/function () {
|
|
|
41
40
|
this.inertiaOptions = options || {};
|
|
42
41
|
this.mousePan.enable();
|
|
43
42
|
this.touchPan.enable();
|
|
44
|
-
|
|
45
|
-
this.el.classList.add('l7-touch-drag-pan');
|
|
46
|
-
}
|
|
43
|
+
this.el.classList.add('l7-touch-drag-pan');
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
@@ -57,9 +54,7 @@ var DragPanHandler = /*#__PURE__*/function () {
|
|
|
57
54
|
value: function disable() {
|
|
58
55
|
this.mousePan.disable();
|
|
59
56
|
this.touchPan.disable();
|
|
60
|
-
|
|
61
|
-
this.el.classList.remove('l7-touch-drag-pan');
|
|
62
|
-
}
|
|
57
|
+
this.el.classList.remove('l7-touch-drag-pan');
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
/**
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import { isMini } from '@antv/l7-utils';
|
|
4
3
|
/**
|
|
5
4
|
* The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
|
|
6
5
|
* pinching on a touchscreen.
|
|
@@ -41,9 +40,7 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
41
40
|
this.touchRotate.enable(options);
|
|
42
41
|
}
|
|
43
42
|
this.tapDragZoom.enable();
|
|
44
|
-
|
|
45
|
-
this.el.classList.add('l7-touch-zoom-rotate');
|
|
46
|
-
}
|
|
43
|
+
this.el.classList.add('l7-touch-zoom-rotate');
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
@@ -58,9 +55,7 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
58
55
|
this.touchZoom.disable();
|
|
59
56
|
this.touchRotate.disable();
|
|
60
57
|
this.tapDragZoom.disable();
|
|
61
|
-
|
|
62
|
-
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
63
|
-
}
|
|
58
|
+
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
/**
|
package/es/hash.js
CHANGED
|
@@ -3,8 +3,8 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
// tslint:disable-next-line:no-submodule-imports
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { lodashUtil } from '@antv/l7-utils';
|
|
7
|
+
var throttle = lodashUtil.throttle;
|
|
8
8
|
/*
|
|
9
9
|
* Adds the map's position to its page's location hash.
|
|
10
10
|
* Passed as an option to the map object.
|
|
@@ -67,14 +67,14 @@ var Hash = /*#__PURE__*/function () {
|
|
|
67
67
|
key: "addTo",
|
|
68
68
|
value: function addTo(map) {
|
|
69
69
|
this.map = map;
|
|
70
|
-
|
|
70
|
+
window.addEventListener('hashchange', this.onHashChange, false);
|
|
71
71
|
this.map.on('moveend', this.updateHash);
|
|
72
72
|
return this;
|
|
73
73
|
}
|
|
74
74
|
}, {
|
|
75
75
|
key: "remove",
|
|
76
76
|
value: function remove() {
|
|
77
|
-
|
|
77
|
+
window.removeEventListener('hashchange', this.onHashChange, false);
|
|
78
78
|
this.map.off('moveend', this.updateHash);
|
|
79
79
|
// clearTimeout(this.updateHash());
|
|
80
80
|
|
package/es/map.js
CHANGED
|
@@ -8,8 +8,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
9
|
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); }; }
|
|
10
10
|
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; } }
|
|
11
|
-
import {
|
|
12
|
-
import { merge } from 'lodash';
|
|
11
|
+
import { DOM, lodashUtil } from '@antv/l7-utils';
|
|
13
12
|
import Camera from "./camera";
|
|
14
13
|
function loadStyles(css, doc) {
|
|
15
14
|
var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
|
|
@@ -53,7 +52,7 @@ import { PerformanceUtils } from "./utils/performance";
|
|
|
53
52
|
import TaskQueue from "./utils/task_queue";
|
|
54
53
|
var defaultMinZoom = -2;
|
|
55
54
|
var defaultMaxZoom = 22;
|
|
56
|
-
|
|
55
|
+
var merge = lodashUtil.merge;
|
|
57
56
|
// the default values, but also the valid range
|
|
58
57
|
var defaultMinPitch = 0;
|
|
59
58
|
var defaultMaxPitch = 60;
|
|
@@ -103,11 +102,7 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
103
102
|
}).update();
|
|
104
103
|
}
|
|
105
104
|
});
|
|
106
|
-
|
|
107
|
-
_this.initMiniContainer();
|
|
108
|
-
} else {
|
|
109
|
-
_this.initContainer();
|
|
110
|
-
}
|
|
105
|
+
_this.initContainer();
|
|
111
106
|
_this.resize();
|
|
112
107
|
_this.handlers = new HandlerManager(_assertThisInitialized(_this), _this.options);
|
|
113
108
|
if (typeof window !== 'undefined') {
|
|
@@ -115,11 +110,9 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
115
110
|
window.addEventListener('resize', _this.onWindowResize, false);
|
|
116
111
|
window.addEventListener('orientationchange', _this.onWindowResize, false);
|
|
117
112
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
_this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
|
|
122
|
-
}
|
|
113
|
+
var hashName = typeof options.hash === 'string' && options.hash || undefined;
|
|
114
|
+
if (options.hash) {
|
|
115
|
+
_this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
|
|
123
116
|
}
|
|
124
117
|
|
|
125
118
|
// don't set position from options if set through hash
|
|
@@ -148,18 +141,15 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
148
141
|
height = _this$containerDimens2[1];
|
|
149
142
|
this.transform.resize(width, height);
|
|
150
143
|
// 小程序环境不需要执行后续动作
|
|
151
|
-
if (isMini) {
|
|
152
|
-
return this;
|
|
153
|
-
}
|
|
154
144
|
var fireMoving = !this.moving;
|
|
155
145
|
if (fireMoving) {
|
|
156
146
|
this.stop();
|
|
157
|
-
this.emit('movestart', new
|
|
158
|
-
this.emit('move', new
|
|
147
|
+
this.emit('movestart', new window.Event('movestart', eventData));
|
|
148
|
+
this.emit('move', new window.Event('move', eventData));
|
|
159
149
|
}
|
|
160
|
-
this.emit('resize', new
|
|
150
|
+
this.emit('resize', new window.Event('resize', eventData));
|
|
161
151
|
if (fireMoving) {
|
|
162
|
-
this.emit('moveend', new
|
|
152
|
+
this.emit('moveend', new window.Event('moveend', eventData));
|
|
163
153
|
}
|
|
164
154
|
return this;
|
|
165
155
|
}
|
|
@@ -385,15 +375,10 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
385
375
|
var width = 0;
|
|
386
376
|
var height = 0;
|
|
387
377
|
if (this.container) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
width = this.container.clientWidth;
|
|
393
|
-
height = this.container.clientHeight;
|
|
394
|
-
width = width === 0 ? 400 : width;
|
|
395
|
-
height = height === 0 ? 300 : height;
|
|
396
|
-
}
|
|
378
|
+
width = this.container.clientWidth;
|
|
379
|
+
height = this.container.clientHeight;
|
|
380
|
+
width = width === 0 ? 400 : width;
|
|
381
|
+
height = height === 0 ? 300 : height;
|
|
397
382
|
}
|
|
398
383
|
return [width, height];
|
|
399
384
|
}
|
package/es/util.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ export declare function pick(src: {
|
|
|
12
12
|
}, properties: string[]): {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
15
|
-
export declare const now:
|
|
16
|
-
export declare const raf:
|
|
17
|
-
export declare const cancel:
|
|
15
|
+
export declare const now: () => number;
|
|
16
|
+
export declare const raf: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
|
|
17
|
+
export declare const cancel: ((handle: number) => void) & typeof cancelAnimationFrame;
|
|
18
18
|
export declare function renderframe(fn: (paintStartTimestamp: number) => void): ICancelable;
|
|
19
19
|
export declare function extend(dest: {
|
|
20
20
|
[key: string]: any;
|
package/es/util.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
2
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
3
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
-
import { $window, isMini } from '@antv/l7-utils';
|
|
5
4
|
// @ts-ignore
|
|
6
5
|
import UnitBezier from '@mapbox/unitbezier';
|
|
7
6
|
var reducedMotionQuery;
|
|
@@ -24,14 +23,10 @@ export function bezier(p1x, p1y, p2x, p2y) {
|
|
|
24
23
|
}
|
|
25
24
|
export var ease = bezier(0.25, 0.1, 0.25, 1);
|
|
26
25
|
export function prefersReducedMotion() {
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
if (isMini || !$window.matchMedia) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
26
|
// Lazily initialize media query
|
|
32
27
|
if (reducedMotionQuery == null) {
|
|
33
28
|
// @ts-ignore
|
|
34
|
-
reducedMotionQuery =
|
|
29
|
+
reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
35
30
|
}
|
|
36
31
|
return reducedMotionQuery.matches;
|
|
37
32
|
}
|
|
@@ -53,21 +48,21 @@ export function pick(src, properties) {
|
|
|
53
48
|
}
|
|
54
49
|
return result;
|
|
55
50
|
}
|
|
56
|
-
export var now =
|
|
57
|
-
export var raf =
|
|
51
|
+
export var now = window.performance && window.performance.now ? window.performance.now.bind(window.performance) : Date.now.bind(Date);
|
|
52
|
+
export var raf = window.requestAnimationFrame ||
|
|
58
53
|
// @ts-ignore
|
|
59
|
-
|
|
54
|
+
window.mozRequestAnimationFrame ||
|
|
60
55
|
// @ts-ignore
|
|
61
|
-
|
|
56
|
+
window.webkitRequestAnimationFrame ||
|
|
62
57
|
// @ts-ignore
|
|
63
|
-
|
|
64
|
-
var _cancel =
|
|
58
|
+
window.msRequestAnimationFrame;
|
|
59
|
+
var _cancel = window.cancelAnimationFrame ||
|
|
65
60
|
// @ts-ignore
|
|
66
|
-
|
|
61
|
+
window.mozCancelAnimationFrame ||
|
|
67
62
|
// @ts-ignore
|
|
68
|
-
|
|
63
|
+
window.webkitCancelAnimationFrame ||
|
|
69
64
|
// @ts-ignore
|
|
70
|
-
|
|
65
|
+
window.msCancelAnimationFrame;
|
|
71
66
|
export { _cancel as cancel };
|
|
72
67
|
export function renderframe(fn) {
|
|
73
68
|
var frame = raf(fn);
|
package/es/utils/dom.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
2
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
3
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
-
import { $window, isMini } from '@antv/l7-utils';
|
|
5
4
|
// @ts-ignore
|
|
6
5
|
import Point from "../geo/point";
|
|
7
6
|
var DOM = {};
|
|
8
7
|
export default DOM;
|
|
9
8
|
DOM.create = function (tagName, className, container) {
|
|
10
|
-
var el =
|
|
9
|
+
var el = window.document.createElement(tagName);
|
|
11
10
|
if (className !== undefined) {
|
|
12
11
|
el.className = className;
|
|
13
12
|
}
|
|
@@ -17,10 +16,10 @@ DOM.create = function (tagName, className, container) {
|
|
|
17
16
|
return el;
|
|
18
17
|
};
|
|
19
18
|
DOM.createNS = function (namespaceURI, tagName) {
|
|
20
|
-
var el =
|
|
19
|
+
var el = window.document.createElementNS(namespaceURI, tagName);
|
|
21
20
|
return el;
|
|
22
21
|
};
|
|
23
|
-
var docStyle =
|
|
22
|
+
var docStyle = window.document && window.document.documentElement.style;
|
|
24
23
|
function testProp(props) {
|
|
25
24
|
if (!docStyle) {
|
|
26
25
|
return props[0];
|
|
@@ -73,9 +72,9 @@ try {
|
|
|
73
72
|
}
|
|
74
73
|
});
|
|
75
74
|
// @ts-ignore
|
|
76
|
-
|
|
75
|
+
window.addEventListener('test', options, options);
|
|
77
76
|
// @ts-ignore
|
|
78
|
-
|
|
77
|
+
window.removeEventListener('test', options, options);
|
|
79
78
|
} catch (err) {
|
|
80
79
|
passiveSupported = false;
|
|
81
80
|
}
|
|
@@ -100,81 +99,38 @@ DOM.removeEventListener = function (target, type, callback) {
|
|
|
100
99
|
var suppressClick = function suppressClick(e) {
|
|
101
100
|
e.preventDefault();
|
|
102
101
|
e.stopPropagation();
|
|
103
|
-
|
|
102
|
+
window.removeEventListener('click', suppressClick, true);
|
|
104
103
|
};
|
|
105
104
|
DOM.suppressClick = function () {
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
$window.addEventListener('click', suppressClick, true);
|
|
105
|
+
window.addEventListener('click', suppressClick, true);
|
|
110
106
|
setTimeout(function () {
|
|
111
|
-
|
|
107
|
+
window.removeEventListener('click', suppressClick, true);
|
|
112
108
|
}, 0);
|
|
113
109
|
};
|
|
114
110
|
DOM.mousePos = function (el, e) {
|
|
115
111
|
// 暂时从 el 上获取 top/left, 后面需要动态获取
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
|
|
119
|
-
} else {
|
|
120
|
-
return new Point(
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
e.clientX - el.left - 0,
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
e.clientY - el.top - 0);
|
|
125
|
-
}
|
|
112
|
+
var rect = el.getBoundingClientRect();
|
|
113
|
+
return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
|
|
126
114
|
};
|
|
127
115
|
DOM.touchPos = function (el, touches) {
|
|
128
116
|
// 暂时从 el 上获取 top/left, 后面需要动态获取
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
points.push(new Point(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
|
|
138
|
-
}
|
|
139
|
-
} catch (err) {
|
|
140
|
-
_iterator2.e(err);
|
|
141
|
-
} finally {
|
|
142
|
-
_iterator2.f();
|
|
143
|
-
}
|
|
144
|
-
return points;
|
|
145
|
-
} else {
|
|
146
|
-
var _points = [];
|
|
147
|
-
var _iterator3 = _createForOfIteratorHelper(touches),
|
|
148
|
-
_step3;
|
|
149
|
-
try {
|
|
150
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
151
|
-
var _touche = _step3.value;
|
|
152
|
-
_points.push(new Point(
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
_touche.clientX - el.left,
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
_touche.clientY - el.top));
|
|
157
|
-
}
|
|
158
|
-
} catch (err) {
|
|
159
|
-
_iterator3.e(err);
|
|
160
|
-
} finally {
|
|
161
|
-
_iterator3.f();
|
|
117
|
+
var rect = el.getBoundingClientRect();
|
|
118
|
+
var points = [];
|
|
119
|
+
var _iterator2 = _createForOfIteratorHelper(touches),
|
|
120
|
+
_step2;
|
|
121
|
+
try {
|
|
122
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
123
|
+
var touche = _step2.value;
|
|
124
|
+
points.push(new Point(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
|
|
162
125
|
}
|
|
163
|
-
|
|
126
|
+
} catch (err) {
|
|
127
|
+
_iterator2.e(err);
|
|
128
|
+
} finally {
|
|
129
|
+
_iterator2.f();
|
|
164
130
|
}
|
|
131
|
+
return points;
|
|
165
132
|
};
|
|
166
133
|
DOM.mouseButton = function (e) {
|
|
167
|
-
if (!isMini) {
|
|
168
|
-
return e.button;
|
|
169
|
-
}
|
|
170
|
-
if (
|
|
171
|
-
// @ts-ignore
|
|
172
|
-
typeof $window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey && $window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
|
|
173
|
-
// Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:
|
|
174
|
-
// Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when
|
|
175
|
-
// using Control + left click
|
|
176
|
-
return 0;
|
|
177
|
-
}
|
|
178
134
|
return e.button;
|
|
179
135
|
};
|
|
180
136
|
DOM.remove = function (node) {
|
package/es/utils/performance.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { $window } from '@antv/l7-utils';
|
|
2
1
|
var lastFrameTime = null;
|
|
3
2
|
var frameTimes = [];
|
|
4
3
|
var minFramerateTarget = 30;
|
|
5
4
|
var frameTimeTarget = 1000 / minFramerateTarget;
|
|
6
|
-
var performance =
|
|
5
|
+
var performance = window.performance;
|
|
7
6
|
export var PerformanceMarkers = {
|
|
8
7
|
create: 'create',
|
|
9
8
|
load: 'load',
|