@antv/l7-map 2.21.11-beta.5 → 2.21.11-beta.7

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 (358) hide show
  1. package/README.md +27 -6
  2. package/es/index.d.ts +3 -4
  3. package/es/index.js +2 -4
  4. package/es/map/camera.d.ts +690 -0
  5. package/es/map/camera.js +1138 -0
  6. package/{lib → es/map}/css/l7.css +41 -7
  7. package/es/map/events.d.ts +384 -0
  8. package/es/map/events.js +222 -0
  9. package/es/map/geo/edge_insets.d.ts +97 -0
  10. package/es/{geo → map/geo}/edge_insets.js +55 -33
  11. package/es/map/geo/lng_lat.d.ts +116 -0
  12. package/es/map/geo/lng_lat.js +159 -0
  13. package/es/map/geo/lng_lat_bounds.d.ts +217 -0
  14. package/es/map/geo/lng_lat_bounds.js +334 -0
  15. package/es/map/geo/mercator_coordinate.d.ts +113 -0
  16. package/es/map/geo/mercator_coordinate.js +142 -0
  17. package/es/map/geo/transform.d.ts +262 -0
  18. package/es/map/geo/transform.js +736 -0
  19. package/{lib → es/map}/handler/box_zoom.d.ts +30 -24
  20. package/es/map/handler/box_zoom.js +145 -0
  21. package/es/map/handler/click_zoom.d.ts +24 -0
  22. package/es/map/handler/click_zoom.js +47 -0
  23. package/es/map/handler/cooperative_gestures.d.ts +40 -0
  24. package/es/map/handler/cooperative_gestures.js +94 -0
  25. package/es/map/handler/drag_handler.d.ts +88 -0
  26. package/es/map/handler/drag_handler.js +89 -0
  27. package/es/map/handler/drag_move_state_manager.d.ts +30 -0
  28. package/es/map/handler/drag_move_state_manager.js +94 -0
  29. package/es/map/handler/handler_util.d.ts +3 -0
  30. package/es/{handler → map/handler}/handler_util.js +1 -2
  31. package/es/map/handler/keyboard.d.ts +88 -0
  32. package/es/map/handler/keyboard.js +197 -0
  33. package/es/map/handler/map_event.d.ts +46 -0
  34. package/es/map/handler/map_event.js +131 -0
  35. package/es/map/handler/mouse.d.ts +30 -0
  36. package/es/map/handler/mouse.js +85 -0
  37. package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
  38. package/es/map/handler/one_finger_touch_drag.js +39 -0
  39. package/es/map/handler/scroll_zoom.d.ts +102 -0
  40. package/es/map/handler/scroll_zoom.js +312 -0
  41. package/es/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
  42. package/es/{handler → map/handler}/shim/dblclick_zoom.js +20 -16
  43. package/es/map/handler/shim/drag_pan.d.ts +79 -0
  44. package/es/map/handler/shim/drag_pan.js +77 -0
  45. package/es/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
  46. package/es/map/handler/shim/drag_rotate.js +66 -0
  47. package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
  48. package/es/map/handler/shim/two_fingers_touch.js +106 -0
  49. package/es/map/handler/tap_drag_zoom.d.ts +28 -0
  50. package/es/map/handler/tap_drag_zoom.js +92 -0
  51. package/es/map/handler/tap_recognizer.d.ts +35 -0
  52. package/es/map/handler/tap_recognizer.js +107 -0
  53. package/es/map/handler/tap_zoom.d.ts +28 -0
  54. package/es/map/handler/tap_zoom.js +87 -0
  55. package/es/map/handler/touch_pan.d.ts +40 -0
  56. package/es/map/handler/touch_pan.js +85 -0
  57. package/es/map/handler/transform-provider.d.ts +23 -0
  58. package/es/map/handler/transform-provider.js +35 -0
  59. package/es/map/handler/two_fingers_touch.d.ts +107 -0
  60. package/es/map/handler/two_fingers_touch.js +289 -0
  61. package/es/map/handler_inertia.d.ts +20 -0
  62. package/es/{handler → map}/handler_inertia.js +36 -50
  63. package/es/map/handler_manager.d.ts +154 -0
  64. package/es/map/handler_manager.js +466 -0
  65. package/es/map/map.d.ts +625 -0
  66. package/es/map/map.js +972 -0
  67. package/es/map/util/abort_error.d.ts +15 -0
  68. package/es/map/util/abort_error.js +21 -0
  69. package/es/map/util/browser.d.ts +10 -0
  70. package/es/map/util/browser.js +30 -0
  71. package/es/map/util/dom.d.ts +30 -0
  72. package/es/map/util/dom.js +105 -0
  73. package/es/map/util/evented.d.ts +75 -0
  74. package/es/map/util/evented.js +158 -0
  75. package/es/map/util/task_queue.d.ts +18 -0
  76. package/es/map/util/task_queue.js +54 -0
  77. package/es/map/util/util.d.ts +104 -0
  78. package/es/map/util/util.js +155 -0
  79. package/lib/index.d.ts +3 -4
  80. package/lib/index.js +12 -42
  81. package/lib/map/camera.d.ts +690 -0
  82. package/lib/map/camera.js +1145 -0
  83. package/{es → lib/map}/css/l7.css +41 -7
  84. package/lib/map/events.d.ts +384 -0
  85. package/lib/map/events.js +231 -0
  86. package/lib/map/geo/edge_insets.d.ts +97 -0
  87. package/lib/{geo → map/geo}/edge_insets.js +56 -35
  88. package/lib/map/geo/lng_lat.d.ts +116 -0
  89. package/lib/map/geo/lng_lat.js +166 -0
  90. package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
  91. package/lib/map/geo/lng_lat_bounds.js +341 -0
  92. package/lib/map/geo/mercator_coordinate.d.ts +113 -0
  93. package/lib/map/geo/mercator_coordinate.js +157 -0
  94. package/lib/map/geo/transform.d.ts +262 -0
  95. package/lib/map/geo/transform.js +744 -0
  96. package/{es → lib/map}/handler/box_zoom.d.ts +30 -24
  97. package/lib/map/handler/box_zoom.js +153 -0
  98. package/lib/map/handler/click_zoom.d.ts +24 -0
  99. package/lib/map/handler/click_zoom.js +54 -0
  100. package/lib/map/handler/cooperative_gestures.d.ts +40 -0
  101. package/lib/map/handler/cooperative_gestures.js +101 -0
  102. package/lib/map/handler/drag_handler.d.ts +88 -0
  103. package/lib/map/handler/drag_handler.js +97 -0
  104. package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
  105. package/lib/map/handler/drag_move_state_manager.js +103 -0
  106. package/lib/map/handler/handler_util.d.ts +3 -0
  107. package/lib/{handler → map/handler}/handler_util.js +1 -2
  108. package/lib/map/handler/keyboard.d.ts +88 -0
  109. package/lib/map/handler/keyboard.js +205 -0
  110. package/lib/map/handler/map_event.d.ts +46 -0
  111. package/lib/map/handler/map_event.js +140 -0
  112. package/lib/map/handler/mouse.d.ts +30 -0
  113. package/lib/map/handler/mouse.js +93 -0
  114. package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
  115. package/lib/map/handler/one_finger_touch_drag.js +47 -0
  116. package/lib/map/handler/scroll_zoom.d.ts +102 -0
  117. package/lib/map/handler/scroll_zoom.js +320 -0
  118. package/lib/{handler → map/handler}/shim/dblclick_zoom.d.ts +14 -10
  119. package/lib/{handler → map/handler}/shim/dblclick_zoom.js +21 -17
  120. package/lib/map/handler/shim/drag_pan.d.ts +79 -0
  121. package/lib/map/handler/shim/drag_pan.js +85 -0
  122. package/lib/{handler → map/handler}/shim/drag_rotate.d.ts +24 -16
  123. package/lib/map/handler/shim/drag_rotate.js +74 -0
  124. package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
  125. package/lib/map/handler/shim/two_fingers_touch.js +114 -0
  126. package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
  127. package/lib/map/handler/tap_drag_zoom.js +99 -0
  128. package/lib/map/handler/tap_recognizer.d.ts +35 -0
  129. package/lib/map/handler/tap_recognizer.js +116 -0
  130. package/lib/map/handler/tap_zoom.d.ts +28 -0
  131. package/lib/map/handler/tap_zoom.js +94 -0
  132. package/lib/map/handler/touch_pan.d.ts +40 -0
  133. package/lib/map/handler/touch_pan.js +92 -0
  134. package/lib/map/handler/transform-provider.d.ts +23 -0
  135. package/lib/map/handler/transform-provider.js +43 -0
  136. package/lib/map/handler/two_fingers_touch.d.ts +107 -0
  137. package/lib/map/handler/two_fingers_touch.js +296 -0
  138. package/lib/map/handler_inertia.d.ts +20 -0
  139. package/lib/{handler → map}/handler_inertia.js +38 -53
  140. package/lib/map/handler_manager.d.ts +154 -0
  141. package/lib/map/handler_manager.js +474 -0
  142. package/lib/map/map.d.ts +625 -0
  143. package/lib/map/map.js +979 -0
  144. package/lib/map/util/abort_error.d.ts +15 -0
  145. package/lib/map/util/abort_error.js +29 -0
  146. package/lib/map/util/browser.d.ts +10 -0
  147. package/lib/map/util/browser.js +36 -0
  148. package/lib/map/util/dom.d.ts +30 -0
  149. package/lib/map/util/dom.js +113 -0
  150. package/lib/map/util/evented.d.ts +75 -0
  151. package/lib/map/util/evented.js +167 -0
  152. package/lib/map/util/task_queue.d.ts +18 -0
  153. package/lib/map/util/task_queue.js +62 -0
  154. package/lib/map/util/util.d.ts +104 -0
  155. package/lib/map/util/util.js +171 -0
  156. package/package.json +6 -3
  157. package/es/camera.d.ts +0 -86
  158. package/es/camera.js +0 -639
  159. package/es/earthmap.d.ts +0 -69
  160. package/es/earthmap.js +0 -445
  161. package/es/geo/edge_insets.d.ts +0 -54
  162. package/es/geo/lng_lat.d.ts +0 -18
  163. package/es/geo/lng_lat.js +0 -59
  164. package/es/geo/lng_lat_bounds.d.ts +0 -25
  165. package/es/geo/lng_lat_bounds.js +0 -118
  166. package/es/geo/mercator.d.ts +0 -30
  167. package/es/geo/mercator.js +0 -72
  168. package/es/geo/point.d.ts +0 -40
  169. package/es/geo/point.js +0 -153
  170. package/es/geo/simple.d.ts +0 -30
  171. package/es/geo/simple.js +0 -75
  172. package/es/geo/transform.d.ts +0 -198
  173. package/es/geo/transform.js +0 -895
  174. package/es/handler/IHandler.d.ts +0 -34
  175. package/es/handler/IHandler.js +0 -1
  176. package/es/handler/blockable_map_event.d.ts +0 -17
  177. package/es/handler/blockable_map_event.js +0 -58
  178. package/es/handler/box_zoom.js +0 -162
  179. package/es/handler/click_zoom.d.ts +0 -16
  180. package/es/handler/click_zoom.js +0 -40
  181. package/es/handler/events/event.d.ts +0 -4
  182. package/es/handler/events/event.js +0 -12
  183. package/es/handler/events/index.d.ts +0 -4
  184. package/es/handler/events/index.js +0 -4
  185. package/es/handler/events/map_mouse_event.d.ts +0 -34
  186. package/es/handler/events/map_mouse_event.js +0 -45
  187. package/es/handler/events/map_touch_event.d.ts +0 -57
  188. package/es/handler/events/map_touch_event.js +0 -75
  189. package/es/handler/events/map_wheel_event.d.ts +0 -33
  190. package/es/handler/events/map_wheel_event.js +0 -33
  191. package/es/handler/events/render_event.d.ts +0 -6
  192. package/es/handler/events/render_event.js +0 -10
  193. package/es/handler/handler_inertia.d.ts +0 -23
  194. package/es/handler/handler_manager.d.ts +0 -61
  195. package/es/handler/handler_manager.js +0 -487
  196. package/es/handler/handler_util.d.ts +0 -4
  197. package/es/handler/keyboard.d.ts +0 -36
  198. package/es/handler/keyboard.js +0 -131
  199. package/es/handler/map_event.d.ts +0 -29
  200. package/es/handler/map_event.js +0 -89
  201. package/es/handler/mouse/index.d.ts +0 -4
  202. package/es/handler/mouse/index.js +0 -4
  203. package/es/handler/mouse/mouse_handler.d.ts +0 -22
  204. package/es/handler/mouse/mouse_handler.js +0 -99
  205. package/es/handler/mouse/mousepan_handler.d.ts +0 -10
  206. package/es/handler/mouse/mousepan_handler.js +0 -21
  207. package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
  208. package/es/handler/mouse/mousepitch_hander.js +0 -24
  209. package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
  210. package/es/handler/mouse/mouserotate_hander.js +0 -24
  211. package/es/handler/mouse/util.d.ts +0 -6
  212. package/es/handler/mouse/util.js +0 -12
  213. package/es/handler/scroll_zoom.d.ts +0 -93
  214. package/es/handler/scroll_zoom.js +0 -315
  215. package/es/handler/shim/drag_pan.d.ts +0 -61
  216. package/es/handler/shim/drag_pan.js +0 -75
  217. package/es/handler/shim/drag_rotate.js +0 -64
  218. package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
  219. package/es/handler/shim/touch_zoom_rotate.js +0 -104
  220. package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
  221. package/es/handler/tap/single_tap_recognizer.js +0 -77
  222. package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
  223. package/es/handler/tap/tap_drag_zoom.js +0 -89
  224. package/es/handler/tap/tap_recognizer.d.ts +0 -17
  225. package/es/handler/tap/tap_recognizer.js +0 -46
  226. package/es/handler/tap/tap_zoom.d.ts +0 -22
  227. package/es/handler/tap/tap_zoom.js +0 -81
  228. package/es/handler/touch/index.d.ts +0 -5
  229. package/es/handler/touch/index.js +0 -5
  230. package/es/handler/touch/touch_pan.d.ts +0 -30
  231. package/es/handler/touch/touch_pan.js +0 -91
  232. package/es/handler/touch/touch_pitch.d.ts +0 -13
  233. package/es/handler/touch/touch_pitch.js +0 -75
  234. package/es/handler/touch/touch_rotate.d.ts +0 -12
  235. package/es/handler/touch/touch_rotate.js +0 -57
  236. package/es/handler/touch/touch_zoom.d.ts +0 -12
  237. package/es/handler/touch/touch_zoom.js +0 -37
  238. package/es/handler/touch/two_touch.d.ts +0 -23
  239. package/es/handler/touch/two_touch.js +0 -98
  240. package/es/hash.d.ts +0 -14
  241. package/es/hash.js +0 -121
  242. package/es/interface.d.ts +0 -34
  243. package/es/interface.js +0 -1
  244. package/es/map.d.ts +0 -70
  245. package/es/map.js +0 -472
  246. package/es/util.d.ts +0 -25
  247. package/es/util.js +0 -70
  248. package/es/utils/Aabb.d.ts +0 -12
  249. package/es/utils/Aabb.js +0 -72
  250. package/es/utils/dom.d.ts +0 -4
  251. package/es/utils/dom.js +0 -117
  252. package/es/utils/performance.d.ts +0 -17
  253. package/es/utils/performance.js +0 -58
  254. package/es/utils/primitives.d.ts +0 -6
  255. package/es/utils/primitives.js +0 -37
  256. package/es/utils/task_queue.d.ts +0 -13
  257. package/es/utils/task_queue.js +0 -60
  258. package/lib/camera.d.ts +0 -86
  259. package/lib/camera.js +0 -648
  260. package/lib/earthmap.d.ts +0 -69
  261. package/lib/earthmap.js +0 -451
  262. package/lib/geo/edge_insets.d.ts +0 -54
  263. package/lib/geo/lng_lat.d.ts +0 -18
  264. package/lib/geo/lng_lat.js +0 -67
  265. package/lib/geo/lng_lat_bounds.d.ts +0 -25
  266. package/lib/geo/lng_lat_bounds.js +0 -126
  267. package/lib/geo/mercator.d.ts +0 -30
  268. package/lib/geo/mercator.js +0 -88
  269. package/lib/geo/point.d.ts +0 -40
  270. package/lib/geo/point.js +0 -161
  271. package/lib/geo/simple.d.ts +0 -30
  272. package/lib/geo/simple.js +0 -92
  273. package/lib/geo/transform.d.ts +0 -198
  274. package/lib/geo/transform.js +0 -906
  275. package/lib/handler/IHandler.d.ts +0 -34
  276. package/lib/handler/IHandler.js +0 -5
  277. package/lib/handler/blockable_map_event.d.ts +0 -17
  278. package/lib/handler/blockable_map_event.js +0 -66
  279. package/lib/handler/box_zoom.js +0 -168
  280. package/lib/handler/click_zoom.d.ts +0 -16
  281. package/lib/handler/click_zoom.js +0 -48
  282. package/lib/handler/events/event.d.ts +0 -4
  283. package/lib/handler/events/event.js +0 -20
  284. package/lib/handler/events/index.d.ts +0 -4
  285. package/lib/handler/events/index.js +0 -27
  286. package/lib/handler/events/map_mouse_event.d.ts +0 -34
  287. package/lib/handler/events/map_mouse_event.js +0 -53
  288. package/lib/handler/events/map_touch_event.d.ts +0 -57
  289. package/lib/handler/events/map_touch_event.js +0 -83
  290. package/lib/handler/events/map_wheel_event.d.ts +0 -33
  291. package/lib/handler/events/map_wheel_event.js +0 -41
  292. package/lib/handler/events/render_event.d.ts +0 -6
  293. package/lib/handler/events/render_event.js +0 -18
  294. package/lib/handler/handler_inertia.d.ts +0 -23
  295. package/lib/handler/handler_manager.d.ts +0 -61
  296. package/lib/handler/handler_manager.js +0 -495
  297. package/lib/handler/handler_util.d.ts +0 -4
  298. package/lib/handler/keyboard.d.ts +0 -36
  299. package/lib/handler/keyboard.js +0 -138
  300. package/lib/handler/map_event.d.ts +0 -29
  301. package/lib/handler/map_event.js +0 -97
  302. package/lib/handler/mouse/index.d.ts +0 -4
  303. package/lib/handler/mouse/index.js +0 -27
  304. package/lib/handler/mouse/mouse_handler.d.ts +0 -22
  305. package/lib/handler/mouse/mouse_handler.js +0 -107
  306. package/lib/handler/mouse/mousepan_handler.d.ts +0 -10
  307. package/lib/handler/mouse/mousepan_handler.js +0 -29
  308. package/lib/handler/mouse/mousepitch_hander.d.ts +0 -9
  309. package/lib/handler/mouse/mousepitch_hander.js +0 -32
  310. package/lib/handler/mouse/mouserotate_hander.d.ts +0 -9
  311. package/lib/handler/mouse/mouserotate_hander.js +0 -32
  312. package/lib/handler/mouse/util.d.ts +0 -6
  313. package/lib/handler/mouse/util.js +0 -19
  314. package/lib/handler/scroll_zoom.d.ts +0 -93
  315. package/lib/handler/scroll_zoom.js +0 -322
  316. package/lib/handler/shim/drag_pan.d.ts +0 -61
  317. package/lib/handler/shim/drag_pan.js +0 -83
  318. package/lib/handler/shim/drag_rotate.js +0 -72
  319. package/lib/handler/shim/touch_zoom_rotate.d.ts +0 -70
  320. package/lib/handler/shim/touch_zoom_rotate.js +0 -112
  321. package/lib/handler/tap/single_tap_recognizer.d.ts +0 -20
  322. package/lib/handler/tap/single_tap_recognizer.js +0 -86
  323. package/lib/handler/tap/tap_drag_zoom.d.ts +0 -22
  324. package/lib/handler/tap/tap_drag_zoom.js +0 -97
  325. package/lib/handler/tap/tap_recognizer.d.ts +0 -17
  326. package/lib/handler/tap/tap_recognizer.js +0 -56
  327. package/lib/handler/tap/tap_zoom.d.ts +0 -22
  328. package/lib/handler/tap/tap_zoom.js +0 -89
  329. package/lib/handler/touch/index.d.ts +0 -5
  330. package/lib/handler/touch/index.js +0 -34
  331. package/lib/handler/touch/touch_pan.d.ts +0 -30
  332. package/lib/handler/touch/touch_pan.js +0 -100
  333. package/lib/handler/touch/touch_pitch.d.ts +0 -13
  334. package/lib/handler/touch/touch_pitch.js +0 -83
  335. package/lib/handler/touch/touch_rotate.d.ts +0 -12
  336. package/lib/handler/touch/touch_rotate.js +0 -65
  337. package/lib/handler/touch/touch_zoom.d.ts +0 -12
  338. package/lib/handler/touch/touch_zoom.js +0 -45
  339. package/lib/handler/touch/two_touch.d.ts +0 -23
  340. package/lib/handler/touch/two_touch.js +0 -106
  341. package/lib/hash.d.ts +0 -14
  342. package/lib/hash.js +0 -129
  343. package/lib/interface.d.ts +0 -34
  344. package/lib/interface.js +0 -5
  345. package/lib/map.d.ts +0 -70
  346. package/lib/map.js +0 -478
  347. package/lib/util.d.ts +0 -25
  348. package/lib/util.js +0 -89
  349. package/lib/utils/Aabb.d.ts +0 -12
  350. package/lib/utils/Aabb.js +0 -80
  351. package/lib/utils/dom.d.ts +0 -4
  352. package/lib/utils/dom.js +0 -125
  353. package/lib/utils/performance.d.ts +0 -17
  354. package/lib/utils/performance.js +0 -64
  355. package/lib/utils/primitives.d.ts +0 -6
  356. package/lib/utils/primitives.js +0 -45
  357. package/lib/utils/task_queue.d.ts +0 -13
  358. package/lib/utils/task_queue.js +0 -67
@@ -1,59 +1,65 @@
1
- import type { EarthMap } from '../earthmap';
2
- import type Point from '../geo/point';
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import { TransformProvider } from './transform-provider';
3
+ import type Point from '@mapbox/point-geometry';
4
+ import type { Handler } from '../handler_manager';
3
5
  import type { Map } from '../map';
4
6
  /**
5
7
  * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
6
8
  * The bounding box is defined by clicking and holding `shift` while dragging the cursor.
9
+ *
10
+ * @group Handlers
7
11
  */
8
- declare class BoxZoomHandler {
9
- private map;
10
- private el;
11
- private container;
12
- private enabled;
13
- private active;
14
- private startPos;
15
- private lastPos;
16
- private box;
17
- private clickTolerance;
18
- /**
19
- * @private
20
- */
21
- constructor(map: Map | EarthMap, options: {
12
+ export declare class BoxZoomHandler implements Handler {
13
+ _map: Map;
14
+ _tr: TransformProvider;
15
+ _el: HTMLElement;
16
+ _container: HTMLElement;
17
+ _enabled: boolean;
18
+ _active: boolean;
19
+ _startPos: Point;
20
+ _lastPos: Point;
21
+ _box: HTMLElement;
22
+ _clickTolerance: number;
23
+ /** @internal */
24
+ constructor(map: Map, options: {
22
25
  clickTolerance: number;
23
26
  });
24
27
  /**
25
28
  * Returns a Boolean indicating whether the "box zoom" interaction is enabled.
26
29
  *
27
- * @returns {boolean} `true` if the "box zoom" interaction is enabled.
30
+ * @returns `true` if the "box zoom" interaction is enabled.
28
31
  */
29
32
  isEnabled(): boolean;
30
33
  /**
31
34
  * Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
32
35
  *
33
- * @returns {boolean} `true` if the "box zoom" interaction is active.
36
+ * @returns `true` if the "box zoom" interaction is active.
34
37
  */
35
38
  isActive(): boolean;
36
39
  /**
37
40
  * Enables the "box zoom" interaction.
38
41
  *
39
42
  * @example
40
- * map.boxZoom.enable();
43
+ * ```ts
44
+ * map.boxZoom.enable();
45
+ * ```
41
46
  */
42
47
  enable(): void;
43
48
  /**
44
49
  * Disables the "box zoom" interaction.
45
50
  *
46
51
  * @example
47
- * map.boxZoom.disable();
52
+ * ```ts
53
+ * map.boxZoom.disable();
54
+ * ```
48
55
  */
49
56
  disable(): void;
50
57
  mousedown(e: MouseEvent, point: Point): void;
51
58
  mousemoveWindow(e: MouseEvent, point: Point): void;
52
59
  mouseupWindow(e: MouseEvent, point: Point): {
53
- cameraAnimation: (map: Map) => boolean | Map;
54
- } | undefined;
60
+ cameraAnimation: (map: any) => any;
61
+ };
55
62
  keydown(e: KeyboardEvent): void;
56
63
  reset(): void;
57
- fireEvent(type: string, e: any): boolean;
64
+ _fireEvent(type: string, e: any): Map;
58
65
  }
59
- export default BoxZoomHandler;
@@ -0,0 +1,145 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { DOM } from "../util/dom";
3
+ import { Event } from "../util/evented";
4
+ import { TransformProvider } from "./transform-provider";
5
+ /**
6
+ * The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
7
+ * The bounding box is defined by clicking and holding `shift` while dragging the cursor.
8
+ *
9
+ * @group Handlers
10
+ */
11
+ export class BoxZoomHandler {
12
+ /** @internal */
13
+ constructor(map, options) {
14
+ _defineProperty(this, "_map", void 0);
15
+ _defineProperty(this, "_tr", void 0);
16
+ _defineProperty(this, "_el", void 0);
17
+ _defineProperty(this, "_container", void 0);
18
+ _defineProperty(this, "_enabled", void 0);
19
+ _defineProperty(this, "_active", void 0);
20
+ _defineProperty(this, "_startPos", void 0);
21
+ _defineProperty(this, "_lastPos", void 0);
22
+ _defineProperty(this, "_box", void 0);
23
+ _defineProperty(this, "_clickTolerance", void 0);
24
+ this._map = map;
25
+ this._tr = new TransformProvider(map);
26
+ this._el = map.getCanvasContainer();
27
+ this._container = map.getContainer();
28
+ this._clickTolerance = options.clickTolerance || 1;
29
+ }
30
+
31
+ /**
32
+ * Returns a Boolean indicating whether the "box zoom" interaction is enabled.
33
+ *
34
+ * @returns `true` if the "box zoom" interaction is enabled.
35
+ */
36
+ isEnabled() {
37
+ return !!this._enabled;
38
+ }
39
+
40
+ /**
41
+ * Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
42
+ *
43
+ * @returns `true` if the "box zoom" interaction is active.
44
+ */
45
+ isActive() {
46
+ return !!this._active;
47
+ }
48
+
49
+ /**
50
+ * Enables the "box zoom" interaction.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * map.boxZoom.enable();
55
+ * ```
56
+ */
57
+ enable() {
58
+ if (this.isEnabled()) return;
59
+ this._enabled = true;
60
+ }
61
+
62
+ /**
63
+ * Disables the "box zoom" interaction.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * map.boxZoom.disable();
68
+ * ```
69
+ */
70
+ disable() {
71
+ if (!this.isEnabled()) return;
72
+ this._enabled = false;
73
+ }
74
+ mousedown(e, point) {
75
+ if (!this.isEnabled()) return;
76
+ if (!(e.shiftKey && e.button === 0)) return;
77
+ DOM.disableDrag();
78
+ this._startPos = this._lastPos = point;
79
+ this._active = true;
80
+ }
81
+ mousemoveWindow(e, point) {
82
+ if (!this._active) return;
83
+ const pos = point;
84
+ if (this._lastPos.equals(pos) || !this._box && pos.dist(this._startPos) < this._clickTolerance) {
85
+ return;
86
+ }
87
+ const p0 = this._startPos;
88
+ this._lastPos = pos;
89
+ if (!this._box) {
90
+ this._box = DOM.create('div', 'l7-boxzoom', this._container);
91
+ this._container.classList.add('l7-crosshair');
92
+ this._fireEvent('boxzoomstart', e);
93
+ }
94
+ const minX = Math.min(p0.x, pos.x),
95
+ maxX = Math.max(p0.x, pos.x),
96
+ minY = Math.min(p0.y, pos.y),
97
+ maxY = Math.max(p0.y, pos.y);
98
+ DOM.setTransform(this._box, `translate(${minX}px,${minY}px)`);
99
+ this._box.style.width = `${maxX - minX}px`;
100
+ this._box.style.height = `${maxY - minY}px`;
101
+ }
102
+ mouseupWindow(e, point) {
103
+ if (!this._active) return;
104
+ if (e.button !== 0) return;
105
+ const p0 = this._startPos,
106
+ p1 = point;
107
+ this.reset();
108
+ DOM.suppressClick();
109
+ if (p0.x === p1.x && p0.y === p1.y) {
110
+ this._fireEvent('boxzoomcancel', e);
111
+ } else {
112
+ this._map.fire(new Event('boxzoomend', {
113
+ originalEvent: e
114
+ }));
115
+ return {
116
+ cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this._tr.bearing, {
117
+ linear: true
118
+ })
119
+ };
120
+ }
121
+ }
122
+ keydown(e) {
123
+ if (!this._active) return;
124
+ if (e.keyCode === 27) {
125
+ this.reset();
126
+ this._fireEvent('boxzoomcancel', e);
127
+ }
128
+ }
129
+ reset() {
130
+ this._active = false;
131
+ this._container.classList.remove('l7-crosshair');
132
+ if (this._box) {
133
+ DOM.remove(this._box);
134
+ this._box = null;
135
+ }
136
+ DOM.enableDrag();
137
+ delete this._startPos;
138
+ delete this._lastPos;
139
+ }
140
+ _fireEvent(type, e) {
141
+ return this._map.fire(new Event(type, {
142
+ originalEvent: e
143
+ }));
144
+ }
145
+ }
@@ -0,0 +1,24 @@
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import type Point from '@mapbox/point-geometry';
3
+ import type { Handler } from '../handler_manager';
4
+ import type { Map } from '../map';
5
+ import { TransformProvider } from './transform-provider';
6
+ /**
7
+ * The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking
8
+ * It is used by other handlers
9
+ */
10
+ export declare class ClickZoomHandler implements Handler {
11
+ _tr: TransformProvider;
12
+ _enabled: boolean;
13
+ _active: boolean;
14
+ /** @internal */
15
+ constructor(map: Map);
16
+ reset(): void;
17
+ dblclick(e: MouseEvent, point: Point): {
18
+ cameraAnimation: (map: Map) => void;
19
+ };
20
+ enable(): void;
21
+ disable(): void;
22
+ isEnabled(): boolean;
23
+ isActive(): boolean;
24
+ }
@@ -0,0 +1,47 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { TransformProvider } from "./transform-provider";
3
+
4
+ /**
5
+ * The `ClickZoomHandler` allows the user to zoom the map at a point by double clicking
6
+ * It is used by other handlers
7
+ */
8
+ export class ClickZoomHandler {
9
+ /** @internal */
10
+ constructor(map) {
11
+ _defineProperty(this, "_tr", void 0);
12
+ _defineProperty(this, "_enabled", void 0);
13
+ _defineProperty(this, "_active", void 0);
14
+ this._tr = new TransformProvider(map);
15
+ this.reset();
16
+ }
17
+ reset() {
18
+ this._active = false;
19
+ }
20
+ dblclick(e, point) {
21
+ e.preventDefault();
22
+ return {
23
+ cameraAnimation: map => {
24
+ map.easeTo({
25
+ duration: 300,
26
+ zoom: this._tr.zoom + (e.shiftKey ? -1 : 1),
27
+ around: this._tr.unproject(point)
28
+ }, {
29
+ originalEvent: e
30
+ });
31
+ }
32
+ };
33
+ }
34
+ enable() {
35
+ this._enabled = true;
36
+ }
37
+ disable() {
38
+ this._enabled = false;
39
+ this.reset();
40
+ }
41
+ isEnabled() {
42
+ return this._enabled;
43
+ }
44
+ isActive() {
45
+ return this._active;
46
+ }
47
+ }
@@ -0,0 +1,40 @@
1
+ import type { Handler } from '../handler_manager';
2
+ import type { Map } from '../map';
3
+ /**
4
+ * The {@link CooperativeGesturesHandler} options object for the gesture settings
5
+ */
6
+ export type GestureOptions = boolean;
7
+ /**
8
+ * A `CooperativeGestureHandler` is a control that adds cooperative gesture info when user tries to zoom in/out.
9
+ *
10
+ * @group Handlers
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const map = new Map({
15
+ * cooperativeGestures: true
16
+ * });
17
+ * ```
18
+ * @see [Example: cooperative gestures](https://maplibre.org/maplibre-gl-js-docs/example/cooperative-gestures/)
19
+ **/
20
+ export declare class CooperativeGesturesHandler implements Handler {
21
+ _options: GestureOptions;
22
+ _map: Map;
23
+ _container: HTMLElement;
24
+ /**
25
+ * This is the key that will allow to bypass the cooperative gesture protection
26
+ */
27
+ _bypassKey: 'metaKey' | 'ctrlKey';
28
+ _enabled: boolean;
29
+ constructor(map: Map, options: GestureOptions);
30
+ isActive(): boolean;
31
+ reset(): void;
32
+ _setupUI(): void;
33
+ _destoryUI(): void;
34
+ enable(): void;
35
+ disable(): void;
36
+ isEnabled(): boolean;
37
+ touchmove(e: TouchEvent): void;
38
+ wheel(e: WheelEvent): void;
39
+ _onCooperativeGesture(showNotification: boolean): void;
40
+ }
@@ -0,0 +1,94 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { DOM } from "../util/dom";
3
+
4
+ /**
5
+ * The {@link CooperativeGesturesHandler} options object for the gesture settings
6
+ */
7
+
8
+ /**
9
+ * A `CooperativeGestureHandler` is a control that adds cooperative gesture info when user tries to zoom in/out.
10
+ *
11
+ * @group Handlers
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const map = new Map({
16
+ * cooperativeGestures: true
17
+ * });
18
+ * ```
19
+ * @see [Example: cooperative gestures](https://maplibre.org/maplibre-gl-js-docs/example/cooperative-gestures/)
20
+ **/
21
+ export class CooperativeGesturesHandler {
22
+ constructor(map, options) {
23
+ _defineProperty(this, "_options", void 0);
24
+ _defineProperty(this, "_map", void 0);
25
+ _defineProperty(this, "_container", void 0);
26
+ /**
27
+ * This is the key that will allow to bypass the cooperative gesture protection
28
+ */
29
+ _defineProperty(this, "_bypassKey", navigator.userAgent.indexOf('Mac') !== -1 ? 'metaKey' : 'ctrlKey');
30
+ _defineProperty(this, "_enabled", void 0);
31
+ this._map = map;
32
+ this._options = options;
33
+ this._enabled = false;
34
+ }
35
+ isActive() {
36
+ return false;
37
+ }
38
+ reset() {}
39
+ _setupUI() {
40
+ if (this._container) return;
41
+ const mapCanvasContainer = this._map.getCanvasContainer();
42
+ // Add a cooperative gestures class (enable touch-action: pan-x pan-y;)
43
+ mapCanvasContainer.classList.add('l7-cooperative-gestures');
44
+ this._container = DOM.create('div', 'l7-cooperative-gesture-screen', mapCanvasContainer);
45
+ // Create and append the desktop message div
46
+ const desktopDiv = document.createElement('div');
47
+ desktopDiv.className = 'l7-desktop-message';
48
+ desktopDiv.textContent = 'Missing UI string';
49
+ this._container.appendChild(desktopDiv);
50
+ // Create and append the mobile message div
51
+ const mobileDiv = document.createElement('div');
52
+ mobileDiv.className = 'l7-mobile-message';
53
+ mobileDiv.textContent = 'Missing UI string';
54
+ this._container.appendChild(mobileDiv);
55
+ // Remove cooperative gesture screen from the accessibility tree since screenreaders cannot interact with the map using gestures
56
+ this._container.setAttribute('aria-hidden', 'true');
57
+ }
58
+ _destoryUI() {
59
+ if (this._container) {
60
+ DOM.remove(this._container);
61
+ const mapCanvasContainer = this._map.getCanvasContainer();
62
+ mapCanvasContainer.classList.remove('l7-cooperative-gestures');
63
+ }
64
+ delete this._container;
65
+ }
66
+ enable() {
67
+ this._setupUI();
68
+ this._enabled = true;
69
+ }
70
+ disable() {
71
+ this._enabled = false;
72
+ this._destoryUI();
73
+ }
74
+ isEnabled() {
75
+ return this._enabled;
76
+ }
77
+ touchmove(e) {
78
+ this._onCooperativeGesture(e.touches.length === 1);
79
+ }
80
+ wheel(e) {
81
+ if (!this._map.scrollZoom.isEnabled()) {
82
+ return;
83
+ }
84
+ this._onCooperativeGesture(!e[this._bypassKey]);
85
+ }
86
+ _onCooperativeGesture(showNotification) {
87
+ if (!this._enabled || !showNotification) return;
88
+ // Alert user how to scroll/pan
89
+ this._container.classList.add('l7-show');
90
+ setTimeout(() => {
91
+ this._container.classList.remove('l7-show');
92
+ }, 100);
93
+ }
94
+ }
@@ -0,0 +1,88 @@
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import type Point from '@mapbox/point-geometry';
3
+ import type { Handler } from '../handler_manager';
4
+ import type { DragMoveStateManager } from './drag_move_state_manager';
5
+ interface DragMovementResult {
6
+ bearingDelta?: number;
7
+ pitchDelta?: number;
8
+ around?: Point;
9
+ panDelta?: Point;
10
+ }
11
+ export interface DragPanResult extends DragMovementResult {
12
+ around: Point;
13
+ panDelta: Point;
14
+ }
15
+ export interface DragRotateResult extends DragMovementResult {
16
+ bearingDelta: number;
17
+ }
18
+ export interface DragPitchResult extends DragMovementResult {
19
+ pitchDelta: number;
20
+ }
21
+ type DragMoveFunction<T extends DragMovementResult> = (lastPoint: Point, point: Point) => T;
22
+ export interface DragMoveHandler<T extends DragMovementResult, E extends Event> extends Handler {
23
+ dragStart: (e: E, point: Point) => void;
24
+ dragMove: (e: E, point: Point) => T | void;
25
+ dragEnd: (e: E) => void;
26
+ getClickTolerance: () => number;
27
+ }
28
+ export type DragMoveHandlerOptions<T, E extends Event> = {
29
+ /**
30
+ * If the movement is shorter than this value, consider it a click.
31
+ */
32
+ clickTolerance: number;
33
+ /**
34
+ * The move function to run on a valid movement.
35
+ */
36
+ move: DragMoveFunction<T>;
37
+ /**
38
+ * A class used to manage the state of the drag event - start, checking valid moves, end. See the class documentation for more details.
39
+ */
40
+ moveStateManager: DragMoveStateManager<E>;
41
+ /**
42
+ * A method used to assign the dragStart, dragMove, and dragEnd methods to the relevant event handlers, as well as assigning the contextmenu handler
43
+ * @param handler - the handler
44
+ */
45
+ assignEvents: (handler: DragMoveHandler<T, E>) => void;
46
+ /**
47
+ * Should the move start on the "start" event, or should it start on the first valid move.
48
+ */
49
+ activateOnStart?: boolean;
50
+ /**
51
+ * If true, handler will be enabled during construction
52
+ */
53
+ enable?: boolean;
54
+ };
55
+ /**
56
+ * A generic class to create handlers for drag events, from both mouse and touch events.
57
+ */
58
+ export declare class DragHandler<T extends DragMovementResult, E extends Event> implements DragMoveHandler<T, E> {
59
+ contextmenu?: Handler['contextmenu'];
60
+ mousedown?: Handler['mousedown'];
61
+ mousemoveWindow?: Handler['mousemoveWindow'];
62
+ mouseup?: Handler['mouseup'];
63
+ touchstart?: Handler['touchstart'];
64
+ touchmoveWindow?: Handler['touchmoveWindow'];
65
+ touchend?: Handler['touchend'];
66
+ _clickTolerance: number;
67
+ _moveFunction: DragMoveFunction<T>;
68
+ _activateOnStart: boolean;
69
+ _active: boolean;
70
+ _enabled: boolean;
71
+ _moved: boolean;
72
+ _lastPoint: Point | null;
73
+ _moveStateManager: DragMoveStateManager<E>;
74
+ constructor(options: DragMoveHandlerOptions<T, E>);
75
+ reset(e?: E): void;
76
+ _move(...params: Parameters<DragMoveFunction<T>>): T;
77
+ dragStart(e: E, point: Point): any;
78
+ dragStart(e: E, point: Point[]): any;
79
+ dragMove(e: E, point: Point): any;
80
+ dragMove(e: E, point: Point[]): any;
81
+ dragEnd(e: E): void;
82
+ enable(): void;
83
+ disable(): void;
84
+ isEnabled(): boolean;
85
+ isActive(): boolean;
86
+ getClickTolerance(): number;
87
+ }
88
+ export {};
@@ -0,0 +1,89 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { DOM } from "../util/dom";
3
+ /**
4
+ * A generic class to create handlers for drag events, from both mouse and touch events.
5
+ */
6
+ export class DragHandler {
7
+ constructor(options) {
8
+ // Event handlers that may be assigned by the implementations of this class
9
+ _defineProperty(this, "contextmenu", void 0);
10
+ _defineProperty(this, "mousedown", void 0);
11
+ _defineProperty(this, "mousemoveWindow", void 0);
12
+ _defineProperty(this, "mouseup", void 0);
13
+ _defineProperty(this, "touchstart", void 0);
14
+ _defineProperty(this, "touchmoveWindow", void 0);
15
+ _defineProperty(this, "touchend", void 0);
16
+ _defineProperty(this, "_clickTolerance", void 0);
17
+ _defineProperty(this, "_moveFunction", void 0);
18
+ _defineProperty(this, "_activateOnStart", void 0);
19
+ _defineProperty(this, "_active", void 0);
20
+ _defineProperty(this, "_enabled", void 0);
21
+ _defineProperty(this, "_moved", void 0);
22
+ _defineProperty(this, "_lastPoint", void 0);
23
+ _defineProperty(this, "_moveStateManager", void 0);
24
+ this._enabled = !!options.enable;
25
+ this._moveStateManager = options.moveStateManager;
26
+ this._clickTolerance = options.clickTolerance || 1;
27
+ this._moveFunction = options.move;
28
+ this._activateOnStart = !!options.activateOnStart;
29
+ options.assignEvents(this);
30
+ this.reset();
31
+ }
32
+ reset(e) {
33
+ this._active = false;
34
+ this._moved = false;
35
+ delete this._lastPoint;
36
+ this._moveStateManager.endMove(e);
37
+ }
38
+ _move(...params) {
39
+ const move = this._moveFunction(...params);
40
+ if (move.bearingDelta || move.pitchDelta || move.around || move.panDelta) {
41
+ this._active = true;
42
+ return move;
43
+ }
44
+ }
45
+ dragStart(e, point) {
46
+ if (!this.isEnabled() || this._lastPoint) return;
47
+ if (!this._moveStateManager.isValidStartEvent(e)) return;
48
+ this._moveStateManager.startMove(e);
49
+ this._lastPoint = point['length'] ? point[0] : point;
50
+ if (this._activateOnStart && this._lastPoint) this._active = true;
51
+ }
52
+ dragMove(e, point) {
53
+ if (!this.isEnabled()) return;
54
+ const lastPoint = this._lastPoint;
55
+ if (!lastPoint) return;
56
+ e.preventDefault();
57
+ if (!this._moveStateManager.isValidMoveEvent(e)) {
58
+ this.reset(e);
59
+ return;
60
+ }
61
+ const movePoint = point['length'] ? point[0] : point;
62
+ if (!this._moved && movePoint.dist(lastPoint) < this._clickTolerance) return;
63
+ this._moved = true;
64
+ this._lastPoint = movePoint;
65
+ return this._move(lastPoint, movePoint);
66
+ }
67
+ dragEnd(e) {
68
+ if (!this.isEnabled() || !this._lastPoint) return;
69
+ if (!this._moveStateManager.isValidEndEvent(e)) return;
70
+ if (this._moved) DOM.suppressClick();
71
+ this.reset(e);
72
+ }
73
+ enable() {
74
+ this._enabled = true;
75
+ }
76
+ disable() {
77
+ this._enabled = false;
78
+ this.reset();
79
+ }
80
+ isEnabled() {
81
+ return this._enabled;
82
+ }
83
+ isActive() {
84
+ return this._active;
85
+ }
86
+ getClickTolerance() {
87
+ return this._clickTolerance;
88
+ }
89
+ }
@@ -0,0 +1,30 @@
1
+ export interface DragMoveStateManager<E extends Event> {
2
+ startMove: (e: E) => void;
3
+ endMove: (e?: E) => void;
4
+ isValidStartEvent: (e: E) => boolean;
5
+ isValidMoveEvent: (e: E) => boolean;
6
+ isValidEndEvent: (e?: E) => boolean;
7
+ }
8
+ export declare class MouseMoveStateManager implements DragMoveStateManager<MouseEvent> {
9
+ _eventButton: number | undefined;
10
+ _correctEvent: (e: MouseEvent) => boolean;
11
+ constructor(options: {
12
+ checkCorrectEvent: (e: MouseEvent) => boolean;
13
+ });
14
+ startMove(e: MouseEvent): void;
15
+ endMove(_e?: MouseEvent): void;
16
+ isValidStartEvent(e: MouseEvent): boolean;
17
+ isValidMoveEvent(e: MouseEvent): boolean;
18
+ isValidEndEvent(e: MouseEvent): boolean;
19
+ }
20
+ export declare class OneFingerTouchMoveStateManager implements DragMoveStateManager<TouchEvent> {
21
+ _firstTouch: number | undefined;
22
+ constructor();
23
+ _isOneFingerTouch(e: TouchEvent): boolean;
24
+ _isSameTouchEvent(e: TouchEvent): boolean;
25
+ startMove(e: TouchEvent): void;
26
+ endMove(_e?: TouchEvent): void;
27
+ isValidStartEvent(e: TouchEvent): boolean;
28
+ isValidMoveEvent(e: TouchEvent): boolean;
29
+ isValidEndEvent(e: TouchEvent): boolean;
30
+ }