@antv/l7-map 2.5.25 → 2.5.26
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/earthmap.d.ts +67 -0
- package/es/earthmap.js +454 -0
- package/es/earthmap.js.map +1 -0
- package/es/handler/IHandler.d.ts +2 -1
- package/es/handler/blockable_map_event.d.ts +2 -1
- package/es/handler/blockable_map_event.js.map +1 -1
- package/es/handler/box_zoom.d.ts +2 -1
- package/es/handler/box_zoom.js.map +1 -1
- package/es/handler/click_zoom.d.ts +2 -1
- package/es/handler/click_zoom.js.map +1 -1
- package/es/handler/events/map_mouse_event.d.ts +3 -2
- package/es/handler/events/map_mouse_event.js.map +1 -1
- package/es/handler/events/map_touch_event.d.ts +3 -2
- package/es/handler/events/map_touch_event.js.map +1 -1
- package/es/handler/events/map_wheel_event.d.ts +4 -3
- package/es/handler/events/map_wheel_event.js.map +1 -1
- package/es/handler/handler_inertia.d.ts +2 -1
- package/es/handler/handler_inertia.js.map +1 -1
- package/es/handler/handler_manager.d.ts +2 -1
- package/es/handler/handler_manager.js.map +1 -1
- package/es/handler/keyboard.d.ts +2 -1
- package/es/handler/keyboard.js.map +1 -1
- package/es/handler/map_event.d.ts +2 -1
- package/es/handler/map_event.js.map +1 -1
- package/es/handler/scroll_zoom.d.ts +2 -1
- package/es/handler/scroll_zoom.js.map +1 -1
- package/es/handler/tap/tap_zoom.d.ts +2 -1
- package/es/handler/tap/tap_zoom.js.map +1 -1
- package/es/hash.d.ts +2 -1
- package/es/hash.js.map +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/lib/earthmap.js +465 -0
- package/lib/earthmap.js.map +1 -0
- package/lib/handler/blockable_map_event.js.map +1 -1
- package/lib/handler/box_zoom.js.map +1 -1
- package/lib/handler/click_zoom.js.map +1 -1
- package/lib/handler/events/map_mouse_event.js.map +1 -1
- package/lib/handler/events/map_touch_event.js.map +1 -1
- package/lib/handler/events/map_wheel_event.js.map +1 -1
- package/lib/handler/handler_inertia.js.map +1 -1
- package/lib/handler/handler_manager.js.map +1 -1
- package/lib/handler/keyboard.js.map +1 -1
- package/lib/handler/map_event.js.map +1 -1
- package/lib/handler/scroll_zoom.js.map +1 -1
- package/lib/handler/tap/tap_zoom.js.map +1 -1
- package/lib/hash.js.map +1 -1
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/es/earthmap.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 EarthMap 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 {};
|
package/es/earthmap.js
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
import _merge from "lodash/merge";
|
|
9
|
+
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
|
|
12
|
+
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; } }
|
|
13
|
+
|
|
14
|
+
import { DOM } from '@antv/l7-utils';
|
|
15
|
+
import Camera from './camera';
|
|
16
|
+
|
|
17
|
+
function loadStyles(css, doc) {
|
|
18
|
+
if (!doc) doc = document;
|
|
19
|
+
|
|
20
|
+
if (!doc) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var head = doc.head || doc.getElementsByTagName('head')[0];
|
|
25
|
+
|
|
26
|
+
if (!head) {
|
|
27
|
+
head = doc.createElement('head');
|
|
28
|
+
var body = doc.body || doc.getElementsByTagName('body')[0];
|
|
29
|
+
|
|
30
|
+
if (body) {
|
|
31
|
+
body.parentNode.insertBefore(head, body);
|
|
32
|
+
} else {
|
|
33
|
+
doc.documentElement.appendChild(head);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var style = doc.createElement('style');
|
|
38
|
+
style.type = 'text/css';
|
|
39
|
+
|
|
40
|
+
if (style.styleSheet) {
|
|
41
|
+
style.styleSheet.cssText = css;
|
|
42
|
+
} else {
|
|
43
|
+
style.appendChild(doc.createTextNode(css));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
head.appendChild(style);
|
|
47
|
+
return style;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
loadStyles(".l7-map {\n font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;\n overflow: hidden;\n position: relative;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.l7-canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.l7-map:-webkit-full-screen {\n width: 100%;\n height: 100%;\n}\n\n.l7-canary {\n background-color: salmon;\n}\n\n.l7-canvas-container.l7-interactive,\n.l7-ctrl-group button.l7-ctrl-compass {\n cursor: -webkit-grab;\n cursor: grab;\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.l7-canvas-container.l7-interactive.l7-track-pointer {\n cursor: pointer;\n}\n\n.l7-canvas-container.l7-interactive:active,\n.l7-ctrl-group button.l7-ctrl-compass:active {\n cursor: -webkit-grabbing;\n cursor: grabbing;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate,\n.l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {\n -ms-touch-action: pan-x pan-y;\n touch-action: pan-x pan-y;\n}\n\n.l7-canvas-container.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: pinch-zoom;\n touch-action: pinch-zoom;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: none;\n touch-action: none;\n}\n\n.l7-ctrl-top-left,\n.l7-ctrl-top-right,\n.l7-ctrl-bottom-left,\n.l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }\n.l7-ctrl-top-left { top: 0; left: 0; }\n.l7-ctrl-top-right { top: 0; right: 0; }\n.l7-ctrl-bottom-left { bottom: 0; left: 0; }\n.l7-ctrl-bottom-right { right: 0; bottom: 0; }\n\n.l7-ctrl {\n clear: both;\n pointer-events: auto;\n\n /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0);\n}\n.l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }\n.l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }\n.l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }\n.l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }\n\n\n.l7-crosshair,\n.l7-crosshair .l7-interactive,\n.l7-crosshair .l7-interactive:active {\n cursor: crosshair;\n}\n\n.l7-boxzoom {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n background: #fff;\n border: 2px dotted #202020;\n opacity: 0.5;\n z-index: 10;\n}\n");
|
|
51
|
+
import LngLat from './geo/lng_lat';
|
|
52
|
+
import LngLatBounds from './geo/lng_lat_bounds';
|
|
53
|
+
import Point from './geo/point';
|
|
54
|
+
import HandlerManager from './handler/handler_manager';
|
|
55
|
+
import Hash from './hash';
|
|
56
|
+
import { renderframe } from './util';
|
|
57
|
+
import { PerformanceUtils } from './utils/performance';
|
|
58
|
+
import TaskQueue from './utils/task_queue';
|
|
59
|
+
var defaultMinZoom = -2;
|
|
60
|
+
var defaultMaxZoom = 22;
|
|
61
|
+
var defaultMinPitch = 0;
|
|
62
|
+
var defaultMaxPitch = 60;
|
|
63
|
+
var DefaultOptions = {
|
|
64
|
+
hash: false,
|
|
65
|
+
zoom: -1,
|
|
66
|
+
center: [112, 32],
|
|
67
|
+
pitch: 0,
|
|
68
|
+
bearing: 0,
|
|
69
|
+
interactive: true,
|
|
70
|
+
minZoom: defaultMinZoom,
|
|
71
|
+
maxZoom: defaultMaxZoom,
|
|
72
|
+
minPitch: defaultMinPitch,
|
|
73
|
+
maxPitch: defaultMaxPitch,
|
|
74
|
+
scrollZoom: true,
|
|
75
|
+
boxZoom: true,
|
|
76
|
+
dragRotate: true,
|
|
77
|
+
dragPan: true,
|
|
78
|
+
keyboard: true,
|
|
79
|
+
doubleClickZoom: true,
|
|
80
|
+
touchZoomRotate: true,
|
|
81
|
+
touchPitch: true,
|
|
82
|
+
bearingSnap: 7,
|
|
83
|
+
clickTolerance: 3,
|
|
84
|
+
pitchWithRotate: true,
|
|
85
|
+
trackResize: true,
|
|
86
|
+
renderWorldCopies: true
|
|
87
|
+
};
|
|
88
|
+
export var EarthMap = function (_Camera) {
|
|
89
|
+
_inherits(EarthMap, _Camera);
|
|
90
|
+
|
|
91
|
+
var _super = _createSuper(EarthMap);
|
|
92
|
+
|
|
93
|
+
function EarthMap(options) {
|
|
94
|
+
var _this;
|
|
95
|
+
|
|
96
|
+
_classCallCheck(this, EarthMap);
|
|
97
|
+
|
|
98
|
+
_this = _super.call(this, _merge({}, DefaultOptions, options));
|
|
99
|
+
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "doubleClickZoom", void 0);
|
|
101
|
+
|
|
102
|
+
_defineProperty(_assertThisInitialized(_this), "dragRotate", void 0);
|
|
103
|
+
|
|
104
|
+
_defineProperty(_assertThisInitialized(_this), "dragPan", void 0);
|
|
105
|
+
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "touchZoomRotate", void 0);
|
|
107
|
+
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "scrollZoom", void 0);
|
|
109
|
+
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "keyboard", void 0);
|
|
111
|
+
|
|
112
|
+
_defineProperty(_assertThisInitialized(_this), "touchPitch", void 0);
|
|
113
|
+
|
|
114
|
+
_defineProperty(_assertThisInitialized(_this), "boxZoom", void 0);
|
|
115
|
+
|
|
116
|
+
_defineProperty(_assertThisInitialized(_this), "handlers", void 0);
|
|
117
|
+
|
|
118
|
+
_defineProperty(_assertThisInitialized(_this), "container", void 0);
|
|
119
|
+
|
|
120
|
+
_defineProperty(_assertThisInitialized(_this), "canvas", void 0);
|
|
121
|
+
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "canvasContainer", void 0);
|
|
123
|
+
|
|
124
|
+
_defineProperty(_assertThisInitialized(_this), "renderTaskQueue", new TaskQueue());
|
|
125
|
+
|
|
126
|
+
_defineProperty(_assertThisInitialized(_this), "frame", void 0);
|
|
127
|
+
|
|
128
|
+
_defineProperty(_assertThisInitialized(_this), "trackResize", true);
|
|
129
|
+
|
|
130
|
+
_defineProperty(_assertThisInitialized(_this), "hash", void 0);
|
|
131
|
+
|
|
132
|
+
_defineProperty(_assertThisInitialized(_this), "onWindowOnline", function () {
|
|
133
|
+
_this.update();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
_defineProperty(_assertThisInitialized(_this), "onWindowResize", function (event) {
|
|
137
|
+
if (_this.trackResize) {
|
|
138
|
+
_this.resize({
|
|
139
|
+
originalEvent: event
|
|
140
|
+
}).update();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
_this.initContainer();
|
|
145
|
+
|
|
146
|
+
_this.resize();
|
|
147
|
+
|
|
148
|
+
_this.handlers = new HandlerManager(_assertThisInitialized(_this), _this.options);
|
|
149
|
+
|
|
150
|
+
if (typeof window !== 'undefined') {
|
|
151
|
+
window.addEventListener('online', _this.onWindowOnline, false);
|
|
152
|
+
window.addEventListener('resize', _this.onWindowResize, false);
|
|
153
|
+
window.addEventListener('orientationchange', _this.onWindowResize, false);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
var hashName = typeof options.hash === 'string' && options.hash || undefined;
|
|
157
|
+
|
|
158
|
+
if (options.hash) {
|
|
159
|
+
_this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!_this.hash || !_this.hash.onHashChange()) {
|
|
163
|
+
_this.jumpTo({
|
|
164
|
+
center: options.center,
|
|
165
|
+
zoom: options.zoom,
|
|
166
|
+
bearing: options.bearing,
|
|
167
|
+
pitch: options.pitch
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (options.bounds) {
|
|
171
|
+
_this.resize();
|
|
172
|
+
|
|
173
|
+
_this.fitBounds(options.bounds, _merge({}, options.fitBoundsOptions, {
|
|
174
|
+
duration: 0
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return _this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_createClass(EarthMap, [{
|
|
183
|
+
key: "resize",
|
|
184
|
+
value: function resize(eventData) {
|
|
185
|
+
var dimensions = this.containerDimensions();
|
|
186
|
+
var width = dimensions[0];
|
|
187
|
+
var height = dimensions[1];
|
|
188
|
+
this.transform.resize(width, height);
|
|
189
|
+
var fireMoving = !this.moving;
|
|
190
|
+
|
|
191
|
+
if (fireMoving) {
|
|
192
|
+
this.stop();
|
|
193
|
+
this.emit('movestart', new Event('movestart', eventData));
|
|
194
|
+
this.emit('move', new Event('move', eventData));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.emit('resize', new Event('resize', eventData));
|
|
198
|
+
|
|
199
|
+
if (fireMoving) {
|
|
200
|
+
this.emit('moveend', new Event('moveend', eventData));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
key: "getContainer",
|
|
207
|
+
value: function getContainer() {
|
|
208
|
+
return this.container;
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "getCanvas",
|
|
212
|
+
value: function getCanvas() {
|
|
213
|
+
return this.canvas;
|
|
214
|
+
}
|
|
215
|
+
}, {
|
|
216
|
+
key: "getCanvasContainer",
|
|
217
|
+
value: function getCanvasContainer() {
|
|
218
|
+
return this.canvasContainer;
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "project",
|
|
222
|
+
value: function project(lngLat) {
|
|
223
|
+
return this.transform.locationPoint(LngLat.convert(lngLat));
|
|
224
|
+
}
|
|
225
|
+
}, {
|
|
226
|
+
key: "unproject",
|
|
227
|
+
value: function unproject(point) {
|
|
228
|
+
return this.transform.pointLocation(Point.convert(point));
|
|
229
|
+
}
|
|
230
|
+
}, {
|
|
231
|
+
key: "getBounds",
|
|
232
|
+
value: function getBounds() {
|
|
233
|
+
return this.transform.getBounds();
|
|
234
|
+
}
|
|
235
|
+
}, {
|
|
236
|
+
key: "getMaxBounds",
|
|
237
|
+
value: function getMaxBounds() {
|
|
238
|
+
return this.transform.getMaxBounds();
|
|
239
|
+
}
|
|
240
|
+
}, {
|
|
241
|
+
key: "setMaxBounds",
|
|
242
|
+
value: function setMaxBounds(bounds) {
|
|
243
|
+
this.transform.setMaxBounds(LngLatBounds.convert(bounds));
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
key: "setStyle",
|
|
247
|
+
value: function setStyle(style) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "setMinZoom",
|
|
252
|
+
value: function setMinZoom(minZoom) {
|
|
253
|
+
minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
|
|
254
|
+
|
|
255
|
+
if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
|
|
256
|
+
this.transform.minZoom = minZoom;
|
|
257
|
+
|
|
258
|
+
if (this.getZoom() < minZoom) {
|
|
259
|
+
this.setZoom(minZoom);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return this;
|
|
263
|
+
} else {
|
|
264
|
+
throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "getMinZoom",
|
|
269
|
+
value: function getMinZoom() {
|
|
270
|
+
return this.transform.minZoom;
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
273
|
+
key: "setMaxZoom",
|
|
274
|
+
value: function setMaxZoom(maxZoom) {
|
|
275
|
+
maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
|
|
276
|
+
|
|
277
|
+
if (maxZoom >= this.transform.minZoom) {
|
|
278
|
+
this.transform.maxZoom = maxZoom;
|
|
279
|
+
|
|
280
|
+
if (this.getZoom() > maxZoom) {
|
|
281
|
+
this.setZoom(maxZoom);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return this;
|
|
285
|
+
} else {
|
|
286
|
+
throw new Error('maxZoom must be greater than the current minZoom');
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
key: "getMaxZoom",
|
|
291
|
+
value: function getMaxZoom() {
|
|
292
|
+
return this.transform.maxZoom;
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
key: "setMinPitch",
|
|
296
|
+
value: function setMinPitch(minPitch) {
|
|
297
|
+
minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
|
|
298
|
+
|
|
299
|
+
if (minPitch < defaultMinPitch) {
|
|
300
|
+
throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
|
|
304
|
+
this.transform.minPitch = minPitch;
|
|
305
|
+
|
|
306
|
+
if (this.getPitch() < minPitch) {
|
|
307
|
+
this.setPitch(minPitch);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return this;
|
|
311
|
+
} else {
|
|
312
|
+
throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
key: "getMinPitch",
|
|
317
|
+
value: function getMinPitch() {
|
|
318
|
+
return this.transform.minPitch;
|
|
319
|
+
}
|
|
320
|
+
}, {
|
|
321
|
+
key: "setMaxPitch",
|
|
322
|
+
value: function setMaxPitch(maxPitch) {
|
|
323
|
+
maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
|
|
324
|
+
|
|
325
|
+
if (maxPitch > defaultMaxPitch) {
|
|
326
|
+
throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (maxPitch >= this.transform.minPitch) {
|
|
330
|
+
this.transform.maxPitch = maxPitch;
|
|
331
|
+
|
|
332
|
+
if (this.getPitch() > maxPitch) {
|
|
333
|
+
this.setPitch(maxPitch);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return this;
|
|
337
|
+
} else {
|
|
338
|
+
throw new Error('maxPitch must be greater than the current minPitch');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}, {
|
|
342
|
+
key: "getMaxPitch",
|
|
343
|
+
value: function getMaxPitch() {
|
|
344
|
+
return this.transform.maxPitch;
|
|
345
|
+
}
|
|
346
|
+
}, {
|
|
347
|
+
key: "getRenderWorldCopies",
|
|
348
|
+
value: function getRenderWorldCopies() {
|
|
349
|
+
return this.transform.renderWorldCopies;
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
key: "setRenderWorldCopies",
|
|
353
|
+
value: function setRenderWorldCopies(renderWorldCopies) {
|
|
354
|
+
this.transform.renderWorldCopies = !!renderWorldCopies;
|
|
355
|
+
}
|
|
356
|
+
}, {
|
|
357
|
+
key: "remove",
|
|
358
|
+
value: function remove() {
|
|
359
|
+
if (this.frame) {
|
|
360
|
+
this.frame.cancel();
|
|
361
|
+
this.frame = null;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
this.renderTaskQueue.clear();
|
|
365
|
+
}
|
|
366
|
+
}, {
|
|
367
|
+
key: "requestRenderFrame",
|
|
368
|
+
value: function requestRenderFrame(cb) {
|
|
369
|
+
this.update();
|
|
370
|
+
return this.renderTaskQueue.add(cb);
|
|
371
|
+
}
|
|
372
|
+
}, {
|
|
373
|
+
key: "cancelRenderFrame",
|
|
374
|
+
value: function cancelRenderFrame(id) {
|
|
375
|
+
return this.renderTaskQueue.remove(id);
|
|
376
|
+
}
|
|
377
|
+
}, {
|
|
378
|
+
key: "triggerRepaint",
|
|
379
|
+
value: function triggerRepaint() {
|
|
380
|
+
var _this2 = this;
|
|
381
|
+
|
|
382
|
+
if (!this.frame) {
|
|
383
|
+
this.frame = renderframe(function (paintStartTimeStamp) {
|
|
384
|
+
PerformanceUtils.frame(paintStartTimeStamp);
|
|
385
|
+
_this2.frame = null;
|
|
386
|
+
|
|
387
|
+
_this2.update(paintStartTimeStamp);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}, {
|
|
392
|
+
key: "update",
|
|
393
|
+
value: function update(time) {
|
|
394
|
+
var _this3 = this;
|
|
395
|
+
|
|
396
|
+
if (!this.frame) {
|
|
397
|
+
this.frame = renderframe(function (paintStartTimeStamp) {
|
|
398
|
+
PerformanceUtils.frame(paintStartTimeStamp);
|
|
399
|
+
_this3.frame = null;
|
|
400
|
+
|
|
401
|
+
_this3.renderTaskQueue.run(time);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}, {
|
|
406
|
+
key: "initContainer",
|
|
407
|
+
value: function initContainer() {
|
|
408
|
+
if (typeof this.options.container === 'string') {
|
|
409
|
+
this.container = window.document.getElementById(this.options.container);
|
|
410
|
+
|
|
411
|
+
if (!this.container) {
|
|
412
|
+
throw new Error("Container '".concat(this.options.container, "' not found."));
|
|
413
|
+
}
|
|
414
|
+
} else if (this.options.container instanceof HTMLElement) {
|
|
415
|
+
this.container = this.options.container;
|
|
416
|
+
} else {
|
|
417
|
+
throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
var container = this.container;
|
|
421
|
+
container.classList.add('l7-map');
|
|
422
|
+
var canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
|
|
423
|
+
|
|
424
|
+
if (this.options.interactive) {
|
|
425
|
+
canvasContainer.classList.add('l7-interactive');
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}, {
|
|
429
|
+
key: "containerDimensions",
|
|
430
|
+
value: function containerDimensions() {
|
|
431
|
+
var width = 0;
|
|
432
|
+
var height = 0;
|
|
433
|
+
|
|
434
|
+
if (this.container) {
|
|
435
|
+
width = this.container.clientWidth || 400;
|
|
436
|
+
height = this.container.clientHeight || 300;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return [width, height];
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
key: "resizeCanvas",
|
|
443
|
+
value: function resizeCanvas(width, height) {
|
|
444
|
+
var pixelRatio = DOM.DPR || 1;
|
|
445
|
+
this.canvas.width = pixelRatio * width;
|
|
446
|
+
this.canvas.height = pixelRatio * height;
|
|
447
|
+
this.canvas.style.width = "".concat(width, "px");
|
|
448
|
+
this.canvas.style.height = "".concat(height, "px");
|
|
449
|
+
}
|
|
450
|
+
}]);
|
|
451
|
+
|
|
452
|
+
return EarthMap;
|
|
453
|
+
}(Camera);
|
|
454
|
+
//# sourceMappingURL=earthmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/earthmap.ts"],"names":["DOM","Camera","LngLat","LngLatBounds","Point","HandlerManager","Hash","renderframe","PerformanceUtils","TaskQueue","defaultMinZoom","defaultMaxZoom","defaultMinPitch","defaultMaxPitch","DefaultOptions","hash","zoom","center","pitch","bearing","interactive","minZoom","maxZoom","minPitch","maxPitch","scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch","bearingSnap","clickTolerance","pitchWithRotate","trackResize","renderWorldCopies","EarthMap","options","update","event","resize","originalEvent","initContainer","handlers","window","addEventListener","onWindowOnline","onWindowResize","hashName","undefined","addTo","onHashChange","jumpTo","bounds","fitBounds","fitBoundsOptions","duration","eventData","dimensions","containerDimensions","width","height","transform","fireMoving","moving","stop","emit","Event","container","canvas","canvasContainer","lngLat","locationPoint","convert","point","pointLocation","getBounds","getMaxBounds","setMaxBounds","style","getZoom","setZoom","Error","getPitch","setPitch","frame","cancel","renderTaskQueue","clear","cb","add","id","remove","paintStartTimeStamp","time","run","document","getElementById","HTMLElement","classList","create","clientWidth","clientHeight","pixelRatio","DPR"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,GAAT,QAAoB,gBAApB;AAEA,OAAOC,MAAP,MAAmB,UAAnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,MAAP,MAAmC,eAAnC;AACA,OAAOC,YAAP,MAA+C,sBAA/C;AAEA,OAAOC,KAAP,MAAiC,aAAjC;AAEA,OAAOC,cAAP,MAA2B,2BAA3B;AASA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,SAASC,WAAT,QAA4B,QAA5B;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AACA,OAAOC,SAAP,MAAkC,oBAAlC;AAEA,IAAMC,cAAc,GAAG,CAAC,CAAxB;AACA,IAAMC,cAAc,GAAG,EAAvB;AAGA,IAAMC,eAAe,GAAG,CAAxB;AACA,IAAMC,eAAe,GAAG,EAAxB;AAEA,IAAMC,cAA2B,GAAG;AAClCC,EAAAA,IAAI,EAAE,KAD4B;AAElCC,EAAAA,IAAI,EAAE,CAAC,CAF2B;AAGlCC,EAAAA,MAAM,EAAE,CAAC,GAAD,EAAM,EAAN,CAH0B;AAIlCC,EAAAA,KAAK,EAAE,CAJ2B;AAKlCC,EAAAA,OAAO,EAAE,CALyB;AAMlCC,EAAAA,WAAW,EAAE,IANqB;A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AIC,MAAM,GAAG,CAAb;;AACA,UAAI,KAAKO,SAAT,EAAoB;AAClBR,QAAAA,KAAK,GAAG,KAAKQ,SAAL,CAAeiC,WAAf,IAA8B,GAAtC;AACAxC,QAAAA,MAAM,GAAG,KAAKO,SAAL,CAAekC,YAAf,IAA+B,GAAxC;AACD;;AACD,aAAO,CAAC1C,KAAD,EAAQC,MAAR,CAAP;AACD;AAzSH;AAAA;AAAA,WA2SE,sBAAqBD,KAArB,EAAoCC,MAApC,EAAoD;AAClD,UAAM0C,UAAU,GAAGzG,GAAG,CAAC0G,GAAJ,IAAW,CAA9B;AACA,WAAKnC,MAAL,CAAYT,KAAZ,GAAoB2C,UAAU,GAAG3C,KAAjC;AACA,WAAKS,MAAL,CAAYR,MAAZ,GAAqB0C,UAAU,GAAG1C,MAAlC;AAGA,WAAKQ,MAAL,CAAYU,KAAZ,CAAkBnB,KAAlB,aAA6BA,KAA7B;AACA,WAAKS,MAAL,CAAYU,KAAZ,CAAkBlB,MAAlB,aAA8BA,MAA9B;AACD;AAnTH;;AAAA;AAAA,EAA8B9D,MAA9B","sourcesContent":["import { DOM } from '@antv/l7-utils';\nimport { merge } from 'lodash';\nimport Camera from './camera';\nimport './css/l7.css';\nimport LngLat, { LngLatLike } from './geo/lng_lat';\nimport LngLatBounds, { LngLatBoundsLike } from './geo/lng_lat_bounds';\n// @ts-ignore\nimport Point, { PointLike } from './geo/point';\nimport BoxZoomHandler from './handler/box_zoom';\nimport HandlerManager from './handler/handler_manager';\nimport KeyboardHandler from './handler/keyboard';\n\nimport ScrollZoomHandler from './handler/scroll_zoom';\nimport DoubleClickZoomHandler from './handler/shim/dblclick_zoom';\nimport DragPanHandler from './handler/shim/drag_pan';\nimport DragRotateHandler from './handler/shim/drag_rotate';\nimport TouchZoomRotateHandler from './handler/shim/touch_zoom_rotate';\nimport { TouchPitchHandler } from './handler/touch';\nimport Hash from './hash';\nimport { IMapOptions } from './interface';\nimport { renderframe } from './util';\nimport { PerformanceUtils } from './utils/performance';\nimport TaskQueue, { TaskID } from './utils/task_queue';\ntype CallBack = (_: number) => void;\nconst defaultMinZoom = -2;\nconst defaultMaxZoom = 22;\n\n// the default values, but also the valid range\nconst defaultMinPitch = 0;\nconst defaultMaxPitch = 60;\n\nconst DefaultOptions: IMapOptions = {\n hash: false,\n zoom: -1,\n center: [112, 32],\n pitch: 0,\n bearing: 0,\n interactive: true,\n minZoom: defaultMinZoom,\n maxZoom: defaultMaxZoom,\n minPitch: defaultMinPitch,\n maxPitch: defaultMaxPitch,\n scrollZoom: true,\n boxZoom: true,\n dragRotate: true,\n dragPan: true,\n keyboard: true,\n doubleClickZoom: true,\n touchZoomRotate: true,\n touchPitch: true,\n bearingSnap: 7,\n clickTolerance: 3,\n pitchWithRotate: true,\n trackResize: true,\n renderWorldCopies: true,\n};\nexport class EarthMap extends Camera {\n public doubleClickZoom: DoubleClickZoomHandler;\n public dragRotate: DragRotateHandler;\n public dragPan: DragPanHandler;\n public touchZoomRotate: TouchZoomRotateHandler;\n public scrollZoom: ScrollZoomHandler;\n public keyboard: KeyboardHandler;\n public touchPitch: TouchPitchHandler;\n public boxZoom: BoxZoomHandler;\n public handlers: HandlerManager;\n\n private container: HTMLElement;\n private canvas: HTMLCanvasElement;\n private canvasContainer: HTMLElement;\n private renderTaskQueue: TaskQueue = new TaskQueue();\n private frame: { cancel: () => void } | null;\n private trackResize: boolean = true;\n private hash: Hash | undefined;\n constructor(options: Partial<IMapOptions>) {\n super(merge({}, DefaultOptions, options));\n this.initContainer();\n this.resize();\n this.handlers = new HandlerManager(this, this.options);\n\n if (typeof window !== 'undefined') {\n window.addEventListener('online', this.onWindowOnline, false);\n window.addEventListener('resize', this.onWindowResize, false);\n window.addEventListener('orientationchange', this.onWindowResize, false);\n }\n\n const hashName =\n (typeof options.hash === 'string' && options.hash) || undefined;\n if (options.hash) {\n this.hash = new Hash(hashName).addTo(this) as Hash;\n }\n\n // don't set position from options if set through hash\n if (!this.hash || !this.hash.onHashChange()) {\n this.jumpTo({\n center: options.center,\n zoom: options.zoom,\n bearing: options.bearing,\n pitch: options.pitch,\n });\n\n if (options.bounds) {\n this.resize();\n this.fitBounds(\n options.bounds,\n merge({}, options.fitBoundsOptions, { duration: 0 }),\n );\n }\n }\n }\n\n public resize(eventData?: any) {\n const dimensions = this.containerDimensions();\n const width = dimensions[0];\n const height = dimensions[1];\n\n // this.resizeCanvas(width, height);\n this.transform.resize(width, height);\n const fireMoving = !this.moving;\n if (fireMoving) {\n this.stop();\n this.emit('movestart', new Event('movestart', eventData));\n this.emit('move', new Event('move', eventData));\n }\n\n this.emit('resize', new Event('resize', eventData));\n\n if (fireMoving) {\n this.emit('moveend', new Event('moveend', eventData));\n }\n\n return this;\n }\n\n public getContainer() {\n return this.container;\n }\n\n public getCanvas() {\n return this.canvas;\n }\n\n public getCanvasContainer() {\n return this.canvasContainer;\n }\n\n public project(lngLat: LngLatLike) {\n return this.transform.locationPoint(LngLat.convert(lngLat));\n }\n\n public unproject(point: PointLike) {\n return this.transform.pointLocation(Point.convert(point));\n }\n\n public getBounds(): LngLatBounds {\n return this.transform.getBounds();\n }\n\n public getMaxBounds(): LngLatBounds | null {\n return this.transform.getMaxBounds();\n }\n\n public setMaxBounds(bounds: LngLatBoundsLike) {\n this.transform.setMaxBounds(LngLatBounds.convert(bounds));\n }\n\n public setStyle(style: any) {\n return;\n }\n public setMinZoom(minZoom?: number) {\n minZoom =\n minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;\n if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {\n this.transform.minZoom = minZoom;\n if (this.getZoom() < minZoom) {\n this.setZoom(minZoom);\n }\n\n return this;\n } else {\n throw new Error(\n `minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`,\n );\n }\n }\n\n public getMinZoom() {\n return this.transform.minZoom;\n }\n\n public setMaxZoom(maxZoom?: number) {\n maxZoom =\n maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;\n\n if (maxZoom >= this.transform.minZoom) {\n this.transform.maxZoom = maxZoom;\n if (this.getZoom() > maxZoom) {\n this.setZoom(maxZoom);\n }\n\n return this;\n } else {\n throw new Error('maxZoom must be greater than the current minZoom');\n }\n }\n public getMaxZoom() {\n return this.transform.maxZoom;\n }\n\n public setMinPitch(minPitch?: number) {\n minPitch =\n minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;\n\n if (minPitch < defaultMinPitch) {\n throw new Error(\n `minPitch must be greater than or equal to ${defaultMinPitch}`,\n );\n }\n\n if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {\n this.transform.minPitch = minPitch;\n if (this.getPitch() < minPitch) {\n this.setPitch(minPitch);\n }\n\n return this;\n } else {\n throw new Error(\n `minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`,\n );\n }\n }\n\n public getMinPitch() {\n return this.transform.minPitch;\n }\n\n public setMaxPitch(maxPitch?: number) {\n maxPitch =\n maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;\n\n if (maxPitch > defaultMaxPitch) {\n throw new Error(\n `maxPitch must be less than or equal to ${defaultMaxPitch}`,\n );\n }\n\n if (maxPitch >= this.transform.minPitch) {\n this.transform.maxPitch = maxPitch;\n if (this.getPitch() > maxPitch) {\n this.setPitch(maxPitch);\n }\n\n return this;\n } else {\n throw new Error('maxPitch must be greater than the current minPitch');\n }\n }\n\n public getMaxPitch() {\n return this.transform.maxPitch;\n }\n\n public getRenderWorldCopies() {\n return this.transform.renderWorldCopies;\n }\n\n public setRenderWorldCopies(renderWorldCopies?: boolean) {\n this.transform.renderWorldCopies = !!renderWorldCopies;\n }\n\n public remove() {\n if (this.frame) {\n this.frame.cancel();\n this.frame = null;\n }\n this.renderTaskQueue.clear();\n }\n\n public requestRenderFrame(cb: CallBack): TaskID {\n this.update();\n return this.renderTaskQueue.add(cb);\n }\n\n public cancelRenderFrame(id: TaskID) {\n return this.renderTaskQueue.remove(id);\n }\n\n public triggerRepaint() {\n if (!this.frame) {\n this.frame = renderframe((paintStartTimeStamp: number) => {\n PerformanceUtils.frame(paintStartTimeStamp);\n this.frame = null;\n this.update(paintStartTimeStamp);\n });\n }\n }\n\n public update(time?: number) {\n if (!this.frame) {\n this.frame = renderframe((paintStartTimeStamp: number) => {\n PerformanceUtils.frame(paintStartTimeStamp);\n this.frame = null;\n this.renderTaskQueue.run(time);\n });\n }\n }\n\n private initContainer() {\n if (typeof this.options.container === 'string') {\n this.container = window.document.getElementById(\n this.options.container,\n ) as HTMLElement;\n if (!this.container) {\n throw new Error(`Container '${this.options.container}' not found.`);\n }\n } else if (this.options.container instanceof HTMLElement) {\n this.container = this.options.container;\n } else {\n throw new Error(\n \"Invalid type: 'container' must be a String or HTMLElement.\",\n );\n }\n\n const container = this.container;\n container.classList.add('l7-map');\n\n const canvasContainer = (this.canvasContainer = DOM.create(\n 'div',\n 'l7-canvas-container',\n container,\n ));\n if (this.options.interactive) {\n canvasContainer.classList.add('l7-interactive');\n }\n\n // this.canvas = DOM.create(\n // 'canvas',\n // 'l7-canvas',\n // canvasContainer,\n // ) as HTMLCanvasElement;\n // this.canvas.setAttribute('tabindex', '-');\n // this.canvas.setAttribute('aria-label', 'Map');\n }\n\n private containerDimensions(): [number, number] {\n let width = 0;\n let height = 0;\n if (this.container) {\n width = this.container.clientWidth || 400;\n height = this.container.clientHeight || 300;\n }\n return [width, height];\n }\n\n private resizeCanvas(width: number, height: number) {\n const pixelRatio = DOM.DPR || 1;\n this.canvas.width = pixelRatio * width;\n this.canvas.height = pixelRatio * height;\n\n // Maintain the same canvas size, potentially downscaling it for HiDPI displays\n this.canvas.style.width = `${width}px`;\n this.canvas.style.height = `${height}px`;\n }\n\n private onWindowOnline = () => {\n this.update();\n };\n\n private onWindowResize = (event: Event) => {\n if (this.trackResize) {\n this.resize({ originalEvent: event }).update();\n }\n };\n}\n"],"file":"earthmap.js"}
|
package/es/handler/IHandler.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EarthMap } from '../earthmap';
|
|
1
2
|
import Point from '../geo/point';
|
|
2
3
|
import { Map } from '../map';
|
|
3
4
|
export interface IHandlerResult {
|
|
@@ -7,7 +8,7 @@ export interface IHandlerResult {
|
|
|
7
8
|
pitchDelta?: number;
|
|
8
9
|
around?: Point | null;
|
|
9
10
|
pinchAround?: Point | null;
|
|
10
|
-
cameraAnimation?: (map: Map) => any;
|
|
11
|
+
cameraAnimation?: (map: Map | EarthMap) => any;
|
|
11
12
|
originalEvent?: any;
|
|
12
13
|
needsRenderFrame?: boolean;
|
|
13
14
|
noInertia?: boolean;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { EarthMap } from '../earthmap';
|
|
1
2
|
import { Map } from '../map';
|
|
2
3
|
export default class BlockableMapEventHandler {
|
|
3
4
|
private map;
|
|
4
5
|
private delayContextMenu;
|
|
5
6
|
private contextMenuEvent;
|
|
6
|
-
constructor(map: Map);
|
|
7
|
+
constructor(map: Map | EarthMap);
|
|
7
8
|
reset(): void;
|
|
8
9
|
mousemove(e: MouseEvent): void;
|
|
9
10
|
mousedown(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/handler/blockable_map_event.ts"],"names":["MapMouseEvent","BlockableMapEventHandler","map","delayContextMenu","contextMenuEvent","e","emit","type","listeners","preventDefault"],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../../src/handler/blockable_map_event.ts"],"names":["MapMouseEvent","BlockableMapEventHandler","map","delayContextMenu","contextMenuEvent","e","emit","type","listeners","preventDefault"],"mappings":";;;AAIA,SAASA,aAAT,QAA4D,UAA5D;;IACqBC,wB;AAKnB,oCAAYC,GAAZ,EAAiC;AAAA;;AAAA;;AAAA;;AAAA;;AAC/B,SAAKA,GAAL,GAAWA,GAAX;AACD;;;;WAED,iBAAe;AACb,WAAKC,gBAAL,GAAwB,KAAxB;AAEA,aAAO,KAAKC,gBAAZ;AACD;;;WAED,mBAAiBC,CAAjB,EAAgC;AAE9B,WAAKH,GAAL,CAASI,IAAT,CAAcD,CAAC,CAACE,IAAhB,EAAsB,IAAIP,aAAJ,CAAkBK,CAAC,CAACE,IAApB,EAA0B,KAAKL,GAA/B,EAAoCG,CAApC,CAAtB;AACD;;;WAED,qBAAmB;AACjB,WAAKF,gBAAL,GAAwB,IAAxB;AACD;;;WAED,mBAAiB;AACf,WAAKA,gBAAL,GAAwB,KAAxB;;AACA,UAAI,KAAKC,gBAAT,EAA2B;AACzB,aAAKF,GAAL,CAASI,IAAT,CACE,aADF,EAEE,IAAIN,aAAJ,CAAkB,aAAlB,EAAiC,KAAKE,GAAtC,EAA2C,KAAKE,gBAAhD,CAFF;AAKA,eAAO,KAAKA,gBAAZ;AACD;AACF;;;WACD,qBAAmBC,CAAnB,EAAkC;AAChC,UAAI,KAAKF,gBAAT,EAA2B;AAEzB,aAAKC,gBAAL,GAAwBC,CAAxB;AACD,OAHD,MAGO;AAEL,aAAKH,GAAL,CAASI,IAAT,CAAcD,CAAC,CAACE,IAAhB,EAAsB,IAAIP,aAAJ,CAAkBK,CAAC,CAACE,IAApB,EAA0B,KAAKL,GAA/B,EAAoCG,CAApC,CAAtB;AACD;;AAGD,UAAI,KAAKH,GAAL,CAASM,SAAT,CAAmB,aAAnB,CAAJ,EAAuC;AACrCH,QAAAA,CAAC,CAACI,cAAF;AACD;AACF;;;WAED,qBAAmB;AACjB,aAAO,IAAP;AACD;;;WAED,oBAAkB;AAChB,aAAO,KAAP;AACD;;;WACD,kBAAgB;AACd,aAAO,IAAP;AACD;;;WACD,mBAAiB;AACf,aAAO,KAAP;AACD;;;;;;SA9DkBR,wB","sourcesContent":["// @ts-ignore\nimport { EarthMap } from '../earthmap';\nimport Point from '../geo/point';\nimport { Map } from '../map';\nimport { MapMouseEvent, MapTouchEvent, MapWheelEvent } from './events';\nexport default class BlockableMapEventHandler {\n private map: Map | EarthMap;\n private delayContextMenu: boolean;\n private contextMenuEvent: MouseEvent;\n\n constructor(map: Map | EarthMap) {\n this.map = map;\n }\n\n public reset() {\n this.delayContextMenu = false;\n // @ts-ignore\n delete this.contextMenuEvent;\n }\n\n public mousemove(e: MouseEvent) {\n // mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active\n this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));\n }\n\n public mousedown() {\n this.delayContextMenu = true;\n }\n\n public mouseup() {\n this.delayContextMenu = false;\n if (this.contextMenuEvent) {\n this.map.emit(\n 'contextmenu',\n new MapMouseEvent('contextmenu', this.map, this.contextMenuEvent),\n );\n // @ts-ignore\n delete this.contextMenuEvent;\n }\n }\n public contextmenu(e: MouseEvent) {\n if (this.delayContextMenu) {\n // Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake\n this.contextMenuEvent = e;\n } else {\n // Windows: contextmenu fired on mouseup, so fire event now\n this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));\n }\n\n // prevent browser context menu when necessary\n if (this.map.listeners('contextmenu')) {\n e.preventDefault();\n }\n }\n\n public isEnabled() {\n return true;\n }\n\n public isActive() {\n return false;\n }\n public enable() {\n return true;\n }\n public disable() {\n return false;\n }\n}\n"],"file":"blockable_map_event.js"}
|
package/es/handler/box_zoom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EarthMap } from '../earthmap';
|
|
1
2
|
import Point from '../geo/point';
|
|
2
3
|
import { Map } from '../map';
|
|
3
4
|
/**
|
|
@@ -17,7 +18,7 @@ declare class BoxZoomHandler {
|
|
|
17
18
|
/**
|
|
18
19
|
* @private
|
|
19
20
|
*/
|
|
20
|
-
constructor(map: Map, options: {
|
|
21
|
+
constructor(map: Map | EarthMap, options: {
|
|
21
22
|
clickTolerance: number;
|
|
22
23
|
});
|
|
23
24
|
/**
|