maplibre-gl 3.1.0 → 3.2.0-pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +7 -7
  2. package/build/generate-doc-images.ts +73 -0
  3. package/build/generate-docs.ts +100 -0
  4. package/build/generate-struct-arrays.ts +9 -12
  5. package/dist/maplibre-gl-csp-worker.js +1 -1
  6. package/dist/maplibre-gl-csp-worker.js.map +1 -1
  7. package/dist/maplibre-gl-csp.js +1 -1
  8. package/dist/maplibre-gl-csp.js.map +1 -1
  9. package/dist/maplibre-gl-dev.js +3303 -3398
  10. package/dist/maplibre-gl-dev.js.map +1 -1
  11. package/dist/maplibre-gl.d.ts +3899 -3531
  12. package/dist/maplibre-gl.js +3 -3
  13. package/dist/maplibre-gl.js.map +1 -1
  14. package/package.json +28 -25
  15. package/src/data/array_types.g.ts +14 -48
  16. package/src/data/bucket/circle_bucket.ts +11 -14
  17. package/src/data/bucket/fill_bucket.test.ts +6 -6
  18. package/src/data/bucket/fill_bucket.ts +10 -12
  19. package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
  20. package/src/data/bucket/heatmap_bucket.ts +3 -6
  21. package/src/data/bucket/line_attributes.ts +1 -2
  22. package/src/data/bucket/line_attributes_ext.ts +1 -2
  23. package/src/data/bucket/line_bucket.test.ts +5 -5
  24. package/src/data/bucket/line_bucket.ts +18 -21
  25. package/src/data/bucket/pattern_attributes.ts +1 -3
  26. package/src/data/bucket/pattern_bucket_features.ts +3 -3
  27. package/src/data/bucket/symbol_bucket.test.ts +5 -5
  28. package/src/data/bucket/symbol_bucket.ts +12 -15
  29. package/src/data/bucket.ts +7 -11
  30. package/src/data/dem_data.test.ts +1 -1
  31. package/src/data/dem_data.ts +1 -1
  32. package/src/data/evaluation_feature.ts +4 -5
  33. package/src/data/extent.ts +1 -4
  34. package/src/data/feature_index.ts +14 -13
  35. package/src/data/feature_position_map.test.ts +4 -4
  36. package/src/data/feature_position_map.ts +1 -1
  37. package/src/data/index_array_type.ts +0 -1
  38. package/src/data/load_geometry.test.ts +1 -1
  39. package/src/data/load_geometry.ts +3 -4
  40. package/src/data/program_configuration.ts +6 -11
  41. package/src/data/segment.ts +9 -6
  42. package/src/geo/edge_insets.test.ts +1 -1
  43. package/src/geo/edge_insets.ts +36 -26
  44. package/src/geo/lng_lat.test.ts +1 -1
  45. package/src/geo/lng_lat.ts +61 -44
  46. package/src/geo/lng_lat_bounds.test.ts +2 -2
  47. package/src/geo/lng_lat_bounds.ts +88 -68
  48. package/src/geo/mercator_coordinate.test.ts +2 -2
  49. package/src/geo/mercator_coordinate.ts +34 -27
  50. package/src/geo/transform.test.ts +3 -3
  51. package/src/geo/transform.ts +58 -79
  52. package/src/gl/color_mode.ts +1 -3
  53. package/src/gl/context.ts +12 -11
  54. package/src/gl/cull_face_mode.ts +1 -3
  55. package/src/gl/depth_mode.ts +1 -3
  56. package/src/gl/framebuffer.ts +5 -4
  57. package/src/gl/index_buffer.ts +5 -4
  58. package/src/gl/render_pool.test.ts +2 -2
  59. package/src/gl/render_pool.ts +5 -5
  60. package/src/gl/state.test.ts +1 -1
  61. package/src/gl/stencil_mode.ts +1 -3
  62. package/src/gl/value.ts +1 -1
  63. package/src/gl/vertex_buffer.test.ts +2 -2
  64. package/src/gl/vertex_buffer.ts +8 -14
  65. package/src/index.test.ts +2 -2
  66. package/src/index.ts +121 -113
  67. package/src/render/draw_background.ts +7 -9
  68. package/src/render/draw_circle.ts +13 -15
  69. package/src/render/draw_collision_debug.ts +11 -13
  70. package/src/render/draw_custom.ts +6 -8
  71. package/src/render/draw_debug.test.ts +4 -4
  72. package/src/render/draw_debug.ts +8 -10
  73. package/src/render/draw_fill.test.ts +13 -13
  74. package/src/render/draw_fill.ts +9 -11
  75. package/src/render/draw_fill_extrusion.ts +10 -12
  76. package/src/render/draw_heatmap.ts +12 -14
  77. package/src/render/draw_hillshade.ts +10 -12
  78. package/src/render/draw_line.ts +9 -9
  79. package/src/render/draw_raster.ts +9 -11
  80. package/src/render/draw_symbol.test.ts +16 -16
  81. package/src/render/draw_symbol.ts +15 -16
  82. package/src/render/draw_terrain.ts +11 -11
  83. package/src/render/glyph_atlas.ts +10 -1
  84. package/src/render/glyph_manager.test.ts +3 -3
  85. package/src/render/glyph_manager.ts +7 -7
  86. package/src/render/image_atlas.ts +6 -3
  87. package/src/render/image_manager.ts +3 -5
  88. package/src/render/line_atlas.test.ts +1 -1
  89. package/src/render/line_atlas.ts +19 -14
  90. package/src/render/painter.ts +85 -65
  91. package/src/render/program/background_program.ts +2 -2
  92. package/src/render/program/circle_program.ts +5 -5
  93. package/src/render/program/clipping_mask_program.ts +1 -1
  94. package/src/render/program/collision_program.ts +4 -4
  95. package/src/render/program/debug_program.ts +1 -1
  96. package/src/render/program/fill_extrusion_program.ts +3 -3
  97. package/src/render/program/fill_program.ts +3 -3
  98. package/src/render/program/heatmap_program.ts +5 -5
  99. package/src/render/program/hillshade_program.ts +7 -7
  100. package/src/render/program/line_program.ts +6 -6
  101. package/src/render/program/pattern.ts +3 -3
  102. package/src/render/program/raster_program.ts +2 -2
  103. package/src/render/program/symbol_program.ts +2 -2
  104. package/src/render/program/terrain_program.ts +1 -1
  105. package/src/render/program.ts +18 -16
  106. package/src/render/render_to_texture.test.ts +15 -15
  107. package/src/render/render_to_texture.ts +10 -10
  108. package/src/render/terrain.test.ts +38 -7
  109. package/src/render/terrain.ts +103 -67
  110. package/src/render/texture.ts +5 -4
  111. package/src/render/uniform_binding.test.ts +1 -1
  112. package/src/render/uniform_binding.ts +7 -1
  113. package/src/render/update_pattern_positions_in_program.ts +5 -5
  114. package/src/render/vertex_array_object.ts +9 -8
  115. package/src/shaders/encode_attribute.ts +0 -2
  116. package/src/shaders/shaders.ts +1 -3
  117. package/src/source/canvas_source.test.ts +6 -6
  118. package/src/source/canvas_source.ts +46 -60
  119. package/src/source/geojson_source.test.ts +5 -5
  120. package/src/source/geojson_source.ts +75 -59
  121. package/src/source/geojson_source_diff.ts +39 -2
  122. package/src/source/geojson_worker_source.test.ts +3 -3
  123. package/src/source/geojson_worker_source.ts +20 -26
  124. package/src/source/geojson_wrapper.test.ts +3 -3
  125. package/src/source/geojson_wrapper.ts +2 -4
  126. package/src/source/image_source.test.ts +9 -8
  127. package/src/source/image_source.ts +49 -35
  128. package/src/source/load_tilejson.ts +2 -2
  129. package/src/source/pixels_to_tile_units.ts +2 -3
  130. package/src/source/query_features.test.ts +3 -3
  131. package/src/source/query_features.ts +50 -19
  132. package/src/source/raster_dem_tile_source.test.ts +3 -3
  133. package/src/source/raster_dem_tile_source.ts +23 -10
  134. package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
  135. package/src/source/raster_dem_tile_worker_source.ts +3 -5
  136. package/src/source/raster_tile_source.test.ts +3 -3
  137. package/src/source/raster_tile_source.ts +38 -11
  138. package/src/source/rtl_text_plugin.ts +4 -1
  139. package/src/source/source.ts +67 -59
  140. package/src/source/source_cache.test.ts +7 -7
  141. package/src/source/source_cache.ts +17 -38
  142. package/src/source/source_state.ts +2 -5
  143. package/src/source/terrain_source_cache.test.ts +8 -8
  144. package/src/source/terrain_source_cache.ts +42 -27
  145. package/src/source/tile.test.ts +3 -3
  146. package/src/source/tile.ts +32 -38
  147. package/src/source/tile_bounds.ts +2 -4
  148. package/src/source/tile_cache.test.ts +2 -2
  149. package/src/source/tile_cache.ts +20 -30
  150. package/src/source/tile_id.ts +11 -2
  151. package/src/source/vector_tile_source.test.ts +3 -3
  152. package/src/source/vector_tile_source.ts +34 -24
  153. package/src/source/vector_tile_worker_source.test.ts +4 -4
  154. package/src/source/vector_tile_worker_source.ts +11 -23
  155. package/src/source/video_source.test.ts +5 -5
  156. package/src/source/video_source.ts +21 -28
  157. package/src/source/worker.ts +6 -8
  158. package/src/source/worker_source.ts +6 -8
  159. package/src/source/worker_tile.test.ts +5 -5
  160. package/src/source/worker_tile.ts +13 -16
  161. package/src/style/create_style_layer.ts +31 -26
  162. package/src/style/evaluation_parameters.ts +5 -4
  163. package/src/style/format_section_override.test.ts +2 -2
  164. package/src/style/format_section_override.ts +1 -1
  165. package/src/style/light.test.ts +2 -2
  166. package/src/style/light.ts +3 -5
  167. package/src/style/load_glyph_range.test.ts +1 -1
  168. package/src/style/load_glyph_range.ts +3 -3
  169. package/src/style/load_sprite.test.ts +1 -1
  170. package/src/style/load_sprite.ts +3 -3
  171. package/src/style/parse_glyph_pbf.ts +1 -1
  172. package/src/style/pauseable_placement.ts +7 -9
  173. package/src/style/properties.ts +4 -53
  174. package/src/style/query_utils.ts +3 -3
  175. package/src/style/style.test.ts +22 -19
  176. package/src/style/style.ts +118 -84
  177. package/src/style/style_glyph.ts +6 -0
  178. package/src/style/style_image.ts +39 -33
  179. package/src/style/style_layer/background_style_layer.ts +2 -4
  180. package/src/style/style_layer/circle_style_layer.ts +7 -6
  181. package/src/style/style_layer/custom_style_layer.ts +23 -48
  182. package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
  183. package/src/style/style_layer/fill_style_layer.ts +5 -7
  184. package/src/style/style_layer/heatmap_style_layer.ts +8 -7
  185. package/src/style/style_layer/hillshade_style_layer.ts +2 -4
  186. package/src/style/style_layer/line_style_layer.ts +6 -8
  187. package/src/style/style_layer/overlap_mode.test.ts +3 -3
  188. package/src/style/style_layer/overlap_mode.ts +3 -0
  189. package/src/style/style_layer/raster_style_layer.ts +2 -4
  190. package/src/style/style_layer/symbol_style_layer.ts +6 -8
  191. package/src/style/style_layer/typed_style_layer.ts +7 -7
  192. package/src/style/style_layer.test.ts +5 -5
  193. package/src/style/style_layer.ts +7 -6
  194. package/src/style/style_layer_index.test.ts +1 -1
  195. package/src/style/style_layer_index.ts +3 -5
  196. package/src/style/zoom_history.ts +1 -3
  197. package/src/symbol/anchor.test.ts +1 -1
  198. package/src/symbol/anchor.ts +1 -3
  199. package/src/symbol/check_max_angle.test.ts +8 -2
  200. package/src/symbol/check_max_angle.ts +10 -13
  201. package/src/symbol/clip_line.test.ts +1 -1
  202. package/src/symbol/clip_line.ts +6 -9
  203. package/src/symbol/collision_feature.test.ts +2 -2
  204. package/src/symbol/collision_feature.ts +7 -12
  205. package/src/symbol/collision_index.test.ts +2 -2
  206. package/src/symbol/collision_index.ts +5 -11
  207. package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
  208. package/src/symbol/cross_tile_symbol_index.ts +5 -7
  209. package/src/symbol/get_anchors.ts +2 -2
  210. package/src/symbol/grid_index.test.ts +1 -1
  211. package/src/symbol/grid_index.ts +4 -5
  212. package/src/symbol/merge_lines.test.ts +1 -1
  213. package/src/symbol/merge_lines.ts +1 -1
  214. package/src/symbol/opacity_state.ts +1 -3
  215. package/src/symbol/path_interpolator.test.ts +1 -1
  216. package/src/symbol/path_interpolator.ts +1 -3
  217. package/src/symbol/placement.ts +9 -9
  218. package/src/symbol/projection.ts +61 -34
  219. package/src/symbol/quads.ts +7 -11
  220. package/src/symbol/shaping.ts +1 -1
  221. package/src/symbol/symbol_layout.ts +9 -12
  222. package/src/symbol/symbol_size.ts +1 -1
  223. package/src/symbol/symbol_style_layer.test.ts +4 -4
  224. package/src/symbol/transform_text.ts +2 -2
  225. package/src/types/callback.ts +14 -14
  226. package/src/types/cancelable.ts +3 -0
  227. package/src/types/transferable.ts +3 -0
  228. package/src/ui/anchor.ts +4 -0
  229. package/src/ui/camera.test.ts +6 -6
  230. package/src/ui/camera.ts +392 -361
  231. package/src/ui/control/attribution_control.test.ts +1 -1
  232. package/src/ui/control/attribution_control.ts +34 -30
  233. package/src/ui/control/control.ts +14 -20
  234. package/src/ui/control/fullscreen_control.test.ts +1 -1
  235. package/src/ui/control/fullscreen_control.ts +21 -26
  236. package/src/ui/control/geolocate_control.test.ts +5 -5
  237. package/src/ui/control/geolocate_control.ts +181 -194
  238. package/src/ui/control/logo_control.ts +20 -16
  239. package/src/ui/control/navigation_control.test.ts +1 -1
  240. package/src/ui/control/navigation_control.ts +46 -42
  241. package/src/ui/control/scale_control.test.ts +1 -1
  242. package/src/ui/control/scale_control.ts +30 -21
  243. package/src/ui/control/terrain_control.test.ts +1 -1
  244. package/src/ui/control/terrain_control.ts +14 -18
  245. package/src/ui/default_locale.ts +1 -3
  246. package/src/ui/events.ts +570 -1281
  247. package/src/ui/handler/box_zoom.test.ts +2 -2
  248. package/src/ui/handler/box_zoom.ts +16 -11
  249. package/src/ui/handler/click_zoom.ts +11 -3
  250. package/src/ui/handler/cooperative_gestures.test.ts +3 -3
  251. package/src/ui/handler/dblclick_zoom.test.ts +1 -1
  252. package/src/ui/handler/drag_handler.ts +30 -22
  253. package/src/ui/handler/drag_move_state_manager.ts +1 -1
  254. package/src/ui/handler/drag_pan.test.ts +2 -2
  255. package/src/ui/handler/drag_rotate.test.ts +3 -3
  256. package/src/ui/handler/keyboard.test.ts +2 -2
  257. package/src/ui/handler/keyboard.ts +22 -13
  258. package/src/ui/handler/map_event.test.ts +2 -2
  259. package/src/ui/handler/map_event.ts +1 -1
  260. package/src/ui/handler/mouse.ts +1 -1
  261. package/src/ui/handler/mouse_rotate.test.ts +3 -3
  262. package/src/ui/handler/scroll_zoom.test.ts +3 -3
  263. package/src/ui/handler/scroll_zoom.ts +45 -52
  264. package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
  265. package/src/ui/handler/shim/drag_pan.ts +34 -14
  266. package/src/ui/handler/shim/drag_rotate.ts +20 -12
  267. package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
  268. package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
  269. package/src/ui/handler/tap_drag_zoom.ts +18 -10
  270. package/src/ui/handler/tap_recognizer.ts +1 -1
  271. package/src/ui/handler/tap_zoom.ts +4 -3
  272. package/src/ui/handler/touch_pan.ts +3 -2
  273. package/src/ui/handler/transform-provider.ts +4 -6
  274. package/src/ui/handler/two_fingers_touch.test.ts +3 -3
  275. package/src/ui/handler/two_fingers_touch.ts +64 -47
  276. package/src/ui/handler_inertia.ts +4 -4
  277. package/src/ui/handler_manager.ts +86 -52
  278. package/src/ui/hash.test.ts +1 -1
  279. package/src/ui/hash.ts +21 -28
  280. package/src/ui/map/isMoving.test.ts +3 -3
  281. package/src/ui/map/isRotating.test.ts +3 -3
  282. package/src/ui/map/isZooming.test.ts +3 -3
  283. package/src/ui/map.test.ts +97 -8
  284. package/src/ui/map.ts +856 -702
  285. package/src/ui/map_events.test.ts +1 -1
  286. package/src/ui/marker.test.ts +35 -15
  287. package/src/ui/marker.ts +220 -141
  288. package/src/ui/popup.test.ts +2 -2
  289. package/src/ui/popup.ts +179 -147
  290. package/src/util/actor.test.ts +7 -7
  291. package/src/util/actor.ts +25 -22
  292. package/src/util/ajax.ts +37 -17
  293. package/src/util/browser.test.ts +1 -1
  294. package/src/util/browser.ts +2 -6
  295. package/src/util/classify_rings.test.ts +1 -1
  296. package/src/util/classify_rings.ts +1 -1
  297. package/src/util/color_ramp.ts +0 -2
  298. package/src/util/config.ts +6 -3
  299. package/src/util/debug.ts +0 -2
  300. package/src/util/dictionary_coder.ts +1 -4
  301. package/src/util/dispatcher.test.ts +3 -3
  302. package/src/util/dispatcher.ts +4 -9
  303. package/src/util/dom.ts +1 -1
  304. package/src/util/evented.ts +23 -18
  305. package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
  306. package/src/util/find_pole_of_inaccessibility.ts +4 -5
  307. package/src/util/global_worker_pool.ts +2 -3
  308. package/src/util/image.ts +10 -4
  309. package/src/util/image_request.test.ts +3 -3
  310. package/src/util/image_request.ts +15 -14
  311. package/src/util/is_char_in_unicode_block.ts +1 -3
  312. package/src/util/offscreen_canvas_supported.ts +1 -1
  313. package/src/util/performance.ts +1 -2
  314. package/src/util/request_manager.ts +4 -0
  315. package/src/util/resolve_tokens.test.ts +1 -1
  316. package/src/util/resolve_tokens.ts +3 -6
  317. package/src/util/script_detection.ts +1 -4
  318. package/src/util/smart_wrap.ts +3 -5
  319. package/src/util/struct_array.ts +18 -14
  320. package/src/util/style.ts +2 -2
  321. package/src/util/task_queue.test.ts +1 -1
  322. package/src/util/task_queue.ts +1 -3
  323. package/src/util/test/mock_webgl.ts +6 -0
  324. package/src/util/test/util.ts +2 -2
  325. package/src/util/throttle.test.ts +1 -1
  326. package/src/util/throttle.ts +1 -2
  327. package/src/util/throttled_invoker.ts +1 -5
  328. package/src/util/transferable_grid_index.test.ts +1 -1
  329. package/src/util/transferable_grid_index.ts +1 -3
  330. package/src/util/util.test.ts +1 -14
  331. package/src/util/util.ts +44 -107
  332. package/src/util/vectortile_to_geojson.ts +13 -3
  333. package/src/util/verticalize_punctuation.ts +1 -1
  334. package/src/util/web_worker.ts +2 -2
  335. package/src/util/web_worker_transfer.ts +11 -8
  336. package/src/util/webp_supported.ts +2 -4
  337. package/src/util/worker_pool.test.ts +1 -1
  338. package/src/util/worker_pool.ts +4 -5
package/src/ui/events.ts CHANGED
@@ -1,1459 +1,748 @@
1
1
  import {Event} from '../util/evented';
2
2
 
3
- import DOM from '../util/dom';
3
+ import {DOM} from '../util/dom';
4
4
  import Point from '@mapbox/point-geometry';
5
5
  import {extend} from '../util/util';
6
6
  import type {MapGeoJSONFeature} from '../util/vectortile_to_geojson';
7
7
 
8
- import type Map from './map';
9
- import type LngLat from '../geo/lng_lat';
8
+ import type {Map} from './map';
9
+ import type {LngLat} from '../geo/lng_lat';
10
10
  import {SourceSpecification} from '@maplibre/maplibre-gl-style-spec';
11
11
 
12
+ /**
13
+ * An event from the mouse relevant to a specific layer.
14
+ *
15
+ * @group Event Related
16
+ */
12
17
  export type MapLayerMouseEvent = MapMouseEvent & { features?: MapGeoJSONFeature[] };
13
18
 
19
+ /**
20
+ * An event from a touch device relevat to a specific layer.
21
+ *
22
+ * @group Event Related
23
+ */
14
24
  export type MapLayerTouchEvent = MapTouchEvent & { features?: MapGeoJSONFeature[] };
15
25
 
26
+ /**
27
+ * The source event data type
28
+ */
16
29
  export type MapSourceDataType = 'content' | 'metadata' | 'visibility' | 'idle';
17
30
 
31
+ /**
32
+ * `MapLayerEventType` - a mapping between the event name and the event.
33
+ * **Note:** These events are compatible with the optional `layerId` parameter.
34
+ * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
35
+ * event action contains a visible portion of the specified layer.
36
+ * The following example can be used for all the events.
37
+ *
38
+ * @group Event Related
39
+ * @example
40
+ * ```ts
41
+ * // Initialize the map
42
+ * let map = new maplibregl.Map({ // map options });
43
+ * // Set an event listener for a specific layer
44
+ * map.on('the-event-name', 'poi-label', function(e) {
45
+ * console.log('An event has occurred on a visible portion of the poi-label layer');
46
+ * });
47
+ * ```
48
+ */
18
49
  export type MapLayerEventType = {
50
+ /**
51
+ * Fired when a pointing device (usually a mouse) is pressed and released contains a visible portion of the specified layer.
52
+ *
53
+ * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)
54
+ * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)
55
+ */
19
56
  click: MapLayerMouseEvent;
57
+ /**
58
+ * Fired when a pointing device (usually a mouse) is pressed and released twice contains a visible portion of the specified layer.
59
+ *
60
+ * **Note:** Under normal conditions, this event will be preceded by two `click` events.
61
+ */
20
62
  dblclick: MapLayerMouseEvent;
63
+ /**
64
+ * Fired when a pointing device (usually a mouse) is pressed while inside a visible portion of the specified layer.
65
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
66
+ */
21
67
  mousedown: MapLayerMouseEvent;
68
+ /**
69
+ * Fired when a pointing device (usually a mouse) is released while inside a visible portion of the specified layer.
70
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
71
+ */
22
72
  mouseup: MapLayerMouseEvent;
73
+ /**
74
+ * Fired when a pointing device (usually a mouse) is moved while the cursor is inside a visible portion of the specified layer.
75
+ * As you move the cursor across the layer, the event will fire every time the cursor changes position within that layer.
76
+ *
77
+ * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)
78
+ * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)
79
+ * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)
80
+ */
23
81
  mousemove: MapLayerMouseEvent;
82
+ /**
83
+ * Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from
84
+ * outside that layer or outside the map canvas.
85
+ *
86
+ * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)
87
+ * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)
88
+ */
24
89
  mouseenter: MapLayerMouseEvent;
90
+ /**
91
+ * Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves
92
+ * the map canvas.
93
+ *
94
+ * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)
95
+ * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-click/)
96
+ */
25
97
  mouseleave: MapLayerMouseEvent;
98
+ /**
99
+ * Fired when a pointing device (usually a mouse) is moved inside a visible portion of the specified layer.
100
+ *
101
+ * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)
102
+ * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)
103
+ * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)
104
+ */
26
105
  mouseover: MapLayerMouseEvent;
106
+ /**
107
+ * Fired when a point device (usually a mouse) leaves the visible portion of the specified layer.
108
+ */
27
109
  mouseout: MapLayerMouseEvent;
110
+ /**
111
+ * Fired when the right button of the mouse is clicked or the context menu key is pressed within visible portion of the specified layer.
112
+ */
28
113
  contextmenu: MapLayerMouseEvent;
29
-
114
+ /**
115
+ * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.
116
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
117
+ */
30
118
  touchstart: MapLayerTouchEvent;
119
+ /**
120
+ * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the visible portion of the specified layer.
121
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
122
+ */
31
123
  touchend: MapLayerTouchEvent;
124
+ /**
125
+ * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the visible portion of the specified layer.
126
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
127
+ */
32
128
  touchcancel: MapLayerTouchEvent;
33
129
  };
34
130
 
35
- export interface MapLibreEvent<TOrig = unknown> {
36
- type: string;
37
- target: Map;
38
- originalEvent: TOrig;
39
- }
40
-
41
- export interface MapStyleDataEvent extends MapLibreEvent {
42
- dataType: 'style';
43
- }
44
-
45
- export interface MapSourceDataEvent extends MapLibreEvent {
46
- dataType: 'source';
47
- isSourceLoaded: boolean;
48
- source: SourceSpecification;
49
- sourceId: string;
50
- sourceDataType: MapSourceDataType;
51
- tile: any;
52
- }
53
131
  /**
54
- * `MapMouseEvent` is the event type for mouse-related map events.
55
- * @extends {Event}
132
+ * `MapEventType` - a mapping between the event name and the event value.
133
+ * These events are used with the {@link Map#on} method.
134
+ * When using a `layerId` with {@link Map#on} method, please refer to {@link MapLayerEventType}.
135
+ * The following example can be used for all the events.
136
+ *
137
+ * @group Event Related
56
138
  * @example
57
- * // The `click` event is an example of a `MapMouseEvent`.
58
- * // Set up an event listener on the map.
59
- * map.on('click', function(e) {
60
- * // The event object (e) contains information like the
61
- * // coordinates of the point on the map that was clicked.
62
- * console.log('A click event has occurred at ' + e.lngLat);
139
+ * ```ts
140
+ * // Initialize the map
141
+ * let map = new maplibregl.Map({ // map options });
142
+ * // Set an event listener
143
+ * map.on('the-event-name', () => {
144
+ * console.log('An event has occurred!');
63
145
  * });
146
+ * ```
64
147
  */
65
- export class MapMouseEvent extends Event implements MapLibreEvent<MouseEvent> {
66
- /**
67
- * The event type (one of {@link Map.event:mousedown},
68
- * {@link Map.event:mouseup},
69
- * {@link Map.event:click},
70
- * {@link Map.event:dblclick},
71
- * {@link Map.event:mousemove},
72
- * {@link Map.event:mouseover},
73
- * {@link Map.event:mouseenter},
74
- * {@link Map.event:mouseleave},
75
- * {@link Map.event:mouseout},
76
- * {@link Map.event:contextmenu}).
77
- */
78
- type: 'mousedown' | 'mouseup' | 'click' | 'dblclick' | 'mousemove' | 'mouseover' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'contextmenu';
79
-
148
+ export type MapEventType = {
80
149
  /**
81
- * The `Map` object that fired the event.
150
+ * Fired when an error occurs. This is GL JS's primary error reporting
151
+ * mechanism. We use an event instead of `throw` to better accommodate
152
+ * asynchronous operations. If no listeners are bound to the `error` event, the
153
+ * error will be printed to the console.
82
154
  */
83
- target: Map;
84
-
155
+ error: ErrorEvent;
85
156
  /**
86
- * The DOM event which caused the map event.
157
+ * @event `load` Fired immediately after all necessary resources have been downloaded
158
+ * and the first visually complete rendering of the map has occurred.
159
+ *
160
+ * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js/docs/examples/geojson-markers/)
161
+ * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/)
162
+ * @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/)
87
163
  */
88
- originalEvent: MouseEvent;
89
-
164
+ load: MapLibreEvent;
90
165
  /**
91
- * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
166
+ * Fired after the last frame rendered before the map enters an
167
+ * "idle" state:
168
+ *
169
+ * - No camera transitions are in progress
170
+ * - All currently requested tiles have loaded
171
+ * - All fade/transition animations have completed
92
172
  */
93
- point: Point;
94
-
173
+ idle: MapLibreEvent;
95
174
  /**
96
- * The geographic location on the map of the mouse cursor.
175
+ * Fired immediately after the map has been removed with {@link Map#remove}.
97
176
  */
98
- lngLat: LngLat;
99
-
177
+ remove: MapLibreEvent;
100
178
  /**
101
- * Prevents subsequent default processing of the event by the map.
102
- *
103
- * Calling this method will prevent the following default map behaviors:
104
- *
105
- * * On `mousedown` events, the behavior of {@link DragPanHandler}
106
- * * On `mousedown` events, the behavior of {@link DragRotateHandler}
107
- * * On `mousedown` events, the behavior of {@link BoxZoomHandler}
108
- * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}
179
+ * Fired whenever the map is drawn to the screen, as the result of
109
180
  *
181
+ * - a change to the map's position, zoom, pitch, or bearing
182
+ * - a change to the map's style
183
+ * - a change to a GeoJSON source
184
+ * - the loading of a vector tile, GeoJSON file, glyph, or sprite
110
185
  */
111
- preventDefault() {
112
- this._defaultPrevented = true;
113
- }
114
-
186
+ render: MapLibreEvent;
115
187
  /**
116
- * `true` if `preventDefault` has been called.
117
- * @private
188
+ * Fired immediately after the map has been resized.
118
189
  */
119
- get defaultPrevented(): boolean {
120
- return this._defaultPrevented;
121
- }
122
-
123
- _defaultPrevented: boolean;
124
-
190
+ resize: MapLibreEvent;
125
191
  /**
126
- * @private
192
+ * Fired when the WebGL context is lost.
127
193
  */
128
- constructor(type: string, map: Map, originalEvent: MouseEvent, data: any = {}) {
129
- const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
130
- const lngLat = map.unproject(point);
131
- super(type, extend({point, lngLat, originalEvent}, data));
132
- this._defaultPrevented = false;
133
- this.target = map;
134
- }
135
- }
136
-
137
- /**
138
- * `MapTouchEvent` is the event type for touch-related map events.
139
- * @extends {Event}
140
- */
141
- export class MapTouchEvent extends Event implements MapLibreEvent<TouchEvent> {
194
+ webglcontextlost: MapContextEvent;
142
195
  /**
143
- * The event type.
196
+ * Fired when the WebGL context is restored.
144
197
  */
145
- type: 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel';
146
-
198
+ webglcontextrestored: MapContextEvent;
147
199
  /**
148
- * The `Map` object that fired the event.
200
+ * Fired when any map data (style, source, tile, etc) begins loading or
201
+ * changing asynchronously. All `dataloading` events are followed by a `data`,
202
+ * `dataabort` or `error` event.
149
203
  */
150
- target: Map;
151
-
204
+ dataloading: MapDataEvent;
152
205
  /**
153
- * The DOM event which caused the map event.
206
+ * Fired when any map data loads or changes. See {@link MapDataEvent} for more information.
207
+ * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)
154
208
  */
155
- originalEvent: TouchEvent;
156
-
209
+ data: MapDataEvent;
210
+ tiledataloading: MapDataEvent;
157
211
  /**
158
- * The geographic location on the map of the center of the touch event points.
212
+ * Fired when one of the map's sources begins loading or changing asynchronously.
213
+ * All `sourcedataloading` events are followed by a `sourcedata`, `sourcedataabort` or `error` event.
159
214
  */
160
- lngLat: LngLat;
161
-
215
+ sourcedataloading: MapSourceDataEvent;
162
216
  /**
163
- * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
164
- * corner.
217
+ * Fired when the map's style begins loading or changing asynchronously.
218
+ * All `styledataloading` events are followed by a `styledata`
219
+ * or `error` event.
165
220
  */
166
- point: Point;
167
-
221
+ styledataloading: MapStyleDataEvent;
168
222
  /**
169
- * The array of pixel coordinates corresponding to a
170
- * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
223
+ * Fired when one of the map's sources loads or changes, including if a tile belonging
224
+ * to a source loads or changes.
171
225
  */
172
- points: Array<Point>;
173
-
226
+ sourcedata: MapSourceDataEvent;
174
227
  /**
175
- * The geographical locations on the map corresponding to a
176
- * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
228
+ * Fired when the map's style loads or changes.
177
229
  */
178
- lngLats: Array<LngLat>;
179
-
230
+ styledata: MapStyleDataEvent;
180
231
  /**
181
- * Prevents subsequent default processing of the event by the map.
182
- *
183
- * Calling this method will prevent the following default map behaviors:
184
- *
185
- * * On `touchstart` events, the behavior of {@link DragPanHandler}
186
- * * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
187
- *
232
+ * Fired when an icon or pattern needed by the style is missing. The missing image can
233
+ * be added with {@link Map#addImage} within this event listener callback to prevent the image from
234
+ * being skipped. This event can be used to dynamically generate icons and patterns.
235
+ * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)
188
236
  */
189
- preventDefault() {
190
- this._defaultPrevented = true;
191
- }
192
-
237
+ styleimagemissing: MapStyleImageMissingEvent;
193
238
  /**
194
- * `true` if `preventDefault` has been called.
195
- * @private
239
+ * Fired when a request for one of the map's sources' tiles or data is aborted.
196
240
  */
197
- get defaultPrevented(): boolean {
198
- return this._defaultPrevented;
199
- }
200
-
201
- _defaultPrevented: boolean;
202
-
241
+ dataabort: MapDataEvent;
203
242
  /**
204
- * @private
243
+ * Fired when a request for one of the map's sources' data is aborted.
205
244
  */
206
- constructor(type: string, map: Map, originalEvent: TouchEvent) {
207
- const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
208
- const points = DOM.touchPos(map.getCanvasContainer(), touches);
209
- const lngLats = points.map((t) => map.unproject(t));
210
- const point = points.reduce((prev, curr, i, arr) => {
211
- return prev.add(curr.div(arr.length));
212
- }, new Point(0, 0));
213
- const lngLat = map.unproject(point);
214
- super(type, {points, point, lngLats, lngLat, originalEvent});
215
- this._defaultPrevented = false;
216
- }
217
- }
218
-
219
- /**
220
- * `MapWheelEvent` is the event type for the `wheel` map event.
221
- * @extends {Object}
222
- */
223
- export class MapWheelEvent extends Event {
245
+ sourcedataabort: MapSourceDataEvent;
224
246
  /**
225
- * The event type.
247
+ * Fired when the user cancels a "box zoom" interaction, or when the bounding box does not meet the minimum size threshold.
248
+ * See {@link BoxZoomHandler}.
226
249
  */
227
- type: 'wheel';
228
-
250
+ boxzoomcancel: MapLibreZoomEvent;
229
251
  /**
230
- * The `Map` object that fired the event.
252
+ * Fired when a "box zoom" interaction starts. See {@link BoxZoomHandler}.
231
253
  */
232
- target: Map;
233
-
254
+ boxzoomstart: MapLibreZoomEvent;
234
255
  /**
235
- * The DOM event which caused the map event.
256
+ * Fired when a "box zoom" interaction ends. See {@link BoxZoomHandler}.
236
257
  */
237
- originalEvent: WheelEvent;
238
-
258
+ boxzoomend: MapLibreZoomEvent;
239
259
  /**
240
- * Prevents subsequent default processing of the event by the map.
241
- *
242
- * Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
260
+ * Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map.
243
261
  */
244
- preventDefault() {
245
- this._defaultPrevented = true;
246
- }
247
-
262
+ touchcancel: MapTouchEvent;
248
263
  /**
249
- * `true` if `preventDefault` has been called.
250
- * @private
264
+ * Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map.
265
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
251
266
  */
252
- get defaultPrevented(): boolean {
253
- return this._defaultPrevented;
254
- }
255
-
256
- _defaultPrevented: boolean;
257
-
267
+ touchmove: MapTouchEvent;
258
268
  /**
259
- * @private
269
+ * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map.
270
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
260
271
  */
261
- constructor(type: string, map: Map, originalEvent: WheelEvent) {
262
- super(type, {originalEvent});
263
- this._defaultPrevented = false;
264
- }
265
- }
266
-
267
- /**
268
- * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}.
269
- *
270
- * @typedef {Object} MapLibreZoomEvent
271
- * @property {MouseEvent} originalEvent The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent`
272
- * @property {string} type The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel`
273
- * @property {Map} target The `Map` instance that triggered the event
274
- */
275
- export type MapLibreZoomEvent = {
276
- type: 'boxzoomstart' | 'boxzoomend' | 'boxzoomcancel';
277
- target: Map;
278
- originalEvent: MouseEvent;
279
- };
280
-
281
- /**
282
- * A `MapDataEvent` object is emitted with the {@link Map.event:data}
283
- * and {@link Map.event:dataloading} events. Possible values for
284
- * `dataType`s are:
285
- *
286
- * - `'source'`: The non-tile data associated with any source
287
- * - `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map
288
- *
289
- * Possible values for `sourceDataType`s are:
290
- *
291
- * - `'metadata'`: indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles
292
- * - `'content'`: indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource)
293
- * - `'visibility'`: send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible')
294
- * - `'idle'`: indicates that no new source data has been fetched (but the source has done loading)
295
- *
296
- * @typedef {Object} MapDataEvent
297
- * @property {string} type The event type.
298
- * @property {string} dataType The type of data that has changed. One of `'source'`, `'style'`.
299
- * @property {boolean} [isSourceLoaded] True if the event has a `dataType` of `source` and the source has no outstanding network requests.
300
- * @property {Object} [source] The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`.
301
- * @property {string} [sourceDataType] Included if the event has a `dataType` of `source` and the event signals
302
- * that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`.
303
- * @property {Object} [tile] The tile being loaded or changed, if the event has a `dataType` of `source` and
304
- * the event is related to loading of a tile.
305
- * @property {Coordinates} [coord] The coordinate of the tile if the event has a `dataType` of `source` and
306
- * the event is related to loading of a tile.
307
- * @example
308
- * // The sourcedata event is an example of MapDataEvent.
309
- * // Set up an event listener on the map.
310
- * map.on('sourcedata', function(e) {
311
- * if (e.isSourceLoaded) {
312
- * // Do something when the source has finished loading
313
- * }
314
- * });
315
- */
316
- export type MapDataEvent = {
317
- type: string;
318
- dataType: string;
319
- sourceDataType: MapSourceDataType;
320
- };
321
-
322
- export type MapTerrainEvent = {
323
- type: 'terrain';
324
- };
325
-
326
- export type MapContextEvent = {
327
- type: 'webglcontextlost' | 'webglcontextrestored';
328
- originalEvent: WebGLContextEvent;
329
- };
330
-
331
- export interface MapStyleImageMissingEvent extends MapLibreEvent {
332
- type: 'styleimagemissing';
333
- id: string;
334
- }
335
-
336
- /**
337
- * MapEventType - a mapping between the event name and the event value
338
- */
339
- export type MapEventType = {
340
- error: ErrorEvent;
341
-
342
- load: MapLibreEvent;
343
- idle: MapLibreEvent;
344
- remove: MapLibreEvent;
345
- render: MapLibreEvent;
346
- resize: MapLibreEvent;
347
-
348
- webglcontextlost: MapContextEvent;
349
- webglcontextrestored: MapContextEvent;
350
-
351
- dataloading: MapDataEvent;
352
- data: MapDataEvent;
353
- tiledataloading: MapDataEvent;
354
- sourcedataloading: MapSourceDataEvent;
355
- styledataloading: MapStyleDataEvent;
356
- sourcedata: MapSourceDataEvent;
357
- styledata: MapStyleDataEvent;
358
- styleimagemissing: MapStyleImageMissingEvent;
359
- dataabort: MapDataEvent;
360
- sourcedataabort: MapSourceDataEvent;
361
-
362
- boxzoomcancel: MapLibreZoomEvent;
363
- boxzoomstart: MapLibreZoomEvent;
364
- boxzoomend: MapLibreZoomEvent;
365
-
366
- touchcancel: MapTouchEvent;
367
- touchmove: MapTouchEvent;
368
272
  touchend: MapTouchEvent;
273
+ /**
274
+ * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map.
275
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
276
+ */
369
277
  touchstart: MapTouchEvent;
370
-
371
- click: MapMouseEvent;
372
- contextmenu: MapMouseEvent;
373
- dblclick: MapMouseEvent;
374
- mousemove: MapMouseEvent;
375
- mouseup: MapMouseEvent;
376
- mousedown: MapMouseEvent;
377
- mouseout: MapMouseEvent;
378
- mouseover: MapMouseEvent;
379
-
380
- movestart: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
381
- move: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
382
- moveend: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
383
-
384
- zoomstart: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
385
- zoom: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
386
- zoomend: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
387
-
388
- rotatestart: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
389
- rotate: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
390
- rotateend: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
391
-
392
- dragstart: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
393
- drag: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
394
- dragend: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
395
-
396
- pitchstart: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
397
- pitch: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
398
- pitchend: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
399
-
400
- wheel: MapWheelEvent;
401
-
402
- terrain: MapTerrainEvent;
403
- };
404
-
405
- export type MapEvent =
406
278
  /**
407
- * Fired when a pointing device (usually a mouse) is pressed within the map.
408
- *
409
- * **Note:** This event is compatible with the optional `layerId` parameter.
410
- * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
411
- * the cursor is pressed while inside a visible portion of the specified layer.
279
+ * Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map.
412
280
  *
413
- * @event mousedown
414
- * @memberof Map
415
- * @instance
416
- * @property {MapMouseEvent} data
417
- * @example
418
- * // Initialize the map
419
- * var map = new maplibregl.Map({ // map options });
420
- * // Set an event listener
421
- * map.on('mousedown', function() {
422
- * console.log('A mousedown event has occurred.');
423
- * });
424
- * @example
425
- * // Initialize the map
426
- * var map = new maplibregl.Map({ // map options });
427
- * // Set an event listener for a specific layer
428
- * map.on('mousedown', 'poi-label', function() {
429
- * console.log('A mousedown event has occurred on a visible portion of the poi-label layer.');
430
- * });
431
- * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-point/)
432
- */
433
- 'mousedown'
434
-
281
+ * @see [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)
282
+ * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js/docs/examples/center-on-symbol/)
283
+ */
284
+ click: MapMouseEvent;
435
285
  /**
436
- * Fired when a pointing device (usually a mouse) is released within the map.
437
- *
438
- * **Note:** This event is compatible with the optional `layerId` parameter.
439
- * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
440
- * the cursor is released while inside a visible portion of the specified layer.
441
- *
442
- * @event mouseup
443
- * @memberof Map
444
- * @instance
445
- * @property {MapMouseEvent} data
446
- * @example
447
- * // Initialize the map
448
- * var map = new maplibregl.Map({ // map options });
449
- * // Set an event listener
450
- * map.on('mouseup', function() {
451
- * console.log('A mouseup event has occurred.');
452
- * });
453
- * @example
454
- * // Initialize the map
455
- * var map = new maplibregl.Map({ // map options });
456
- * // Set an event listener for a specific layer
457
- * map.on('mouseup', 'poi-label', function() {
458
- * console.log('A mouseup event has occurred on a visible portion of the poi-label layer.');
459
- * });
460
- * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-point/)
461
- */
462
- | 'mouseup'
463
-
286
+ * Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.
287
+ */
288
+ contextmenu: MapMouseEvent;
464
289
  /**
465
- * Fired when a pointing device (usually a mouse) is moved within the map.
466
- * As you move the cursor across a web page containing a map,
467
- * the event will fire each time it enters the map or any child elements.
290
+ * Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on the map in rapid succession.
468
291
  *
469
- * **Note:** This event is compatible with the optional `layerId` parameter.
470
- * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
471
- * the cursor is moved inside a visible portion of the specified layer.
472
- *
473
- * @event mouseover
474
- * @memberof Map
475
- * @instance
476
- * @property {MapMouseEvent} data
477
- * @example
478
- * // Initialize the map
479
- * var map = new maplibregl.Map({ // map options });
480
- * // Set an event listener
481
- * map.on('mouseover', function() {
482
- * console.log('A mouseover event has occurred.');
483
- * });
484
- * @example
485
- * // Initialize the map
486
- * var map = new maplibregl.Map({ // map options });
487
- * // Set an event listener for a specific layer
488
- * map.on('mouseover', 'poi-label', function() {
489
- * console.log('A mouseover event has occurred on a visible portion of the poi-label layer.');
490
- * });
491
- * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js-docs/example/mouse-position/)
492
- * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js-docs/example/hover-styles/)
493
- * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js-docs/example/popup-on-hover/)
494
- */
495
- | 'mouseover'
496
-
292
+ * **Note:** Under normal conditions, this event will be preceded by two `click` events.
293
+ */
294
+ dblclick: MapMouseEvent;
497
295
  /**
498
296
  * Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map.
499
297
  * As you move the cursor across the map, the event will fire every time the cursor changes position within the map.
500
298
  *
501
- * **Note:** This event is compatible with the optional `layerId` parameter.
502
- * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
503
- * the cursor is inside a visible portion of the specified layer.
504
- *
505
- * @event mousemove
506
- * @memberof Map
507
- * @instance
508
- * @property {MapMouseEvent} data
509
- * @example
510
- * // Initialize the map
511
- * var map = new maplibregl.Map({ // map options });
512
- * // Set an event listener
513
- * map.on('mousemove', function() {
514
- * console.log('A mousemove event has occurred.');
515
- * });
516
- * @example
517
- * // Initialize the map
518
- * var map = new maplibregl.Map({ // map options });
519
- * // Set an event listener for a specific layer
520
- * map.on('mousemove', 'poi-label', function() {
521
- * console.log('A mousemove event has occurred on a visible portion of the poi-label layer.');
522
- * });
523
- * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js-docs/example/mouse-position/)
524
- * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js-docs/example/hover-styles/)
525
- * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js-docs/example/popup-on-hover/)
526
- */
527
- | 'mousemove'
528
-
529
- /**
530
- * Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map.
531
- *
532
- * **Note:** This event is compatible with the optional `layerId` parameter.
533
- * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
534
- * point that is pressed and released contains a visible portion of the specified layer.
535
- *
536
- * @event click
537
- * @memberof Map
538
- * @instance
539
- * @property {MapMouseEvent} data
540
- * @example
541
- * // Initialize the map
542
- * var map = new maplibregl.Map({ // map options });
543
- * // Set an event listener
544
- * map.on('click', function(e) {
545
- * console.log('A click event has occurred at ' + e.lngLat);
546
- * });
547
- * @example
548
- * // Initialize the map
549
- * var map = new maplibregl.Map({ // map options });
550
- * // Set an event listener for a specific layer
551
- * map.on('click', 'poi-label', function(e) {
552
- * console.log('A click event has occurred on a visible portion of the poi-label layer at ' + e.lngLat);
553
- * });
554
- * @see [Measure distances](https://maplibre.org/maplibre-gl-js-docs/example/measure/)
555
- * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js-docs/example/center-on-symbol/)
556
- */
557
- | 'click'
558
-
559
- /**
560
- * Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on
561
- * the map in rapid succession.
562
- *
563
- * **Note:** This event is compatible with the optional `layerId` parameter.
564
- * If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only
565
- * when the point that is clicked twice contains a visible portion of the specified layer.
566
- *
567
- * **Note:** Under normal conditions, this event will be preceded by two {@link Map.event:click} events.
568
- *
569
- * @event dblclick
570
- * @memberof Map
571
- * @instance
572
- * @property {MapMouseEvent} data
573
- * @example
574
- * // Initialize the map
575
- * var map = new maplibregl.Map({ // map options });
576
- * // Set an event listener
577
- * map.on('dblclick', function(e) {
578
- * console.log('A dblclick event has occurred at ' + e.lngLat);
579
- * });
580
- * @example
581
- * // Initialize the map
582
- * var map = new maplibregl.Map({ // map options });
583
- * // Set an event listener for a specific layer
584
- * map.on('dblclick', 'poi-label', function(e) {
585
- * console.log('A dblclick event has occurred on a visible portion of the poi-label layer at ' + e.lngLat);
586
- * });
587
- */
588
- | 'dblclick'
589
-
299
+ * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)
300
+ * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)
301
+ * @see [Display a popup on over](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)
302
+ */
303
+ mousemove: MapMouseEvent;
590
304
  /**
591
- * Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from
592
- * outside that layer or outside the map canvas.
593
- *
594
- * **Important:** This event can only be listened for when {@link Map#on} includes three arguments,
595
- * where the second argument specifies the desired layer.
305
+ * Fired when a pointing device (usually a mouse) is released within the map.
596
306
  *
597
- * @event mouseenter
598
- * @memberof Map
599
- * @instance
600
- * @property {MapMouseEvent} data
601
- * @example
602
- * // Initialize the map
603
- * var map = new maplibregl.Map({ // map options });
604
- * // Set an event listener
605
- * map.on('mouseenter', 'water', function() {
606
- * console.log('A mouseenter event occurred on a visible portion of the water layer.');
607
- * });
608
- * @see [Center the map on a clicked symbol](https://maplibre.org/maplibre-gl-js-docs/example/center-on-symbol/)
609
- * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js-docs/example/popup-on-click/)
610
- */
611
- | 'mouseenter'
612
-
307
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
308
+ */
309
+ mouseup: MapMouseEvent;
613
310
  /**
614
- * Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves
615
- * the map canvas.
616
- *
617
- * **Important:** This event can only be listened for when {@link Map#on} includes three arguments,
618
- * where the second argument specifies the desired layer.
311
+ * Fired when a pointing device (usually a mouse) is pressed within the map.
619
312
  *
620
- * @event mouseleave
621
- * @memberof Map
622
- * @instance
623
- * @property {MapMouseEvent} data
624
- * @example
625
- * // Initialize the map
626
- * var map = new maplibregl.Map({ // map options });
627
- * // Set an event listener that fires
628
- * // when the pointing device leaves
629
- * // a visible portion of the specified layer.
630
- * map.on('mouseleave', 'water', function() {
631
- * console.log('A mouseleave event occurred.');
632
- * });
633
- * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js-docs/example/hover-styles/)
634
- * @see [Display a popup on click](https://maplibre.org/maplibre-gl-js-docs/example/popup-on-click/)
635
- */
636
- | 'mouseleave'
637
-
313
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
314
+ */
315
+ mousedown: MapMouseEvent;
638
316
  /**
639
317
  * Fired when a point device (usually a mouse) leaves the map's canvas.
640
- *
641
- * @event mouseout
642
- * @memberof Map
643
- * @instance
644
- * @property {MapMouseEvent} data
645
- * @example
646
- * // Initialize the map
647
- * var map = new maplibregl.Map({ // map options });
648
- * // Set an event listener that fires
649
- * // when the pointing device leave's
650
- * // the map's canvas.
651
- * map.on('mouseout', function() {
652
- * console.log('A mouseout event occurred.');
653
- * });
654
- */
655
- | 'mouseout'
656
-
657
- /**
658
- * Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.
659
- *
660
- * @event contextmenu
661
- * @memberof Map
662
- * @instance
663
- * @property {MapMouseEvent} data
664
- * @example
665
- * // Initialize the map
666
- * var map = new maplibregl.Map({ // map options });
667
- * // Set an event listener that fires
668
- * // when the right mouse button is
669
- * // pressed within the map.
670
- * map.on('contextmenu', function() {
671
- * console.log('A contextmenu event occurred.');
672
- * });
673
- */
674
- | 'contextmenu'
675
-
676
- /**
677
- * Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map.
678
- *
679
- * @event wheel
680
- * @memberof Map
681
- * @instance
682
- * @property {MapWheelEvent} data
683
- * @example
684
- * // Initialize the map
685
- * var map = new maplibregl.Map({ // map options });
686
- * // Set an event listener that fires
687
- * // when a wheel event occurs within the map.
688
- * map.on('wheel', function() {
689
- * console.log('A wheel event occurred.');
690
- * });
691
- */
692
- | 'wheel'
693
-
694
- /**
695
- * Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map.
696
- *
697
- * @event touchstart
698
- * @memberof Map
699
- * @instance
700
- * @property {MapTouchEvent} data
701
- * @example
702
- * // Initialize the map
703
- * var map = new maplibregl.Map({ // map options });
704
- * // Set an event listener that fires
705
- * // when a touchstart event occurs within the map.
706
- * map.on('touchstart', function() {
707
- * console.log('A touchstart event occurred.');
708
- * });
709
- * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-point/)
710
- */
711
- | 'touchstart'
712
-
713
- /**
714
- * Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map.
715
- *
716
- * @event touchend
717
- * @memberof Map
718
- * @instance
719
- * @property {MapTouchEvent} data
720
- * @example
721
- * // Initialize the map
722
- * var map = new maplibregl.Map({ // map options });
723
- * // Set an event listener that fires
724
- * // when a touchstart event occurs within the map.
725
- * map.on('touchstart', function() {
726
- * console.log('A touchstart event occurred.');
727
- * });
728
- * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-point/)
729
- */
730
- | 'touchend'
731
-
732
- /**
733
- * Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map.
734
- *
735
- * @event touchmove
736
- * @memberof Map
737
- * @instance
738
- * @property {MapTouchEvent} data
739
- * @example
740
- * // Initialize the map
741
- * var map = new maplibregl.Map({ // map options });
742
- * // Set an event listener that fires
743
- * // when a touchmove event occurs within the map.
744
- * map.on('touchmove', function() {
745
- * console.log('A touchmove event occurred.');
746
- * });
747
- * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-point/)
748
- */
749
- | 'touchmove'
750
-
318
+ */
319
+ mouseout: MapMouseEvent;
751
320
  /**
752
- * Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map.
321
+ * Fired when a pointing device (usually a mouse) is moved within the map.
322
+ * As you move the cursor across a web page containing a map,
323
+ * the event will fire each time it enters the map or any child elements.
753
324
  *
754
- * @event touchcancel
755
- * @memberof Map
756
- * @instance
757
- * @property {MapTouchEvent} data
758
- * @example
759
- * // Initialize the map
760
- * var map = new maplibregl.Map({ // map options });
761
- * // Set an event listener that fires
762
- * // when a touchcancel event occurs within the map.
763
- * map.on('touchcancel', function() {
764
- * console.log('A touchcancel event occurred.');
765
- * });
766
- */
767
- | 'touchcancel'
768
-
325
+ * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/)
326
+ * @see [Highlight features under the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)
327
+ * @see [Display a popup on hover](https://maplibre.org/maplibre-gl-js/docs/examples/popup-on-hover/)
328
+ */
329
+ mouseover: MapMouseEvent;
769
330
  /**
770
331
  * Fired just before the map begins a transition from one
771
332
  * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.
772
333
  *
773
- * @event movestart
774
- * @memberof Map
775
- * @instance
776
- * @property {{originalEvent: DragEvent}} data
777
- * @example
778
- * // Initialize the map
779
- * var map = new maplibregl.Map({ // map options });
780
- * // Set an event listener that fires
781
- * // just before the map begins a transition
782
- * // from one view to another.
783
- * map.on('movestart', function() {
784
- * console.log('A movestart` event occurred.');
785
- * });
786
- */
787
- | 'movestart'
788
-
334
+ */
335
+ movestart: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
789
336
  /**
790
337
  * Fired repeatedly during an animated transition from one view to
791
338
  * another, as the result of either user interaction or methods such as {@link Map#flyTo}.
792
339
  *
793
- * @event move
794
- * @memberof Map
795
- * @instance
796
- * @property {MapMouseEvent | MapTouchEvent} data
797
- * @example
798
- * // Initialize the map
799
- * var map = new maplibregl.Map({ // map options });
800
- * // Set an event listener that fires
801
- * // repeatedly during an animated transition.
802
- * map.on('move', function() {
803
- * console.log('A move event occurred.');
804
- * });
805
- * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js-docs/example/cluster-html/)
806
- */
807
- | 'move'
808
-
340
+ * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)
341
+ */
342
+ move: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
809
343
  /**
810
344
  * Fired just after the map completes a transition from one
811
345
  * view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.
812
346
  *
813
- * @event moveend
814
- * @memberof Map
815
- * @instance
816
- * @property {{originalEvent: DragEvent}} data
817
- * @example
818
- * // Initialize the map
819
- * var map = new maplibregl.Map({ // map options });
820
- * // Set an event listener that fires
821
- * // just after the map completes a transition.
822
- * map.on('moveend', function() {
823
- * console.log('A moveend event occurred.');
824
- * });
825
- * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js-docs/example/cluster-html/)
826
- */
827
- | 'moveend'
828
-
347
+ * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)
348
+ */
349
+ moveend: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
350
+ /**
351
+ * Fired just before the map begins a transition from one zoom level to another,
352
+ * as the result of either user interaction or methods such as {@link Map#flyTo}.
353
+ */
354
+ zoomstart: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
355
+ /**
356
+ * Fired repeatedly during an animated transition from one zoom level to another,
357
+ * as the result of either user interaction or methods such as {@link Map#flyTo}.
358
+ */
359
+ zoom: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
360
+ /**
361
+ * Fired just after the map completes a transition from one zoom level to another,
362
+ * as the result of either user interaction or methods such as {@link Map#flyTo}.
363
+ */
364
+ zoomend: MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>;
365
+ /**
366
+ * Fired when a "drag to rotate" interaction starts. See {@link DragRotateHandler}.
367
+ */
368
+ rotatestart: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
369
+ /**
370
+ * Fired repeatedly during a "drag to rotate" interaction. See {@link DragRotateHandler}.
371
+ */
372
+ rotate: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
373
+ /**
374
+ * Fired when a "drag to rotate" interaction ends. See {@link DragRotateHandler}.
375
+ */
376
+ rotateend: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
829
377
  /**
830
378
  * Fired when a "drag to pan" interaction starts. See {@link DragPanHandler}.
831
- *
832
- * @event dragstart
833
- * @memberof Map
834
- * @instance
835
- * @property {{originalEvent: DragEvent}} data
836
- * @example
837
- * // Initialize the map
838
- * var map = new maplibregl.Map({ // map options });
839
- * // Set an event listener that fires
840
- * // when a "drag to pan" interaction starts.
841
- * map.on('dragstart', function() {
842
- * console.log('A dragstart event occurred.');
843
- * });
844
- */
845
- | 'dragstart'
846
-
379
+ */
380
+ dragstart: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
847
381
  /**
848
382
  * Fired repeatedly during a "drag to pan" interaction. See {@link DragPanHandler}.
849
- *
850
- * @event drag
851
- * @memberof Map
852
- * @instance
853
- * @property {MapMouseEvent | MapTouchEvent} data
854
- * @example
855
- * // Initialize the map
856
- * var map = new maplibregl.Map({ // map options });
857
- * // Set an event listener that fires
858
- * // repeatedly during a "drag to pan" interaction.
859
- * map.on('drag', function() {
860
- * console.log('A drag event occurred.');
861
- * });
862
- */
863
- | 'drag'
864
-
383
+ */
384
+ drag: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
865
385
  /**
866
386
  * Fired when a "drag to pan" interaction ends. See {@link DragPanHandler}.
867
- *
868
- * @event dragend
869
- * @memberof Map
870
- * @instance
871
- * @property {{originalEvent: DragEvent}} data
872
- * @example
873
- * // Initialize the map
874
- * var map = new maplibregl.Map({ // map options });
875
- * // Set an event listener that fires
876
- * // when a "drag to pan" interaction ends.
877
- * map.on('dragend', function() {
878
- * console.log('A dragend event occurred.');
879
- * });
880
- * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js-docs/example/drag-a-marker/)
881
- */
882
- | 'dragend'
883
-
387
+ * @see [Create a draggable marker](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-marker/)
388
+ */
389
+ dragend: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
884
390
  /**
885
- * Fired just before the map begins a transition from one zoom level to another,
886
- * as the result of either user interaction or methods such as {@link Map#flyTo}.
887
- *
888
- * @event zoomstart
889
- * @memberof Map
890
- * @instance
891
- * @property {MapMouseEvent | MapTouchEvent} data
892
- * @example
893
- * // Initialize the map
894
- * var map = new maplibregl.Map({ // map options });
895
- * // Set an event listener that fires
896
- * // just before a zoom transition starts.
897
- * map.on('zoomstart', function() {
898
- * console.log('A zoomstart event occurred.');
899
- * });
900
- */
901
- | 'zoomstart'
902
-
391
+ * Fired whenever the map's pitch (tilt) begins a change as
392
+ * the result of either user interaction or methods such as {@link Map#flyTo} .
393
+ */
394
+ pitchstart: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
903
395
  /**
904
- * Fired repeatedly during an animated transition from one zoom level to another,
905
- * as the result of either user interaction or methods such as {@link Map#flyTo}.
906
- *
907
- * @event zoom
908
- * @memberof Map
909
- * @instance
910
- * @property {MapMouseEvent | MapTouchEvent} data
911
- * @example
912
- * // Initialize the map
913
- * var map = new maplibregl.Map({ // map options });
914
- * // Set an event listener that fires
915
- * // repeatedly during a zoom transition.
916
- * map.on('zoom', function() {
917
- * console.log('A zoom event occurred.');
918
- * });
919
- */
920
- | 'zoom'
396
+ * Fired repeatedly during the map's pitch (tilt) animation between
397
+ * one state and another as the result of either user interaction
398
+ * or methods such as {@link Map#flyTo}.
399
+ */
400
+ pitch: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
401
+ /**
402
+ * Fired immediately after the map's pitch (tilt) finishes changing as
403
+ * the result of either user interaction or methods such as {@link Map#flyTo}.
404
+ */
405
+ pitchend: MapLibreEvent<MouseEvent | TouchEvent | undefined>;
406
+ /**
407
+ * Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map.
408
+ */
409
+ wheel: MapWheelEvent;
410
+ /**
411
+ * Fired when terrain is changed
412
+ */
413
+ terrain: MapTerrainEvent;
414
+ };
415
+
416
+ /**
417
+ * The base event for MapLibre
418
+ *
419
+ * @group Event Related
420
+ */
421
+ export type MapLibreEvent<TOrig = unknown> = {
422
+ type: keyof MapEventType | keyof MapLayerEventType;
423
+ target: Map;
424
+ originalEvent: TOrig;
425
+ }
426
+
427
+ /**
428
+ * The style data event
429
+ *
430
+ * @group Event Related
431
+ */
432
+ export type MapStyleDataEvent = MapLibreEvent & {
433
+ dataType: 'style';
434
+ }
921
435
 
436
+ /**
437
+ * The source data event interface
438
+ *
439
+ * @group Event Related
440
+ */
441
+ export type MapSourceDataEvent = MapLibreEvent & {
442
+ dataType: 'source';
922
443
  /**
923
- * Fired just after the map completes a transition from one zoom level to another,
924
- * as the result of either user interaction or methods such as {@link Map#flyTo}.
925
- *
926
- * @event zoomend
927
- * @memberof Map
928
- * @instance
929
- * @property {MapMouseEvent | MapTouchEvent} data
930
- * @example
931
- * // Initialize the map
932
- * var map = new maplibregl.Map({ // map options });
933
- * // Set an event listener that fires
934
- * // just after a zoom transition finishes.
935
- * map.on('zoomend', function() {
936
- * console.log('A zoomend event occurred.');
937
- * });
938
- */
939
- | 'zoomend'
444
+ * True if the event has a `dataType` of `source` and the source has no outstanding network requests.
445
+ */
446
+ isSourceLoaded: boolean;
447
+ /**
448
+ * The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`.
449
+ */
450
+ source: SourceSpecification;
451
+ sourceId: string;
452
+ sourceDataType: MapSourceDataType;
453
+ /**
454
+ * The tile being loaded or changed, if the event has a `dataType` of `source` and
455
+ * the event is related to loading of a tile.
456
+ */
457
+ tile: any;
458
+ }
459
+ /**
460
+ * `MapMouseEvent` is the event type for mouse-related map events.
461
+ * @example
462
+ * ```ts
463
+ * // The `click` event is an example of a `MapMouseEvent`.
464
+ * // Set up an event listener on the map.
465
+ * map.on('click', function(e) {
466
+ * // The event object (e) contains information like the
467
+ * // coordinates of the point on the map that was clicked.
468
+ * console.log('A click event has occurred at ' + e.lngLat);
469
+ * });
470
+ * ```
471
+ */
472
+ export class MapMouseEvent extends Event implements MapLibreEvent<MouseEvent> {
473
+ /**
474
+ * The event type
475
+ */
476
+ type: 'mousedown' | 'mouseup' | 'click' | 'dblclick' | 'mousemove' | 'mouseover' | 'mouseenter' | 'mouseleave' | 'mouseout' | 'contextmenu';
940
477
 
941
478
  /**
942
- * Fired when a "drag to rotate" interaction starts. See {@link DragRotateHandler}.
943
- *
944
- * @event rotatestart
945
- * @memberof Map
946
- * @instance
947
- * @property {MapMouseEvent | MapTouchEvent} data
948
- * @example
949
- * // Initialize the map
950
- * var map = new maplibregl.Map({ // map options });
951
- * // Set an event listener that fires
952
- * // just before a "drag to rotate" interaction starts.
953
- * map.on('rotatestart', function() {
954
- * console.log('A rotatestart event occurred.');
955
- * });
956
- */
957
- | 'rotatestart'
479
+ * The `Map` object that fired the event.
480
+ */
481
+ target: Map;
958
482
 
959
483
  /**
960
- * Fired repeatedly during a "drag to rotate" interaction. See {@link DragRotateHandler}.
961
- *
962
- * @event rotate
963
- * @memberof Map
964
- * @instance
965
- * @property {MapMouseEvent | MapTouchEvent} data
966
- * @example
967
- * // Initialize the map
968
- * var map = new maplibregl.Map({ // map options });
969
- * // Set an event listener that fires
970
- * // repeatedly during "drag to rotate" interaction.
971
- * map.on('rotate', function() {
972
- * console.log('A rotate event occurred.');
973
- * });
974
- */
975
- | 'rotate'
484
+ * The DOM event which caused the map event.
485
+ */
486
+ originalEvent: MouseEvent;
976
487
 
977
488
  /**
978
- * Fired when a "drag to rotate" interaction ends. See {@link DragRotateHandler}.
979
- *
980
- * @event rotateend
981
- * @memberof Map
982
- * @instance
983
- * @property {MapMouseEvent | MapTouchEvent} data
984
- * @example
985
- * // Initialize the map
986
- * var map = new maplibregl.Map({ // map options });
987
- * // Set an event listener that fires
988
- * // just after a "drag to rotate" interaction ends.
989
- * map.on('rotateend', function() {
990
- * console.log('A rotateend event occurred.');
991
- * });
992
- */
993
- | 'rotateend'
489
+ * The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
490
+ */
491
+ point: Point;
994
492
 
995
493
  /**
996
- * Fired whenever the map's pitch (tilt) begins a change as
997
- * the result of either user interaction or methods such as {@link Map#flyTo} .
998
- *
999
- * @event pitchstart
1000
- * @memberof Map
1001
- * @instance
1002
- * @property {MapEventData} data
1003
- * @example
1004
- * // Initialize the map
1005
- * var map = new maplibregl.Map({ // map options });
1006
- * // Set an event listener that fires
1007
- * // just before a pitch (tilt) transition starts.
1008
- * map.on('pitchstart', function() {
1009
- * console.log('A pitchstart event occurred.');
1010
- * });
1011
- */
1012
- | 'pitchstart'
494
+ * The geographic location on the map of the mouse cursor.
495
+ */
496
+ lngLat: LngLat;
1013
497
 
1014
498
  /**
1015
- * Fired repeatedly during the map's pitch (tilt) animation between
1016
- * one state and another as the result of either user interaction
1017
- * or methods such as {@link Map#flyTo}.
499
+ * Prevents subsequent default processing of the event by the map.
1018
500
  *
1019
- * @event pitch
1020
- * @memberof Map
1021
- * @instance
1022
- * @property {MapEventData} data
1023
- * @example
1024
- * // Initialize the map
1025
- * var map = new maplibregl.Map({ // map options });
1026
- * // Set an event listener that fires
1027
- * // repeatedly during a pitch (tilt) transition.
1028
- * map.on('pitch', function() {
1029
- * console.log('A pitch event occurred.');
1030
- * });
1031
- */
1032
- | 'pitch'
1033
-
1034
- /**
1035
- * Fired immediately after the map's pitch (tilt) finishes changing as
1036
- * the result of either user interaction or methods such as {@link Map#flyTo}.
501
+ * Calling this method will prevent the following default map behaviors:
502
+ *
503
+ * * On `mousedown` events, the behavior of {@link DragPanHandler}
504
+ * * On `mousedown` events, the behavior of {@link DragRotateHandler}
505
+ * * On `mousedown` events, the behavior of {@link BoxZoomHandler}
506
+ * * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}
1037
507
  *
1038
- * @event pitchend
1039
- * @memberof Map
1040
- * @instance
1041
- * @property {MapEventData} data
1042
- * @example
1043
- * // Initialize the map
1044
- * var map = new maplibregl.Map({ // map options });
1045
- * // Set an event listener that fires
1046
- * // just after a pitch (tilt) transition ends.
1047
- * map.on('pitchend', function() {
1048
- * console.log('A pitchend event occurred.');
1049
- * });
1050
- */
1051
- | 'pitchend'
508
+ */
509
+ preventDefault() {
510
+ this._defaultPrevented = true;
511
+ }
1052
512
 
1053
513
  /**
1054
- * Fired when a "box zoom" interaction starts. See {@link BoxZoomHandler}.
1055
- *
1056
- * @event boxzoomstart
1057
- * @memberof Map
1058
- * @instance
1059
- * @property {MapLibreZoomEvent} data
1060
- * @example
1061
- * // Initialize the map
1062
- * var map = new maplibregl.Map({ // map options });
1063
- * // Set an event listener that fires
1064
- * // just before a "box zoom" interaction starts.
1065
- * map.on('boxzoomstart', function() {
1066
- * console.log('A boxzoomstart event occurred.');
1067
- * });
1068
- */
1069
- | 'boxzoomstart'
514
+ * `true` if `preventDefault` has been called.
515
+ */
516
+ get defaultPrevented(): boolean {
517
+ return this._defaultPrevented;
518
+ }
519
+
520
+ _defaultPrevented: boolean;
521
+
522
+ constructor(type: string, map: Map, originalEvent: MouseEvent, data: any = {}) {
523
+ const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
524
+ const lngLat = map.unproject(point);
525
+ super(type, extend({point, lngLat, originalEvent}, data));
526
+ this._defaultPrevented = false;
527
+ this.target = map;
528
+ }
529
+ }
1070
530
 
531
+ /**
532
+ * `MapTouchEvent` is the event type for touch-related map events.
533
+ *
534
+ * @group Event Related
535
+ */
536
+ export class MapTouchEvent extends Event implements MapLibreEvent<TouchEvent> {
1071
537
  /**
1072
- * Fired when a "box zoom" interaction ends. See {@link BoxZoomHandler}.
1073
- *
1074
- * @event boxzoomend
1075
- * @memberof Map
1076
- * @instance
1077
- * @type {Object}
1078
- * @property {MapLibreZoomEvent} data
1079
- * @example
1080
- * // Initialize the map
1081
- * var map = new maplibregl.Map({ // map options });
1082
- * // Set an event listener that fires
1083
- * // just after a "box zoom" interaction ends.
1084
- * map.on('boxzoomend', function() {
1085
- * console.log('A boxzoomend event occurred.');
1086
- * });
1087
- */
1088
- | 'boxzoomend'
538
+ * The event type.
539
+ */
540
+ type: 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel';
1089
541
 
1090
542
  /**
1091
- * Fired when the user cancels a "box zoom" interaction, or when the bounding box does not meet the minimum size threshold.
1092
- * See {@link BoxZoomHandler}.
1093
- *
1094
- * @event boxzoomcancel
1095
- * @memberof Map
1096
- * @instance
1097
- * @property {MapLibreZoomEvent} data
1098
- * @example
1099
- * // Initialize the map
1100
- * var map = new maplibregl.Map({ // map options });
1101
- * // Set an event listener that fires
1102
- * // the user cancels a "box zoom" interaction.
1103
- * map.on('boxzoomcancel', function() {
1104
- * console.log('A boxzoomcancel event occurred.');
1105
- * });
1106
- */
1107
- | 'boxzoomcancel'
543
+ * The `Map` object that fired the event.
544
+ */
545
+ target: Map;
1108
546
 
1109
547
  /**
1110
- * Fired immediately after the map has been resized.
1111
- *
1112
- * @event resize
1113
- * @memberof Map
1114
- * @instance
1115
- * @example
1116
- * // Initialize the map
1117
- * var map = new maplibregl.Map({ // map options });
1118
- * // Set an event listener that fires
1119
- * // immediately after the map has been resized.
1120
- * map.on('resize', function() {
1121
- * console.log('A resize event occurred.');
1122
- * });
1123
- */
1124
- | 'resize'
548
+ * The DOM event which caused the map event.
549
+ */
550
+ originalEvent: TouchEvent;
1125
551
 
1126
552
  /**
1127
- * Fired when the WebGL context is lost.
1128
- *
1129
- * @event webglcontextlost
1130
- * @memberof Map
1131
- * @instance
1132
- * @example
1133
- * // Initialize the map
1134
- * var map = new maplibregl.Map({ // map options });
1135
- * // Set an event listener that fires
1136
- * // when the WebGL context is lost.
1137
- * map.on('webglcontextlost', function() {
1138
- * console.log('A webglcontextlost event occurred.');
1139
- * });
1140
- */
1141
- | 'webglcontextlost'
553
+ * The geographic location on the map of the center of the touch event points.
554
+ */
555
+ lngLat: LngLat;
1142
556
 
1143
557
  /**
1144
- * Fired when the WebGL context is restored.
1145
- *
1146
- * @event webglcontextrestored
1147
- * @memberof Map
1148
- * @instance
1149
- * @example
1150
- * // Initialize the map
1151
- * var map = new maplibregl.Map({ // map options });
1152
- * // Set an event listener that fires
1153
- * // when the WebGL context is restored.
1154
- * map.on('webglcontextrestored', function() {
1155
- * console.log('A webglcontextrestored event occurred.');
1156
- * });
1157
- */
1158
- | 'webglcontextrestored'
558
+ * The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
559
+ * corner.
560
+ */
561
+ point: Point;
1159
562
 
1160
563
  /**
1161
- * Fired immediately after all necessary resources have been downloaded
1162
- * and the first visually complete rendering of the map has occurred.
1163
- *
1164
- * @event load
1165
- * @memberof Map
1166
- * @instance
1167
- * @type {Object}
1168
- * @example
1169
- * // Initialize the map
1170
- * var map = new maplibregl.Map({ // map options });
1171
- * // Set an event listener that fires
1172
- * // when the map has finished loading.
1173
- * map.on('load', function() {
1174
- * console.log('A load event occurred.');
1175
- * });
1176
- * @see [Draw GeoJSON points](https://maplibre.org/maplibre-gl-js-docs/example/geojson-markers/)
1177
- * @see [Add live realtime data](https://maplibre.org/maplibre-gl-js-docs/example/live-geojson/)
1178
- * @see [Animate a point](https://maplibre.org/maplibre-gl-js-docs/example/animate-point-along-line/)
1179
- */
1180
- | 'load'
564
+ * The array of pixel coordinates corresponding to a
565
+ * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
566
+ */
567
+ points: Array<Point>;
1181
568
 
1182
569
  /**
1183
- * Fired whenever the map is drawn to the screen, as the result of
1184
- *
1185
- * - a change to the map's position, zoom, pitch, or bearing
1186
- * - a change to the map's style
1187
- * - a change to a GeoJSON source
1188
- * - the loading of a vector tile, GeoJSON file, glyph, or sprite
1189
- *
1190
- * @event render
1191
- * @memberof Map
1192
- * @instance
1193
- * @example
1194
- * // Initialize the map
1195
- * var map = new maplibregl.Map({ // map options });
1196
- * // Set an event listener that fires
1197
- * // whenever the map is drawn to the screen.
1198
- * map.on('render', function() {
1199
- * console.log('A render event occurred.');
1200
- * });
1201
- */
1202
- | 'render'
570
+ * The geographical locations on the map corresponding to a
571
+ * [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
572
+ */
573
+ lngLats: Array<LngLat>;
1203
574
 
1204
575
  /**
1205
- * Fired after the last frame rendered before the map enters an
1206
- * "idle" state:
576
+ * Prevents subsequent default processing of the event by the map.
1207
577
  *
1208
- * - No camera transitions are in progress
1209
- * - All currently requested tiles have loaded
1210
- * - All fade/transition animations have completed
578
+ * Calling this method will prevent the following default map behaviors:
1211
579
  *
1212
- * @event idle
1213
- * @memberof Map
1214
- * @instance
1215
- * @example
1216
- * // Initialize the map
1217
- * var map = new maplibregl.Map({ // map options });
1218
- * // Set an event listener that fires
1219
- * // just before the map enters an "idle" state.
1220
- * map.on('idle', function() {
1221
- * console.log('A idle event occurred.');
1222
- * });
1223
- */
1224
- | 'idle'
1225
-
1226
- /**
1227
- * Fired immediately after the map has been removed with {@link Map.event:remove}.
580
+ * * On `touchstart` events, the behavior of {@link DragPanHandler}
581
+ * * On `touchstart` events, the behavior of {@link TwoFingersTouchZoomRotateHandler}
1228
582
  *
1229
- * @event remove
1230
- * @memberof Map
1231
- * @instance
1232
- * @example
1233
- * // Initialize the map
1234
- * var map = new maplibregl.Map({ // map options });
1235
- * // Set an event listener that fires
1236
- * // just after the map is removed.
1237
- * map.on('remove', function() {
1238
- * console.log('A remove event occurred.');
1239
- * });
1240
- */
1241
- | 'remove'
583
+ */
584
+ preventDefault() {
585
+ this._defaultPrevented = true;
586
+ }
1242
587
 
1243
588
  /**
1244
- * Fired when an error occurs. This is GL JS's primary error reporting
1245
- * mechanism. We use an event instead of `throw` to better accommodate
1246
- * asynchronous operations. If no listeners are bound to the `error` event, the
1247
- * error will be printed to the console.
1248
- *
1249
- * @event error
1250
- * @memberof Map
1251
- * @instance
1252
- * @property {{error: {message: string}}} data
1253
- * @example
1254
- * // Initialize the map
1255
- * var map = new maplibregl.Map({ // map options });
1256
- * // Set an event listener that fires
1257
- * // when an error occurs.
1258
- * map.on('error', function() {
1259
- * console.log('A error event occurred.');
1260
- * });
1261
- */
1262
- | 'error'
589
+ * `true` if `preventDefault` has been called.
590
+ */
591
+ get defaultPrevented(): boolean {
592
+ return this._defaultPrevented;
593
+ }
1263
594
 
1264
- /**
1265
- * Fired when any map data loads or changes. See {@link MapDataEvent}
1266
- * for more information.
1267
- *
1268
- * @event data
1269
- * @memberof Map
1270
- * @instance
1271
- * @property {MapDataEvent} data
1272
- * @example
1273
- * // Initialize the map
1274
- * var map = new maplibregl.Map({ // map options });
1275
- * // Set an event listener that fires
1276
- * // when map data loads or changes.
1277
- * map.on('data', function() {
1278
- * console.log('A data event occurred.');
1279
- * });
1280
- * @see [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js-docs/example/cluster-html/)
1281
- */
1282
- | 'data'
595
+ _defaultPrevented: boolean;
1283
596
 
1284
- /**
1285
- * Fired when the map's style loads or changes. See
1286
- * {@link MapDataEvent} for more information.
1287
- *
1288
- * @event styledata
1289
- * @memberof Map
1290
- * @instance
1291
- * @property {MapDataEvent} data
1292
- * @example
1293
- * // Initialize the map
1294
- * var map = new maplibregl.Map({ // map options });
1295
- * // Set an event listener that fires
1296
- * // when the map's style loads or changes.
1297
- * map.on('styledata', function() {
1298
- * console.log('A styledata event occurred.');
1299
- * });
1300
- */
1301
- | 'styledata'
597
+ constructor(type: string, map: Map, originalEvent: TouchEvent) {
598
+ const touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
599
+ const points = DOM.touchPos(map.getCanvasContainer(), touches);
600
+ const lngLats = points.map((t) => map.unproject(t));
601
+ const point = points.reduce((prev, curr, i, arr) => {
602
+ return prev.add(curr.div(arr.length));
603
+ }, new Point(0, 0));
604
+ const lngLat = map.unproject(point);
605
+ super(type, {points, point, lngLats, lngLat, originalEvent});
606
+ this._defaultPrevented = false;
607
+ }
608
+ }
1302
609
 
610
+ /**
611
+ * `MapWheelEvent` is the event type for the `wheel` map event.
612
+ *
613
+ * @group Event Related
614
+ */
615
+ export class MapWheelEvent extends Event {
1303
616
  /**
1304
- * Fired when one of the map's sources loads or changes, including if a tile belonging
1305
- * to a source loads or changes. See {@link MapDataEvent} for more information.
1306
- *
1307
- * @event sourcedata
1308
- * @memberof Map
1309
- * @instance
1310
- * @property {MapDataEvent} data
1311
- * @example
1312
- * // Initialize the map
1313
- * var map = new maplibregl.Map({ // map options });
1314
- * // Set an event listener that fires
1315
- * // when one of the map's sources loads or changes.
1316
- * map.on('sourcedata', function() {
1317
- * console.log('A sourcedata event occurred.');
1318
- * });
1319
- */
1320
- | 'sourcedata'
617
+ * The event type.
618
+ */
619
+ type: 'wheel';
1321
620
 
1322
621
  /**
1323
- * Fired when any map data (style, source, tile, etc) begins loading or
1324
- * changing asynchronously. All `dataloading` events are followed by a `data`,
1325
- * `dataabort` or `error` event. See {@link MapDataEvent} for more information.
1326
- *
1327
- * @event dataloading
1328
- * @memberof Map
1329
- * @instance
1330
- * @property {MapDataEvent} data
1331
- * @example
1332
- * // Initialize the map
1333
- * var map = new maplibregl.Map({ // map options });
1334
- * // Set an event listener that fires
1335
- * // when any map data begins loading
1336
- * // or changing asynchronously.
1337
- * map.on('dataloading', function() {
1338
- * console.log('A dataloading event occurred.');
1339
- * });
1340
- */
1341
- | 'dataloading'
622
+ * The `Map` object that fired the event.
623
+ */
624
+ target: Map;
1342
625
 
1343
626
  /**
1344
- * Fired when the map's style begins loading or changing asynchronously.
1345
- * All `styledataloading` events are followed by a `styledata`
1346
- * or `error` event. See {@link MapDataEvent} for more information.
1347
- *
1348
- * @event styledataloading
1349
- * @memberof Map
1350
- * @instance
1351
- * @property {MapDataEvent} data
1352
- * @example
1353
- * // Initialize the map
1354
- * var map = new maplibregl.Map({ // map options });
1355
- * // Set an event listener that fires
1356
- * // map's style begins loading or
1357
- * // changing asynchronously.
1358
- * map.on('styledataloading', function() {
1359
- * console.log('A styledataloading event occurred.');
1360
- * });
1361
- */
1362
- | 'styledataloading'
627
+ * The DOM event which caused the map event.
628
+ */
629
+ originalEvent: WheelEvent;
1363
630
 
1364
631
  /**
1365
- * Fired when one of the map's sources begins loading or changing asynchronously.
1366
- * All `sourcedataloading` events are followed by a `sourcedata`, `sourcedataabort` or `error` event.
1367
- * See {@link MapDataEvent} for more information.
632
+ * Prevents subsequent default processing of the event by the map.
1368
633
  *
1369
- * @event sourcedataloading
1370
- * @memberof Map
1371
- * @instance
1372
- * @property {MapDataEvent} data
1373
- * @example
1374
- * // Initialize the map
1375
- * var map = new maplibregl.Map({ // map options });
1376
- * // Set an event listener that fires
1377
- * // map's sources begin loading or
1378
- * // changing asynchronously.
1379
- * map.on('sourcedataloading', function() {
1380
- * console.log('A sourcedataloading event occurred.');
1381
- * });
1382
- */
1383
- | 'sourcedataloading'
634
+ * Calling this method will prevent the behavior of {@link ScrollZoomHandler}.
635
+ */
636
+ preventDefault() {
637
+ this._defaultPrevented = true;
638
+ }
1384
639
 
1385
640
  /**
1386
- * Fired when an icon or pattern needed by the style is missing. The missing image can
1387
- * be added with {@link Map#addImage} within this event listener callback to prevent the image from
1388
- * being skipped. This event can be used to dynamically generate icons and patterns.
1389
- *
1390
- * @event styleimagemissing
1391
- * @memberof Map
1392
- * @instance
1393
- * @property {string} id The id of the missing image.
1394
- * @example
1395
- * // Initialize the map
1396
- * var map = new maplibregl.Map({ // map options });
1397
- * // Set an event listener that fires an icon or pattern is missing.
1398
- * map.on('styleimagemissing', function(event: MapStyleImageMissingEvent) {
1399
- * const imageId = event.id
1400
- * console.log('A styleimagemissing event occurred for image id', imageId);
1401
- * });
1402
- * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js-docs/example/add-image-missing-generated/)
1403
- */
1404
- | 'styleimagemissing'
641
+ * `true` if `preventDefault` has been called.
642
+ */
643
+ get defaultPrevented(): boolean {
644
+ return this._defaultPrevented;
645
+ }
646
+
647
+ _defaultPrevented: boolean;
648
+
649
+ /** */
650
+ constructor(type: string, map: Map, originalEvent: WheelEvent) {
651
+ super(type, {originalEvent});
652
+ this._defaultPrevented = false;
653
+ }
654
+ }
1405
655
 
656
+ /**
657
+ * A `MapLibreZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}.
658
+ *
659
+ * @group Event Related
660
+ */
661
+ export type MapLibreZoomEvent = {
1406
662
  /**
1407
- * @event style.load
1408
- * @memberof Map
1409
- * @instance
1410
- * @private
663
+ * The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel`
1411
664
  */
1412
- | 'style.load'
1413
-
665
+ type: 'boxzoomstart' | 'boxzoomend' | 'boxzoomcancel';
1414
666
  /**
1415
- * @event terrain
1416
- * @memberof Map
1417
- * @instance
1418
- * @private
667
+ * The `Map` instance that triggered the event
1419
668
  */
1420
- | 'terrain'
1421
-
669
+ target: Map;
1422
670
  /**
1423
- * Fired when a request for one of the map's sources' tiles is aborted.
1424
- * Fired when a request for one of the map's sources' data is aborted.
1425
- * See {@link MapDataEvent} for more information.
1426
- *
1427
- * @event dataabort
1428
- * @memberof Map
1429
- * @instance
1430
- * @property {MapDataEvent} data
1431
- * @example
1432
- * // Initialize the map
1433
- * var map = new maplibregl.Map({ // map options });
1434
- * // Set an event listener that fires
1435
- * // when a request for one of the map's sources' data is aborted.
1436
- * map.on('dataabort', function() {
1437
- * console.log('A dataabort event occurred.');
1438
- * });
1439
- */
1440
- | 'dataabort'
671
+ * The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent`
672
+ */
673
+ originalEvent: MouseEvent;
674
+ };
1441
675
 
676
+ /**
677
+ * A `MapDataEvent` object is emitted with the `data`
678
+ * and `dataloading` events. Possible values for
679
+ * `dataType`s are:
680
+ *
681
+ * - `'source'`: The non-tile data associated with any source
682
+ * - `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map
683
+ *
684
+ * Possible values for `sourceDataType`s are:
685
+ *
686
+ * - `'metadata'`: indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles
687
+ * - `'content'`: indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource)
688
+ * - `'visibility'`: send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible')
689
+ * - `'idle'`: indicates that no new source data has been fetched (but the source has done loading)
690
+ *
691
+ * @group Event Related
692
+ *
693
+ * @example
694
+ * ```ts
695
+ * // The sourcedata event is an example of MapDataEvent.
696
+ * // Set up an event listener on the map.
697
+ * map.on('sourcedata', function(e) {
698
+ * if (e.isSourceLoaded) {
699
+ * // Do something when the source has finished loading
700
+ * }
701
+ * });
702
+ * ```
703
+ */
704
+ export type MapDataEvent = {
1442
705
  /**
1443
- * Fired when a request for one of the map's sources' data is aborted.
1444
- * See {@link MapDataEvent} for more information.
1445
- *
1446
- * @event sourcedataabort
1447
- * @memberof Map
1448
- * @instance
1449
- * @property {MapDataEvent} data
1450
- * @example
1451
- * // Initialize the map
1452
- * var map = new maplibregl.Map({ // map options });
1453
- * // Set an event listener that fires
1454
- * // when a request for one of the map's sources' data is aborted.
1455
- * map.on('sourcedataabort', function() {
1456
- * console.log('A sourcedataabort event occurred.');
1457
- * });
1458
- */
1459
- | 'sourcedataabort';
706
+ * The event type.
707
+ */
708
+ type: string;
709
+ /**
710
+ * The type of data that has changed. One of `'source'`, `'style'`.
711
+ */
712
+ dataType: string;
713
+ /**
714
+ * Included if the event has a `dataType` of `source` and the event signals that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`.
715
+ */
716
+ sourceDataType: MapSourceDataType;
717
+ };
718
+
719
+ /**
720
+ * The terrain event
721
+ *
722
+ * @group Event Related
723
+ */
724
+ export type MapTerrainEvent = {
725
+ type: 'terrain';
726
+ };
727
+
728
+ /**
729
+ * An event related to the web gl context
730
+ *
731
+ * @group Event Related
732
+ */
733
+ export type MapContextEvent = {
734
+ type: 'webglcontextlost' | 'webglcontextrestored';
735
+ originalEvent: WebGLContextEvent;
736
+ };
737
+
738
+ /**
739
+ * The style image missing event
740
+ *
741
+ * @group Event Related
742
+ *
743
+ * @see [Generate and add a missing icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)
744
+ */
745
+ export type MapStyleImageMissingEvent = MapLibreEvent & {
746
+ type: 'styleimagemissing';
747
+ id: string;
748
+ }