@antv/l7-map 2.18.0 → 2.18.2

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 (168) hide show
  1. package/package.json +3 -3
  2. package/es/camera.d.ts +0 -85
  3. package/es/camera.js +0 -718
  4. package/es/css/l7.css +0 -98
  5. package/es/earthmap.d.ts +0 -66
  6. package/es/earthmap.js +0 -369
  7. package/es/geo/edge_insets.d.ts +0 -54
  8. package/es/geo/edge_insets.js +0 -108
  9. package/es/geo/lng_lat.d.ts +0 -18
  10. package/es/geo/lng_lat.js +0 -73
  11. package/es/geo/lng_lat_bounds.d.ts +0 -24
  12. package/es/geo/lng_lat_bounds.js +0 -154
  13. package/es/geo/mercator.d.ts +0 -29
  14. package/es/geo/mercator.js +0 -84
  15. package/es/geo/point.d.ts +0 -40
  16. package/es/geo/point.js +0 -224
  17. package/es/geo/simple.d.ts +0 -29
  18. package/es/geo/simple.js +0 -87
  19. package/es/geo/transform.d.ts +0 -198
  20. package/es/geo/transform.js +0 -961
  21. package/es/handler/IHandler.d.ts +0 -34
  22. package/es/handler/IHandler.js +0 -1
  23. package/es/handler/blockable_map_event.d.ts +0 -17
  24. package/es/handler/blockable_map_event.js +0 -78
  25. package/es/handler/box_zoom.d.ts +0 -59
  26. package/es/handler/box_zoom.js +0 -180
  27. package/es/handler/click_zoom.d.ts +0 -16
  28. package/es/handler/click_zoom.js +0 -54
  29. package/es/handler/events/event.d.ts +0 -4
  30. package/es/handler/events/event.js +0 -11
  31. package/es/handler/events/index.d.ts +0 -4
  32. package/es/handler/events/index.js +0 -4
  33. package/es/handler/events/map_mouse_event.d.ts +0 -34
  34. package/es/handler/events/map_mouse_event.js +0 -64
  35. package/es/handler/events/map_touch_event.d.ts +0 -57
  36. package/es/handler/events/map_touch_event.js +0 -95
  37. package/es/handler/events/map_wheel_event.d.ts +0 -33
  38. package/es/handler/events/map_wheel_event.js +0 -50
  39. package/es/handler/events/render_event.d.ts +0 -5
  40. package/es/handler/events/render_event.js +0 -26
  41. package/es/handler/handler_inertia.d.ts +0 -23
  42. package/es/handler/handler_inertia.js +0 -157
  43. package/es/handler/handler_manager.d.ts +0 -61
  44. package/es/handler/handler_manager.js +0 -577
  45. package/es/handler/handler_util.d.ts +0 -4
  46. package/es/handler/handler_util.js +0 -9
  47. package/es/handler/keyboard.d.ts +0 -36
  48. package/es/handler/keyboard.js +0 -143
  49. package/es/handler/map_event.d.ts +0 -29
  50. package/es/handler/map_event.js +0 -125
  51. package/es/handler/mouse/index.d.ts +0 -4
  52. package/es/handler/mouse/index.js +0 -4
  53. package/es/handler/mouse/mouse_handler.d.ts +0 -22
  54. package/es/handler/mouse/mouse_handler.js +0 -118
  55. package/es/handler/mouse/mousepan_handler.d.ts +0 -10
  56. package/es/handler/mouse/mousepan_handler.js +0 -44
  57. package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
  58. package/es/handler/mouse/mousepitch_hander.js +0 -46
  59. package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
  60. package/es/handler/mouse/mouserotate_hander.js +0 -46
  61. package/es/handler/mouse/util.d.ts +0 -6
  62. package/es/handler/mouse/util.js +0 -11
  63. package/es/handler/scroll_zoom.d.ts +0 -93
  64. package/es/handler/scroll_zoom.js +0 -325
  65. package/es/handler/shim/dblclick_zoom.d.ts +0 -40
  66. package/es/handler/shim/dblclick_zoom.js +0 -67
  67. package/es/handler/shim/drag_pan.d.ts +0 -61
  68. package/es/handler/shim/drag_pan.js +0 -84
  69. package/es/handler/shim/drag_rotate.d.ts +0 -46
  70. package/es/handler/shim/drag_rotate.js +0 -74
  71. package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
  72. package/es/handler/shim/touch_zoom_rotate.js +0 -115
  73. package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
  74. package/es/handler/tap/single_tap_recognizer.js +0 -97
  75. package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
  76. package/es/handler/tap/tap_drag_zoom.js +0 -106
  77. package/es/handler/tap/tap_recognizer.d.ts +0 -17
  78. package/es/handler/tap/tap_recognizer.js +0 -54
  79. package/es/handler/tap/tap_zoom.d.ts +0 -22
  80. package/es/handler/tap/tap_zoom.js +0 -109
  81. package/es/handler/touch/index.d.ts +0 -5
  82. package/es/handler/touch/index.js +0 -5
  83. package/es/handler/touch/touch_pan.d.ts +0 -30
  84. package/es/handler/touch/touch_pan.js +0 -110
  85. package/es/handler/touch/touch_pitch.d.ts +0 -13
  86. package/es/handler/touch/touch_pitch.js +0 -93
  87. package/es/handler/touch/touch_rotate.d.ts +0 -12
  88. package/es/handler/touch/touch_rotate.js +0 -77
  89. package/es/handler/touch/touch_zoom.d.ts +0 -12
  90. package/es/handler/touch/touch_zoom.js +0 -54
  91. package/es/handler/touch/two_touch.d.ts +0 -23
  92. package/es/handler/touch/two_touch.js +0 -125
  93. package/es/hash.d.ts +0 -14
  94. package/es/hash.js +0 -134
  95. package/es/index.d.ts +0 -4
  96. package/es/index.js +0 -4
  97. package/es/interface.d.ts +0 -34
  98. package/es/interface.js +0 -1
  99. package/es/map.d.ts +0 -70
  100. package/es/map.js +0 -387
  101. package/es/util.d.ts +0 -25
  102. package/es/util.js +0 -88
  103. package/es/utils/Aabb.d.ts +0 -12
  104. package/es/utils/Aabb.js +0 -112
  105. package/es/utils/dom.d.ts +0 -4
  106. package/es/utils/dom.js +0 -140
  107. package/es/utils/performance.d.ts +0 -17
  108. package/es/utils/performance.js +0 -62
  109. package/es/utils/primitives.d.ts +0 -6
  110. package/es/utils/primitives.js +0 -47
  111. package/es/utils/task_queue.d.ts +0 -13
  112. package/es/utils/task_queue.js +0 -89
  113. package/lib/camera.js +0 -724
  114. package/lib/css/l7.css +0 -98
  115. package/lib/earthmap.js +0 -376
  116. package/lib/geo/edge_insets.js +0 -114
  117. package/lib/geo/lng_lat.js +0 -81
  118. package/lib/geo/lng_lat_bounds.js +0 -161
  119. package/lib/geo/mercator.js +0 -100
  120. package/lib/geo/point.js +0 -231
  121. package/lib/geo/simple.js +0 -104
  122. package/lib/geo/transform.js +0 -971
  123. package/lib/handler/IHandler.js +0 -5
  124. package/lib/handler/blockable_map_event.js +0 -84
  125. package/lib/handler/box_zoom.js +0 -186
  126. package/lib/handler/click_zoom.js +0 -61
  127. package/lib/handler/events/event.js +0 -20
  128. package/lib/handler/events/index.js +0 -27
  129. package/lib/handler/events/map_mouse_event.js +0 -70
  130. package/lib/handler/events/map_touch_event.js +0 -100
  131. package/lib/handler/events/map_wheel_event.js +0 -57
  132. package/lib/handler/events/render_event.js +0 -33
  133. package/lib/handler/handler_inertia.js +0 -162
  134. package/lib/handler/handler_manager.js +0 -584
  135. package/lib/handler/handler_util.js +0 -15
  136. package/lib/handler/keyboard.js +0 -151
  137. package/lib/handler/map_event.js +0 -131
  138. package/lib/handler/mouse/index.js +0 -27
  139. package/lib/handler/mouse/mouse_handler.js +0 -124
  140. package/lib/handler/mouse/mousepan_handler.js +0 -49
  141. package/lib/handler/mouse/mousepitch_hander.js +0 -51
  142. package/lib/handler/mouse/mouserotate_hander.js +0 -51
  143. package/lib/handler/mouse/util.js +0 -22
  144. package/lib/handler/scroll_zoom.js +0 -333
  145. package/lib/handler/shim/dblclick_zoom.js +0 -74
  146. package/lib/handler/shim/drag_pan.js +0 -91
  147. package/lib/handler/shim/drag_rotate.js +0 -81
  148. package/lib/handler/shim/touch_zoom_rotate.js +0 -122
  149. package/lib/handler/tap/single_tap_recognizer.js +0 -106
  150. package/lib/handler/tap/tap_drag_zoom.js +0 -112
  151. package/lib/handler/tap/tap_recognizer.js +0 -63
  152. package/lib/handler/tap/tap_zoom.js +0 -115
  153. package/lib/handler/touch/index.js +0 -34
  154. package/lib/handler/touch/touch_pan.js +0 -117
  155. package/lib/handler/touch/touch_pitch.js +0 -98
  156. package/lib/handler/touch/touch_rotate.js +0 -82
  157. package/lib/handler/touch/touch_zoom.js +0 -59
  158. package/lib/handler/touch/two_touch.js +0 -131
  159. package/lib/hash.js +0 -143
  160. package/lib/index.js +0 -49
  161. package/lib/interface.js +0 -5
  162. package/lib/map.js +0 -394
  163. package/lib/util.js +0 -108
  164. package/lib/utils/Aabb.js +0 -119
  165. package/lib/utils/dom.js +0 -147
  166. package/lib/utils/performance.js +0 -70
  167. package/lib/utils/primitives.js +0 -54
  168. package/lib/utils/task_queue.js +0 -97
@@ -1,82 +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.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _two_touch = _interopRequireDefault(require("./two_touch"));
15
- 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); }; }
16
- 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; } } // @ts-ignore
17
- var ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
18
-
19
- function getBearingDelta(a, b) {
20
- return a.angleWith(b) * 180 / Math.PI;
21
- }
22
- var TouchRotateHandler = /*#__PURE__*/function (_TwoTouchHandler) {
23
- (0, _inherits2.default)(TouchRotateHandler, _TwoTouchHandler);
24
- var _super = _createSuper(TouchRotateHandler);
25
- function TouchRotateHandler() {
26
- (0, _classCallCheck2.default)(this, TouchRotateHandler);
27
- return _super.apply(this, arguments);
28
- }
29
- (0, _createClass2.default)(TouchRotateHandler, [{
30
- key: "reset",
31
- value: function reset() {
32
- (0, _get2.default)((0, _getPrototypeOf2.default)(TouchRotateHandler.prototype), "reset", this).call(this);
33
- // @ts-ignore
34
- delete this.minDiameter;
35
- // @ts-ignore
36
- delete this.startVector;
37
- // @ts-ignore
38
- delete this.vector;
39
- }
40
- }, {
41
- key: "start",
42
- value: function start(points) {
43
- this.startVector = this.vector = points[0].sub(points[1]);
44
- this.minDiameter = points[0].dist(points[1]);
45
- }
46
- }, {
47
- key: "move",
48
- value: function move(points, pinchAround) {
49
- var lastVector = this.vector;
50
- this.vector = points[0].sub(points[1]);
51
- if (!this.active && this.isBelowThreshold(this.vector)) {
52
- return;
53
- }
54
- this.active = true;
55
- return {
56
- bearingDelta: getBearingDelta(this.vector, lastVector),
57
- pinchAround: pinchAround
58
- };
59
- }
60
- }, {
61
- key: "isBelowThreshold",
62
- value: function isBelowThreshold(vector) {
63
- /*
64
- * The threshold before a rotation actually happens is configured in
65
- * pixels alongth circumference of the circle formed by the two fingers.
66
- * This makes the threshold in degrees larger when the fingers are close
67
- * together and smaller when the fingers are far apart.
68
- *
69
- * Use the smallest diameter from the whole gesture to reduce sensitivity
70
- * when pinching in and out.
71
- */
72
-
73
- this.minDiameter = Math.min(this.minDiameter, vector.mag());
74
- var circumference = Math.PI * this.minDiameter;
75
- var threshold = ROTATION_THRESHOLD / circumference * 360;
76
- var bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
77
- return Math.abs(bearingDeltaSinceStart) < threshold;
78
- }
79
- }]);
80
- return TouchRotateHandler;
81
- }(_two_touch.default);
82
- exports.default = TouchRotateHandler;
@@ -1,59 +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.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _two_touch = _interopRequireDefault(require("./two_touch"));
15
- 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); }; }
16
- 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; } } // @ts-ignore
17
- var ZOOM_THRESHOLD = 0.1;
18
- function getZoomDelta(distance, lastDistance) {
19
- return Math.log(distance / lastDistance) / Math.LN2;
20
- }
21
- var TouchZoomHandler = /*#__PURE__*/function (_TwoTouchHandler) {
22
- (0, _inherits2.default)(TouchZoomHandler, _TwoTouchHandler);
23
- var _super = _createSuper(TouchZoomHandler);
24
- function TouchZoomHandler() {
25
- (0, _classCallCheck2.default)(this, TouchZoomHandler);
26
- return _super.apply(this, arguments);
27
- }
28
- (0, _createClass2.default)(TouchZoomHandler, [{
29
- key: "reset",
30
- value: function reset() {
31
- (0, _get2.default)((0, _getPrototypeOf2.default)(TouchZoomHandler.prototype), "reset", this).call(this);
32
- // @ts-ignore
33
- delete this.distance;
34
- // @ts-ignore
35
- delete this.startDistance;
36
- }
37
- }, {
38
- key: "start",
39
- value: function start(points) {
40
- this.startDistance = this.distance = points[0].dist(points[1]);
41
- }
42
- }, {
43
- key: "move",
44
- value: function move(points, pinchAround) {
45
- var lastDistance = this.distance;
46
- this.distance = points[0].dist(points[1]);
47
- if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
48
- return;
49
- }
50
- this.active = true;
51
- return {
52
- zoomDelta: getZoomDelta(this.distance, lastDistance),
53
- pinchAround: pinchAround
54
- };
55
- }
56
- }]);
57
- return TouchZoomHandler;
58
- }(_two_touch.default);
59
- exports.default = TouchZoomHandler;
@@ -1,131 +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.default = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _dom = _interopRequireDefault(require("../../utils/dom"));
12
- // @ts-ignore
13
- var TwoTouchHandler = /*#__PURE__*/function () {
14
- function TwoTouchHandler() {
15
- (0, _classCallCheck2.default)(this, TwoTouchHandler);
16
- this.reset();
17
- }
18
- (0, _createClass2.default)(TwoTouchHandler, [{
19
- key: "reset",
20
- value: function reset() {
21
- this.active = false;
22
- // @ts-ignore
23
- delete this.firstTwoTouches;
24
- }
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
- }, {
27
- key: "start",
28
- value: function start(points) {
29
- return;
30
- } // eslint-disable-line
31
- }, {
32
- key: "move",
33
- value: function move(
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- points,
36
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
- pinchAround,
38
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
- e) {
40
- return;
41
- } // eslint-disable-line
42
- }, {
43
- key: "touchstart",
44
- value: function touchstart(e, points, mapTouches) {
45
- // console.log(e.target, e.targetTouches.length ? e.targetTouches[0].target : null);
46
- // log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);
47
- if (this.firstTwoTouches || mapTouches.length < 2) {
48
- return;
49
- }
50
- this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
51
-
52
- // implemented by child classes
53
- this.start([points[0], points[1]]);
54
- }
55
- }, {
56
- key: "touchmove",
57
- value: function touchmove(e, points, mapTouches) {
58
- if (!this.firstTwoTouches) {
59
- return;
60
- }
61
- e.preventDefault();
62
- var _this$firstTwoTouches = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
63
- idA = _this$firstTwoTouches[0],
64
- idB = _this$firstTwoTouches[1];
65
- var a = getTouchById(mapTouches, points, idA);
66
- var b = getTouchById(mapTouches, points, idB);
67
- if (!a || !b) {
68
- return;
69
- }
70
- var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
71
-
72
- // implemented by child classes
73
- return this.move([a, b], pinchAround, e);
74
- }
75
- }, {
76
- key: "touchend",
77
- value: function touchend(e, points, mapTouches) {
78
- if (!this.firstTwoTouches) {
79
- return;
80
- }
81
- var _this$firstTwoTouches2 = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
82
- idA = _this$firstTwoTouches2[0],
83
- idB = _this$firstTwoTouches2[1];
84
- var a = getTouchById(mapTouches, points, idA);
85
- var b = getTouchById(mapTouches, points, idB);
86
- if (a && b) {
87
- return;
88
- }
89
- if (this.active) {
90
- _dom.default.suppressClick();
91
- }
92
- this.reset();
93
- }
94
- }, {
95
- key: "touchcancel",
96
- value: function touchcancel() {
97
- this.reset();
98
- }
99
- }, {
100
- key: "enable",
101
- value: function enable(options) {
102
- this.enabled = true;
103
- this.aroundCenter = !!options && options.around === 'center';
104
- }
105
- }, {
106
- key: "disable",
107
- value: function disable() {
108
- this.enabled = false;
109
- this.reset();
110
- }
111
- }, {
112
- key: "isEnabled",
113
- value: function isEnabled() {
114
- return this.enabled;
115
- }
116
- }, {
117
- key: "isActive",
118
- value: function isActive() {
119
- return this.active;
120
- }
121
- }]);
122
- return TwoTouchHandler;
123
- }();
124
- exports.default = TwoTouchHandler;
125
- function getTouchById(mapTouches, points, identifier) {
126
- for (var i = 0; i < mapTouches.length; i++) {
127
- if (mapTouches[i].identifier === identifier) {
128
- return points[i];
129
- }
130
- }
131
- }
package/lib/hash.js DELETED
@@ -1,143 +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.default = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _l7Utils = require("@antv/l7-utils");
12
- // @ts-ignore
13
- // tslint:disable-next-line:no-submodule-imports
14
-
15
- var throttle = _l7Utils.lodashUtil.throttle;
16
- /*
17
- * Adds the map's position to its page's location hash.
18
- * Passed as an option to the map object.
19
- *
20
- * @returns {Hash} `this`
21
- */
22
- var Hash = /*#__PURE__*/function () {
23
- function Hash(hashName) {
24
- var _this = this;
25
- (0, _classCallCheck2.default)(this, Hash);
26
- (0, _defineProperty2.default)(this, "onHashChange", function () {
27
- var loc = _this.getCurrentHash();
28
- if (loc.length >= 3 && !loc.some(function (v) {
29
- return isNaN(+v);
30
- })) {
31
- var bearing = _this.map.dragRotate.isEnabled() && _this.map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : _this.map.getBearing();
32
- _this.map.jumpTo({
33
- center: [+loc[2], +loc[1]],
34
- zoom: +loc[0],
35
- bearing: bearing,
36
- pitch: +(loc[4] || 0)
37
- });
38
- return true;
39
- }
40
- return false;
41
- });
42
- (0, _defineProperty2.default)(this, "getCurrentHash", function () {
43
- // Get the current hash from location, stripped from its number sign
44
- var hash = window.location.hash.replace('#', '');
45
- if (_this.hashName) {
46
- // Split the parameter-styled hash into parts and find the value we need
47
- var keyval;
48
- hash.split('&').map(function (part) {
49
- return part.split('=');
50
- }).forEach(function (part) {
51
- if (part[0] === _this.hashName) {
52
- keyval = part;
53
- }
54
- });
55
- return (keyval ? keyval[1] || '' : '').split('/');
56
- }
57
- return hash.split('/');
58
- });
59
- (0, _defineProperty2.default)(this, "updateHashUnthrottled", function () {
60
- var hash = _this.getHashString();
61
- try {
62
- window.history.replaceState(window.history.state, '', hash);
63
- } catch (SecurityError) {
64
- // IE11 does not allow this if the page is within an iframe created
65
- // with iframe.contentWindow.document.write(...).
66
- // https://github.com/mapbox/mapbox-gl-js/issues/7410
67
- }
68
- });
69
- this.hashName = hashName && encodeURIComponent(hashName);
70
-
71
- // Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.
72
- this.updateHash = throttle(this.updateHashUnthrottled, 30 * 1000 / 100);
73
- }
74
- (0, _createClass2.default)(Hash, [{
75
- key: "addTo",
76
- value: function addTo(map) {
77
- this.map = map;
78
- window.addEventListener('hashchange', this.onHashChange, false);
79
- this.map.on('moveend', this.updateHash);
80
- return this;
81
- }
82
- }, {
83
- key: "remove",
84
- value: function remove() {
85
- window.removeEventListener('hashchange', this.onHashChange, false);
86
- this.map.off('moveend', this.updateHash);
87
- // clearTimeout(this.updateHash());
88
-
89
- // @ts-ignore
90
- delete this.map;
91
- return this;
92
- }
93
- }, {
94
- key: "getHashString",
95
- value: function getHashString(mapFeedback) {
96
- var center = this.map.getCenter();
97
- var zoom = Math.round(this.map.getZoom() * 100) / 100;
98
- // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
99
- var precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10);
100
- var m = Math.pow(10, precision);
101
- var lng = Math.round(center.lng * m) / m;
102
- var lat = Math.round(center.lat * m) / m;
103
- var bearing = this.map.getBearing();
104
- var pitch = this.map.getPitch();
105
- var hash = '';
106
- if (mapFeedback) {
107
- // new map feedback site has some constraints that don't allow
108
- // us to use the same hash format as we do for the Map hash option.
109
- hash += "/".concat(lng, "/").concat(lat, "/").concat(zoom);
110
- } else {
111
- hash += "".concat(zoom, "/").concat(lat, "/").concat(lng);
112
- }
113
- if (bearing || pitch) {
114
- hash += "/".concat(Math.round(bearing * 10) / 10);
115
- }
116
- if (pitch) {
117
- hash += "/".concat(Math.round(pitch));
118
- }
119
- if (this.hashName) {
120
- var hashName = this.hashName;
121
- var found = false;
122
- var parts = window.location.hash.slice(1).split('&').map(function (part) {
123
- var key = part.split('=')[0];
124
- if (key === hashName) {
125
- found = true;
126
- return "".concat(key, "=").concat(hash);
127
- }
128
- return part;
129
- }).filter(function (a) {
130
- return a;
131
- });
132
- if (!found) {
133
- parts.push("".concat(hashName, "=").concat(hash));
134
- }
135
- return "#".concat(parts.join('&'));
136
- }
137
- return "#".concat(hash);
138
- }
139
- }]);
140
- return Hash;
141
- }();
142
- var _default = Hash;
143
- exports.default = _default;
package/lib/index.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _earthmap = require("./earthmap");
7
- Object.keys(_earthmap).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _earthmap[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function get() {
13
- return _earthmap[key];
14
- }
15
- });
16
- });
17
- var _mercator = require("./geo/mercator");
18
- Object.keys(_mercator).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _mercator[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function get() {
24
- return _mercator[key];
25
- }
26
- });
27
- });
28
- var _interface = require("./interface");
29
- Object.keys(_interface).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _interface[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function get() {
35
- return _interface[key];
36
- }
37
- });
38
- });
39
- var _map = require("./map");
40
- Object.keys(_map).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _map[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function get() {
46
- return _map[key];
47
- }
48
- });
49
- });
package/lib/interface.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });