@antv/l7-map 2.25.5 → 2.25.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/package.json +2 -2
  2. package/es/index.d.ts +0 -5
  3. package/es/index.js +0 -4
  4. package/es/map/camera.d.ts +0 -690
  5. package/es/map/camera.js +0 -1138
  6. package/es/map/css/l7.css +0 -171
  7. package/es/map/events.d.ts +0 -384
  8. package/es/map/events.js +0 -231
  9. package/es/map/geo/edge_insets.d.ts +0 -97
  10. package/es/map/geo/edge_insets.js +0 -115
  11. package/es/map/geo/lng_lat.d.ts +0 -116
  12. package/es/map/geo/lng_lat.js +0 -159
  13. package/es/map/geo/lng_lat_bounds.d.ts +0 -217
  14. package/es/map/geo/lng_lat_bounds.js +0 -334
  15. package/es/map/geo/mercator_coordinate.d.ts +0 -113
  16. package/es/map/geo/mercator_coordinate.js +0 -142
  17. package/es/map/geo/transform.d.ts +0 -262
  18. package/es/map/geo/transform.js +0 -736
  19. package/es/map/handler/box_zoom.d.ts +0 -65
  20. package/es/map/handler/box_zoom.js +0 -145
  21. package/es/map/handler/click_zoom.d.ts +0 -24
  22. package/es/map/handler/click_zoom.js +0 -47
  23. package/es/map/handler/cooperative_gestures.d.ts +0 -40
  24. package/es/map/handler/cooperative_gestures.js +0 -94
  25. package/es/map/handler/drag_handler.d.ts +0 -88
  26. package/es/map/handler/drag_handler.js +0 -89
  27. package/es/map/handler/drag_move_state_manager.d.ts +0 -30
  28. package/es/map/handler/drag_move_state_manager.js +0 -94
  29. package/es/map/handler/handler_util.d.ts +0 -3
  30. package/es/map/handler/handler_util.js +0 -8
  31. package/es/map/handler/keyboard.d.ts +0 -88
  32. package/es/map/handler/keyboard.js +0 -197
  33. package/es/map/handler/map_event.d.ts +0 -46
  34. package/es/map/handler/map_event.js +0 -131
  35. package/es/map/handler/mouse.d.ts +0 -30
  36. package/es/map/handler/mouse.js +0 -85
  37. package/es/map/handler/one_finger_touch_drag.d.ts +0 -15
  38. package/es/map/handler/one_finger_touch_drag.js +0 -39
  39. package/es/map/handler/scroll_zoom.d.ts +0 -102
  40. package/es/map/handler/scroll_zoom.js +0 -312
  41. package/es/map/handler/shim/dblclick_zoom.d.ts +0 -44
  42. package/es/map/handler/shim/dblclick_zoom.js +0 -60
  43. package/es/map/handler/shim/drag_pan.d.ts +0 -79
  44. package/es/map/handler/shim/drag_pan.js +0 -77
  45. package/es/map/handler/shim/drag_rotate.d.ts +0 -54
  46. package/es/map/handler/shim/drag_rotate.js +0 -66
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +0 -74
  48. package/es/map/handler/shim/two_fingers_touch.js +0 -106
  49. package/es/map/handler/tap_drag_zoom.d.ts +0 -28
  50. package/es/map/handler/tap_drag_zoom.js +0 -92
  51. package/es/map/handler/tap_recognizer.d.ts +0 -35
  52. package/es/map/handler/tap_recognizer.js +0 -107
  53. package/es/map/handler/tap_zoom.d.ts +0 -28
  54. package/es/map/handler/tap_zoom.js +0 -87
  55. package/es/map/handler/touch_pan.d.ts +0 -40
  56. package/es/map/handler/touch_pan.js +0 -85
  57. package/es/map/handler/transform-provider.d.ts +0 -23
  58. package/es/map/handler/transform-provider.js +0 -35
  59. package/es/map/handler/two_fingers_touch.d.ts +0 -107
  60. package/es/map/handler/two_fingers_touch.js +0 -289
  61. package/es/map/handler_inertia.d.ts +0 -20
  62. package/es/map/handler_inertia.js +0 -128
  63. package/es/map/handler_manager.d.ts +0 -154
  64. package/es/map/handler_manager.js +0 -466
  65. package/es/map/map.d.ts +0 -637
  66. package/es/map/map.js +0 -984
  67. package/es/map/util/abort_error.d.ts +0 -15
  68. package/es/map/util/abort_error.js +0 -21
  69. package/es/map/util/browser.d.ts +0 -10
  70. package/es/map/util/browser.js +0 -30
  71. package/es/map/util/dom.d.ts +0 -30
  72. package/es/map/util/dom.js +0 -105
  73. package/es/map/util/evented.d.ts +0 -75
  74. package/es/map/util/evented.js +0 -158
  75. package/es/map/util/simpleMapCoord.d.ts +0 -31
  76. package/es/map/util/simpleMapCoord.js +0 -54
  77. package/es/map/util/task_queue.d.ts +0 -18
  78. package/es/map/util/task_queue.js +0 -54
  79. package/es/map/util/util.d.ts +0 -104
  80. package/es/map/util/util.js +0 -155
  81. package/lib/index.d.ts +0 -5
  82. package/lib/index.js +0 -33
  83. package/lib/map/camera.d.ts +0 -690
  84. package/lib/map/camera.js +0 -1145
  85. package/lib/map/css/l7.css +0 -171
  86. package/lib/map/events.d.ts +0 -384
  87. package/lib/map/events.js +0 -240
  88. package/lib/map/geo/edge_insets.d.ts +0 -97
  89. package/lib/map/geo/edge_insets.js +0 -122
  90. package/lib/map/geo/lng_lat.d.ts +0 -116
  91. package/lib/map/geo/lng_lat.js +0 -166
  92. package/lib/map/geo/lng_lat_bounds.d.ts +0 -217
  93. package/lib/map/geo/lng_lat_bounds.js +0 -341
  94. package/lib/map/geo/mercator_coordinate.d.ts +0 -113
  95. package/lib/map/geo/mercator_coordinate.js +0 -157
  96. package/lib/map/geo/transform.d.ts +0 -262
  97. package/lib/map/geo/transform.js +0 -744
  98. package/lib/map/handler/box_zoom.d.ts +0 -65
  99. package/lib/map/handler/box_zoom.js +0 -153
  100. package/lib/map/handler/click_zoom.d.ts +0 -24
  101. package/lib/map/handler/click_zoom.js +0 -54
  102. package/lib/map/handler/cooperative_gestures.d.ts +0 -40
  103. package/lib/map/handler/cooperative_gestures.js +0 -101
  104. package/lib/map/handler/drag_handler.d.ts +0 -88
  105. package/lib/map/handler/drag_handler.js +0 -97
  106. package/lib/map/handler/drag_move_state_manager.d.ts +0 -30
  107. package/lib/map/handler/drag_move_state_manager.js +0 -103
  108. package/lib/map/handler/handler_util.d.ts +0 -3
  109. package/lib/map/handler/handler_util.js +0 -14
  110. package/lib/map/handler/keyboard.d.ts +0 -88
  111. package/lib/map/handler/keyboard.js +0 -205
  112. package/lib/map/handler/map_event.d.ts +0 -46
  113. package/lib/map/handler/map_event.js +0 -140
  114. package/lib/map/handler/mouse.d.ts +0 -30
  115. package/lib/map/handler/mouse.js +0 -93
  116. package/lib/map/handler/one_finger_touch_drag.d.ts +0 -15
  117. package/lib/map/handler/one_finger_touch_drag.js +0 -47
  118. package/lib/map/handler/scroll_zoom.d.ts +0 -102
  119. package/lib/map/handler/scroll_zoom.js +0 -320
  120. package/lib/map/handler/shim/dblclick_zoom.d.ts +0 -44
  121. package/lib/map/handler/shim/dblclick_zoom.js +0 -68
  122. package/lib/map/handler/shim/drag_pan.d.ts +0 -79
  123. package/lib/map/handler/shim/drag_pan.js +0 -85
  124. package/lib/map/handler/shim/drag_rotate.d.ts +0 -54
  125. package/lib/map/handler/shim/drag_rotate.js +0 -74
  126. package/lib/map/handler/shim/two_fingers_touch.d.ts +0 -74
  127. package/lib/map/handler/shim/two_fingers_touch.js +0 -114
  128. package/lib/map/handler/tap_drag_zoom.d.ts +0 -28
  129. package/lib/map/handler/tap_drag_zoom.js +0 -99
  130. package/lib/map/handler/tap_recognizer.d.ts +0 -35
  131. package/lib/map/handler/tap_recognizer.js +0 -116
  132. package/lib/map/handler/tap_zoom.d.ts +0 -28
  133. package/lib/map/handler/tap_zoom.js +0 -94
  134. package/lib/map/handler/touch_pan.d.ts +0 -40
  135. package/lib/map/handler/touch_pan.js +0 -92
  136. package/lib/map/handler/transform-provider.d.ts +0 -23
  137. package/lib/map/handler/transform-provider.js +0 -43
  138. package/lib/map/handler/two_fingers_touch.d.ts +0 -107
  139. package/lib/map/handler/two_fingers_touch.js +0 -296
  140. package/lib/map/handler_inertia.d.ts +0 -20
  141. package/lib/map/handler_inertia.js +0 -136
  142. package/lib/map/handler_manager.d.ts +0 -154
  143. package/lib/map/handler_manager.js +0 -474
  144. package/lib/map/map.d.ts +0 -637
  145. package/lib/map/map.js +0 -991
  146. package/lib/map/util/abort_error.d.ts +0 -15
  147. package/lib/map/util/abort_error.js +0 -29
  148. package/lib/map/util/browser.d.ts +0 -10
  149. package/lib/map/util/browser.js +0 -36
  150. package/lib/map/util/dom.d.ts +0 -30
  151. package/lib/map/util/dom.js +0 -113
  152. package/lib/map/util/evented.d.ts +0 -75
  153. package/lib/map/util/evented.js +0 -167
  154. package/lib/map/util/simpleMapCoord.d.ts +0 -31
  155. package/lib/map/util/simpleMapCoord.js +0 -62
  156. package/lib/map/util/task_queue.d.ts +0 -18
  157. package/lib/map/util/task_queue.js +0 -62
  158. package/lib/map/util/util.d.ts +0 -104
  159. package/lib/map/util/util.js +0 -171
@@ -1,15 +0,0 @@
1
- /**
2
- * An error message to use when an operation is aborted
3
- */
4
- export declare const ABORT_ERROR = "AbortError";
5
- /**
6
- * Check if an error is an abort error
7
- * @param error - An error object
8
- * @returns - true if the error is an abort error
9
- */
10
- export declare function isAbortError(error: Error): boolean;
11
- /**
12
- * Use this when you need to create an abort error.
13
- * @returns An error object with the message "AbortError"
14
- */
15
- export declare function createAbortError(): Error;
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ABORT_ERROR = void 0;
7
- exports.createAbortError = createAbortError;
8
- exports.isAbortError = isAbortError;
9
- /**
10
- * An error message to use when an operation is aborted
11
- */
12
- const ABORT_ERROR = exports.ABORT_ERROR = 'AbortError';
13
-
14
- /**
15
- * Check if an error is an abort error
16
- * @param error - An error object
17
- * @returns - true if the error is an abort error
18
- */
19
- function isAbortError(error) {
20
- return error.message === ABORT_ERROR;
21
- }
22
-
23
- /**
24
- * Use this when you need to create an abort error.
25
- * @returns An error object with the message "AbortError"
26
- */
27
- function createAbortError() {
28
- return new Error(ABORT_ERROR);
29
- }
@@ -1,10 +0,0 @@
1
- /** */
2
- export declare const browser: {
3
- /**
4
- * Provides a function that outputs milliseconds: either performance.now()
5
- * or a fallback to Date.now()
6
- */
7
- now: any;
8
- frameAsync(abortController: AbortController): Promise<number>;
9
- readonly prefersReducedMotion: boolean;
10
- };
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.browser = void 0;
7
- var _abort_error = require("./abort_error");
8
- const now = typeof performance !== 'undefined' && performance && performance.now ? performance.now.bind(performance) : Date.now.bind(Date);
9
- let reducedMotionQuery;
10
-
11
- /** */
12
- const browser = exports.browser = {
13
- /**
14
- * Provides a function that outputs milliseconds: either performance.now()
15
- * or a fallback to Date.now()
16
- */
17
- now,
18
- frameAsync(abortController) {
19
- return new Promise((resolve, reject) => {
20
- const frame = requestAnimationFrame(resolve);
21
- abortController.signal.addEventListener('abort', () => {
22
- cancelAnimationFrame(frame);
23
- reject((0, _abort_error.createAbortError)());
24
- });
25
- });
26
- },
27
- get prefersReducedMotion() {
28
- // In case your test crashes when checking matchMedia, call setMatchMedia from 'src/util/test/util'
29
- if (!window.matchMedia) return false;
30
- //Lazily initialize media query
31
- if (reducedMotionQuery == null) {
32
- reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
33
- }
34
- return reducedMotionQuery.matches;
35
- }
36
- };
@@ -1,30 +0,0 @@
1
- /// <reference types="mapbox__point-geometry" />
2
- import Point from '@mapbox/point-geometry';
3
- export declare class DOM {
4
- private static readonly docStyle;
5
- private static userSelect;
6
- private static selectProp;
7
- private static transformProp;
8
- private static testProp;
9
- static create<K extends keyof HTMLElementTagNameMap>(tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K];
10
- static createNS(namespaceURI: string, tagName: string): Element;
11
- static disableDrag(): void;
12
- static enableDrag(): void;
13
- static setTransform(el: HTMLElement, value: string): void;
14
- static addEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options?: {
15
- passive?: boolean;
16
- capture?: boolean;
17
- }): void;
18
- static removeEventListener(target: HTMLElement | Window | Document, type: string, callback: EventListenerOrEventListenerObject, options?: {
19
- passive?: boolean;
20
- capture?: boolean;
21
- }): void;
22
- private static suppressClickInternal;
23
- static suppressClick(): void;
24
- private static getScale;
25
- private static getPoint;
26
- static mousePos(el: HTMLElement, e: MouseEvent | Touch): Point;
27
- static touchPos(el: HTMLElement, touches: TouchList): Point[];
28
- static mouseButton(e: MouseEvent): number;
29
- static remove(node: HTMLElement): void;
30
- }
@@ -1,113 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DOM = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
10
- var _class;
11
- class DOM {
12
- static testProp(props) {
13
- if (!DOM.docStyle) return props[0];
14
- for (let i = 0; i < props.length; i++) {
15
- if (props[i] in DOM.docStyle) {
16
- return props[i];
17
- }
18
- }
19
- return props[0];
20
- }
21
- static create(tagName, className, container) {
22
- const el = window.document.createElement(tagName);
23
- if (className !== undefined) el.className = className;
24
- if (container) container.appendChild(el);
25
- return el;
26
- }
27
- static createNS(namespaceURI, tagName) {
28
- const el = window.document.createElementNS(namespaceURI, tagName);
29
- return el;
30
- }
31
- static disableDrag() {
32
- if (DOM.docStyle && DOM.selectProp) {
33
- DOM.userSelect = DOM.docStyle[DOM.selectProp];
34
- DOM.docStyle[DOM.selectProp] = 'none';
35
- }
36
- }
37
- static enableDrag() {
38
- if (DOM.docStyle && DOM.selectProp) {
39
- DOM.docStyle[DOM.selectProp] = DOM.userSelect;
40
- }
41
- }
42
- static setTransform(el, value) {
43
- el.style[DOM.transformProp] = value;
44
- }
45
- static addEventListener(target, type, callback, options = {}) {
46
- if ('passive' in options) {
47
- target.addEventListener(type, callback, options);
48
- } else {
49
- target.addEventListener(type, callback, options.capture);
50
- }
51
- }
52
- static removeEventListener(target, type, callback, options = {}) {
53
- if ('passive' in options) {
54
- target.removeEventListener(type, callback, options);
55
- } else {
56
- target.removeEventListener(type, callback, options.capture);
57
- }
58
- }
59
-
60
- // Suppress the next click, but only if it's immediate.
61
- static suppressClickInternal(e) {
62
- e.preventDefault();
63
- e.stopPropagation();
64
- window.removeEventListener('click', DOM.suppressClickInternal, true);
65
- }
66
- static suppressClick() {
67
- window.addEventListener('click', DOM.suppressClickInternal, true);
68
- window.setTimeout(() => {
69
- window.removeEventListener('click', DOM.suppressClickInternal, true);
70
- }, 0);
71
- }
72
- static getScale(element) {
73
- const rect = element.getBoundingClientRect();
74
- return {
75
- x: rect.width / element.offsetWidth || 1,
76
- y: rect.height / element.offsetHeight || 1,
77
- boundingClientRect: rect
78
- };
79
- }
80
- static getPoint(el, scale, e) {
81
- const rect = scale.boundingClientRect;
82
- return new _pointGeometry.default(
83
- // rect.left/top values are in page scale (like clientX/Y),
84
- // whereas clientLeft/Top (border width) values are the original values (before CSS scale applies).
85
- (e.clientX - rect.left) / scale.x - el.clientLeft, (e.clientY - rect.top) / scale.y - el.clientTop);
86
- }
87
- static mousePos(el, e) {
88
- const scale = DOM.getScale(el);
89
- return DOM.getPoint(el, scale, e);
90
- }
91
- static touchPos(el, touches) {
92
- const points = [];
93
- const scale = DOM.getScale(el);
94
- for (let i = 0; i < touches.length; i++) {
95
- points.push(DOM.getPoint(el, scale, touches[i]));
96
- }
97
- return points;
98
- }
99
- static mouseButton(e) {
100
- return e.button;
101
- }
102
- static remove(node) {
103
- if (node.parentNode) {
104
- node.parentNode.removeChild(node);
105
- }
106
- }
107
- }
108
- exports.DOM = DOM;
109
- _class = DOM;
110
- (0, _defineProperty2.default)(DOM, "docStyle", typeof window !== 'undefined' && window.document && window.document.documentElement.style);
111
- (0, _defineProperty2.default)(DOM, "userSelect", void 0);
112
- (0, _defineProperty2.default)(DOM, "selectProp", _class.testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']));
113
- (0, _defineProperty2.default)(DOM, "transformProp", _class.testProp(['transform', 'WebkitTransform']));
@@ -1,75 +0,0 @@
1
- /**
2
- * A listener method used as a callback to events
3
- */
4
- export type Listener = (a: any) => any;
5
- type Listeners = {
6
- [_: string]: Array<Listener>;
7
- };
8
- /**
9
- * The event class
10
- */
11
- export declare class Event {
12
- readonly type: string;
13
- constructor(type: string, data?: any);
14
- }
15
- interface ErrorLike {
16
- message: string;
17
- }
18
- /**
19
- * An error event
20
- */
21
- export declare class ErrorEvent extends Event {
22
- error: ErrorLike;
23
- constructor(error: ErrorLike, data?: any);
24
- }
25
- /**
26
- * Methods mixed in to other classes for event capabilities.
27
- *
28
- * @group Event Related
29
- */
30
- export declare class Evented {
31
- _listeners: Listeners;
32
- _oneTimeListeners: Listeners;
33
- _eventedParent: Evented;
34
- _eventedParentData: any | (() => any);
35
- /**
36
- * Adds a listener to a specified event type.
37
- *
38
- * @param type - The event type to add a listen for.
39
- * @param listener - The function to be called when the event is fired.
40
- * The listener function is called with the data object passed to `fire`,
41
- * extended with `target` and `type` properties.
42
- */
43
- on(type: string, listener: Listener): this;
44
- /**
45
- * Removes a previously registered event listener.
46
- *
47
- * @param type - The event type to remove listeners for.
48
- * @param listener - The listener function to remove.
49
- */
50
- off(type: string, listener: Listener): this;
51
- /**
52
- * Adds a listener that will be called only once to a specified event type.
53
- *
54
- * The listener will be called first time the event fires after the listener is registered.
55
- *
56
- * @param type - The event type to listen for.
57
- * @param listener - The function to be called when the event is fired the first time.
58
- * @returns `this` or a promise if a listener is not provided
59
- */
60
- once(type: string, listener?: Listener): this | Promise<any>;
61
- fire(event: Event | string, properties?: any): this;
62
- emit(event: Event | string, properties?: any): this;
63
- /**
64
- * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
65
- *
66
- * @param type - The event type
67
- * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise
68
- */
69
- listens(type: string): boolean;
70
- /**
71
- * Bubble all events fired by this instance of Evented to this parent instance of Evented.
72
- */
73
- setEventedParent(parent?: Evented | null, data?: any | (() => any)): this;
74
- }
75
- export {};
@@ -1,167 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Evented = exports.Event = exports.ErrorEvent = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _util = require("./util");
10
- /**
11
- * A listener method used as a callback to events
12
- */
13
-
14
- function _addEventListener(type, listener, listenerList) {
15
- const listenerExists = listenerList[type] && listenerList[type].indexOf(listener) !== -1;
16
- if (!listenerExists) {
17
- listenerList[type] = listenerList[type] || [];
18
- listenerList[type].push(listener);
19
- }
20
- }
21
- function _removeEventListener(type, listener, listenerList) {
22
- if (listenerList && listenerList[type]) {
23
- const index = listenerList[type].indexOf(listener);
24
- if (index !== -1) {
25
- listenerList[type].splice(index, 1);
26
- }
27
- }
28
- }
29
-
30
- /**
31
- * The event class
32
- */
33
- class Event {
34
- constructor(type, data = {}) {
35
- (0, _defineProperty2.default)(this, "type", void 0);
36
- (0, _util.extend)(this, data);
37
- this.type = type;
38
- }
39
- }
40
- exports.Event = Event;
41
- /**
42
- * An error event
43
- */
44
- class ErrorEvent extends Event {
45
- constructor(error, data = {}) {
46
- super('error', data);
47
- (0, _defineProperty2.default)(this, "error", void 0);
48
- this.error = error;
49
- }
50
- }
51
-
52
- /**
53
- * Methods mixed in to other classes for event capabilities.
54
- *
55
- * @group Event Related
56
- */
57
- exports.ErrorEvent = ErrorEvent;
58
- class Evented {
59
- constructor() {
60
- (0, _defineProperty2.default)(this, "_listeners", void 0);
61
- (0, _defineProperty2.default)(this, "_oneTimeListeners", void 0);
62
- (0, _defineProperty2.default)(this, "_eventedParent", void 0);
63
- (0, _defineProperty2.default)(this, "_eventedParentData", void 0);
64
- }
65
- /**
66
- * Adds a listener to a specified event type.
67
- *
68
- * @param type - The event type to add a listen for.
69
- * @param listener - The function to be called when the event is fired.
70
- * The listener function is called with the data object passed to `fire`,
71
- * extended with `target` and `type` properties.
72
- */
73
- on(type, listener) {
74
- this._listeners = this._listeners || {};
75
- _addEventListener(type, listener, this._listeners);
76
- return this;
77
- }
78
-
79
- /**
80
- * Removes a previously registered event listener.
81
- *
82
- * @param type - The event type to remove listeners for.
83
- * @param listener - The listener function to remove.
84
- */
85
- off(type, listener) {
86
- _removeEventListener(type, listener, this._listeners);
87
- _removeEventListener(type, listener, this._oneTimeListeners);
88
- return this;
89
- }
90
-
91
- /**
92
- * Adds a listener that will be called only once to a specified event type.
93
- *
94
- * The listener will be called first time the event fires after the listener is registered.
95
- *
96
- * @param type - The event type to listen for.
97
- * @param listener - The function to be called when the event is fired the first time.
98
- * @returns `this` or a promise if a listener is not provided
99
- */
100
- once(type, listener) {
101
- if (!listener) {
102
- return new Promise(resolve => this.once(type, resolve));
103
- }
104
- this._oneTimeListeners = this._oneTimeListeners || {};
105
- _addEventListener(type, listener, this._oneTimeListeners);
106
- return this;
107
- }
108
- fire(event, properties) {
109
- // Compatibility with (type: string, properties: Object) signature from previous versions.
110
- // See https://github.com/mapbox/mapbox-gl-js/issues/6522,
111
- // https://github.com/mapbox/mapbox-gl-draw/issues/766
112
- if (typeof event === 'string') {
113
- event = new Event(event, properties || {});
114
- }
115
- const type = event.type;
116
- if (this.listens(type)) {
117
- event.target = this;
118
-
119
- // make sure adding or removing listeners inside other listeners won't cause an infinite loop
120
- const listeners = this._listeners && this._listeners[type] ? this._listeners[type].slice() : [];
121
- for (const listener of listeners) {
122
- listener.call(this, event);
123
- }
124
- const oneTimeListeners = this._oneTimeListeners && this._oneTimeListeners[type] ? this._oneTimeListeners[type].slice() : [];
125
- for (const listener of oneTimeListeners) {
126
- _removeEventListener(type, listener, this._oneTimeListeners);
127
- listener.call(this, event);
128
- }
129
- const parent = this._eventedParent;
130
- if (parent) {
131
- (0, _util.extend)(event, typeof this._eventedParentData === 'function' ? this._eventedParentData() : this._eventedParentData);
132
- parent.fire(event);
133
- }
134
-
135
- // To ensure that no error events are dropped, print them to the
136
- // console if they have no listeners.
137
- } else if (event instanceof ErrorEvent) {
138
- console.error(event.error);
139
- }
140
- return this;
141
- }
142
- emit(event, properties) {
143
- return this.fire(event, properties);
144
- }
145
-
146
- /**
147
- * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
148
- *
149
- * @param type - The event type
150
- * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise
151
- */
152
- listens(type) {
153
- return this._listeners && this._listeners[type] && this._listeners[type].length > 0 || this._oneTimeListeners && this._oneTimeListeners[type] && this._oneTimeListeners[type].length > 0 || this._eventedParent && this._eventedParent.listens(type);
154
- }
155
-
156
- /**
157
- * Bubble all events fired by this instance of Evented to this parent instance of Evented.
158
- */
159
- setEventedParent(parent, data) {
160
- if (parent) {
161
- this._eventedParent = parent;
162
- }
163
- this._eventedParentData = data;
164
- return this;
165
- }
166
- }
167
- exports.Evented = Evented;
@@ -1,31 +0,0 @@
1
- export interface ISimpleMapCoord {
2
- setSize(size: number): void;
3
- getSize(): [number, number];
4
- project(lnglat: [number, number]): [number, number];
5
- unproject(xy: [number, number]): [number, number];
6
- }
7
- export declare class SimpleMapCoord implements ISimpleMapCoord {
8
- private size;
9
- constructor(size?: number);
10
- setSize(size: number): void;
11
- getSize(): [number, number];
12
- /**
13
- * coord
14
- * ^ y (y > 0)
15
- * |
16
- * |
17
- * |
18
- * |(x = 0, y = 0)
19
- * ---------------> x (x > 0)
20
- */
21
- /***
22
- * lng: [-180, 180] 360
23
- * lat: [-85.05112877980659, 85.05112877980659] 170.10225755961318
24
- */
25
- mercatorXfromLng(lng: number): number;
26
- mercatorYfromLat(lat: number): number;
27
- lngFromMercatorX(x: number): number;
28
- latFromMercatorY(y: number): number;
29
- project(lnglat: [number, number]): [number, number];
30
- unproject(xy: [number, number]): [number, number];
31
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.SimpleMapCoord = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- class SimpleMapCoord {
10
- constructor(size) {
11
- (0, _defineProperty2.default)(this, "size", 10000);
12
- this.size = size ? size : 10000;
13
- }
14
- setSize(size) {
15
- this.size = size;
16
- }
17
- getSize() {
18
- return [this.size, this.size];
19
- }
20
-
21
- /**
22
- * coord
23
- * ^ y (y > 0)
24
- * |
25
- * |
26
- * |
27
- * |(x = 0, y = 0)
28
- * ---------------> x (x > 0)
29
- */
30
-
31
- /***
32
- * lng: [-180, 180] 360
33
- * lat: [-85.05112877980659, 85.05112877980659] 170.10225755961318
34
- */
35
-
36
- mercatorXfromLng(lng) {
37
- // (0 - 1) * this.size
38
- return (180 + lng) / 360 * this.size;
39
- }
40
- mercatorYfromLat(lat) {
41
- // (0 - 1) * this.size
42
- return (1 - (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360) * this.size;
43
- }
44
- lngFromMercatorX(x) {
45
- return x / this.size * 360 - 180;
46
- }
47
- latFromMercatorY(y) {
48
- const y2 = 180 - (1 - y / this.size) * 360;
49
- return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
50
- }
51
- project(lnglat) {
52
- const x = this.mercatorXfromLng(lnglat[0]);
53
- const y = this.mercatorYfromLat(lnglat[1]);
54
- return [x, y];
55
- }
56
- unproject(xy) {
57
- const lng = this.lngFromMercatorX(xy[0]);
58
- const lat = this.latFromMercatorY(xy[1]);
59
- return [lng, lat];
60
- }
61
- }
62
- exports.SimpleMapCoord = SimpleMapCoord;
@@ -1,18 +0,0 @@
1
- export type TaskID = number;
2
- type Task = {
3
- callback: (timeStamp: number) => void;
4
- id: TaskID;
5
- cancelled: boolean;
6
- };
7
- export declare class TaskQueue {
8
- _queue: Array<Task>;
9
- _id: TaskID;
10
- _cleared: boolean;
11
- _currentlyRunning: Array<Task> | false;
12
- constructor();
13
- add(callback: (timeStamp: number) => void): TaskID;
14
- remove(id: TaskID): void;
15
- run(timeStamp?: number): void;
16
- clear(): void;
17
- }
18
- export {};
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.TaskQueue = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- class TaskQueue {
10
- constructor() {
11
- (0, _defineProperty2.default)(this, "_queue", void 0);
12
- (0, _defineProperty2.default)(this, "_id", void 0);
13
- (0, _defineProperty2.default)(this, "_cleared", void 0);
14
- (0, _defineProperty2.default)(this, "_currentlyRunning", void 0);
15
- this._queue = [];
16
- this._id = 0;
17
- this._cleared = false;
18
- this._currentlyRunning = false;
19
- }
20
- add(callback) {
21
- const id = ++this._id;
22
- const queue = this._queue;
23
- queue.push({
24
- callback,
25
- id,
26
- cancelled: false
27
- });
28
- return id;
29
- }
30
- remove(id) {
31
- const running = this._currentlyRunning;
32
- const queue = running ? this._queue.concat(running) : this._queue;
33
- for (const task of queue) {
34
- if (task.id === id) {
35
- task.cancelled = true;
36
- return;
37
- }
38
- }
39
- }
40
- run(timeStamp = 0) {
41
- if (this._currentlyRunning) throw new Error('Attempting to run(), but is already running.');
42
- const queue = this._currentlyRunning = this._queue;
43
-
44
- // Tasks queued by callbacks in the current queue should be executed
45
- // on the next run, not the current run.
46
- this._queue = [];
47
- for (const task of queue) {
48
- if (task.cancelled) continue;
49
- task.callback(timeStamp);
50
- if (this._cleared) break;
51
- }
52
- this._cleared = false;
53
- this._currentlyRunning = false;
54
- }
55
- clear() {
56
- if (this._currentlyRunning) {
57
- this._cleared = true;
58
- }
59
- this._queue = [];
60
- }
61
- }
62
- exports.TaskQueue = TaskQueue;