@antv/l7-map 2.21.11-beta.4 → 2.21.11-beta.6

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
package/lib/map/map.js ADDED
@@ -0,0 +1,979 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Map = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
11
+ var _camera = require("./camera");
12
+ var _lng_lat = require("./geo/lng_lat");
13
+ var _lng_lat_bounds = require("./geo/lng_lat_bounds");
14
+ var _transform = require("./geo/transform");
15
+ var _handler_manager = require("./handler_manager");
16
+ var _browser = require("./util/browser");
17
+ var _dom = require("./util/dom");
18
+ var _evented = require("./util/evented");
19
+ var _task_queue = require("./util/task_queue");
20
+ var _util = require("./util/util");
21
+ var _l7Utils = require("@antv/l7-utils");
22
+ function loadStyles(css, doc) {
23
+ var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
24
+ var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
25
+ if (isMiniAli || isWeChatMiniProgram) {
26
+ return;
27
+ }
28
+ if (!doc) doc = document;
29
+ if (!doc) {
30
+ return;
31
+ }
32
+ var head = doc.head || doc.getElementsByTagName('head')[0];
33
+ if (!head) {
34
+ head = doc.createElement('head');
35
+ var body = doc.body || doc.getElementsByTagName('body')[0];
36
+ if (body) {
37
+ body.parentNode.insertBefore(head, body);
38
+ } else {
39
+ doc.documentElement.appendChild(head);
40
+ }
41
+ }
42
+ var style = doc.createElement('style');
43
+ style.type = 'text/css';
44
+ if (style.styleSheet) {
45
+ style.styleSheet.cssText = css;
46
+ } else {
47
+ style.appendChild(doc.createTextNode(css));
48
+ }
49
+ head.appendChild(style);
50
+ return style;
51
+ }
52
+ loadStyles(`.l7-map {
53
+ font:
54
+ 12px/20px 'Helvetica Neue',
55
+ Arial,
56
+ Helvetica,
57
+ sans-serif;
58
+ overflow: hidden;
59
+ position: relative;
60
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
61
+ }
62
+
63
+ .l7-canvas {
64
+ position: absolute;
65
+ left: 0;
66
+ top: 0;
67
+ }
68
+
69
+ .l7-map:-webkit-full-screen {
70
+ width: 100%;
71
+ height: 100%;
72
+ }
73
+
74
+ .l7-canary {
75
+ background-color: salmon;
76
+ }
77
+
78
+ .l7-canvas-container.l7-interactive,
79
+ .l7-ctrl-group button.l7-ctrl-compass {
80
+ cursor: grab;
81
+ -webkit-user-select: none;
82
+ -moz-user-select: none;
83
+ -ms-user-select: none;
84
+ user-select: none;
85
+ }
86
+
87
+ .l7-canvas-container.l7-interactive.l7-track-pointer {
88
+ cursor: pointer;
89
+ }
90
+
91
+ .l7-canvas-container.l7-interactive:active,
92
+ .l7-ctrl-group button.l7-ctrl-compass:active {
93
+ cursor: grabbing;
94
+ }
95
+
96
+ .l7-canvas-container.l7-touch-zoom-rotate,
97
+ .l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {
98
+ touch-action: pan-x pan-y;
99
+ }
100
+
101
+ .l7-canvas-container.l7-touch-drag-pan,
102
+ .l7-canvas-container.l7-touch-drag-pan .l7-canvas {
103
+ touch-action: pinch-zoom;
104
+ }
105
+
106
+ .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,
107
+ .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {
108
+ touch-action: none;
109
+ }
110
+
111
+ .l7-canvas-container.l7-touch-drag-pan.l7-cooperative-gestures,
112
+ .l7-canvas-container.l7-touch-drag-pan.l7-cooperative-gestures .l7-canvas {
113
+ touch-action: pan-x pan-y;
114
+ }
115
+
116
+ .l7-cooperative-gesture-screen {
117
+ background: rgba(0 0 0 / 40%);
118
+ position: absolute;
119
+ inset: 0;
120
+ display: flex;
121
+ justify-content: center;
122
+ align-items: center;
123
+ color: white;
124
+ padding: 1rem;
125
+ font-size: 1.4em;
126
+ line-height: 1.2;
127
+ opacity: 0;
128
+ pointer-events: none;
129
+ transition: opacity 1s ease 1s;
130
+ z-index: 99999;
131
+ }
132
+
133
+ .l7-cooperative-gesture-screen.l7-show {
134
+ opacity: 1;
135
+ transition: opacity 0.05s;
136
+ }
137
+
138
+ .l7-cooperative-gesture-screen .l7-mobile-message {
139
+ display: none;
140
+ }
141
+
142
+ @media (hover: none), (width <= 480px) {
143
+ .l7-cooperative-gesture-screen .l7-desktop-message {
144
+ display: none;
145
+ }
146
+
147
+ .l7-cooperative-gesture-screen .l7-mobile-message {
148
+ display: block;
149
+ }
150
+ }
151
+
152
+ .l7-ctrl-top-left,
153
+ .l7-ctrl-top-right,
154
+ .l7-ctrl-bottom-left,
155
+ .l7-ctrl-bottom-right {
156
+ position: absolute;
157
+ pointer-events: none;
158
+ z-index: 2;
159
+ }
160
+ .l7-ctrl-top-left {
161
+ top: 0;
162
+ left: 0;
163
+ }
164
+ .l7-ctrl-top-right {
165
+ top: 0;
166
+ right: 0;
167
+ }
168
+ .l7-ctrl-bottom-left {
169
+ bottom: 0;
170
+ left: 0;
171
+ }
172
+ .l7-ctrl-bottom-right {
173
+ right: 0;
174
+ bottom: 0;
175
+ }
176
+
177
+ .l7-ctrl {
178
+ clear: both;
179
+ pointer-events: auto;
180
+
181
+ /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */
182
+ -webkit-transform: translate(0, 0);
183
+ transform: translate(0, 0);
184
+ }
185
+ .l7-ctrl-top-left .l7-ctrl {
186
+ margin: 10px 0 0 10px;
187
+ float: left;
188
+ }
189
+ .l7-ctrl-top-right .l7-ctrl {
190
+ margin: 10px 10px 0 0;
191
+ float: right;
192
+ }
193
+ .l7-ctrl-bottom-left .l7-ctrl {
194
+ margin: 0 0 10px 10px;
195
+ float: left;
196
+ }
197
+ .l7-ctrl-bottom-right .l7-ctrl {
198
+ margin: 0 10px 10px 0;
199
+ float: right;
200
+ }
201
+
202
+ .l7-crosshair,
203
+ .l7-crosshair .l7-interactive,
204
+ .l7-crosshair .l7-interactive:active {
205
+ cursor: crosshair;
206
+ }
207
+
208
+ .l7-boxzoom {
209
+ position: absolute;
210
+ top: 0;
211
+ left: 0;
212
+ width: 0;
213
+ height: 0;
214
+ background: #fff;
215
+ border: 2px dotted #202020;
216
+ opacity: 0.5;
217
+ z-index: 10;
218
+ }
219
+ `);
220
+ /**
221
+ * The {@link Map} options object.
222
+ */
223
+
224
+ // This type is used inside map since all properties are assigned a default value.
225
+
226
+ const defaultMinZoom = -2;
227
+ const defaultMaxZoom = 22;
228
+
229
+ // the default values, but also the valid range
230
+ const defaultMinPitch = 0;
231
+ const defaultMaxPitch = 60;
232
+
233
+ // use this variable to check maxPitch for validity
234
+ const maxPitchThreshold = 85;
235
+ const defaultOptions = {
236
+ interactive: true,
237
+ bearingSnap: 7,
238
+ scrollZoom: true,
239
+ minZoom: defaultMinZoom,
240
+ maxZoom: defaultMaxZoom,
241
+ minPitch: defaultMinPitch,
242
+ maxPitch: defaultMaxPitch,
243
+ boxZoom: true,
244
+ dragRotate: true,
245
+ dragPan: true,
246
+ keyboard: true,
247
+ doubleClickZoom: true,
248
+ touchZoomRotate: true,
249
+ touchPitch: true,
250
+ cooperativeGestures: false,
251
+ trackResize: true,
252
+ center: [0, 0],
253
+ zoom: 0,
254
+ bearing: 0,
255
+ pitch: 0,
256
+ renderWorldCopies: true,
257
+ fadeDuration: 300,
258
+ clickTolerance: 3,
259
+ pitchWithRotate: true
260
+ };
261
+
262
+ /**
263
+ * The `Map` object represents the map on your page. It exposes methods
264
+ * and properties that enable you to programmatically change the map,
265
+ * and fires events as users interact with it.
266
+ *
267
+ * You create a `Map` by specifying a `container` and other options, see {@link MapOptions} for the full list.
268
+ * Then MapLibre GL JS initializes the map on the page and returns your `Map` object.
269
+ *
270
+ * @group Main
271
+ *
272
+ * @example
273
+ * ```ts
274
+ * let map = new Map({
275
+ * container: 'map',
276
+ * center: [-122.420679, 37.772537],
277
+ * zoom: 13,
278
+ * });
279
+ * ```
280
+ */
281
+ class Map extends _camera.Camera {
282
+ constructor(options) {
283
+ const resolvedOptions = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultOptions), options);
284
+ if (resolvedOptions.minZoom != null && resolvedOptions.maxZoom != null && resolvedOptions.minZoom > resolvedOptions.maxZoom) {
285
+ throw new Error('maxZoom must be greater than or equal to minZoom');
286
+ }
287
+ if (resolvedOptions.minPitch != null && resolvedOptions.maxPitch != null && resolvedOptions.minPitch > resolvedOptions.maxPitch) {
288
+ throw new Error('maxPitch must be greater than or equal to minPitch');
289
+ }
290
+ if (resolvedOptions.minPitch != null && resolvedOptions.minPitch < defaultMinPitch) {
291
+ throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
292
+ }
293
+ if (resolvedOptions.maxPitch != null && resolvedOptions.maxPitch > maxPitchThreshold) {
294
+ throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);
295
+ }
296
+ const transform = new _transform.Transform(resolvedOptions.minZoom, resolvedOptions.maxZoom, resolvedOptions.minPitch, resolvedOptions.maxPitch, resolvedOptions.renderWorldCopies);
297
+ super(transform, {
298
+ bearingSnap: resolvedOptions.bearingSnap
299
+ });
300
+ (0, _defineProperty2.default)(this, "_container", void 0);
301
+ (0, _defineProperty2.default)(this, "_canvasContainer", void 0);
302
+ (0, _defineProperty2.default)(this, "_interactive", void 0);
303
+ (0, _defineProperty2.default)(this, "_frameRequest", void 0);
304
+ (0, _defineProperty2.default)(this, "_loaded", void 0);
305
+ (0, _defineProperty2.default)(this, "_idleTriggered", false);
306
+ // accounts for placement finishing as well
307
+ (0, _defineProperty2.default)(this, "_fullyLoaded", void 0);
308
+ (0, _defineProperty2.default)(this, "_trackResize", void 0);
309
+ (0, _defineProperty2.default)(this, "_resizeObserver", void 0);
310
+ (0, _defineProperty2.default)(this, "_preserveDrawingBuffer", void 0);
311
+ (0, _defineProperty2.default)(this, "_failIfMajorPerformanceCaveat", void 0);
312
+ (0, _defineProperty2.default)(this, "_fadeDuration", void 0);
313
+ (0, _defineProperty2.default)(this, "_crossSourceCollisions", void 0);
314
+ (0, _defineProperty2.default)(this, "_crossFadingFactor", 1);
315
+ (0, _defineProperty2.default)(this, "_collectResourceTiming", void 0);
316
+ (0, _defineProperty2.default)(this, "_renderTaskQueue", new _task_queue.TaskQueue());
317
+ (0, _defineProperty2.default)(this, "_mapId", (0, _util.uniqueId)());
318
+ (0, _defineProperty2.default)(this, "_removed", void 0);
319
+ (0, _defineProperty2.default)(this, "_clickTolerance", void 0);
320
+ /**
321
+ * The map's {@link ScrollZoomHandler}, which implements zooming in and out with a scroll wheel or trackpad.
322
+ * Find more details and examples using `scrollZoom` in the {@link ScrollZoomHandler} section.
323
+ */
324
+ (0, _defineProperty2.default)(this, "scrollZoom", void 0);
325
+ /**
326
+ * The map's {@link BoxZoomHandler}, which implements zooming using a drag gesture with the Shift key pressed.
327
+ * Find more details and examples using `boxZoom` in the {@link BoxZoomHandler} section.
328
+ */
329
+ (0, _defineProperty2.default)(this, "boxZoom", void 0);
330
+ /**
331
+ * The map's {@link DragRotateHandler}, which implements rotating the map while dragging with the right
332
+ * mouse button or with the Control key pressed. Find more details and examples using `dragRotate`
333
+ * in the {@link DragRotateHandler} section.
334
+ */
335
+ (0, _defineProperty2.default)(this, "dragRotate", void 0);
336
+ /**
337
+ * The map's {@link DragPanHandler}, which implements dragging the map with a mouse or touch gesture.
338
+ * Find more details and examples using `dragPan` in the {@link DragPanHandler} section.
339
+ */
340
+ (0, _defineProperty2.default)(this, "dragPan", void 0);
341
+ /**
342
+ * The map's {@link KeyboardHandler}, which allows the user to zoom, rotate, and pan the map using keyboard
343
+ * shortcuts. Find more details and examples using `keyboard` in the {@link KeyboardHandler} section.
344
+ */
345
+ (0, _defineProperty2.default)(this, "keyboard", void 0);
346
+ /**
347
+ * The map's {@link DoubleClickZoomHandler}, which allows the user to zoom by double clicking.
348
+ * Find more details and examples using `doubleClickZoom` in the {@link DoubleClickZoomHandler} section.
349
+ */
350
+ (0, _defineProperty2.default)(this, "doubleClickZoom", void 0);
351
+ /**
352
+ * The map's {@link TwoFingersTouchZoomRotateHandler}, which allows the user to zoom or rotate the map with touch gestures.
353
+ * Find more details and examples using `touchZoomRotate` in the {@link TwoFingersTouchZoomRotateHandler} section.
354
+ */
355
+ (0, _defineProperty2.default)(this, "touchZoomRotate", void 0);
356
+ /**
357
+ * The map's {@link TwoFingersTouchPitchHandler}, which allows the user to pitch the map with touch gestures.
358
+ * Find more details and examples using `touchPitch` in the {@link TwoFingersTouchPitchHandler} section.
359
+ */
360
+ (0, _defineProperty2.default)(this, "touchPitch", void 0);
361
+ /**
362
+ * The map's {@link CooperativeGesturesHandler}, which allows the user to see cooperative gesture info when user tries to zoom in/out.
363
+ * Find more details and examples using `cooperativeGestures` in the {@link CooperativeGesturesHandler} section.
364
+ */
365
+ (0, _defineProperty2.default)(this, "cooperativeGestures", void 0);
366
+ (0, _defineProperty2.default)(this, "_onMapScroll", event => {
367
+ if (event.target !== this._container) return;
368
+
369
+ // Revert any scroll which would move the canvas outside of the view
370
+ this._container.scrollTop = 0;
371
+ this._container.scrollLeft = 0;
372
+ return false;
373
+ });
374
+ this._interactive = resolvedOptions.interactive;
375
+ this._trackResize = resolvedOptions.trackResize === true;
376
+ this._bearingSnap = resolvedOptions.bearingSnap;
377
+ this._fadeDuration = resolvedOptions.fadeDuration;
378
+ this._clickTolerance = resolvedOptions.clickTolerance;
379
+ if (typeof resolvedOptions.container === 'string') {
380
+ this._container = document.getElementById(resolvedOptions.container);
381
+ if (!this._container) {
382
+ throw new Error(`Container '${resolvedOptions.container}' not found.`);
383
+ }
384
+ } else if (resolvedOptions.container instanceof HTMLElement) {
385
+ this._container = resolvedOptions.container;
386
+ } else {
387
+ throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
388
+ }
389
+ if (resolvedOptions.maxBounds) {
390
+ this.setMaxBounds(resolvedOptions.maxBounds);
391
+ }
392
+ this._setupContainer();
393
+ this.on('move', () => this._update()).on('moveend', () => this._update()).on('zoom', () => this._update()).once('idle', () => {
394
+ this._idleTriggered = true;
395
+ });
396
+ if (typeof window !== 'undefined') {
397
+ let initialResizeEventCaptured = false;
398
+ const throttledResizeCallback = _l7Utils.lodashUtil.throttle(entries => {
399
+ if (this._trackResize && !this._removed) {
400
+ this.resize(entries)._update();
401
+ }
402
+ }, 50);
403
+ this._resizeObserver = new ResizeObserver(entries => {
404
+ if (!initialResizeEventCaptured) {
405
+ initialResizeEventCaptured = true;
406
+ return;
407
+ }
408
+ throttledResizeCallback(entries);
409
+ });
410
+ this._resizeObserver.observe(this._container);
411
+ }
412
+ this.handlers = new _handler_manager.HandlerManager(this, resolvedOptions);
413
+ this.jumpTo({
414
+ center: resolvedOptions.center,
415
+ zoom: resolvedOptions.zoom,
416
+ bearing: resolvedOptions.bearing,
417
+ pitch: resolvedOptions.pitch
418
+ });
419
+ if (resolvedOptions.bounds) {
420
+ this.resize();
421
+ this.fitBounds(resolvedOptions.bounds, (0, _util.extend)({}, resolvedOptions.fitBoundsOptions, {
422
+ duration: 0
423
+ }));
424
+ }
425
+ this.resize();
426
+ }
427
+
428
+ /**
429
+ * @internal
430
+ * Returns a unique number for this map instance which is used for the MapLoadEvent
431
+ * to make sure we only fire one event per instantiated map object.
432
+ * @returns the uniq map ID
433
+ */
434
+ _getMapId() {
435
+ return this._mapId;
436
+ }
437
+ calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo) {
438
+ return super.calculateCameraOptionsFromTo(from, altitudeFrom, to, altitudeTo);
439
+ }
440
+
441
+ /**
442
+ * Resizes the map according to the dimensions of its
443
+ * `container` element.
444
+ *
445
+ * Checks if the map container size changed and updates the map if it has changed.
446
+ * This method must be called after the map's `container` is resized programmatically
447
+ * or when the map is shown after being initially hidden with CSS.
448
+ *
449
+ * Triggers the following events: `movestart`, `move`, `moveend`, and `resize`.
450
+ *
451
+ * @param eventData - Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend`
452
+ * events that get triggered as a result of resize. This can be useful for differentiating the
453
+ * source of an event (for example, user-initiated or programmatically-triggered events).
454
+ * @example
455
+ * Resize the map when the map container is shown after being initially hidden with CSS.
456
+ * ```ts
457
+ * let mapDiv = document.getElementById('map');
458
+ * if (mapDiv.style.visibility === true) map.resize();
459
+ * ```
460
+ */
461
+ resize(eventData) {
462
+ var _this$_requestedCamer;
463
+ const dimensions = this._containerDimensions();
464
+ const width = dimensions[0];
465
+ const height = dimensions[1];
466
+ this.transform.resize(width, height);
467
+ (_this$_requestedCamer = this._requestedCameraState) === null || _this$_requestedCamer === void 0 || _this$_requestedCamer.resize(width, height);
468
+ const fireMoving = !this._moving;
469
+ if (fireMoving) {
470
+ this.stop();
471
+ this.fire(new _evented.Event('movestart', eventData)).fire(new _evented.Event('move', eventData));
472
+ }
473
+ this.fire(new _evented.Event('resize', eventData));
474
+ if (fireMoving) this.fire(new _evented.Event('moveend', eventData));
475
+ return this;
476
+ }
477
+
478
+ /**
479
+ * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not
480
+ * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.
481
+ * @returns The geographical bounds of the map as {@link LngLatBounds}.
482
+ * @example
483
+ * ```ts
484
+ * let bounds = map.getBounds();
485
+ * ```
486
+ */
487
+ getBounds() {
488
+ return this.transform.getBounds();
489
+ }
490
+
491
+ /**
492
+ * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.
493
+ * @returns The map object.
494
+ * @example
495
+ * ```ts
496
+ * let maxBounds = map.getMaxBounds();
497
+ * ```
498
+ */
499
+ getMaxBounds() {
500
+ return this.transform.getMaxBounds();
501
+ }
502
+
503
+ /**
504
+ * Sets or clears the map's geographical bounds.
505
+ *
506
+ * Pan and zoom operations are constrained within these bounds.
507
+ * If a pan or zoom is performed that would
508
+ * display regions outside these bounds, the map will
509
+ * instead display a position and zoom level
510
+ * as close as possible to the operation's request while still
511
+ * remaining within the bounds.
512
+ *
513
+ * @param bounds - The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds.
514
+ * @example
515
+ * Define bounds that conform to the `LngLatBoundsLike` object as set the max bounds.
516
+ * ```ts
517
+ * let bounds = [
518
+ * [-74.04728, 40.68392], // [west, south]
519
+ * [-73.91058, 40.87764] // [east, north]
520
+ * ];
521
+ * map.setMaxBounds(bounds);
522
+ * ```
523
+ */
524
+ setMaxBounds(bounds) {
525
+ this.transform.setMaxBounds(bounds && _lng_lat_bounds.LngLatBounds.convert(bounds));
526
+ return this._update();
527
+ }
528
+
529
+ /**
530
+ * Sets or clears the map's minimum zoom level.
531
+ * If the map's current zoom level is lower than the new minimum,
532
+ * the map will zoom to the new minimum.
533
+ *
534
+ * It is not always possible to zoom out and reach the set `minZoom`.
535
+ * Other factors such as map height may restrict zooming. For example,
536
+ * if the map is 512px tall it will not be possible to zoom below zoom 0
537
+ * no matter what the `minZoom` is set to.
538
+ *
539
+ * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.
540
+ *
541
+ * @param minZoom - The minimum zoom level to set (-2 - 24).
542
+ * If `null` or `undefined` is provided, the function removes the current minimum zoom (i.e. sets it to -2).
543
+ * @example
544
+ * ```ts
545
+ * map.setMinZoom(12.25);
546
+ * ```
547
+ */
548
+ setMinZoom(minZoom) {
549
+ minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
550
+ if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
551
+ this.transform.minZoom = minZoom;
552
+ this._update();
553
+ if (this.getZoom() < minZoom) this.setZoom(minZoom);
554
+ return this;
555
+ } else throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
556
+ }
557
+
558
+ /**
559
+ * Returns the map's minimum allowable zoom level.
560
+ *
561
+ * @returns minZoom
562
+ * @example
563
+ * ```ts
564
+ * let minZoom = map.getMinZoom();
565
+ * ```
566
+ */
567
+ getMinZoom() {
568
+ return this.transform.minZoom;
569
+ }
570
+
571
+ /**
572
+ * Sets or clears the map's maximum zoom level.
573
+ * If the map's current zoom level is higher than the new maximum,
574
+ * the map will zoom to the new maximum.
575
+ *
576
+ * A {@link ErrorEvent} event will be fired if minZoom is out of bounds.
577
+ *
578
+ * @param maxZoom - The maximum zoom level to set.
579
+ * If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22).
580
+ * @example
581
+ * ```ts
582
+ * map.setMaxZoom(18.75);
583
+ * ```
584
+ */
585
+ setMaxZoom(maxZoom) {
586
+ maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
587
+ if (maxZoom >= this.transform.minZoom) {
588
+ this.transform.maxZoom = maxZoom;
589
+ if (this.getZoom() > maxZoom) this.setZoom(maxZoom);
590
+ return this;
591
+ } else throw new Error('maxZoom must be greater than the current minZoom');
592
+ }
593
+
594
+ /**
595
+ * Returns the map's maximum allowable zoom level.
596
+ *
597
+ * @returns The maxZoom
598
+ * @example
599
+ * ```ts
600
+ * let maxZoom = map.getMaxZoom();
601
+ * ```
602
+ */
603
+ getMaxZoom() {
604
+ return this.transform.maxZoom;
605
+ }
606
+
607
+ /**
608
+ * Sets or clears the map's minimum pitch.
609
+ * If the map's current pitch is lower than the new minimum,
610
+ * the map will pitch to the new minimum.
611
+ *
612
+ * A {@link ErrorEvent} event will be fired if minPitch is out of bounds.
613
+ *
614
+ * @param minPitch - The minimum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
615
+ * If `null` or `undefined` is provided, the function removes the current minimum pitch (i.e. sets it to 0).
616
+ */
617
+ setMinPitch(minPitch) {
618
+ minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
619
+ if (minPitch < defaultMinPitch) {
620
+ throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
621
+ }
622
+ if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
623
+ this.transform.minPitch = minPitch;
624
+ if (this.getPitch() < minPitch) this.setPitch(minPitch);
625
+ return this;
626
+ } else throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
627
+ }
628
+
629
+ /**
630
+ * Returns the map's minimum allowable pitch.
631
+ *
632
+ * @returns The minPitch
633
+ */
634
+ getMinPitch() {
635
+ return this.transform.minPitch;
636
+ }
637
+
638
+ /**
639
+ * Sets or clears the map's maximum pitch.
640
+ * If the map's current pitch is higher than the new maximum,
641
+ * the map will pitch to the new maximum.
642
+ *
643
+ * A {@link ErrorEvent} event will be fired if maxPitch is out of bounds.
644
+ *
645
+ * @param maxPitch - The maximum pitch to set (0-85). Values greater than 60 degrees are experimental and may result in rendering issues. If you encounter any, please raise an issue with details in the MapLibre project.
646
+ * If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 60).
647
+ */
648
+ setMaxPitch(maxPitch) {
649
+ maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
650
+ if (maxPitch > maxPitchThreshold) {
651
+ throw new Error(`maxPitch must be less than or equal to ${maxPitchThreshold}`);
652
+ }
653
+ if (maxPitch >= this.transform.minPitch) {
654
+ this.transform.maxPitch = maxPitch;
655
+ if (this.getPitch() > maxPitch) this.setPitch(maxPitch);
656
+ return this;
657
+ } else throw new Error('maxPitch must be greater than the current minPitch');
658
+ }
659
+
660
+ /**
661
+ * Returns the map's maximum allowable pitch.
662
+ *
663
+ * @returns The maxPitch
664
+ */
665
+ getMaxPitch() {
666
+ return this.transform.maxPitch;
667
+ }
668
+
669
+ /**
670
+ * Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:
671
+ *
672
+ * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire
673
+ * container, there will be blank space beyond 180 and -180 degrees longitude.
674
+ * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the
675
+ * map and the other on the left edge of the map) at every zoom level.
676
+ * @returns The renderWorldCopies
677
+ * @example
678
+ * ```ts
679
+ * let worldCopiesRendered = map.getRenderWorldCopies();
680
+ * ```
681
+ * @see [Render world copies](https://maplibre.org/maplibre-gl-js/docs/examples/render-world-copies/)
682
+ */
683
+ getRenderWorldCopies() {
684
+ return this.transform.renderWorldCopies;
685
+ }
686
+
687
+ /**
688
+ * Sets the state of `renderWorldCopies`.
689
+ *
690
+ * @param renderWorldCopies - If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`:
691
+ *
692
+ * - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire
693
+ * container, there will be blank space beyond 180 and -180 degrees longitude.
694
+ * - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the
695
+ * map and the other on the left edge of the map) at every zoom level.
696
+ *
697
+ * `undefined` is treated as `true`, `null` is treated as `false`.
698
+ * @example
699
+ * ```ts
700
+ * map.setRenderWorldCopies(true);
701
+ * ```
702
+ */
703
+ setRenderWorldCopies(renderWorldCopies) {
704
+ this.transform.renderWorldCopies = renderWorldCopies;
705
+ }
706
+
707
+ /**
708
+ * Returns a [Point](https://github.com/mapbox/point-geometry) representing pixel coordinates, relative to the map's `container`,
709
+ * that correspond to the specified geographical location.
710
+ *
711
+ * @param lnglat - The geographical location to project.
712
+ * @returns The [Point](https://github.com/mapbox/point-geometry) corresponding to `lnglat`, relative to the map's `container`.
713
+ * @example
714
+ * ```ts
715
+ * let coordinate = [-122.420679, 37.772537];
716
+ * let point = map.project(coordinate);
717
+ * ```
718
+ */
719
+ project(lnglat) {
720
+ return this.transform.locationPoint(_lng_lat.LngLat.convert(lnglat));
721
+ }
722
+
723
+ /**
724
+ * Returns a {@link LngLat} representing geographical coordinates that correspond
725
+ * to the specified pixel coordinates.
726
+ *
727
+ * @param point - The pixel coordinates to unproject.
728
+ * @returns The {@link LngLat} corresponding to `point`.
729
+ * @example
730
+ * ```ts
731
+ * map.on('click', (e) => {
732
+ * // When the map is clicked, get the geographic coordinate.
733
+ * let coordinate = map.unproject(e.point);
734
+ * });
735
+ * ```
736
+ */
737
+ unproject(point) {
738
+ return this.transform.pointLocation(_pointGeometry.default.convert(point));
739
+ }
740
+
741
+ /**
742
+ * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.
743
+ * @returns true if the map is moving.
744
+ * @example
745
+ * ```ts
746
+ * let isMoving = map.isMoving();
747
+ * ```
748
+ */
749
+ isMoving() {
750
+ var _this$handlers;
751
+ return this._moving || ((_this$handlers = this.handlers) === null || _this$handlers === void 0 ? void 0 : _this$handlers.isMoving());
752
+ }
753
+
754
+ /**
755
+ * Returns true if the map is zooming due to a camera animation or user gesture.
756
+ * @returns true if the map is zooming.
757
+ * @example
758
+ * ```ts
759
+ * let isZooming = map.isZooming();
760
+ * ```
761
+ */
762
+ isZooming() {
763
+ var _this$handlers2;
764
+ return this._zooming || ((_this$handlers2 = this.handlers) === null || _this$handlers2 === void 0 ? void 0 : _this$handlers2.isZooming());
765
+ }
766
+
767
+ /**
768
+ * Returns true if the map is rotating due to a camera animation or user gesture.
769
+ * @returns true if the map is rotating.
770
+ * @example
771
+ * ```ts
772
+ * map.isRotating();
773
+ * ```
774
+ */
775
+ isRotating() {
776
+ var _this$handlers3;
777
+ return this._rotating || ((_this$handlers3 = this.handlers) === null || _this$handlers3 === void 0 ? void 0 : _this$handlers3.isRotating());
778
+ }
779
+
780
+ /**
781
+ * Overload of the `on` method that allows to listen to events without specifying a layer.
782
+ * @event
783
+ * @param type - The type of the event.
784
+ * @param listener - The listener callback.
785
+ */
786
+
787
+ /**
788
+ * Overload of the `on` method that allows to listen to events without specifying a layer.
789
+ * @event
790
+ * @param type - The type of the event.
791
+ * @param listener - The listener callback.
792
+ */
793
+
794
+ on(type, listener) {
795
+ return super.on(type, listener);
796
+ }
797
+
798
+ /**
799
+ * Overload of the `once` method that allows to listen to events without specifying a layer.
800
+ * @event
801
+ * @param type - The type of the event.
802
+ * @param listener - The listener callback.
803
+ */
804
+
805
+ /**
806
+ * Overload of the `once` method that allows to listen to events without specifying a layer.
807
+ * @event
808
+ * @param type - The type of the event.
809
+ * @param listener - The listener callback.
810
+ */
811
+
812
+ once(type, listener) {
813
+ return super.once(type, listener);
814
+ }
815
+
816
+ /**
817
+ * Overload of the `off` method that allows to listen to events without specifying a layer.
818
+ * @event
819
+ * @param type - The type of the event.
820
+ * @param listener - The function previously installed as a listener.
821
+ */
822
+
823
+ /**
824
+ * Overload of the `off` method that allows to listen to events without specifying a layer.
825
+ * @event
826
+ * @param type - The type of the event.
827
+ * @param listener - The function previously installed as a listener.
828
+ */
829
+
830
+ off(type, listener) {
831
+ return super.off(type, listener);
832
+ }
833
+
834
+ /**
835
+ * Returns the map's containing HTML element.
836
+ *
837
+ * @returns The map's container.
838
+ */
839
+ getContainer() {
840
+ return this._container;
841
+ }
842
+
843
+ /**
844
+ * Returns the HTML element containing the map's `<canvas>` element.
845
+ *
846
+ * If you want to add non-GL overlays to the map, you should append them to this element.
847
+ *
848
+ * This is the element to which event bindings for map interactivity (such as panning and zooming) are
849
+ * attached. It will receive bubbled events from child elements such as the `<canvas>`, but not from
850
+ * map controls.
851
+ *
852
+ * @returns The container of the map's `<canvas>`.
853
+ * @see [Create a draggable point](https://maplibre.org/maplibre-gl-js/docs/examples/drag-a-point/)
854
+ */
855
+ getCanvasContainer() {
856
+ return this._canvasContainer;
857
+ }
858
+ _containerDimensions() {
859
+ let width = 0;
860
+ let height = 0;
861
+ if (this._container) {
862
+ width = this._container.clientWidth || 400;
863
+ height = this._container.clientHeight || 300;
864
+ }
865
+ return [width, height];
866
+ }
867
+ _setupContainer() {
868
+ const container = this._container;
869
+ container.classList.add('l7-map');
870
+ const canvasContainer = this._canvasContainer = _dom.DOM.create('div', 'l7-canvas-container', container);
871
+ if (this._interactive) {
872
+ canvasContainer.classList.add('l7-interactive');
873
+ }
874
+ this._container.addEventListener('scroll', this._onMapScroll, false);
875
+ }
876
+ /**
877
+ * @internal
878
+ * Update this map's style and sources, and re-render the map.
879
+ *
880
+ * @param updateStyle - mark the map's style for reprocessing as
881
+ * well as its sources
882
+ */
883
+ _update() {
884
+ this.triggerRepaint();
885
+ return this;
886
+ }
887
+
888
+ /**
889
+ * @internal
890
+ * Request that the given callback be executed during the next render
891
+ * frame. Schedule a render frame if one is not already scheduled.
892
+ *
893
+ * @returns An id that can be used to cancel the callback
894
+ */
895
+ _requestRenderFrame(callback) {
896
+ this._update();
897
+ return this._renderTaskQueue.add(callback);
898
+ }
899
+ _cancelRenderFrame(id) {
900
+ this._renderTaskQueue.remove(id);
901
+ }
902
+
903
+ /**
904
+ * @internal
905
+ * Call when a (re-)render of the map is required:
906
+ *
907
+ * - The style has changed (`setPaintProperty()`, etc.)
908
+ * - Source data has changed (e.g. tiles have finished loading)
909
+ * - The map has is moving (or just finished moving)
910
+ * - A transition is in progress
911
+ *
912
+ * @param paintStartTimeStamp - The time when the animation frame began executing.
913
+ */
914
+ _render(paintStartTimeStamp) {
915
+ this._renderTaskQueue.run(paintStartTimeStamp);
916
+ // A task queue callback may have fired a user event which may have removed the map
917
+ if (this._removed) return;
918
+ this.fire(new _evented.Event('render'));
919
+ if (!this.isMoving()) {
920
+ this.fire(new _evented.Event('idle'));
921
+ }
922
+ return this;
923
+ }
924
+
925
+ /**
926
+ * Clean up and release all internal resources associated with this map.
927
+ *
928
+ * This includes DOM elements, event bindings, web workers, and WebGL resources.
929
+ *
930
+ * Use this method when you are done using the map and wish to ensure that it no
931
+ * longer consumes browser resources. Afterwards, you must not call any other
932
+ * methods on the map.
933
+ */
934
+ remove() {
935
+ var _this$_resizeObserver;
936
+ if (this._frameRequest) {
937
+ this._frameRequest.abort();
938
+ this._frameRequest = null;
939
+ }
940
+ this._renderTaskQueue.clear();
941
+ this.handlers.destroy();
942
+ delete this.handlers;
943
+ (_this$_resizeObserver = this._resizeObserver) === null || _this$_resizeObserver === void 0 || _this$_resizeObserver.disconnect();
944
+ _dom.DOM.remove(this._canvasContainer);
945
+ this._container.classList.remove('l7-map');
946
+ this._removed = true;
947
+ this.fire(new _evented.Event('remove'));
948
+ }
949
+
950
+ /**
951
+ * Trigger the rendering of a single frame. Use this method with custom layers to
952
+ * repaint the map when the layer changes. Calling this multiple times before the
953
+ * next frame is rendered will still result in only a single frame being rendered.
954
+ * @example
955
+ * ```ts
956
+ * map.triggerRepaint();
957
+ * ```
958
+ */
959
+ triggerRepaint() {
960
+ if (!this._frameRequest) {
961
+ this._frameRequest = new AbortController();
962
+ _browser.browser.frameAsync(this._frameRequest).then(paintStartTimeStamp => {
963
+ this._frameRequest = null;
964
+ this._render(paintStartTimeStamp);
965
+ }).catch(() => {}); // ignore abort error
966
+ }
967
+ }
968
+
969
+ /**
970
+ * Returns the elevation for the point where the camera is looking.
971
+ * This value corresponds to:
972
+ * "meters above sea level" * "exaggeration"
973
+ * @returns The elevation.
974
+ */
975
+ getCameraTargetElevation() {
976
+ return this.transform.elevation;
977
+ }
978
+ }
979
+ exports.Map = Map;