@antv/l7-map 2.17.11 → 2.17.12

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