@mapwhit/tilerenderer 0.50.0 → 0.51.1
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/build/min/package.json +1 -1
- package/build/min/src/shaders/.dir +0 -0
- package/build/min/src/shaders/{_prelude.fragment.glsl.txt → _prelude.fragment.glsl.js} +2 -1
- package/build/min/src/shaders/{_prelude.vertex.glsl.txt → _prelude.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/background.fragment.glsl.js +5 -0
- package/build/min/src/shaders/background.vertex.glsl.js +1 -0
- package/build/min/src/shaders/background_pattern.fragment.glsl.js +5 -0
- package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -0
- package/build/min/src/shaders/{circle.fragment.glsl.txt → circle.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{circle.vertex.glsl.txt → circle.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -0
- package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -0
- package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -0
- package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -0
- package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -0
- package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -0
- package/build/min/src/shaders/debug.fragment.glsl.js +1 -0
- package/build/min/src/shaders/debug.vertex.glsl.js +1 -0
- package/build/min/src/shaders/{fill.fragment.glsl.txt → fill.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{fill.vertex.glsl.txt → fill.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +5 -0
- package/build/min/src/shaders/{fill_extrusion.vertex.glsl.txt → fill_extrusion.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_extrusion_pattern.fragment.glsl.txt → fill_extrusion_pattern.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_extrusion_pattern.vertex.glsl.txt → fill_extrusion_pattern.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_outline.fragment.glsl.txt → fill_outline.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_outline.vertex.glsl.txt → fill_outline.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_outline_pattern.fragment.glsl.txt → fill_outline_pattern.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_outline_pattern.vertex.glsl.txt → fill_outline_pattern.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_pattern.fragment.glsl.txt → fill_pattern.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{fill_pattern.vertex.glsl.txt → fill_pattern.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{heatmap.fragment.glsl.txt → heatmap.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{heatmap.vertex.glsl.txt → heatmap.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +5 -0
- package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -0
- package/build/min/src/shaders/{hillshade.fragment.glsl.txt → hillshade.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -0
- package/build/min/src/shaders/{hillshade_prepare.fragment.glsl.txt → hillshade_prepare.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -0
- package/build/min/src/shaders/{line.fragment.glsl.txt → line.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{line.vertex.glsl.txt → line.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{line_gradient.fragment.glsl.txt → line_gradient.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{line_gradient.vertex.glsl.txt → line_gradient.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{line_pattern.fragment.glsl.txt → line_pattern.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{line_pattern.vertex.glsl.txt → line_pattern.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{line_sdf.fragment.glsl.txt → line_sdf.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{line_sdf.vertex.glsl.txt → line_sdf.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/raster.fragment.glsl.js +5 -0
- package/build/min/src/shaders/raster.vertex.glsl.js +1 -0
- package/build/min/src/shaders/{symbol_icon.fragment.glsl.txt → symbol_icon.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{symbol_icon.vertex.glsl.txt → symbol_icon.vertex.glsl.js} +2 -2
- package/build/min/src/shaders/{symbol_sdf.fragment.glsl.txt → symbol_sdf.fragment.glsl.js} +2 -2
- package/build/min/src/shaders/{symbol_sdf.vertex.glsl.txt → symbol_sdf.vertex.glsl.js} +2 -2
- package/package.json +14 -10
- package/src/data/array_types.js +1 -1
- package/src/data/bucket/fill_bucket.js +1 -1
- package/src/data/bucket/fill_extrusion_bucket.js +2 -2
- package/src/data/bucket/line_bucket.js +1 -1
- package/src/data/bucket/symbol_bucket.js +3 -3
- package/src/data/feature_index.js +1 -1
- package/src/data/program_configuration.js +1 -1
- package/src/geo/transform.js +1 -1
- package/src/gl/color_mode.js +1 -1
- package/src/gl/value.js +1 -1
- package/src/index.js +2 -2
- package/src/render/draw_debug.js +1 -1
- package/src/render/draw_fill.js +1 -1
- package/src/render/draw_heatmap.js +1 -1
- package/src/render/glyph_manager.js +6 -130
- package/src/render/painter.js +1 -1
- package/src/render/uniform_binding.js +1 -1
- package/src/shaders/index.js +50 -50
- package/src/source/geojson_source.js +1 -1
- package/src/source/geojson_worker_source.js +4 -4
- package/src/source/geojson_wrapper.js +35 -27
- package/src/source/image_source.js +2 -2
- package/src/source/raster_tile_source.js +1 -1
- package/src/source/resources/glyphs.js +73 -0
- package/src/source/resources/images.js +68 -0
- package/src/source/resources/index.js +22 -0
- package/src/source/rtl_text_plugin.js +1 -1
- package/src/source/source_cache.js +2 -2
- package/src/source/tile.js +1 -1
- package/src/source/vector_tile_source.js +1 -1
- package/src/source/vector_tile_worker_source.js +5 -5
- package/src/source/worker.js +6 -5
- package/src/source/worker_tile.js +4 -4
- package/src/style/light.js +1 -1
- package/src/style/properties.js +1 -2
- package/src/style/query_utils.js +1 -1
- package/src/style/style.js +4 -4
- package/src/style/style_layer/circle_style_layer.js +1 -1
- package/src/style/style_layer/fill_extrusion_style_layer.js +1 -1
- package/src/style/style_layer/line_style_layer.js +1 -1
- package/src/style/style_layer/symbol_style_layer.js +1 -1
- package/src/style/style_layer.js +2 -2
- package/src/style-spec/feature_filter/index.js +43 -34
- package/src/style-spec/group_by_layout.js +10 -32
- package/src/symbol/anchor.js +1 -1
- package/src/symbol/clip_line.js +1 -1
- package/src/symbol/collision_feature.js +1 -1
- package/src/symbol/collision_index.js +1 -1
- package/src/symbol/mergelines.js +0 -2
- package/src/symbol/projection.js +1 -1
- package/src/symbol/quads.js +1 -1
- package/src/symbol/symbol_layout.js +0 -1
- package/src/symbol/symbol_size.js +1 -1
- package/src/symbol/transform_text.js +0 -1
- package/src/ui/camera.js +2 -2
- package/src/ui/map.js +11 -41
- package/src/util/browser.js +3 -18
- package/src/util/classify_rings.js +1 -1
- package/src/util/config.js +1 -1
- package/src/util/dom.js +0 -88
- package/src/util/find_pole_of_inaccessibility.js +3 -3
- package/src/util/intersection_tests.js +1 -1
- package/src/util/web_worker_transfer.js +4 -4
- package/src/worker.js +4 -0
- package/build/min/src/shaders/background.fragment.glsl.txt +0 -5
- package/build/min/src/shaders/background.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/background_pattern.fragment.glsl.txt +0 -5
- package/build/min/src/shaders/background_pattern.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/clipping_mask.fragment.glsl.txt +0 -1
- package/build/min/src/shaders/clipping_mask.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/collision_box.fragment.glsl.txt +0 -1
- package/build/min/src/shaders/collision_box.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/collision_circle.fragment.glsl.txt +0 -1
- package/build/min/src/shaders/collision_circle.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/debug.fragment.glsl.txt +0 -1
- package/build/min/src/shaders/debug.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/fill_extrusion.fragment.glsl.txt +0 -5
- package/build/min/src/shaders/heatmap_texture.fragment.glsl.txt +0 -5
- package/build/min/src/shaders/heatmap_texture.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/hillshade.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/hillshade_prepare.vertex.glsl.txt +0 -1
- package/build/min/src/shaders/raster.fragment.glsl.txt +0 -5
- package/build/min/src/shaders/raster.vertex.glsl.txt +0 -1
- package/src/style/load_glyph_range.js +0 -17
- package/src/style-spec/expression/compound_expression.js +0 -132
- package/src/style-spec/expression/definitions/assertion.js +0 -116
- package/src/style-spec/expression/definitions/at.js +0 -57
- package/src/style-spec/expression/definitions/case.js +0 -73
- package/src/style-spec/expression/definitions/coalesce.js +0 -66
- package/src/style-spec/expression/definitions/coercion.js +0 -120
- package/src/style-spec/expression/definitions/collator.js +0 -80
- package/src/style-spec/expression/definitions/comparison.js +0 -193
- package/src/style-spec/expression/definitions/format.js +0 -97
- package/src/style-spec/expression/definitions/index.js +0 -339
- package/src/style-spec/expression/definitions/interpolate.js +0 -245
- package/src/style-spec/expression/definitions/length.js +0 -54
- package/src/style-spec/expression/definitions/let.js +0 -60
- package/src/style-spec/expression/definitions/literal.js +0 -69
- package/src/style-spec/expression/definitions/match.js +0 -142
- package/src/style-spec/expression/definitions/step.js +0 -116
- package/src/style-spec/expression/definitions/var.js +0 -38
- package/src/style-spec/expression/evaluation_context.js +0 -38
- package/src/style-spec/expression/index.js +0 -330
- package/src/style-spec/expression/is_constant.js +0 -63
- package/src/style-spec/expression/parsing_context.js +0 -221
- package/src/style-spec/expression/parsing_error.js +0 -9
- package/src/style-spec/expression/runtime_error.js +0 -12
- package/src/style-spec/expression/scope.js +0 -34
- package/src/style-spec/expression/stops.js +0 -37
- package/src/style-spec/expression/types/collator.js +0 -24
- package/src/style-spec/expression/types/formatted.js +0 -39
- package/src/style-spec/expression/types.js +0 -88
- package/src/style-spec/expression/values.js +0 -149
- package/src/style-spec/function/convert.js +0 -240
- package/src/style-spec/function/index.js +0 -303
- package/src/style-spec/util/color.js +0 -73
- package/src/style-spec/util/color_spaces.js +0 -128
- package/src/style-spec/util/get_type.js +0 -18
- package/src/style-spec/util/interpolate.js +0 -21
- package/src/style-spec/util/properties.js +0 -17
- package/src/style-spec/util/result.js +0 -19
- package/src/ui/anchor.js +0 -24
- package/src/ui/bind_handlers.js +0 -199
- package/src/ui/events.js +0 -210
- package/src/ui/handler/box_zoom.js +0 -151
- package/src/ui/handler/dblclick_zoom.js +0 -91
- package/src/ui/handler/drag_pan.js +0 -285
- package/src/ui/handler/drag_rotate.js +0 -290
- package/src/ui/handler/frame.js +0 -28
- package/src/ui/handler/inertia.js +0 -45
- package/src/ui/handler/keyboard.js +0 -148
- package/src/ui/handler/scroll_zoom.js +0 -284
- package/src/ui/handler/touch_zoom_rotate.js +0 -263
- package/src/util/evented.js +0 -182
package/src/ui/bind_handlers.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
const { MapMouseEvent, MapTouchEvent, MapWheelEvent } = require('../ui/events');
|
|
2
|
-
const DOM = require('../util/dom');
|
|
3
|
-
const scrollZoom = require('./handler/scroll_zoom');
|
|
4
|
-
const boxZoom = require('./handler/box_zoom');
|
|
5
|
-
const dragRotate = require('./handler/drag_rotate');
|
|
6
|
-
const dragPan = require('./handler/drag_pan');
|
|
7
|
-
const keyboard = require('./handler/keyboard');
|
|
8
|
-
const doubleClickZoom = require('./handler/dblclick_zoom');
|
|
9
|
-
const touchZoomRotate = require('./handler/touch_zoom_rotate');
|
|
10
|
-
|
|
11
|
-
const handlers = {
|
|
12
|
-
scrollZoom,
|
|
13
|
-
boxZoom,
|
|
14
|
-
dragRotate,
|
|
15
|
-
dragPan,
|
|
16
|
-
keyboard,
|
|
17
|
-
doubleClickZoom,
|
|
18
|
-
touchZoomRotate
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
module.exports = function bindHandlers(map, options) {
|
|
22
|
-
const el = map.getCanvasContainer();
|
|
23
|
-
let contextMenuEvent = null;
|
|
24
|
-
let mouseDown = false;
|
|
25
|
-
let startPos = null;
|
|
26
|
-
|
|
27
|
-
Object.entries(handlers).forEach(([name, handler]) => {
|
|
28
|
-
map[name] = handler(map, options);
|
|
29
|
-
if (options.interactive && options[name]) {
|
|
30
|
-
map[name].enable(options[name]);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
el.addEventListener('mouseout', onMouseOut);
|
|
35
|
-
el.addEventListener('mousedown', onMouseDown);
|
|
36
|
-
el.addEventListener('mouseup', onMouseUp);
|
|
37
|
-
el.addEventListener('mousemove', onMouseMove);
|
|
38
|
-
el.addEventListener('mouseover', onMouseOver);
|
|
39
|
-
|
|
40
|
-
// Bind touchstart and touchmove with passive: false because, even though
|
|
41
|
-
// they only fire a map events and therefore could theoretically be
|
|
42
|
-
// passive, binding with passive: true causes iOS not to respect
|
|
43
|
-
// e.preventDefault() in _other_ handlers, even if they are non-passive
|
|
44
|
-
// (see https://bugs.webkit.org/show_bug.cgi?id=184251)
|
|
45
|
-
el.addEventListener('touchstart', onTouchStart, { passive: false });
|
|
46
|
-
el.addEventListener('touchmove', onTouchMove, { passive: false });
|
|
47
|
-
|
|
48
|
-
el.addEventListener('touchend', onTouchEnd);
|
|
49
|
-
el.addEventListener('touchcancel', onTouchCancel);
|
|
50
|
-
el.addEventListener('click', onClick);
|
|
51
|
-
el.addEventListener('dblclick', onDblClick);
|
|
52
|
-
el.addEventListener('contextmenu', onContextMenu);
|
|
53
|
-
el.addEventListener('wheel', onWheel, { passive: false });
|
|
54
|
-
|
|
55
|
-
function onMouseDown(e) {
|
|
56
|
-
mouseDown = true;
|
|
57
|
-
startPos = DOM.mousePos(el, e);
|
|
58
|
-
|
|
59
|
-
const mapEvent = new MapMouseEvent('mousedown', map, e);
|
|
60
|
-
map.fire(mapEvent);
|
|
61
|
-
|
|
62
|
-
if (mapEvent.defaultPrevented) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (options.interactive && !map.doubleClickZoom.isActive()) {
|
|
67
|
-
map.stop();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
map.boxZoom.onMouseDown(e);
|
|
71
|
-
|
|
72
|
-
if (!map.boxZoom.isActive() && !map.dragPan.isActive()) {
|
|
73
|
-
map.dragRotate.onMouseDown(e);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!map.boxZoom.isActive() && !map.dragRotate.isActive()) {
|
|
77
|
-
map.dragPan.onMouseDown(e);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function onMouseUp(e) {
|
|
82
|
-
const rotating = map.dragRotate.isActive();
|
|
83
|
-
|
|
84
|
-
if (contextMenuEvent && !rotating) {
|
|
85
|
-
// This will be the case for Mac
|
|
86
|
-
map.fire(new MapMouseEvent('contextmenu', map, contextMenuEvent));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
contextMenuEvent = null;
|
|
90
|
-
mouseDown = false;
|
|
91
|
-
|
|
92
|
-
map.fire(new MapMouseEvent('mouseup', map, e));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function onMouseMove(e) {
|
|
96
|
-
if (map.dragPan.isActive()) return;
|
|
97
|
-
if (map.dragRotate.isActive()) return;
|
|
98
|
-
if (map.touchZoomRotate.isActive()) return;
|
|
99
|
-
|
|
100
|
-
let target = e.target;
|
|
101
|
-
while (target && target !== el) target = target.parentNode;
|
|
102
|
-
if (target !== el) return;
|
|
103
|
-
|
|
104
|
-
map.fire(new MapMouseEvent('mousemove', map, e));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function onMouseOver(e) {
|
|
108
|
-
let { target } = e;
|
|
109
|
-
while (target && target !== el) target = target.parentNode;
|
|
110
|
-
if (target !== el) return;
|
|
111
|
-
|
|
112
|
-
map.fire(new MapMouseEvent('mouseover', map, e));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function onMouseOut(e) {
|
|
116
|
-
map.fire(new MapMouseEvent('mouseout', map, e));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function onTouchStart(e) {
|
|
120
|
-
const mapEvent = new MapTouchEvent('touchstart', map, e);
|
|
121
|
-
map.fire(mapEvent);
|
|
122
|
-
|
|
123
|
-
if (mapEvent.defaultPrevented) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (options.interactive) {
|
|
128
|
-
map.stop();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (!map.boxZoom.isActive() && !map.dragRotate.isActive()) {
|
|
132
|
-
map.dragPan.onTouchStart(e);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
map.touchZoomRotate.onStart(e);
|
|
136
|
-
map.doubleClickZoom.onTouchStart(mapEvent);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function onTouchMove(e) {
|
|
140
|
-
if (map.dragPan.isActive()) return;
|
|
141
|
-
if (map.dragRotate.isActive()) return;
|
|
142
|
-
if (map.touchZoomRotate.isActive()) return;
|
|
143
|
-
|
|
144
|
-
map.fire(new MapTouchEvent('touchmove', map, e));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function onTouchEnd(e) {
|
|
148
|
-
map.fire(new MapTouchEvent('touchend', map, e));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function onTouchCancel(e) {
|
|
152
|
-
map.fire(new MapTouchEvent('touchcancel', map, e));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function onClick(e) {
|
|
156
|
-
if (startPos) {
|
|
157
|
-
const pos = DOM.mousePos(el, e);
|
|
158
|
-
if (pos.dist(startPos) > options.clickTolerance) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
map.fire(new MapMouseEvent('click', map, e));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function onDblClick(e) {
|
|
166
|
-
const mapEvent = new MapMouseEvent('dblclick', map, e);
|
|
167
|
-
map.fire(mapEvent);
|
|
168
|
-
|
|
169
|
-
if (mapEvent.defaultPrevented) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
map.doubleClickZoom.onDblClick(mapEvent);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function onContextMenu(e) {
|
|
177
|
-
const rotating = map.dragRotate.isActive();
|
|
178
|
-
if (!mouseDown && !rotating) {
|
|
179
|
-
// Windows: contextmenu fired on mouseup, so fire event now
|
|
180
|
-
map.fire(new MapMouseEvent('contextmenu', map, e));
|
|
181
|
-
} else if (mouseDown) {
|
|
182
|
-
// Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake
|
|
183
|
-
contextMenuEvent = e;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
e.preventDefault();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function onWheel(e) {
|
|
190
|
-
const mapEvent = new MapWheelEvent('wheel', map, e);
|
|
191
|
-
map.fire(mapEvent);
|
|
192
|
-
|
|
193
|
-
if (mapEvent.defaultPrevented) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
map.scrollZoom.onWheel(e);
|
|
198
|
-
}
|
|
199
|
-
};
|
package/src/ui/events.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
const { Event } = require('../util/evented');
|
|
2
|
-
|
|
3
|
-
const DOM = require('../util/dom');
|
|
4
|
-
const Point = require('@mapbox/point-geometry');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* `MapMouseEvent` is the event type for mouse-related map events.
|
|
8
|
-
* @extends {Object}
|
|
9
|
-
*/
|
|
10
|
-
class MapMouseEvent extends Event {
|
|
11
|
-
/**
|
|
12
|
-
* The event type.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The `Map` object that fired the event.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The DOM event which caused the map event.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The geographic location on the map of the mouse cursor.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Prevents subsequent default processing of the event by the map.
|
|
33
|
-
*
|
|
34
|
-
* Calling this method will prevent the following default map behaviors:
|
|
35
|
-
*
|
|
36
|
-
* * On `mousedown` events, the behavior of {@link DragPanHandler}
|
|
37
|
-
* * On `mousedown` events, the behavior of {@link DragRotateHandler}
|
|
38
|
-
* * On `mousedown` events, the behavior of {@link BoxZoomHandler}
|
|
39
|
-
* * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
preventDefault() {
|
|
43
|
-
this._defaultPrevented = true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* `true` if `preventDefault` has been called.
|
|
48
|
-
*/
|
|
49
|
-
get defaultPrevented() {
|
|
50
|
-
return this._defaultPrevented;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
constructor(type, map, originalEvent, data = {}) {
|
|
57
|
-
const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
|
|
58
|
-
const lngLat = map.unproject(point);
|
|
59
|
-
super(type, Object.assign({ point, lngLat, originalEvent }, data));
|
|
60
|
-
this._defaultPrevented = false;
|
|
61
|
-
this.target = map;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* `MapTouchEvent` is the event type for touch-related map events.
|
|
67
|
-
* @extends {Object}
|
|
68
|
-
*/
|
|
69
|
-
class MapTouchEvent extends Event {
|
|
70
|
-
/**
|
|
71
|
-
* The event type.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The `Map` object that fired the event.
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The DOM event which caused the map event.
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* The geographic location on the map of the center of the touch event points.
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
|
|
88
|
-
* corner.
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The array of pixel coordinates corresponding to a
|
|
93
|
-
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The geographical locations on the map corresponding to a
|
|
98
|
-
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Prevents subsequent default processing of the event by the map.
|
|
103
|
-
*
|
|
104
|
-
* Calling this method will prevent the following default map behaviors:
|
|
105
|
-
*
|
|
106
|
-
* * On `touchstart` events, the behavior of {@link DragPanHandler}
|
|
107
|
-
* * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
|
|
108
|
-
*
|
|
109
|
-
*/
|
|
110
|
-
preventDefault() {
|
|
111
|
-
this._defaultPrevented = true;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* `true` if `preventDefault` has been called.
|
|
116
|
-
*/
|
|
117
|
-
get defaultPrevented() {
|
|
118
|
-
return this._defaultPrevented;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @private
|
|
123
|
-
*/
|
|
124
|
-
constructor(type, map, originalEvent) {
|
|
125
|
-
const points = DOM.touchPos(map.getCanvasContainer(), originalEvent);
|
|
126
|
-
const lngLats = points.map(t => map.unproject(t));
|
|
127
|
-
const point = points.reduce((prev, curr, i, arr) => {
|
|
128
|
-
return prev.add(curr.div(arr.length));
|
|
129
|
-
}, new Point(0, 0));
|
|
130
|
-
const lngLat = map.unproject(point);
|
|
131
|
-
super(type, { points, point, lngLats, lngLat, originalEvent });
|
|
132
|
-
this._defaultPrevented = false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* `MapWheelEvent` is the event type for the `wheel` map event.
|
|
138
|
-
* @extends {Object}
|
|
139
|
-
*/
|
|
140
|
-
class MapWheelEvent extends Event {
|
|
141
|
-
/**
|
|
142
|
-
* The event type.
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* The `Map` object that fired the event.
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* The DOM event which caused the map event.
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Prevents subsequent default processing of the event by the map.
|
|
155
|
-
*
|
|
156
|
-
* Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
|
|
157
|
-
*/
|
|
158
|
-
preventDefault() {
|
|
159
|
-
this._defaultPrevented = true;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* `true` if `preventDefault` has been called.
|
|
164
|
-
*/
|
|
165
|
-
get defaultPrevented() {
|
|
166
|
-
return this._defaultPrevented;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @private
|
|
171
|
-
*/
|
|
172
|
-
constructor(type, map, originalEvent) {
|
|
173
|
-
super(type, { originalEvent });
|
|
174
|
-
this._defaultPrevented = false;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
module.exports = {
|
|
179
|
-
MapMouseEvent,
|
|
180
|
-
MapTouchEvent,
|
|
181
|
-
MapWheelEvent
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @typedef {Object} MapBoxZoomEvent
|
|
186
|
-
* @property {MouseEvent} originalEvent
|
|
187
|
-
* @property {LngLatBounds} boxZoomBounds The bounding box of the "box zoom" interaction.
|
|
188
|
-
* This property is only provided for `boxzoomend` events.
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* A `MapDataEvent` object is emitted with the {@link Map.event:data}
|
|
193
|
-
* and {@link Map.event:dataloading} events. Possible values for
|
|
194
|
-
* `dataType`s are:
|
|
195
|
-
*
|
|
196
|
-
* - `'source'`: The non-tile data associated with any source
|
|
197
|
-
* - `'style'`: The [style](https://www.mapbox.com/mapbox-gl-style-spec/) used by the map
|
|
198
|
-
*
|
|
199
|
-
* @typedef {Object} MapDataEvent
|
|
200
|
-
* @property {string} type The event type.
|
|
201
|
-
* @property {string} dataType The type of data that has changed. One of `'source'`, `'style'`.
|
|
202
|
-
* @property {boolean} [isSourceLoaded] True if the event has a `dataType` of `source` and the source has no outstanding network requests.
|
|
203
|
-
* @property {Object} [source] The [style spec representation of the source](https://www.mapbox.com/mapbox-gl-style-spec/#sources) if the event has a `dataType` of `source`.
|
|
204
|
-
* @property {string} [sourceDataType] Included if the event has a `dataType` of `source` and the event signals
|
|
205
|
-
* that internal data has been received or changed. Possible values are `metadata` and `content`.
|
|
206
|
-
* @property {Object} [tile] The tile being loaded or changed, if the event has a `dataType` of `source` and
|
|
207
|
-
* the event is related to loading of a tile.
|
|
208
|
-
* @property {Coordinate} [coord] The coordinate of the tile if the event has a `dataType` of `source` and
|
|
209
|
-
* the event is related to loading of a tile.
|
|
210
|
-
*/
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
const DOM = require('../../util/dom');
|
|
2
|
-
|
|
3
|
-
const LngLatBounds = require('../../geo/lng_lat_bounds');
|
|
4
|
-
const { Event } = require('../../util/evented');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
|
|
8
|
-
* The bounding box is defined by clicking and holding `shift` while dragging the cursor.
|
|
9
|
-
*/
|
|
10
|
-
function boxZoomHandler(map) {
|
|
11
|
-
const el = map.getCanvasContainer();
|
|
12
|
-
const container = map.getContainer();
|
|
13
|
-
|
|
14
|
-
let enabled = false;
|
|
15
|
-
let active = false;
|
|
16
|
-
let startPos;
|
|
17
|
-
let box;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Returns a Boolean indicating whether the "box zoom" interaction is enabled.
|
|
21
|
-
*
|
|
22
|
-
* @returns {boolean} `true` if the "box zoom" interaction is enabled.
|
|
23
|
-
*/
|
|
24
|
-
function isEnabled() {
|
|
25
|
-
return enabled;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
|
|
30
|
-
*
|
|
31
|
-
* @returns {boolean} `true` if the "box zoom" interaction is active.
|
|
32
|
-
*/
|
|
33
|
-
function isActive() {
|
|
34
|
-
return active;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Enables the "box zoom" interaction.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* map.boxZoom.enable();
|
|
42
|
-
*/
|
|
43
|
-
function enable() {
|
|
44
|
-
enabled = true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Disables the "box zoom" interaction.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* map.boxZoom.disable();
|
|
52
|
-
*/
|
|
53
|
-
function disable() {
|
|
54
|
-
enabled = false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function onMouseDown(e) {
|
|
58
|
-
if (!enabled) return;
|
|
59
|
-
if (!(e.shiftKey && e.button === 0)) return;
|
|
60
|
-
|
|
61
|
-
window.document.addEventListener('mousemove', onMouseMove, false);
|
|
62
|
-
window.document.addEventListener('keydown', onKeyDown, false);
|
|
63
|
-
window.document.addEventListener('mouseup', onMouseUp, false);
|
|
64
|
-
|
|
65
|
-
DOM.disableDrag();
|
|
66
|
-
startPos = DOM.mousePos(el, e);
|
|
67
|
-
active = true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function onMouseMove(e) {
|
|
71
|
-
const p0 = startPos;
|
|
72
|
-
const p1 = DOM.mousePos(el, e);
|
|
73
|
-
|
|
74
|
-
if (!box) {
|
|
75
|
-
box = DOM.create('div', 'mapboxgl-boxzoom', container);
|
|
76
|
-
container.classList.add('mapboxgl-crosshair');
|
|
77
|
-
fireEvent('boxzoomstart', e);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const minX = Math.min(p0.x, p1.x);
|
|
81
|
-
const maxX = Math.max(p0.x, p1.x);
|
|
82
|
-
const minY = Math.min(p0.y, p1.y);
|
|
83
|
-
const maxY = Math.max(p0.y, p1.y);
|
|
84
|
-
|
|
85
|
-
box.style.transform = `translate(${minX}px,${minY}px)`;
|
|
86
|
-
box.style.width = `${maxX - minX}px`;
|
|
87
|
-
box.style.height = `${maxY - minY}px`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function onMouseUp(e) {
|
|
91
|
-
if (e.button !== 0) return;
|
|
92
|
-
|
|
93
|
-
const p0 = startPos;
|
|
94
|
-
const p1 = DOM.mousePos(el, e);
|
|
95
|
-
|
|
96
|
-
const bounds = new LngLatBounds().extend(map.unproject(p0)).extend(map.unproject(p1));
|
|
97
|
-
|
|
98
|
-
finish();
|
|
99
|
-
|
|
100
|
-
DOM.suppressClick();
|
|
101
|
-
|
|
102
|
-
if (p0.x === p1.x && p0.y === p1.y) {
|
|
103
|
-
fireEvent('boxzoomcancel', e);
|
|
104
|
-
} else {
|
|
105
|
-
map
|
|
106
|
-
.fitBounds(bounds, { linear: true })
|
|
107
|
-
.fire(new Event('boxzoomend', { originalEvent: e, boxZoomBounds: bounds }));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function onKeyDown(e) {
|
|
112
|
-
if (e.keyCode === 27) {
|
|
113
|
-
finish();
|
|
114
|
-
fireEvent('boxzoomcancel', e);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function finish() {
|
|
119
|
-
active = false;
|
|
120
|
-
|
|
121
|
-
window.document.removeEventListener('mousemove', onMouseMove, false);
|
|
122
|
-
window.document.removeEventListener('keydown', onKeyDown, false);
|
|
123
|
-
window.document.removeEventListener('mouseup', onMouseUp, false);
|
|
124
|
-
|
|
125
|
-
container.classList.remove('mapboxgl-crosshair');
|
|
126
|
-
|
|
127
|
-
if (box) {
|
|
128
|
-
box.remove();
|
|
129
|
-
box = undefined;
|
|
130
|
-
}
|
|
131
|
-
startPos = undefined;
|
|
132
|
-
|
|
133
|
-
DOM.enableDrag();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function fireEvent(type, e) {
|
|
137
|
-
return map.fire(new Event(type, { originalEvent: e }));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
DOM.initEnableDisableDrag();
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
isEnabled,
|
|
144
|
-
isActive,
|
|
145
|
-
enable,
|
|
146
|
-
disable,
|
|
147
|
-
onMouseDown
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
module.exports = boxZoomHandler;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `DoubleClickZoomHandler` allows the user to zoom the map at a point by
|
|
3
|
-
* double clicking or double tapping.
|
|
4
|
-
*/
|
|
5
|
-
function doubleClickZoomHandler(map) {
|
|
6
|
-
let enabled = false;
|
|
7
|
-
let active = false;
|
|
8
|
-
|
|
9
|
-
let tapped;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
|
|
13
|
-
*
|
|
14
|
-
* @returns {boolean} `true` if the "double click to zoom" interaction is enabled.
|
|
15
|
-
*/
|
|
16
|
-
function isEnabled() {
|
|
17
|
-
return enabled;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
|
|
22
|
-
*
|
|
23
|
-
* @returns {boolean} `true` if the "double click to zoom" interaction is active.
|
|
24
|
-
*/
|
|
25
|
-
function isActive() {
|
|
26
|
-
return active;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Enables the "double click to zoom" interaction.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* map.doubleClickZoom.enable();
|
|
34
|
-
*/
|
|
35
|
-
function enable() {
|
|
36
|
-
enabled = true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Disables the "double click to zoom" interaction.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* map.doubleClickZoom.disable();
|
|
44
|
-
*/
|
|
45
|
-
function disable() {
|
|
46
|
-
enabled = false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function onTouchStart(e) {
|
|
50
|
-
if (!enabled) return;
|
|
51
|
-
if (e.points.length > 1) return;
|
|
52
|
-
|
|
53
|
-
if (!tapped) {
|
|
54
|
-
tapped = setTimeout(() => {
|
|
55
|
-
tapped = undefined;
|
|
56
|
-
}, 300);
|
|
57
|
-
} else {
|
|
58
|
-
clearTimeout(tapped);
|
|
59
|
-
tapped = undefined;
|
|
60
|
-
zoom(e);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function onDblClick(e) {
|
|
65
|
-
if (!enabled) return;
|
|
66
|
-
e.originalEvent.preventDefault();
|
|
67
|
-
zoom(e);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function zoom(e) {
|
|
71
|
-
active = true;
|
|
72
|
-
map.on('zoomend', onZoomEnd);
|
|
73
|
-
map.zoomTo(map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1), { around: e.lngLat }, e);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function onZoomEnd() {
|
|
77
|
-
active = false;
|
|
78
|
-
map.off('zoomend', onZoomEnd);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
isEnabled,
|
|
83
|
-
isActive,
|
|
84
|
-
enable,
|
|
85
|
-
disable,
|
|
86
|
-
onDblClick,
|
|
87
|
-
onTouchStart
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
module.exports = doubleClickZoomHandler;
|