@antv/l7-map 2.18.2 → 2.18.3
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.d.ts +85 -0
- package/es/camera.js +718 -0
- package/es/css/l7.css +98 -0
- package/es/earthmap.d.ts +66 -0
- package/es/earthmap.js +369 -0
- package/es/geo/edge_insets.d.ts +54 -0
- package/es/geo/edge_insets.js +108 -0
- package/es/geo/lng_lat.d.ts +18 -0
- package/es/geo/lng_lat.js +73 -0
- package/es/geo/lng_lat_bounds.d.ts +24 -0
- package/es/geo/lng_lat_bounds.js +154 -0
- package/es/geo/mercator.d.ts +29 -0
- package/es/geo/mercator.js +84 -0
- package/es/geo/point.d.ts +40 -0
- package/es/geo/point.js +224 -0
- package/es/geo/simple.d.ts +29 -0
- package/es/geo/simple.js +87 -0
- package/es/geo/transform.d.ts +198 -0
- package/es/geo/transform.js +961 -0
- package/es/handler/IHandler.d.ts +34 -0
- package/es/handler/IHandler.js +1 -0
- package/es/handler/blockable_map_event.d.ts +17 -0
- package/es/handler/blockable_map_event.js +78 -0
- package/es/handler/box_zoom.d.ts +59 -0
- package/es/handler/box_zoom.js +180 -0
- package/es/handler/click_zoom.d.ts +16 -0
- package/es/handler/click_zoom.js +54 -0
- package/es/handler/events/event.d.ts +4 -0
- package/es/handler/events/event.js +11 -0
- package/es/handler/events/index.d.ts +4 -0
- package/es/handler/events/index.js +4 -0
- package/es/handler/events/map_mouse_event.d.ts +34 -0
- package/es/handler/events/map_mouse_event.js +64 -0
- package/es/handler/events/map_touch_event.d.ts +57 -0
- package/es/handler/events/map_touch_event.js +95 -0
- package/es/handler/events/map_wheel_event.d.ts +33 -0
- package/es/handler/events/map_wheel_event.js +50 -0
- package/es/handler/events/render_event.d.ts +5 -0
- package/es/handler/events/render_event.js +26 -0
- package/es/handler/handler_inertia.d.ts +23 -0
- package/es/handler/handler_inertia.js +157 -0
- package/es/handler/handler_manager.d.ts +61 -0
- package/es/handler/handler_manager.js +577 -0
- package/es/handler/handler_util.d.ts +4 -0
- package/es/handler/handler_util.js +9 -0
- package/es/handler/keyboard.d.ts +36 -0
- package/es/handler/keyboard.js +143 -0
- package/es/handler/map_event.d.ts +29 -0
- package/es/handler/map_event.js +125 -0
- package/es/handler/mouse/index.d.ts +4 -0
- package/es/handler/mouse/index.js +4 -0
- package/es/handler/mouse/mouse_handler.d.ts +22 -0
- package/es/handler/mouse/mouse_handler.js +118 -0
- package/es/handler/mouse/mousepan_handler.d.ts +10 -0
- package/es/handler/mouse/mousepan_handler.js +44 -0
- package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/es/handler/mouse/mousepitch_hander.js +46 -0
- package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/es/handler/mouse/mouserotate_hander.js +46 -0
- package/es/handler/mouse/util.d.ts +6 -0
- package/es/handler/mouse/util.js +11 -0
- package/es/handler/scroll_zoom.d.ts +93 -0
- package/es/handler/scroll_zoom.js +325 -0
- package/es/handler/shim/dblclick_zoom.d.ts +40 -0
- package/es/handler/shim/dblclick_zoom.js +67 -0
- package/es/handler/shim/drag_pan.d.ts +61 -0
- package/es/handler/shim/drag_pan.js +84 -0
- package/es/handler/shim/drag_rotate.d.ts +46 -0
- package/es/handler/shim/drag_rotate.js +74 -0
- package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/es/handler/shim/touch_zoom_rotate.js +115 -0
- package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/es/handler/tap/single_tap_recognizer.js +97 -0
- package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/es/handler/tap/tap_drag_zoom.js +106 -0
- package/es/handler/tap/tap_recognizer.d.ts +17 -0
- package/es/handler/tap/tap_recognizer.js +54 -0
- package/es/handler/tap/tap_zoom.d.ts +22 -0
- package/es/handler/tap/tap_zoom.js +109 -0
- package/es/handler/touch/index.d.ts +5 -0
- package/es/handler/touch/index.js +5 -0
- package/es/handler/touch/touch_pan.d.ts +30 -0
- package/es/handler/touch/touch_pan.js +110 -0
- package/es/handler/touch/touch_pitch.d.ts +13 -0
- package/es/handler/touch/touch_pitch.js +93 -0
- package/es/handler/touch/touch_rotate.d.ts +12 -0
- package/es/handler/touch/touch_rotate.js +77 -0
- package/es/handler/touch/touch_zoom.d.ts +12 -0
- package/es/handler/touch/touch_zoom.js +54 -0
- package/es/handler/touch/two_touch.d.ts +23 -0
- package/es/handler/touch/two_touch.js +125 -0
- package/es/hash.d.ts +14 -0
- package/es/hash.js +134 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/interface.d.ts +34 -0
- package/es/interface.js +1 -0
- package/es/map.d.ts +70 -0
- package/es/map.js +387 -0
- package/es/util.d.ts +25 -0
- package/es/util.js +88 -0
- package/es/utils/Aabb.d.ts +12 -0
- package/es/utils/Aabb.js +112 -0
- package/es/utils/dom.d.ts +4 -0
- package/es/utils/dom.js +140 -0
- package/es/utils/performance.d.ts +17 -0
- package/es/utils/performance.js +62 -0
- package/es/utils/primitives.d.ts +6 -0
- package/es/utils/primitives.js +47 -0
- package/es/utils/task_queue.d.ts +13 -0
- package/es/utils/task_queue.js +89 -0
- package/lib/camera.js +724 -0
- package/lib/css/l7.css +98 -0
- package/lib/earthmap.js +376 -0
- package/lib/geo/edge_insets.js +114 -0
- package/lib/geo/lng_lat.js +81 -0
- package/lib/geo/lng_lat_bounds.js +161 -0
- package/lib/geo/mercator.js +100 -0
- package/lib/geo/point.js +231 -0
- package/lib/geo/simple.js +104 -0
- package/lib/geo/transform.js +971 -0
- package/lib/handler/IHandler.js +5 -0
- package/lib/handler/blockable_map_event.js +84 -0
- package/lib/handler/box_zoom.js +186 -0
- package/lib/handler/click_zoom.js +61 -0
- package/lib/handler/events/event.js +20 -0
- package/lib/handler/events/index.js +27 -0
- package/lib/handler/events/map_mouse_event.js +70 -0
- package/lib/handler/events/map_touch_event.js +100 -0
- package/lib/handler/events/map_wheel_event.js +57 -0
- package/lib/handler/events/render_event.js +33 -0
- package/lib/handler/handler_inertia.js +162 -0
- package/lib/handler/handler_manager.js +584 -0
- package/lib/handler/handler_util.js +15 -0
- package/lib/handler/keyboard.js +151 -0
- package/lib/handler/map_event.js +131 -0
- package/lib/handler/mouse/index.js +27 -0
- package/lib/handler/mouse/mouse_handler.js +124 -0
- package/lib/handler/mouse/mousepan_handler.js +49 -0
- package/lib/handler/mouse/mousepitch_hander.js +51 -0
- package/lib/handler/mouse/mouserotate_hander.js +51 -0
- package/lib/handler/mouse/util.js +22 -0
- package/lib/handler/scroll_zoom.js +333 -0
- package/lib/handler/shim/dblclick_zoom.js +74 -0
- package/lib/handler/shim/drag_pan.js +91 -0
- package/lib/handler/shim/drag_rotate.js +81 -0
- package/lib/handler/shim/touch_zoom_rotate.js +122 -0
- package/lib/handler/tap/single_tap_recognizer.js +106 -0
- package/lib/handler/tap/tap_drag_zoom.js +112 -0
- package/lib/handler/tap/tap_recognizer.js +63 -0
- package/lib/handler/tap/tap_zoom.js +115 -0
- package/lib/handler/touch/index.js +34 -0
- package/lib/handler/touch/touch_pan.js +117 -0
- package/lib/handler/touch/touch_pitch.js +98 -0
- package/lib/handler/touch/touch_rotate.js +82 -0
- package/lib/handler/touch/touch_zoom.js +59 -0
- package/lib/handler/touch/two_touch.js +131 -0
- package/lib/hash.js +143 -0
- package/lib/index.js +49 -0
- package/lib/interface.js +5 -0
- package/lib/map.js +394 -0
- package/lib/util.js +108 -0
- package/lib/utils/Aabb.js +119 -0
- package/lib/utils/dom.js +147 -0
- package/lib/utils/performance.js +70 -0
- package/lib/utils/primitives.js +54 -0
- package/lib/utils/task_queue.js +97 -0
- package/package.json +3 -3
|
@@ -0,0 +1,82 @@
|
|
|
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;
|
|
@@ -0,0 +1,59 @@
|
|
|
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;
|
|
@@ -0,0 +1,131 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
});
|