@antv/l7-map 2.5.37-mini2 → 2.5.39
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/LICENSE.md +21 -0
- package/es/camera.d.ts +82 -0
- package/es/camera.js +729 -0
- package/es/camera.js.map +1 -0
- package/es/earthmap.d.ts +67 -0
- package/es/earthmap.js +461 -0
- package/es/earthmap.js.map +1 -0
- package/es/geo/edge_insets.d.ts +54 -0
- package/es/geo/edge_insets.js +88 -0
- package/es/geo/edge_insets.js.map +1 -0
- package/es/geo/lng_lat.d.ts +18 -0
- package/es/geo/lng_lat.js +77 -0
- package/es/geo/lng_lat.js.map +1 -0
- package/es/geo/lng_lat_bounds.d.ts +24 -0
- package/es/geo/lng_lat_bounds.js +170 -0
- package/es/geo/lng_lat_bounds.js.map +1 -0
- package/es/geo/mercator.d.ts +28 -0
- package/es/geo/mercator.js +79 -0
- package/es/geo/mercator.js.map +1 -0
- package/es/geo/point.d.ts +40 -0
- package/es/geo/point.js +237 -0
- package/es/geo/point.js.map +1 -0
- package/es/geo/simple.d.ts +28 -0
- package/es/geo/simple.js +78 -0
- package/es/geo/simple.js.map +1 -0
- package/es/geo/transform.d.ts +198 -0
- package/es/geo/transform.js +663 -0
- package/es/geo/transform.js.map +1 -0
- package/es/handler/IHandler.d.ts +34 -0
- package/es/handler/IHandler.js +2 -0
- package/es/handler/IHandler.js.map +1 -0
- package/es/handler/blockable_map_event.d.ts +17 -0
- package/es/handler/blockable_map_event.js +84 -0
- package/es/handler/blockable_map_event.js.map +1 -0
- package/es/handler/box_zoom.d.ts +59 -0
- package/es/handler/box_zoom.js +184 -0
- package/es/handler/box_zoom.js.map +1 -0
- package/es/handler/click_zoom.d.ts +16 -0
- package/es/handler/click_zoom.js +64 -0
- package/es/handler/click_zoom.js.map +1 -0
- package/es/handler/events/event.d.ts +4 -0
- package/es/handler/events/event.js +14 -0
- package/es/handler/events/event.js.map +1 -0
- package/es/handler/events/index.d.ts +4 -0
- package/es/handler/events/index.js +5 -0
- package/es/handler/events/index.js.map +1 -0
- package/es/handler/events/map_mouse_event.d.ts +34 -0
- package/es/handler/events/map_mouse_event.js +65 -0
- package/es/handler/events/map_mouse_event.js.map +1 -0
- package/es/handler/events/map_touch_event.d.ts +57 -0
- package/es/handler/events/map_touch_event.js +75 -0
- package/es/handler/events/map_touch_event.js.map +1 -0
- package/es/handler/events/map_wheel_event.d.ts +33 -0
- package/es/handler/events/map_wheel_event.js +52 -0
- package/es/handler/events/map_wheel_event.js.map +1 -0
- package/es/handler/events/render_event.d.ts +5 -0
- package/es/handler/events/render_event.js +41 -0
- package/es/handler/events/render_event.js.map +1 -0
- package/es/handler/handler_inertia.d.ts +23 -0
- package/es/handler/handler_inertia.js +186 -0
- package/es/handler/handler_inertia.js.map +1 -0
- package/es/handler/handler_manager.d.ts +57 -0
- package/es/handler/handler_manager.js +655 -0
- package/es/handler/handler_manager.js.map +1 -0
- package/es/handler/handler_util.d.ts +4 -0
- package/es/handler/handler_util.js +10 -0
- package/es/handler/handler_util.js.map +1 -0
- package/es/handler/keyboard.d.ts +36 -0
- package/es/handler/keyboard.js +157 -0
- package/es/handler/keyboard.js.map +1 -0
- package/es/handler/map_event.d.ts +29 -0
- package/es/handler/map_event.js +120 -0
- package/es/handler/map_event.js.map +1 -0
- package/es/handler/mouse/index.d.ts +4 -0
- package/es/handler/mouse/index.js +5 -0
- package/es/handler/mouse/index.js.map +1 -0
- package/es/handler/mouse/mouse_handler.d.ts +22 -0
- package/es/handler/mouse/mouse_handler.js +131 -0
- package/es/handler/mouse/mouse_handler.js.map +1 -0
- package/es/handler/mouse/mousepan_handler.d.ts +10 -0
- package/es/handler/mouse/mousepan_handler.js +54 -0
- package/es/handler/mouse/mousepan_handler.js.map +1 -0
- package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/es/handler/mouse/mousepitch_hander.js +54 -0
- package/es/handler/mouse/mousepitch_hander.js.map +1 -0
- package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/es/handler/mouse/mouserotate_hander.js +54 -0
- package/es/handler/mouse/mouserotate_hander.js.map +1 -0
- package/es/handler/mouse/util.d.ts +6 -0
- package/es/handler/mouse/util.js +12 -0
- package/es/handler/mouse/util.js.map +1 -0
- package/es/handler/scroll_zoom.d.ts +93 -0
- package/es/handler/scroll_zoom.js +317 -0
- package/es/handler/scroll_zoom.js.map +1 -0
- package/es/handler/shim/dblclick_zoom.d.ts +40 -0
- package/es/handler/shim/dblclick_zoom.js +45 -0
- package/es/handler/shim/dblclick_zoom.js.map +1 -0
- package/es/handler/shim/drag_pan.d.ts +61 -0
- package/es/handler/shim/drag_pan.js +53 -0
- package/es/handler/shim/drag_pan.js.map +1 -0
- package/es/handler/shim/drag_rotate.d.ts +46 -0
- package/es/handler/shim/drag_rotate.js +51 -0
- package/es/handler/shim/drag_rotate.js.map +1 -0
- package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/es/handler/shim/touch_zoom_rotate.js +80 -0
- package/es/handler/shim/touch_zoom_rotate.js.map +1 -0
- package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/es/handler/tap/single_tap_recognizer.js +127 -0
- package/es/handler/tap/single_tap_recognizer.js.map +1 -0
- package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/es/handler/tap/tap_drag_zoom.js +124 -0
- package/es/handler/tap/tap_drag_zoom.js.map +1 -0
- package/es/handler/tap/tap_recognizer.d.ts +17 -0
- package/es/handler/tap/tap_recognizer.js +72 -0
- package/es/handler/tap/tap_recognizer.js.map +1 -0
- package/es/handler/tap/tap_zoom.d.ts +22 -0
- package/es/handler/tap/tap_zoom.js +124 -0
- package/es/handler/tap/tap_zoom.js.map +1 -0
- package/es/handler/touch/index.d.ts +5 -0
- package/es/handler/touch/index.js +6 -0
- package/es/handler/touch/index.js.map +1 -0
- package/es/handler/touch/touch_pan.d.ts +30 -0
- package/es/handler/touch/touch_pan.js +139 -0
- package/es/handler/touch/touch_pan.js.map +1 -0
- package/es/handler/touch/touch_pitch.d.ts +13 -0
- package/es/handler/touch/touch_pitch.js +120 -0
- package/es/handler/touch/touch_pitch.js.map +1 -0
- package/es/handler/touch/touch_rotate.d.ts +12 -0
- package/es/handler/touch/touch_rotate.js +88 -0
- package/es/handler/touch/touch_rotate.js.map +1 -0
- package/es/handler/touch/touch_zoom.d.ts +12 -0
- package/es/handler/touch/touch_zoom.js +79 -0
- package/es/handler/touch/touch_zoom.js.map +1 -0
- package/es/handler/touch/two_touch.d.ts +23 -0
- package/es/handler/touch/two_touch.js +140 -0
- package/es/handler/touch/two_touch.js.map +1 -0
- package/es/hash.d.ts +15 -0
- package/es/hash.js +143 -0
- package/es/hash.js.map +1 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -0
- package/es/index.js.map +1 -0
- package/es/interface.d.ts +31 -0
- package/es/interface.js +2 -0
- package/es/interface.js.map +1 -0
- package/es/map.d.ts +67 -0
- package/es/map.js +461 -0
- package/es/map.js.map +1 -0
- package/es/util.d.ts +18 -0
- package/es/util.js +74 -0
- package/es/util.js.map +1 -0
- package/es/utils/Aabb.d.ts +12 -0
- package/es/utils/Aabb.js +134 -0
- package/es/utils/Aabb.js.map +1 -0
- package/es/utils/dom.d.ts +4 -0
- package/es/utils/dom.js +165 -0
- package/es/utils/dom.js.map +1 -0
- package/es/utils/performance.d.ts +17 -0
- package/es/utils/performance.js +57 -0
- package/es/utils/performance.js.map +1 -0
- package/es/utils/primitives.d.ts +6 -0
- package/es/utils/primitives.js +44 -0
- package/es/utils/primitives.js.map +1 -0
- package/es/utils/task_queue.d.ts +13 -0
- package/es/utils/task_queue.js +113 -0
- package/es/utils/task_queue.js.map +1 -0
- package/lib/camera.js.map +1 -1
- package/lib/earthmap.js +26 -0
- package/lib/earthmap.js.map +1 -1
- package/lib/handler/handler_manager.js +33 -55
- package/lib/handler/handler_manager.js.map +1 -1
- package/lib/handler/shim/drag_pan.js +2 -10
- package/lib/handler/shim/drag_pan.js.map +1 -1
- package/lib/handler/shim/touch_zoom_rotate.js +2 -10
- package/lib/handler/shim/touch_zoom_rotate.js.map +1 -1
- package/lib/hash.js +4 -9
- package/lib/hash.js.map +1 -1
- package/lib/map.js +19 -32
- package/lib/map.js.map +1 -1
- package/lib/util.js +5 -7
- package/lib/util.js.map +1 -1
- package/lib/utils/dom.js +26 -66
- package/lib/utils/dom.js.map +1 -1
- package/lib/utils/performance.js +1 -4
- package/lib/utils/performance.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/handler/touch/two_touch.ts"],"names":["DOM","TwoTouchHandler","reset","active","firstTwoTouches","points","pinchAround","e","mapTouches","length","identifier","start","preventDefault","idA","idB","a","getTouchById","b","aroundCenter","add","div","move","suppressClick","options","enabled","around","i"],"mappings":";;;;AAEA,OAAOA,GAAP,MAAgB,iBAAhB;;IAEqBC,e;AAQnB,6BAAc;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACZ,SAAKC,KAAL;AACD;;;;WAED,iBAAe;AACb,WAAKC,MAAL,GAAc,KAAd;AACA,aAAO,KAAKC,eAAZ;AACD;;;WACD,eAAaC,MAAb,EAAqC;AACnC;AACD;;;WACD,cACEA,MADF,EAEEC,WAFF,EAGEC,CAHF,EAIE;AACA;AACD;;;WAED,oBAAkBA,CAAlB,EAAiCF,MAAjC,EAAkDG,UAAlD,EAAuE;AAGrE,UAAI,KAAKJ,eAAL,IAAwBI,UAAU,CAACC,MAAX,GAAoB,CAAhD,EAAmD;AACjD;AACD;;AAED,WAAKL,eAAL,GAAuB,CAACI,UAAU,CAAC,CAAD,CAAV,CAAcE,UAAf,EAA2BF,UAAU,CAAC,CAAD,CAAV,CAAcE,UAAzC,CAAvB;AAGA,WAAKC,KAAL,CAAW,CAACN,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,CAAX;AACD;;;WAED,mBAAiBE,CAAjB,EAAgCF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AAL,GAAoB,CAAC,CAACK,OAAF,IAAaA,OAAO,CAACE,MAAR,KAAmB,QAApD;AACD;;;WAED,mBAAiB;AACf,WAAKD,OAAL,GAAe,KAAf;AACA,WAAKtB,KAAL;AACD;;;WAED,qBAAmB;AACjB,aAAO,KAAKsB,OAAZ;AACD;;;WAED,oBAAkB;AAChB,aAAO,KAAKrB,MAAZ;AACD;;;;;;SAlGkBF,e;;AAqGrB,SAASe,YAAT,CACER,UADF,EAEEH,MAFF,EAGEK,UAHF,EAIE;AACA,OAAK,IAAIgB,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGlB,UAAU,CAACC,MAA/B,EAAuCiB,CAAC,EAAxC,EAA4C;AAC1C,QAAIlB,UAAU,CAACkB,CAAD,CAAV,CAAchB,UAAd,KAA6BA,UAAjC,EAA6C;AAC3C,aAAOL,MAAM,CAACqB,CAAD,CAAb;AACD;AACF;AACF","sourcesContent":["// @ts-ignore\nimport Point from '../../geo/point';\nimport DOM from '../../utils/dom';\n\nexport default class TwoTouchHandler {\n protected enabled: boolean;\n protected active: boolean;\n protected firstTwoTouches: [number, number];\n protected vector: Point;\n protected startVector: Point;\n protected aroundCenter: boolean;\n\n constructor() {\n this.reset();\n }\n\n public reset() {\n this.active = false;\n delete this.firstTwoTouches;\n }\n public start(points: [Point, Point]) {\n return;\n } // eslint-disable-line\n public move(\n points: [Point, Point],\n pinchAround: Point | null,\n e: TouchEvent,\n ) {\n return;\n } // eslint-disable-line\n\n public touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]) {\n // console.log(e.target, e.targetTouches.length ? e.targetTouches[0].target : null);\n // log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);\n if (this.firstTwoTouches || mapTouches.length < 2) {\n return;\n }\n\n this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];\n\n // implemented by child classes\n this.start([points[0], points[1]]);\n }\n\n public touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]) {\n if (!this.firstTwoTouches) {\n return;\n }\n\n e.preventDefault();\n\n const [idA, idB] = this.firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (!a || !b) {\n return;\n }\n const pinchAround = this.aroundCenter ? null : a.add(b).div(2);\n\n // implemented by child classes\n return this.move([a, b], pinchAround, e);\n }\n\n public touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]) {\n if (!this.firstTwoTouches) {\n return;\n }\n\n const [idA, idB] = this.firstTwoTouches;\n const a = getTouchById(mapTouches, points, idA);\n const b = getTouchById(mapTouches, points, idB);\n if (a && b) {\n return;\n }\n\n if (this.active) {\n DOM.suppressClick();\n }\n\n this.reset();\n }\n\n public touchcancel() {\n this.reset();\n }\n\n public enable(options?: { around?: 'center' }) {\n this.enabled = true;\n this.aroundCenter = !!options && options.around === 'center';\n }\n\n public disable() {\n this.enabled = false;\n this.reset();\n }\n\n public isEnabled() {\n return this.enabled;\n }\n\n public isActive() {\n return this.active;\n }\n}\n\nfunction getTouchById(\n mapTouches: Touch[],\n points: Point[],\n identifier: number,\n) {\n for (let i = 0; i < mapTouches.length; i++) {\n if (mapTouches[i].identifier === identifier) {\n return points[i];\n }\n }\n}\n"],"file":"two_touch.js"}
|
package/es/hash.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EarthMap } from './earthmap';
|
|
2
|
+
import { Map } from './map';
|
|
3
|
+
declare class Hash {
|
|
4
|
+
private map;
|
|
5
|
+
private updateHash;
|
|
6
|
+
private hashName?;
|
|
7
|
+
constructor(hashName?: string);
|
|
8
|
+
addTo(map: Map | EarthMap): this;
|
|
9
|
+
remove(): this;
|
|
10
|
+
onHashChange: () => boolean;
|
|
11
|
+
private getCurrentHash;
|
|
12
|
+
private getHashString;
|
|
13
|
+
private updateHashUnthrottled;
|
|
14
|
+
}
|
|
15
|
+
export default Hash;
|
package/es/hash.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import throttle from 'lodash/throttle';
|
|
5
|
+
|
|
6
|
+
var Hash = function () {
|
|
7
|
+
function Hash(hashName) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
|
|
10
|
+
_classCallCheck(this, Hash);
|
|
11
|
+
|
|
12
|
+
_defineProperty(this, "map", void 0);
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "updateHash", void 0);
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "hashName", void 0);
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "onHashChange", function () {
|
|
19
|
+
var loc = _this.getCurrentHash();
|
|
20
|
+
|
|
21
|
+
if (loc.length >= 3 && !loc.some(function (v) {
|
|
22
|
+
return isNaN(+v);
|
|
23
|
+
})) {
|
|
24
|
+
var bearing = _this.map.dragRotate.isEnabled() && _this.map.touchZoomRotate.isEnabled() ? +(loc[3] || 0) : _this.map.getBearing();
|
|
25
|
+
|
|
26
|
+
_this.map.jumpTo({
|
|
27
|
+
center: [+loc[2], +loc[1]],
|
|
28
|
+
zoom: +loc[0],
|
|
29
|
+
bearing: bearing,
|
|
30
|
+
pitch: +(loc[4] || 0)
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "getCurrentHash", function () {
|
|
40
|
+
var hash = window.location.hash.replace('#', '');
|
|
41
|
+
|
|
42
|
+
if (_this.hashName) {
|
|
43
|
+
var keyval;
|
|
44
|
+
hash.split('&').map(function (part) {
|
|
45
|
+
return part.split('=');
|
|
46
|
+
}).forEach(function (part) {
|
|
47
|
+
if (part[0] === _this.hashName) {
|
|
48
|
+
keyval = part;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return (keyval ? keyval[1] || '' : '').split('/');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return hash.split('/');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
_defineProperty(this, "updateHashUnthrottled", function () {
|
|
58
|
+
var hash = _this.getHashString();
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
window.history.replaceState(window.history.state, '', hash);
|
|
62
|
+
} catch (SecurityError) {}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
this.hashName = hashName && encodeURIComponent(hashName);
|
|
66
|
+
this.updateHash = throttle(this.updateHashUnthrottled, 30 * 1000 / 100);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_createClass(Hash, [{
|
|
70
|
+
key: "addTo",
|
|
71
|
+
value: function addTo(map) {
|
|
72
|
+
this.map = map;
|
|
73
|
+
window.addEventListener('hashchange', this.onHashChange, false);
|
|
74
|
+
this.map.on('moveend', this.updateHash);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "remove",
|
|
79
|
+
value: function remove() {
|
|
80
|
+
window.removeEventListener('hashchange', this.onHashChange, false);
|
|
81
|
+
this.map.off('moveend', this.updateHash);
|
|
82
|
+
delete this.map;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "getHashString",
|
|
87
|
+
value: function getHashString(mapFeedback) {
|
|
88
|
+
var center = this.map.getCenter();
|
|
89
|
+
var zoom = Math.round(this.map.getZoom() * 100) / 100;
|
|
90
|
+
var precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10);
|
|
91
|
+
var m = Math.pow(10, precision);
|
|
92
|
+
var lng = Math.round(center.lng * m) / m;
|
|
93
|
+
var lat = Math.round(center.lat * m) / m;
|
|
94
|
+
var bearing = this.map.getBearing();
|
|
95
|
+
var pitch = this.map.getPitch();
|
|
96
|
+
var hash = '';
|
|
97
|
+
|
|
98
|
+
if (mapFeedback) {
|
|
99
|
+
hash += "/".concat(lng, "/").concat(lat, "/").concat(zoom);
|
|
100
|
+
} else {
|
|
101
|
+
hash += "".concat(zoom, "/").concat(lat, "/").concat(lng);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (bearing || pitch) {
|
|
105
|
+
hash += "/".concat(Math.round(bearing * 10) / 10);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (pitch) {
|
|
109
|
+
hash += "/".concat(Math.round(pitch));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (this.hashName) {
|
|
113
|
+
var hashName = this.hashName;
|
|
114
|
+
var found = false;
|
|
115
|
+
var parts = window.location.hash.slice(1).split('&').map(function (part) {
|
|
116
|
+
var key = part.split('=')[0];
|
|
117
|
+
|
|
118
|
+
if (key === hashName) {
|
|
119
|
+
found = true;
|
|
120
|
+
return "".concat(key, "=").concat(hash);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return part;
|
|
124
|
+
}).filter(function (a) {
|
|
125
|
+
return a;
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (!found) {
|
|
129
|
+
parts.push("".concat(hashName, "=").concat(hash));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return "#".concat(parts.join('&'));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return "#".concat(hash);
|
|
136
|
+
}
|
|
137
|
+
}]);
|
|
138
|
+
|
|
139
|
+
return Hash;
|
|
140
|
+
}();
|
|
141
|
+
|
|
142
|
+
export default Hash;
|
|
143
|
+
//# sourceMappingURL=hash.js.map
|
package/es/hash.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hash.ts"],"names":["throttle","Hash","hashName","loc","getCurrentHash","length","some","v","isNaN","bearing","map","dragRotate","isEnabled","touchZoomRotate","getBearing","jumpTo","center","zoom","pitch","hash","window","location","replace","keyval","split","part","forEach","getHashString","history","replaceState","state","SecurityError","encodeURIComponent","updateHash","updateHashUnthrottled","addEventListener","onHashChange","on","removeEventListener","off","mapFeedback","getCenter","Math","round","getZoom","precision","ceil","LN2","log","LN10","m","pow","lng","lat","getPitch","found","parts","slice","key","filter","a","push","join"],"mappings":";;;AAEA,OAAOA,QAAP,MAAqB,iBAArB;;IAUMC,I;AAKJ,gBAAYC,QAAZ,EAA+B;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,0CAuBT,YAAM;AAC1B,UAAMC,GAAG,GAAG,KAAI,CAACC,cAAL,EAAZ;;AACA,UAAID,GAAG,CAACE,MAAJ,IAAc,CAAd,IAAmB,CAACF,GAAG,CAACG,IAAJ,CAAS,UAACC,CAAD;AAAA,eAAeC,KAAK,CAAC,CAACD,CAAF,CAApB;AAAA,OAAT,CAAxB,EAA4D;AAC1D,YAAME,OAAO,GACX,KAAI,CAACC,GAAL,CAASC,UAAT,CAAoBC,SAApB,MAAmC,KAAI,CAACF,GAAL,CAASG,eAAT,CAAyBD,SAAzB,EAAnC,GACI,EAAET,GAAG,CAAC,CAAD,CAAH,IAAU,CAAZ,CADJ,GAEI,KAAI,CAACO,GAAL,CAASI,UAAT,EAHN;;AAIA,QAAA,KAAI,CAACJ,GAAL,CAASK,MAAT,CAAgB;AACdC,UAAAA,MAAM,EAAE,CAAC,CAACb,GAAG,CAAC,CAAD,CAAL,EAAU,CAACA,GAAG,CAAC,CAAD,CAAd,CADM;AAEdc,UAAAA,IAAI,EAAE,CAACd,GAAG,CAAC,CAAD,CAFI;AAGdM,UAAAA,OAAO,EAAPA,OAHc;AAIdS,UAAAA,KAAK,EAAE,EAAEf,GAAG,CAAC,CAAD,CAAH,IAAU,CAAZ;AAJO,SAAhB;;AAMA,eAAO,IAAP;AACD;;AACD,aAAO,KAAP;AACD,KAvC8B;;AAAA,4CAyCN,YAAM;AAE7B,UAAMgB,IAAI,GAAGC,MAAM,CAACC,QAAP,CAAgBF,IAAhB,CAAqBG,OAArB,CAA6B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,CAAJ;AACD;;AAED,UAAI3C,OAAO,IAAIS,KAAf,EAAsB;AACpBC,QAAAA,IAAI,eAAQuB,IAAI,CAACC,KAAL,CAAWlC,OAAO,GAAG,EAArB,IAA2B,EAAnC,CAAJ;AACD;;AACD,UAAIS,KAAJ,EAAW;AACTC,QAAAA,IAAI,eAAQuB,IAAI,CAACC,KAAL,CAAWzB,KAAX,CAAR,CAAJ;AACD;;AAED,UAAI,KAAKhB,QAAT,EAAmB;AACjB,YAAMA,QAAQ,GAAG,KAAKA,QAAtB;AACA,YAAIqD,KAAK,GAAG,KAAZ;AACA,YAAMC,KAAK,GAAGpC,MAAM,CAACC,QAAP,CAAgBF,IAAhB,CACXsC,KADW,CACL,CADK,EAEXjC,KAFW,CAEL,GAFK,EAGXd,GAHW,CAGP,UAACe,IAAD,EAAU;AACb,cAAMiC,GAAG,GAAGjC,IAAI,CAACD,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAAZ;;AACA,cAAIkC,GAAG,KAAKxD,QAAZ,EAAsB;AACpBqD,YAAAA,KAAK,GAAG,IAAR;AACA,6BAAUG,GAAV,cAAiBvC,IAAjB;AACD;;AACD,iBAAOM,IAAP;AACD,SAVW,EAWXkC,MAXW,CAWJ,UAACC,CAAD;AAAA,iBAAOA,CAAP;AAAA,SAXI,CAAd;;AAYA,YAAI,CAACL,KAAL,EAAY;AACVC,UAAAA,KAAK,CAACK,IAAN,WAAc3D,QAAd,cAA0BiB,IAA1B;AACD;;AACD,0BAAWqC,KAAK,CAACM,IAAN,CAAW,GAAX,CAAX;AACD;;AAED,wBAAW3C,IAAX;AACD;;;;;;AAcH,eAAelB,IAAf","sourcesContent":["// @ts-ignore\n// tslint:disable-next-line:no-submodule-imports\nimport throttle from 'lodash/throttle';\nimport { EarthMap } from './earthmap';\nimport { Map } from './map';\n\n/*\n * Adds the map's position to its page's location hash.\n * Passed as an option to the map object.\n *\n * @returns {Hash} `this`\n */\nclass Hash {\n private map: Map | EarthMap;\n private updateHash: () => number | void;\n private hashName?: string;\n\n constructor(hashName?: string) {\n this.hashName = hashName && encodeURIComponent(hashName);\n\n // Mobile Safari doesn't allow updating the hash more than 100 times per 30 seconds.\n this.updateHash = throttle(this.updateHashUnthrottled, (30 * 1000) / 100);\n }\n public addTo(map: Map | EarthMap) {\n this.map = map;\n window.addEventListener('hashchange', this.onHashChange, false);\n // @ts-ignore\n this.map.on('moveend', this.updateHash);\n return this;\n }\n public remove() {\n window.removeEventListener('hashchange', this.onHashChange, false);\n // @ts-ignore\n this.map.off('moveend', this.updateHash);\n // clearTimeout(this.updateHash());\n // @ts-ignore\n delete this.map;\n return this;\n }\n\n public onHashChange = () => {\n const loc = this.getCurrentHash();\n if (loc.length >= 3 && !loc.some((v: string) => isNaN(+v))) {\n const bearing =\n this.map.dragRotate.isEnabled() && this.map.touchZoomRotate.isEnabled()\n ? +(loc[3] || 0)\n : this.map.getBearing();\n this.map.jumpTo({\n center: [+loc[2], +loc[1]],\n zoom: +loc[0],\n bearing,\n pitch: +(loc[4] || 0),\n });\n return true;\n }\n return false;\n };\n\n private getCurrentHash = () => {\n // Get the current hash from location, stripped from its number sign\n const hash = window.location.hash.replace('#', '');\n if (this.hashName) {\n // Split the parameter-styled hash into parts and find the value we need\n let keyval;\n hash\n .split('&')\n .map((part) => part.split('='))\n .forEach((part) => {\n if (part[0] === this.hashName) {\n keyval = part;\n }\n });\n return (keyval ? keyval[1] || '' : '').split('/');\n }\n return hash.split('/');\n };\n\n private getHashString(mapFeedback?: boolean) {\n const center = this.map.getCenter();\n const zoom = Math.round(this.map.getZoom() * 100) / 100;\n // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px\n const precision = Math.ceil(\n (zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10,\n );\n const m = Math.pow(10, precision);\n const lng = Math.round(center.lng * m) / m;\n const lat = Math.round(center.lat * m) / m;\n const bearing = this.map.getBearing();\n const pitch = this.map.getPitch();\n let hash = '';\n if (mapFeedback) {\n // new map feedback site has some constraints that don't allow\n // us to use the same hash format as we do for the Map hash option.\n hash += `/${lng}/${lat}/${zoom}`;\n } else {\n hash += `${zoom}/${lat}/${lng}`;\n }\n\n if (bearing || pitch) {\n hash += `/${Math.round(bearing * 10) / 10}`;\n }\n if (pitch) {\n hash += `/${Math.round(pitch)}`;\n }\n\n if (this.hashName) {\n const hashName = this.hashName;\n let found = false;\n const parts = window.location.hash\n .slice(1)\n .split('&')\n .map((part) => {\n const key = part.split('=')[0];\n if (key === hashName) {\n found = true;\n return `${key}=${hash}`;\n }\n return part;\n })\n .filter((a) => a);\n if (!found) {\n parts.push(`${hashName}=${hash}`);\n }\n return `#${parts.join('&')}`;\n }\n\n return `#${hash}`;\n }\n\n private updateHashUnthrottled = () => {\n const hash = this.getHashString();\n try {\n window.history.replaceState(window.history.state, '', hash);\n } catch (SecurityError) {\n // IE11 does not allow this if the page is within an iframe created\n // with iframe.contentWindow.document.write(...).\n // https://github.com/mapbox/mapbox-gl-js/issues/7410\n }\n };\n}\n\nexport default Hash;\n"],"file":"hash.js"}
|
package/es/index.d.ts
ADDED
package/es/index.js
ADDED
package/es/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAd;AACA,cAAc,YAAd","sourcesContent":["export * from './map';\nexport * from './earthmap';\n"],"file":"index.js"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LngLatBoundsLike } from './geo/lng_lat_bounds';
|
|
2
|
+
export interface IMapOptions {
|
|
3
|
+
hash: boolean;
|
|
4
|
+
style?: any;
|
|
5
|
+
container?: HTMLElement | string;
|
|
6
|
+
center: [number, number];
|
|
7
|
+
zoom: number;
|
|
8
|
+
bearing: number;
|
|
9
|
+
pitch: number;
|
|
10
|
+
interactive: boolean;
|
|
11
|
+
scrollZoom: boolean;
|
|
12
|
+
bounds?: LngLatBoundsLike;
|
|
13
|
+
maxBounds?: LngLatBoundsLike;
|
|
14
|
+
fitBoundsOptions?: any;
|
|
15
|
+
minZoom: number;
|
|
16
|
+
maxZoom: number;
|
|
17
|
+
minPitch: number;
|
|
18
|
+
maxPitch: number;
|
|
19
|
+
boxZoom: boolean;
|
|
20
|
+
dragRotate: boolean;
|
|
21
|
+
dragPan: boolean;
|
|
22
|
+
keyboard: boolean;
|
|
23
|
+
doubleClickZoom: boolean;
|
|
24
|
+
touchZoomRotate: boolean;
|
|
25
|
+
touchPitch: boolean;
|
|
26
|
+
trackResize: boolean;
|
|
27
|
+
renderWorldCopies: boolean;
|
|
28
|
+
bearingSnap: number;
|
|
29
|
+
clickTolerance: number;
|
|
30
|
+
pitchWithRotate: boolean;
|
|
31
|
+
}
|
package/es/interface.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"interface.js"}
|
package/es/map.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Camera from './camera';
|
|
2
|
+
import './css/l7.css';
|
|
3
|
+
import LngLat, { LngLatLike } from './geo/lng_lat';
|
|
4
|
+
import LngLatBounds, { LngLatBoundsLike } from './geo/lng_lat_bounds';
|
|
5
|
+
import Point, { PointLike } from './geo/point';
|
|
6
|
+
import BoxZoomHandler from './handler/box_zoom';
|
|
7
|
+
import HandlerManager from './handler/handler_manager';
|
|
8
|
+
import KeyboardHandler from './handler/keyboard';
|
|
9
|
+
import ScrollZoomHandler from './handler/scroll_zoom';
|
|
10
|
+
import DoubleClickZoomHandler from './handler/shim/dblclick_zoom';
|
|
11
|
+
import DragPanHandler from './handler/shim/drag_pan';
|
|
12
|
+
import DragRotateHandler from './handler/shim/drag_rotate';
|
|
13
|
+
import TouchZoomRotateHandler from './handler/shim/touch_zoom_rotate';
|
|
14
|
+
import { TouchPitchHandler } from './handler/touch';
|
|
15
|
+
import { IMapOptions } from './interface';
|
|
16
|
+
import { TaskID } from './utils/task_queue';
|
|
17
|
+
declare type CallBack = (_: number) => void;
|
|
18
|
+
export declare class Map extends Camera {
|
|
19
|
+
doubleClickZoom: DoubleClickZoomHandler;
|
|
20
|
+
dragRotate: DragRotateHandler;
|
|
21
|
+
dragPan: DragPanHandler;
|
|
22
|
+
touchZoomRotate: TouchZoomRotateHandler;
|
|
23
|
+
scrollZoom: ScrollZoomHandler;
|
|
24
|
+
keyboard: KeyboardHandler;
|
|
25
|
+
touchPitch: TouchPitchHandler;
|
|
26
|
+
boxZoom: BoxZoomHandler;
|
|
27
|
+
handlers: HandlerManager;
|
|
28
|
+
private container;
|
|
29
|
+
private canvas;
|
|
30
|
+
private canvasContainer;
|
|
31
|
+
private renderTaskQueue;
|
|
32
|
+
private frame;
|
|
33
|
+
private trackResize;
|
|
34
|
+
private hash;
|
|
35
|
+
constructor(options: Partial<IMapOptions>);
|
|
36
|
+
resize(eventData?: any): this;
|
|
37
|
+
getContainer(): HTMLElement;
|
|
38
|
+
getCanvas(): HTMLCanvasElement;
|
|
39
|
+
getCanvasContainer(): HTMLElement;
|
|
40
|
+
project(lngLat: LngLatLike): Point;
|
|
41
|
+
unproject(point: PointLike): LngLat;
|
|
42
|
+
getBounds(): LngLatBounds;
|
|
43
|
+
getMaxBounds(): LngLatBounds | null;
|
|
44
|
+
setMaxBounds(bounds: LngLatBoundsLike): void;
|
|
45
|
+
setStyle(style: any): void;
|
|
46
|
+
setMinZoom(minZoom?: number): this;
|
|
47
|
+
getMinZoom(): number;
|
|
48
|
+
setMaxZoom(maxZoom?: number): this;
|
|
49
|
+
getMaxZoom(): number;
|
|
50
|
+
setMinPitch(minPitch?: number): this;
|
|
51
|
+
getMinPitch(): number;
|
|
52
|
+
setMaxPitch(maxPitch?: number): this;
|
|
53
|
+
getMaxPitch(): number;
|
|
54
|
+
getRenderWorldCopies(): boolean;
|
|
55
|
+
setRenderWorldCopies(renderWorldCopies?: boolean): void;
|
|
56
|
+
remove(): void;
|
|
57
|
+
requestRenderFrame(cb: CallBack): TaskID;
|
|
58
|
+
cancelRenderFrame(id: TaskID): void;
|
|
59
|
+
triggerRepaint(): void;
|
|
60
|
+
update(time?: number): void;
|
|
61
|
+
private initContainer;
|
|
62
|
+
private containerDimensions;
|
|
63
|
+
private resizeCanvas;
|
|
64
|
+
private onWindowOnline;
|
|
65
|
+
private onWindowResize;
|
|
66
|
+
}
|
|
67
|
+
export {};
|