@prushforth/map 1.0.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -0
  3. package/demo/index.html +78 -0
  4. package/dist/cjs/AttributionButton-DgbgLHy4.js +106 -0
  5. package/dist/cjs/MapTileLayer-D4vp8bR4.js +454 -0
  6. package/dist/cjs/app-globals-DY--Q2Nl.js +775 -0
  7. package/dist/cjs/calculatePosition-CDcdNl7C.js +92 -0
  8. package/dist/cjs/gcds-ext-map.cjs.js +47 -0
  9. package/dist/cjs/gcds-ext-map_2.cjs.entry.js +8081 -0
  10. package/dist/cjs/index-CW_WOSnc.js +32697 -0
  11. package/dist/cjs/index.cjs.js +2 -0
  12. package/dist/cjs/loader.cjs.js +14 -0
  13. package/dist/cjs/locale-_4nEyxeO.js +153 -0
  14. package/dist/cjs/map-a.cjs.entry.js +16 -0
  15. package/dist/cjs/map-caption.cjs.entry.js +55 -0
  16. package/dist/cjs/map-extent.cjs.entry.js +993 -0
  17. package/dist/cjs/map-feature.cjs.entry.js +636 -0
  18. package/dist/cjs/map-featurecaption.cjs.entry.js +14 -0
  19. package/dist/cjs/map-geometry.cjs.entry.js +36 -0
  20. package/dist/cjs/map-input.cjs.entry.js +348 -0
  21. package/dist/cjs/map-link.cjs.entry.js +6055 -0
  22. package/dist/cjs/map-meta.cjs.entry.js +40 -0
  23. package/dist/cjs/map-properties.cjs.entry.js +14 -0
  24. package/dist/cjs/map-select.cjs.entry.js +100 -0
  25. package/dist/cjs/map-span.cjs.entry.js +14 -0
  26. package/dist/cjs/map-style.cjs.entry.js +127 -0
  27. package/dist/cjs/map-tile.cjs.entry.js +274 -0
  28. package/dist/cjs/renderStyles-yOMXvf12.js +59 -0
  29. package/dist/collection/assets/canada.json +1 -0
  30. package/dist/collection/assets/images/w3community.ico +0 -0
  31. package/dist/collection/assets/mapml/en/apstile/arctic +18 -0
  32. package/dist/collection/assets/mapml/en/cbmtile/canvec +22 -0
  33. package/dist/collection/assets/mapml/en/cbmtile/cbmt +24 -0
  34. package/dist/collection/assets/mapml/en/cbmtile/cbmtgeom +20 -0
  35. package/dist/collection/assets/mapml/en/cbmtile/cbmtsimple +20 -0
  36. package/dist/collection/assets/mapml/en/cbmtile/current_conditions +33 -0
  37. package/dist/collection/assets/mapml/en/cbmtile/toporama +25 -0
  38. package/dist/collection/assets/mapml/en/custom/arcticsdi.mapml +18 -0
  39. package/dist/collection/assets/mapml/en/osmtile/cbmt +24 -0
  40. package/dist/collection/assets/mapml/en/osmtile/current_conditions +32 -0
  41. package/dist/collection/assets/mapml/en/osmtile/dark.mapml +19 -0
  42. package/dist/collection/assets/mapml/en/osmtile/light.mapml +19 -0
  43. package/dist/collection/assets/mapml/en/osmtile/osm +19 -0
  44. package/dist/collection/assets/mapml/en/osmtile/toporama +25 -0
  45. package/dist/collection/assets/mapml/fr/apstile/arctic +19 -0
  46. package/dist/collection/assets/mapml/fr/cbmtile/canvec +22 -0
  47. package/dist/collection/assets/mapml/fr/cbmtile/cbmt +24 -0
  48. package/dist/collection/assets/mapml/fr/cbmtile/cbmtgeom +20 -0
  49. package/dist/collection/assets/mapml/fr/cbmtile/cbmtsimple +20 -0
  50. package/dist/collection/assets/mapml/fr/cbmtile/current_conditions +25 -0
  51. package/dist/collection/assets/mapml/fr/cbmtile/toporama +25 -0
  52. package/dist/collection/assets/mapml/fr/osmtile/cbmt +24 -0
  53. package/dist/collection/assets/mapml/fr/osmtile/current_conditions +24 -0
  54. package/dist/collection/assets/mapml/fr/osmtile/dark.mapml +19 -0
  55. package/dist/collection/assets/mapml/fr/osmtile/light.mapml +19 -0
  56. package/dist/collection/assets/mapml/fr/osmtile/osm +19 -0
  57. package/dist/collection/assets/mapml/fr/osmtile/toporama +25 -0
  58. package/dist/collection/assets/pmtiles/darkTheme.js +19 -0
  59. package/dist/collection/assets/pmtiles/lightTheme.js +19 -0
  60. package/dist/collection/collection-manifest.json +28 -0
  61. package/dist/collection/components/gcds-ext-map/assets/pmtiles/darkTheme.js +19 -0
  62. package/dist/collection/components/gcds-ext-map/assets/pmtiles/lightTheme.js +19 -0
  63. package/dist/collection/components/gcds-ext-map/gcds-ext-map.css +2138 -0
  64. package/dist/collection/components/gcds-ext-map/gcds-ext-map.js +1517 -0
  65. package/dist/collection/components/gcds-ext-map/stories/gcds-ext-map.stories.js +367 -0
  66. package/dist/collection/components/map-a/map-a.js +89 -0
  67. package/dist/collection/components/map-caption/map-caption.js +52 -0
  68. package/dist/collection/components/map-extent/map-extent.js +809 -0
  69. package/dist/collection/components/map-feature/map-feature.js +724 -0
  70. package/dist/collection/components/map-featurecaption/map-featurecaption.js +6 -0
  71. package/dist/collection/components/map-geometry/map-geometry.js +57 -0
  72. package/dist/collection/components/map-input/map-input.js +355 -0
  73. package/dist/collection/components/map-layer/map-layer.js +1245 -0
  74. package/dist/collection/components/map-layer/stories/map-layer.stories.js +101 -0
  75. package/dist/collection/components/map-link/map-link.js +1149 -0
  76. package/dist/collection/components/map-meta/map-meta.js +82 -0
  77. package/dist/collection/components/map-properties/map-properties.js +7 -0
  78. package/dist/collection/components/map-select/map-select.js +145 -0
  79. package/dist/collection/components/map-span/map-span.js +7 -0
  80. package/dist/collection/components/map-style/map-style.js +144 -0
  81. package/dist/collection/components/map-tile/map-tile.js +370 -0
  82. package/dist/collection/components/utils/mapml/DOMTokenList.js +123 -0
  83. package/dist/collection/components/utils/mapml/DefaultMapOptions.js +11 -0
  84. package/dist/collection/components/utils/mapml/Util.js +1601 -0
  85. package/dist/collection/components/utils/mapml/control/AttributionButton.js +101 -0
  86. package/dist/collection/components/utils/mapml/control/FullscreenButton.js +181 -0
  87. package/dist/collection/components/utils/mapml/control/GeolocationButton.js +70 -0
  88. package/dist/collection/components/utils/mapml/control/LayerControl.js +212 -0
  89. package/dist/collection/components/utils/mapml/control/ReloadButton.js +75 -0
  90. package/dist/collection/components/utils/mapml/control/ScaleBar.js +108 -0
  91. package/dist/collection/components/utils/mapml/control/SearchButton.js +565 -0
  92. package/dist/collection/components/utils/mapml/elementSupport/extents/createLayerControlForExtent.js +259 -0
  93. package/dist/collection/components/utils/mapml/elementSupport/inputs/heightInput.js +18 -0
  94. package/dist/collection/components/utils/mapml/elementSupport/inputs/hiddenInput.js +19 -0
  95. package/dist/collection/components/utils/mapml/elementSupport/inputs/locationInput.js +127 -0
  96. package/dist/collection/components/utils/mapml/elementSupport/inputs/widthInput.js +18 -0
  97. package/dist/collection/components/utils/mapml/elementSupport/inputs/zoomInput.js +30 -0
  98. package/dist/collection/components/utils/mapml/elementSupport/layers/calculatePosition.js +88 -0
  99. package/dist/collection/components/utils/mapml/elementSupport/layers/createLayerControlForLayer.js +326 -0
  100. package/dist/collection/components/utils/mapml/elementSupport/layers/renderStyles.js +55 -0
  101. package/dist/collection/components/utils/mapml/elementSupport/viewers/matchMedia.js +251 -0
  102. package/dist/collection/components/utils/mapml/features/featureRenderer.js +342 -0
  103. package/dist/collection/components/utils/mapml/features/geometry.js +268 -0
  104. package/dist/collection/components/utils/mapml/features/path.js +485 -0
  105. package/dist/collection/components/utils/mapml/handlers/AnnounceMovement.js +154 -0
  106. package/dist/collection/components/utils/mapml/handlers/ContextMenu.js +1436 -0
  107. package/dist/collection/components/utils/mapml/handlers/FeatureIndex.js +116 -0
  108. package/dist/collection/components/utils/mapml/handlers/QueryHandler.js +476 -0
  109. package/dist/collection/components/utils/mapml/handlers/keyboard.js +60 -0
  110. package/dist/collection/components/utils/mapml/layers/Crosshair.js +108 -0
  111. package/dist/collection/components/utils/mapml/layers/DebugOverlay.js +357 -0
  112. package/dist/collection/components/utils/mapml/layers/FeatureIndexOverlay.js +239 -0
  113. package/dist/collection/components/utils/mapml/layers/ImageLayer.js +136 -0
  114. package/dist/collection/components/utils/mapml/layers/MapExtentLayer.js +114 -0
  115. package/dist/collection/components/utils/mapml/layers/MapFeatureLayer.js +623 -0
  116. package/dist/collection/components/utils/mapml/layers/MapLayer.js +640 -0
  117. package/dist/collection/components/utils/mapml/layers/MapTileLayer.js +450 -0
  118. package/dist/collection/components/utils/mapml/layers/TemplatedFeaturesOrTilesLayer.js +346 -0
  119. package/dist/collection/components/utils/mapml/layers/TemplatedImageLayer.js +276 -0
  120. package/dist/collection/components/utils/mapml/layers/TemplatedPMTilesLayer.js +135 -0
  121. package/dist/collection/components/utils/mapml/layers/TemplatedTileLayer.js +664 -0
  122. package/dist/collection/components/utils/utils.js +26 -0
  123. package/dist/collection/fonts/icons/LICENSE.txt +92 -0
  124. package/dist/collection/fonts/icons/README.md +543 -0
  125. package/dist/collection/fonts/icons/gcds-icons.css +110 -0
  126. package/dist/collection/fonts/icons/gcds-icons.eot +0 -0
  127. package/dist/collection/fonts/icons/gcds-icons.svg +82 -0
  128. package/dist/collection/fonts/icons/gcds-icons.ttf +0 -0
  129. package/dist/collection/fonts/icons/gcds-icons.woff +0 -0
  130. package/dist/collection/fonts/lato/LICENSE.txt +48 -0
  131. package/dist/collection/fonts/lato/README.md +195 -0
  132. package/dist/collection/fonts/lato/gcds-lato-italic.woff +0 -0
  133. package/dist/collection/fonts/lato/gcds-lato-italic.woff2 +0 -0
  134. package/dist/collection/fonts/lato/gcds-lato.css +30 -0
  135. package/dist/collection/fonts/lato/gcds-lato.woff +0 -0
  136. package/dist/collection/fonts/lato/gcds-lato.woff2 +0 -0
  137. package/dist/collection/fonts/noto-sans/LICENSE.txt +43 -0
  138. package/dist/collection/fonts/noto-sans/README.md +423 -0
  139. package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold-italic.woff +0 -0
  140. package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold-italic.woff2 +0 -0
  141. package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold.woff +0 -0
  142. package/dist/collection/fonts/noto-sans/gcds-noto-sans-bold.woff2 +0 -0
  143. package/dist/collection/fonts/noto-sans/gcds-noto-sans-light-italic.woff +0 -0
  144. package/dist/collection/fonts/noto-sans/gcds-noto-sans-light-italic.woff2 +0 -0
  145. package/dist/collection/fonts/noto-sans/gcds-noto-sans-light.woff +0 -0
  146. package/dist/collection/fonts/noto-sans/gcds-noto-sans-light.woff2 +0 -0
  147. package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium-italic.woff +0 -0
  148. package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium-italic.woff2 +0 -0
  149. package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium.woff +0 -0
  150. package/dist/collection/fonts/noto-sans/gcds-noto-sans-medium.woff2 +0 -0
  151. package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular-italic.woff +0 -0
  152. package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular-italic.woff2 +0 -0
  153. package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular.woff +0 -0
  154. package/dist/collection/fonts/noto-sans/gcds-noto-sans-regular.woff2 +0 -0
  155. package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff +0 -0
  156. package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff2 +0 -0
  157. package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold.woff +0 -0
  158. package/dist/collection/fonts/noto-sans/gcds-noto-sans-semibold.woff2 +0 -0
  159. package/dist/collection/fonts/noto-sans/gcds-noto-sans.css +89 -0
  160. package/dist/collection/fonts/noto-sans-mono/LICENSE.txt +93 -0
  161. package/dist/collection/fonts/noto-sans-mono/README.md +135 -0
  162. package/dist/collection/fonts/noto-sans-mono/gcds-noto-sans-mono.css +17 -0
  163. package/dist/collection/fonts/noto-sans-mono/gcds-noto-sans-mono.woff +0 -0
  164. package/dist/collection/fonts/noto-sans-mono/gcds-noto-sans-mono.woff2 +0 -0
  165. package/dist/collection/generated/locale.js +148 -0
  166. package/dist/collection/global/mapml-globals.js +916 -0
  167. package/dist/collection/index.js +1 -0
  168. package/dist/collection/leaflet-src.esm.js +14419 -0
  169. package/dist/components/gcds-ext-map.d.ts +11 -0
  170. package/dist/components/gcds-ext-map.js +10 -0
  171. package/dist/components/index.d.ts +35 -0
  172. package/dist/components/index.js +1 -0
  173. package/dist/components/map-a.d.ts +11 -0
  174. package/dist/components/map-a.js +1 -0
  175. package/dist/components/map-caption.d.ts +11 -0
  176. package/dist/components/map-caption.js +1 -0
  177. package/dist/components/map-extent.d.ts +11 -0
  178. package/dist/components/map-extent.js +1 -0
  179. package/dist/components/map-feature.d.ts +11 -0
  180. package/dist/components/map-feature.js +1 -0
  181. package/dist/components/map-featurecaption.d.ts +11 -0
  182. package/dist/components/map-featurecaption.js +1 -0
  183. package/dist/components/map-geometry.d.ts +11 -0
  184. package/dist/components/map-geometry.js +1 -0
  185. package/dist/components/map-input.d.ts +11 -0
  186. package/dist/components/map-input.js +1 -0
  187. package/dist/components/map-layer.d.ts +11 -0
  188. package/dist/components/map-layer.js +1 -0
  189. package/dist/components/map-link.d.ts +11 -0
  190. package/dist/components/map-link.js +1 -0
  191. package/dist/components/map-meta.d.ts +11 -0
  192. package/dist/components/map-meta.js +1 -0
  193. package/dist/components/map-properties.d.ts +11 -0
  194. package/dist/components/map-properties.js +1 -0
  195. package/dist/components/map-select.d.ts +11 -0
  196. package/dist/components/map-select.js +1 -0
  197. package/dist/components/map-span.d.ts +11 -0
  198. package/dist/components/map-span.js +1 -0
  199. package/dist/components/map-style.d.ts +11 -0
  200. package/dist/components/map-style.js +1 -0
  201. package/dist/components/map-tile.d.ts +11 -0
  202. package/dist/components/map-tile.js +1 -0
  203. package/dist/components/p-B4YLD_Og.js +1 -0
  204. package/dist/components/p-BE41zrui.js +1 -0
  205. package/dist/components/p-Bpv_U_Lb.js +1 -0
  206. package/dist/components/p-CwRxGZga.js +5 -0
  207. package/dist/components/p-EYVT9Efh.js +1 -0
  208. package/dist/components/p-gwC_yeRa.js +1 -0
  209. package/dist/esm/AttributionButton-CfaoSLCu.js +103 -0
  210. package/dist/esm/MapTileLayer-DvC_iOIS.js +451 -0
  211. package/dist/esm/app-globals-De5ze2BD.js +773 -0
  212. package/dist/esm/calculatePosition-B4YLD_Og.js +90 -0
  213. package/dist/esm/gcds-ext-map.js +43 -0
  214. package/dist/esm/gcds-ext-map_2.entry.js +8078 -0
  215. package/dist/esm/index-BUsJ7i5g.js +32656 -0
  216. package/dist/esm/index.js +1 -0
  217. package/dist/esm/loader.js +12 -0
  218. package/dist/esm/locale-Bpv_U_Lb.js +150 -0
  219. package/dist/esm/map-a.entry.js +14 -0
  220. package/dist/esm/map-caption.entry.js +53 -0
  221. package/dist/esm/map-extent.entry.js +991 -0
  222. package/dist/esm/map-feature.entry.js +634 -0
  223. package/dist/esm/map-featurecaption.entry.js +12 -0
  224. package/dist/esm/map-geometry.entry.js +34 -0
  225. package/dist/esm/map-input.entry.js +346 -0
  226. package/dist/esm/map-link.entry.js +6035 -0
  227. package/dist/esm/map-meta.entry.js +38 -0
  228. package/dist/esm/map-properties.entry.js +12 -0
  229. package/dist/esm/map-select.entry.js +98 -0
  230. package/dist/esm/map-span.entry.js +12 -0
  231. package/dist/esm/map-style.entry.js +125 -0
  232. package/dist/esm/map-tile.entry.js +272 -0
  233. package/dist/esm/renderStyles-EYVT9Efh.js +57 -0
  234. package/dist/gcds-ext-map/assets/canada.json +1 -0
  235. package/dist/gcds-ext-map/assets/images/w3community.ico +0 -0
  236. package/dist/gcds-ext-map/assets/mapml/en/apstile/arctic +18 -0
  237. package/dist/gcds-ext-map/assets/mapml/en/cbmtile/canvec +22 -0
  238. package/dist/gcds-ext-map/assets/mapml/en/cbmtile/cbmt +24 -0
  239. package/dist/gcds-ext-map/assets/mapml/en/cbmtile/cbmtgeom +20 -0
  240. package/dist/gcds-ext-map/assets/mapml/en/cbmtile/cbmtsimple +20 -0
  241. package/dist/gcds-ext-map/assets/mapml/en/cbmtile/current_conditions +33 -0
  242. package/dist/gcds-ext-map/assets/mapml/en/cbmtile/toporama +25 -0
  243. package/dist/gcds-ext-map/assets/mapml/en/custom/arcticsdi.mapml +18 -0
  244. package/dist/gcds-ext-map/assets/mapml/en/osmtile/cbmt +24 -0
  245. package/dist/gcds-ext-map/assets/mapml/en/osmtile/current_conditions +32 -0
  246. package/dist/gcds-ext-map/assets/mapml/en/osmtile/dark.mapml +19 -0
  247. package/dist/gcds-ext-map/assets/mapml/en/osmtile/light.mapml +19 -0
  248. package/dist/gcds-ext-map/assets/mapml/en/osmtile/osm +19 -0
  249. package/dist/gcds-ext-map/assets/mapml/en/osmtile/toporama +25 -0
  250. package/dist/gcds-ext-map/assets/mapml/fr/apstile/arctic +19 -0
  251. package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/canvec +22 -0
  252. package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/cbmt +24 -0
  253. package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/cbmtgeom +20 -0
  254. package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/cbmtsimple +20 -0
  255. package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/current_conditions +25 -0
  256. package/dist/gcds-ext-map/assets/mapml/fr/cbmtile/toporama +25 -0
  257. package/dist/gcds-ext-map/assets/mapml/fr/osmtile/cbmt +24 -0
  258. package/dist/gcds-ext-map/assets/mapml/fr/osmtile/current_conditions +24 -0
  259. package/dist/gcds-ext-map/assets/mapml/fr/osmtile/dark.mapml +19 -0
  260. package/dist/gcds-ext-map/assets/mapml/fr/osmtile/light.mapml +19 -0
  261. package/dist/gcds-ext-map/assets/mapml/fr/osmtile/osm +19 -0
  262. package/dist/gcds-ext-map/assets/mapml/fr/osmtile/toporama +25 -0
  263. package/dist/gcds-ext-map/assets/pmtiles/darkTheme.js +19 -0
  264. package/dist/gcds-ext-map/assets/pmtiles/lightTheme.js +19 -0
  265. package/dist/gcds-ext-map/fonts/icons/LICENSE.txt +92 -0
  266. package/dist/gcds-ext-map/fonts/icons/README.md +543 -0
  267. package/dist/gcds-ext-map/fonts/icons/gcds-icons.css +110 -0
  268. package/dist/gcds-ext-map/fonts/icons/gcds-icons.eot +0 -0
  269. package/dist/gcds-ext-map/fonts/icons/gcds-icons.svg +82 -0
  270. package/dist/gcds-ext-map/fonts/icons/gcds-icons.ttf +0 -0
  271. package/dist/gcds-ext-map/fonts/icons/gcds-icons.woff +0 -0
  272. package/dist/gcds-ext-map/fonts/lato/LICENSE.txt +48 -0
  273. package/dist/gcds-ext-map/fonts/lato/README.md +195 -0
  274. package/dist/gcds-ext-map/fonts/lato/gcds-lato-italic.woff +0 -0
  275. package/dist/gcds-ext-map/fonts/lato/gcds-lato-italic.woff2 +0 -0
  276. package/dist/gcds-ext-map/fonts/lato/gcds-lato.css +30 -0
  277. package/dist/gcds-ext-map/fonts/lato/gcds-lato.woff +0 -0
  278. package/dist/gcds-ext-map/fonts/lato/gcds-lato.woff2 +0 -0
  279. package/dist/gcds-ext-map/fonts/noto-sans/LICENSE.txt +43 -0
  280. package/dist/gcds-ext-map/fonts/noto-sans/README.md +423 -0
  281. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold-italic.woff +0 -0
  282. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold-italic.woff2 +0 -0
  283. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold.woff +0 -0
  284. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-bold.woff2 +0 -0
  285. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light-italic.woff +0 -0
  286. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light-italic.woff2 +0 -0
  287. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light.woff +0 -0
  288. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-light.woff2 +0 -0
  289. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium-italic.woff +0 -0
  290. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium-italic.woff2 +0 -0
  291. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium.woff +0 -0
  292. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-medium.woff2 +0 -0
  293. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular-italic.woff +0 -0
  294. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular-italic.woff2 +0 -0
  295. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular.woff +0 -0
  296. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-regular.woff2 +0 -0
  297. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff +0 -0
  298. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold-italic.woff2 +0 -0
  299. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold.woff +0 -0
  300. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans-semibold.woff2 +0 -0
  301. package/dist/gcds-ext-map/fonts/noto-sans/gcds-noto-sans.css +89 -0
  302. package/dist/gcds-ext-map/fonts/noto-sans-mono/LICENSE.txt +93 -0
  303. package/dist/gcds-ext-map/fonts/noto-sans-mono/README.md +135 -0
  304. package/dist/gcds-ext-map/fonts/noto-sans-mono/gcds-noto-sans-mono.css +17 -0
  305. package/dist/gcds-ext-map/fonts/noto-sans-mono/gcds-noto-sans-mono.woff +0 -0
  306. package/dist/gcds-ext-map/fonts/noto-sans-mono/gcds-noto-sans-mono.woff2 +0 -0
  307. package/dist/gcds-ext-map/gcds-ext-map.esm.js +1 -0
  308. package/dist/gcds-ext-map/index.esm.js +0 -0
  309. package/dist/gcds-ext-map/leaflet-src.esm.js +14419 -0
  310. package/dist/gcds-ext-map/p-1b22f774.entry.js +1 -0
  311. package/dist/gcds-ext-map/p-29b4ba34.entry.js +1 -0
  312. package/dist/gcds-ext-map/p-2dd09d44.entry.js +1 -0
  313. package/dist/gcds-ext-map/p-3fef47e5.entry.js +1 -0
  314. package/dist/gcds-ext-map/p-4e324a1d.entry.js +1 -0
  315. package/dist/gcds-ext-map/p-4f4a6873.entry.js +1 -0
  316. package/dist/gcds-ext-map/p-9cc5ad37.entry.js +1 -0
  317. package/dist/gcds-ext-map/p-9edfea7d.entry.js +1 -0
  318. package/dist/gcds-ext-map/p-B4YLD_Og.js +1 -0
  319. package/dist/gcds-ext-map/p-B8Id5Ptd.js +1 -0
  320. package/dist/gcds-ext-map/p-BUsJ7i5g.js +6 -0
  321. package/dist/gcds-ext-map/p-Bpv_U_Lb.js +1 -0
  322. package/dist/gcds-ext-map/p-CtOuMgy9.js +1 -0
  323. package/dist/gcds-ext-map/p-Dd474fsL.js +1 -0
  324. package/dist/gcds-ext-map/p-EYVT9Efh.js +1 -0
  325. package/dist/gcds-ext-map/p-a67d721d.entry.js +1 -0
  326. package/dist/gcds-ext-map/p-b16e862b.entry.js +1 -0
  327. package/dist/gcds-ext-map/p-b9cbf1e0.entry.js +10 -0
  328. package/dist/gcds-ext-map/p-cab5246e.entry.js +1 -0
  329. package/dist/gcds-ext-map/p-d58d409b.entry.js +1 -0
  330. package/dist/gcds-ext-map/p-dfa21368.entry.js +1 -0
  331. package/dist/gcds-ext-map/p-f211048a.entry.js +1 -0
  332. package/dist/index.cjs.js +1 -0
  333. package/dist/index.js +1 -0
  334. package/dist/types/components/gcds-ext-map/gcds-ext-map.d.ts +125 -0
  335. package/dist/types/components/gcds-ext-map/stories/gcds-ext-map.stories.d.ts +230 -0
  336. package/dist/types/components/map-a/map-a.d.ts +7 -0
  337. package/dist/types/components/map-caption/map-caption.d.ts +7 -0
  338. package/dist/types/components/map-extent/map-extent.d.ts +53 -0
  339. package/dist/types/components/map-feature/map-feature.d.ts +50 -0
  340. package/dist/types/components/map-featurecaption/map-featurecaption.d.ts +3 -0
  341. package/dist/types/components/map-geometry/map-geometry.d.ts +7 -0
  342. package/dist/types/components/map-input/map-input.d.ts +24 -0
  343. package/dist/types/components/map-layer/map-layer.d.ts +85 -0
  344. package/dist/types/components/map-layer/stories/map-layer.stories.d.ts +96 -0
  345. package/dist/types/components/map-link/map-link.d.ts +66 -0
  346. package/dist/types/components/map-meta/map-meta.d.ts +11 -0
  347. package/dist/types/components/map-properties/map-properties.d.ts +3 -0
  348. package/dist/types/components/map-select/map-select.d.ts +13 -0
  349. package/dist/types/components/map-span/map-span.d.ts +5 -0
  350. package/dist/types/components/map-style/map-style.d.ts +17 -0
  351. package/dist/types/components/map-tile/map-tile.d.ts +32 -0
  352. package/dist/types/components/utils/mapml/DOMTokenList.d.ts +30 -0
  353. package/dist/types/components/utils/mapml/elementSupport/inputs/heightInput.d.ts +7 -0
  354. package/dist/types/components/utils/mapml/elementSupport/inputs/hiddenInput.d.ts +7 -0
  355. package/dist/types/components/utils/mapml/elementSupport/inputs/locationInput.d.ts +14 -0
  356. package/dist/types/components/utils/mapml/elementSupport/inputs/widthInput.d.ts +7 -0
  357. package/dist/types/components/utils/mapml/elementSupport/inputs/zoomInput.d.ts +11 -0
  358. package/dist/types/components/utils/mapml/layers/MapLayer.d.ts +69 -0
  359. package/dist/types/components/utils/utils.d.ts +2 -0
  360. package/dist/types/components.d.ts +521 -0
  361. package/dist/types/gcds-ext-map.d.ts +17 -0
  362. package/dist/types/generated/locale.d.ts +146 -0
  363. package/dist/types/index.d.ts +11 -0
  364. package/dist/types/stencil-public-runtime.d.ts +1861 -0
  365. package/loader/cdn.js +1 -0
  366. package/loader/index.cjs.js +1 -0
  367. package/loader/index.d.ts +24 -0
  368. package/loader/index.es2017.js +1 -0
  369. package/loader/index.js +2 -0
  370. package/package.json +87 -0
@@ -0,0 +1,1436 @@
1
+ import {
2
+ Handler,
3
+ Browser,
4
+ DomUtil,
5
+ DomEvent,
6
+ point,
7
+ stamp,
8
+ extend
9
+ } from 'leaflet';
10
+ import { Util } from '../Util.js';
11
+ /*
12
+ MIT License related to portions of M.ContextMenu
13
+ Copyright (c) 2017 adam.ratcliffe@gmail.com
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
15
+ to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
17
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
18
+ */
19
+ /* global M, KeyboardEvent */
20
+
21
+ export var ContextMenu = Handler.extend({
22
+ _touchstart: Browser.msPointer
23
+ ? 'MSPointerDown'
24
+ : Browser.pointer
25
+ ? 'pointerdown'
26
+ : 'touchstart',
27
+ _getLocale: function (map) {
28
+ return map.options.mapEl && map.options.mapEl.locale
29
+ ? map.options.mapEl.locale
30
+ : M.options.locale;
31
+ },
32
+ initialize: function (map) {
33
+ Handler.prototype.initialize.call(this, map);
34
+ let locale = this._getLocale(map);
35
+ this.activeIndex = 0; //current fous index on menu
36
+ this.excludedIndices = [4, 7]; //menu indexes that are --------
37
+ this.isRunned = false; //variable for tracking edge case
38
+ //setting the items in the context menu and their callback functions
39
+ this._menuItems = {};
40
+
41
+ const CTXBACK = 0,
42
+ CTXFWD = 1,
43
+ CTXRELOAD = 2,
44
+ CTXFULLSCR = 3,
45
+ CTXSPACER1 = 4,
46
+ CTXCOPY = 5,
47
+ CTXPASTE = 6,
48
+ CTXSPACER2 = 7,
49
+ CTXCNTRLS = 8,
50
+ CTXDEBUG = 9,
51
+ CTXVWSRC = 10;
52
+ this._menuItems.CTXBACK = CTXBACK;
53
+ this._menuItems.CTXFWD = CTXFWD;
54
+ this._menuItems.CTXRELOAD = CTXRELOAD;
55
+ this._menuItems.CTXFULLSCR = CTXFULLSCR;
56
+ this._menuItems.CTXSPACER1 = CTXSPACER1;
57
+ this._menuItems.CTXCOPY = CTXCOPY;
58
+ this._menuItems.CTXPASTE = CTXPASTE;
59
+ this._menuItems.CTXSPACER2 = CTXSPACER2;
60
+ this._menuItems.CTXCNTRLS = CTXCNTRLS;
61
+ this._menuItems.CTXDEBUG = CTXDEBUG;
62
+ this._menuItems.CTXVWSRC = CTXVWSRC;
63
+
64
+ this._items = [
65
+ {
66
+ // 0
67
+ text: locale.cmBack + ' (<kbd>Alt+Left Arrow</kbd>)',
68
+ callback: this._goBack
69
+ },
70
+ {
71
+ // 1
72
+ text: locale.cmForward + ' (<kbd>Alt+Right Arrow</kbd>)',
73
+ callback: this._goForward
74
+ },
75
+ {
76
+ // 2
77
+ text: locale.cmReload + ' (<kbd>Ctrl+R</kbd>)',
78
+ callback: this._reload
79
+ },
80
+ {
81
+ // 3
82
+ text: locale.btnFullScreen + ' (<kbd>F</kbd>)',
83
+ callback: this._toggleFullScreen
84
+ },
85
+ {
86
+ // 4
87
+ spacer: '-'
88
+ },
89
+ {
90
+ // 5
91
+ text: locale.cmCopyCoords + ' (<kbd>C</kbd>)<span></span>',
92
+ callback: this._copyCoords,
93
+ hideOnSelect: false,
94
+ popup: true,
95
+ submenu: [
96
+ {
97
+ // 5.0
98
+ text: locale.cmCopyMapML,
99
+ callback: this._copyMapML
100
+ },
101
+ {
102
+ // 5.1
103
+ text: locale.cmCopyExtent,
104
+ callback: this._copyExtent
105
+ },
106
+ {
107
+ // 5.2
108
+ text: locale.cmCopyLocation,
109
+ callback: this._copyLocation
110
+ }
111
+ ]
112
+ },
113
+ {
114
+ // 6
115
+ text: locale.cmPasteLayer + ' (<kbd>P</kbd>)',
116
+ callback: this._paste
117
+ },
118
+ {
119
+ // 7
120
+ spacer: '-'
121
+ },
122
+ {
123
+ // 8
124
+ text: locale.cmToggleControls + ' (<kbd>T</kbd>)',
125
+ callback: this._toggleControls
126
+ },
127
+ {
128
+ // 9
129
+ text: locale.cmToggleDebug + ' (<kbd>D</kbd>)',
130
+ callback: this._toggleDebug
131
+ },
132
+ {
133
+ // 10
134
+ text: locale.cmViewSource + ' (<kbd>V</kbd>)',
135
+ callback: this._viewSource
136
+ }
137
+ ];
138
+
139
+ // setting the default cs for copying location and extent
140
+ // should be public as they are used in tests
141
+ this.defExtCS = M.options.defaultExtCoor;
142
+ this.defLocCS = M.options.defaultLocCoor;
143
+
144
+ // Used for layer and map-extent contextmenu
145
+ const LYRZOOMTO = 0,
146
+ LYRCOPY = 1;
147
+ this._menuItems.LYRZOOMTO = LYRZOOMTO;
148
+ this._menuItems.LYRCOPY = LYRCOPY;
149
+
150
+ this._layerItems = [
151
+ {
152
+ // 0
153
+ text: locale.lmZoomToLayer + ' (<kbd>Z</kbd>)',
154
+ callback: this._zoomToLayer
155
+ },
156
+ {
157
+ // 1
158
+ text: locale.lmCopyLayer + ' (<kbd>L</kbd>)',
159
+ callback: this._copyLayer
160
+ }
161
+ ];
162
+
163
+ this._extentLayerItems = [
164
+ {
165
+ // 0
166
+ text: locale.lmZoomToExtent + ' (<kbd>Z</kbd>)',
167
+ callback: this._zoomToMapExtent
168
+ },
169
+ {
170
+ // 1
171
+ text: locale.lmCopyExtent + ' (<kbd>L</kbd>)',
172
+ callback: this._copyMapExtent
173
+ }
174
+ ];
175
+ this._mapMenuVisible = false;
176
+ this._keyboardEvent = false;
177
+
178
+ this._container = DomUtil.create(
179
+ 'div',
180
+ 'mapml-contextmenu',
181
+ map.getContainer()
182
+ );
183
+ this._container.setAttribute('hidden', '');
184
+
185
+ this._items[CTXBACK].el = this._createItem(
186
+ this._container,
187
+ this._items[CTXBACK]
188
+ );
189
+ this._items[CTXFWD].el = this._createItem(
190
+ this._container,
191
+ this._items[CTXFWD]
192
+ );
193
+ this._items[CTXRELOAD].el = this._createItem(
194
+ this._container,
195
+ this._items[CTXRELOAD]
196
+ );
197
+ this._items[CTXFULLSCR].el = this._createItem(
198
+ this._container,
199
+ this._items[CTXFULLSCR]
200
+ );
201
+ this._items[CTXSPACER1].el = this._createItem(
202
+ this._container,
203
+ this._items[CTXSPACER1]
204
+ );
205
+ this._items[CTXCOPY].el = this._createItem(
206
+ this._container,
207
+ this._items[CTXCOPY]
208
+ );
209
+
210
+ this._copySubMenu = DomUtil.create(
211
+ 'div',
212
+ 'mapml-contextmenu mapml-submenu',
213
+ this._container
214
+ );
215
+ this._copySubMenu.id = 'mapml-copy-submenu';
216
+ this._copySubMenu.setAttribute('hidden', '');
217
+
218
+ this._clickEvent = null;
219
+
220
+ const CPYMENUMAP = 0,
221
+ CPYMENUEXTENT = 1,
222
+ CPYMENULOC = 2;
223
+ this._menuItems.CPYMENUMAP = CPYMENUMAP;
224
+ this._menuItems.CPYMENUEXTENT = CPYMENUEXTENT;
225
+ this._menuItems.CPYMENULOC = CPYMENULOC;
226
+ this._createItem(
227
+ this._copySubMenu,
228
+ this._items[CTXCOPY].submenu[CPYMENUMAP],
229
+ CPYMENUMAP
230
+ );
231
+ this._createItem(
232
+ this._copySubMenu,
233
+ this._items[CTXCOPY].submenu[CPYMENUEXTENT],
234
+ CPYMENUEXTENT
235
+ );
236
+ this._createItem(
237
+ this._copySubMenu,
238
+ this._items[CTXCOPY].submenu[CPYMENULOC],
239
+ CPYMENULOC
240
+ );
241
+
242
+ this._items[CTXPASTE].el = this._createItem(
243
+ this._container,
244
+ this._items[CTXPASTE]
245
+ );
246
+ this._items[CTXSPACER2].el = this._createItem(
247
+ this._container,
248
+ this._items[CTXSPACER2]
249
+ );
250
+ this._items[CTXCNTRLS].el = this._createItem(
251
+ this._container,
252
+ this._items[CTXCNTRLS]
253
+ );
254
+ this._items[CTXDEBUG].el = this._createItem(
255
+ this._container,
256
+ this._items[CTXDEBUG]
257
+ );
258
+ this._items[CTXVWSRC].el = this._createItem(
259
+ this._container,
260
+ this._items[CTXVWSRC]
261
+ );
262
+
263
+ this._layerMenu = DomUtil.create(
264
+ 'div',
265
+ 'mapml-contextmenu mapml-layer-menu',
266
+ map.getContainer()
267
+ );
268
+ this._layerMenu.setAttribute('hidden', '');
269
+ this._createItem(this._layerMenu, this._layerItems[LYRZOOMTO]);
270
+ this._createItem(this._layerMenu, this._layerItems[LYRCOPY]);
271
+
272
+ this._extentLayerMenu = DomUtil.create(
273
+ 'div',
274
+ 'mapml-contextmenu mapml-extent-menu',
275
+ map.getContainer()
276
+ );
277
+ this._extentLayerMenu.setAttribute('hidden', '');
278
+ this._createItem(this._extentLayerMenu, this._extentLayerItems[LYRZOOMTO]);
279
+ this._createItem(this._extentLayerMenu, this._extentLayerItems[LYRCOPY]);
280
+
281
+ DomEvent.on(this._container, 'click', DomEvent.stop)
282
+ .on(this._container, 'mousedown', DomEvent.stop)
283
+ .on(this._container, 'dblclick', DomEvent.stop)
284
+ .on(this._container, 'contextmenu', DomEvent.stop)
285
+ .on(this._layerMenu, 'click', DomEvent.stop)
286
+ .on(this._layerMenu, 'mousedown', DomEvent.stop)
287
+ .on(this._layerMenu, 'dblclick', DomEvent.stop)
288
+ .on(this._layerMenu, 'contextmenu', DomEvent.stop)
289
+ .on(this._extentLayerMenu, 'click', DomEvent.stop)
290
+ .on(this._extentLayerMenu, 'mousedown', DomEvent.stop)
291
+ .on(this._extentLayerMenu, 'dblclick', DomEvent.stop)
292
+ .on(this._extentLayerMenu, 'contextmenu', DomEvent.stop);
293
+
294
+ this.t = document.createElement('template');
295
+ this.t.innerHTML = `<map-feature zoom="">
296
+ <map-featurecaption></map-featurecaption>
297
+ <map-properties>
298
+ <h2></h2>
299
+ <div style="text-align:center"></div>
300
+ </map-properties>
301
+ <map-geometry cs="">
302
+ <map-point>
303
+ <map-coordinates></map-coordinates>
304
+ </map-point>
305
+ </map-geometry>
306
+ </map-feature>`;
307
+ },
308
+
309
+ addHooks: function () {
310
+ var container = this._map.getContainer();
311
+
312
+ DomEvent.on(container, 'mouseleave', this._hide, this).on(
313
+ document,
314
+ 'keydown',
315
+ this._onKeyDown,
316
+ this
317
+ );
318
+
319
+ if (Browser.touch) {
320
+ DomEvent.on(document, this._touchstart, this._hide, this);
321
+ }
322
+
323
+ this._map.on(
324
+ {
325
+ contextmenu: this._show,
326
+ mousedown: this._hide,
327
+ zoomstart: this._hide
328
+ },
329
+ this
330
+ );
331
+ },
332
+
333
+ removeHooks: function () {
334
+ var container = this._map.getContainer();
335
+
336
+ DomEvent.off(container, 'mouseleave', this._hide, this).off(
337
+ document,
338
+ 'keydown',
339
+ this._onKeyDown,
340
+ this
341
+ );
342
+
343
+ if (Browser.touch) {
344
+ DomEvent.off(document, this._touchstart, this._hide, this);
345
+ }
346
+
347
+ this._map.off(
348
+ {
349
+ contextmenu: this._show,
350
+ mousedown: this._hide,
351
+ zoomstart: this._hide
352
+ },
353
+ this
354
+ );
355
+ },
356
+
357
+ _updateCS: function () {
358
+ if (
359
+ this.defExtCS !== M.options.defaultExtCoor ||
360
+ this.defLocCS !== M.options.defaultLocCoor
361
+ ) {
362
+ this.defExtCS = M.options.defaultExtCoor;
363
+ this.defLocCS = M.options.defaultLocCoor;
364
+ }
365
+ },
366
+
367
+ _copyExtent: function (e) {
368
+ let context =
369
+ e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu,
370
+ coord = context.defExtCS ? context.defExtCS.toLowerCase() : 'pcrs',
371
+ tL =
372
+ e instanceof KeyboardEvent
373
+ ? this.extent.topLeft[coord]
374
+ : this.options.mapEl.extent.topLeft[coord],
375
+ bR =
376
+ e instanceof KeyboardEvent
377
+ ? this.extent.bottomRight[coord]
378
+ : this.options.mapEl.extent.bottomRight[coord],
379
+ data = '';
380
+ switch (coord) {
381
+ case 'MapML':
382
+ default:
383
+ if (coord === 'pcrs') {
384
+ data = `<map-meta name="extent" content="top-left-easting=${Math.round(
385
+ tL.horizontal
386
+ )}, top-left-northing=${Math.round(
387
+ tL.vertical
388
+ )}, bottom-right-easting=${Math.round(
389
+ bR.horizontal
390
+ )}, bottom-right-northing=${Math.round(bR.vertical)}"></map-meta>`;
391
+ } else if (coord === 'gcrs') {
392
+ data = `<map-meta name="extent" content="top-left-longitude=${tL.horizontal}, top-left-latitude=${tL.vertical}, bottom-right-longitude=${bR.horizontal}, bottom-right-latitude=${bR.vertical}"></map-meta>`;
393
+ } else if (coord === 'tcrs') {
394
+ data = `<map-meta name="extent" content="top-left-x=${
395
+ tL[0].horizontal
396
+ }, top-left-y=${tL[0].vertical}, bottom-right-x=${
397
+ bR[bR.length - 1].horizontal
398
+ }, bottom-right-y=${bR[bR.length - 1].vertical}"></map-meta>`;
399
+ } else if (coord === 'tilematrix') {
400
+ data = `<map-meta name="extent" content="top-left-column=${
401
+ tL[0].horizontal
402
+ }, top-left-row=${tL[0].vertical}, bottom-right-column=${
403
+ bR[bR.length - 1].horizontal
404
+ }, bottom-right-row=${bR[bR.length - 1].vertical}"></map-meta>`;
405
+ } else {
406
+ console.log('not support');
407
+ }
408
+ break;
409
+ }
410
+ context._copyData(data);
411
+ },
412
+
413
+ _zoomToLayer: function (e) {
414
+ let context =
415
+ e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu;
416
+ context._layerClicked.layer._layerEl.zoomTo();
417
+ },
418
+
419
+ _copyLayer: function (e) {
420
+ let context =
421
+ e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu,
422
+ layerElem = context._layerClicked.layer._layerEl;
423
+ context._copyData(layerElem.getOuterHTML());
424
+ },
425
+
426
+ _zoomToMapExtent: function (e) {
427
+ let context =
428
+ e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu;
429
+ context._layerClicked.extent.zoomTo();
430
+ },
431
+
432
+ _copyMapExtent: function (e) {
433
+ let context =
434
+ e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu,
435
+ extentElem = context._layerClicked.extent;
436
+ context._copyData(extentElem.getOuterHTML());
437
+ },
438
+
439
+ _goForward: function (e) {
440
+ let mapEl =
441
+ e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
442
+ mapEl.forward();
443
+ },
444
+
445
+ _goBack: function (e) {
446
+ let mapEl =
447
+ e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
448
+ mapEl.back();
449
+ },
450
+
451
+ _reload: function (e) {
452
+ let mapEl =
453
+ e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
454
+ mapEl.reload();
455
+ },
456
+
457
+ _toggleFullScreen: function (e) {
458
+ let mapEl =
459
+ e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
460
+ mapEl._toggleFullScreen();
461
+ },
462
+
463
+ _toggleControls: function (e) {
464
+ let mapEl =
465
+ e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
466
+ if (mapEl.controls) {
467
+ mapEl.controls = false;
468
+ } else {
469
+ mapEl.controls = true;
470
+ }
471
+ },
472
+
473
+ _copyMapML: function (e) {
474
+ let context =
475
+ e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu,
476
+ mapEl =
477
+ e instanceof KeyboardEvent
478
+ ? this._map.options.mapEl
479
+ : this.options.mapEl;
480
+ context._copyData(
481
+ mapEl.outerHTML.replace(
482
+ /<div class="mapml-web-map">.*?<\/div>|<style>\[is="web-map"].*?<\/style>|<style>mapml-viewer.*?<\/style>/gm,
483
+ ''
484
+ )
485
+ );
486
+ },
487
+
488
+ // Add support for pasting GeoJSON in the future
489
+ _paste: function (e) {
490
+ let context =
491
+ e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu,
492
+ mapEl =
493
+ e instanceof KeyboardEvent
494
+ ? this._map.options.mapEl
495
+ : this.options.mapEl;
496
+ navigator.clipboard.readText().then((layer) => {
497
+ Util._pasteLayer(mapEl, layer);
498
+ });
499
+ },
500
+
501
+ _viewSource: function (e) {
502
+ let mapEl =
503
+ e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
504
+ mapEl.viewSource();
505
+ },
506
+
507
+ _toggleDebug: function (e) {
508
+ let mapEl =
509
+ e instanceof KeyboardEvent ? this._map.options.mapEl : this.options.mapEl;
510
+ mapEl.toggleDebug();
511
+ },
512
+
513
+ _copyCoords: function (e) {
514
+ let directory = this.contextMenu ? this.contextMenu : this;
515
+ directory._showCopySubMenu(e);
516
+ },
517
+
518
+ _copyData: function (data) {
519
+ // Remove Stencil/runtime artifacts from HTML
520
+ data = data
521
+ .replace(/\s*class="[^"]*hydrated[^"]*"/gi, '') // Remove class with "hydrated"
522
+ .replace(/\s*class=""/g, ' ') // Remove empty class attributes
523
+
524
+ const el = document.createElement('textarea');
525
+ el.value = data;
526
+ document.body.appendChild(el);
527
+ el.select();
528
+ document.execCommand('copy');
529
+ document.body.removeChild(el);
530
+ },
531
+
532
+ _copyLocation: function (e) {
533
+ const menu = this.contextMenu;
534
+ switch (menu.defLocCS.toLowerCase()) {
535
+ case 'tile':
536
+ menu._copyTile.call(this, e);
537
+ break;
538
+ case 'tilematrix':
539
+ menu._copyTileMatrix.call(this, e);
540
+ break;
541
+ case 'map':
542
+ menu._copyMap.call(this, e);
543
+ break;
544
+ case 'tcrs':
545
+ menu._copyTCRS.call(this, e);
546
+ break;
547
+ case 'pcrs':
548
+ menu._copyPCRS.call(this, e);
549
+ break;
550
+ case 'gcrs':
551
+ default:
552
+ menu._copyGCRS.call(this, e);
553
+ break;
554
+ }
555
+ },
556
+
557
+ _copyGCRS: function (e) {
558
+ let mapEl = this.options.mapEl,
559
+ click = this.contextMenu._clickEvent,
560
+ projection = mapEl.projection,
561
+ feature = this.contextMenu.t.content.firstElementChild.cloneNode(true),
562
+ caption = feature.querySelector('map-featurecaption'),
563
+ h2 = feature.querySelector('h2'),
564
+ div = feature.querySelector('div'),
565
+ geom = feature.querySelector('map-geometry'),
566
+ coords = feature.querySelector('map-coordinates');
567
+
568
+ feature.setAttribute('zoom', mapEl.zoom);
569
+ geom.setAttribute('cs', 'gcrs');
570
+ caption.textContent = `Copied ${projection} gcrs location`;
571
+ h2.textContent = `Copied ${projection} gcrs location`;
572
+ div.textContent = `${click.latlng.lng.toFixed(
573
+ 6
574
+ )} ${click.latlng.lat.toFixed(6)}`;
575
+ coords.textContent = `${click.latlng.lng.toFixed(
576
+ 6
577
+ )} ${click.latlng.lat.toFixed(6)}`;
578
+ this.contextMenu._copyData(feature.outerHTML);
579
+ },
580
+
581
+ _copyTCRS: function (e) {
582
+ let mapEl = this.options.mapEl,
583
+ click = this.contextMenu._clickEvent,
584
+ pt0 = mapEl._map.project(click.latlng),
585
+ pt = { x: pt0.x.toFixed(), y: pt0.y.toFixed() },
586
+ projection = mapEl.projection,
587
+ feature = this.contextMenu.t.content.firstElementChild.cloneNode(true),
588
+ caption = feature.querySelector('map-featurecaption'),
589
+ h2 = feature.querySelector('h2'),
590
+ div = feature.querySelector('div'),
591
+ geom = feature.querySelector('map-geometry'),
592
+ coords = feature.querySelector('map-coordinates');
593
+
594
+ feature.setAttribute('zoom', mapEl.zoom);
595
+ geom.setAttribute('cs', 'tcrs');
596
+ caption.textContent = `Copied ${projection} tcrs location`;
597
+ h2.textContent = `Copied ${projection} tcrs location`;
598
+ div.textContent = `${pt.x} ${pt.y}`;
599
+ coords.textContent = `${pt.x} ${pt.y}`;
600
+ this.contextMenu._copyData(feature.outerHTML);
601
+ },
602
+
603
+ _copyTileMatrix: function (e) {
604
+ let mapEl = this.options.mapEl,
605
+ click = this.contextMenu._clickEvent,
606
+ pt = mapEl._map.project(click.latlng),
607
+ tileSize = mapEl._map.options.crs.options.crs.tile.bounds.max.x,
608
+ projection = mapEl.projection,
609
+ feature = this.contextMenu.t.content.firstElementChild.cloneNode(true),
610
+ caption = feature.querySelector('map-featurecaption'),
611
+ h2 = feature.querySelector('h2'),
612
+ div = feature.querySelector('div'),
613
+ geom = feature.querySelector('map-geometry'),
614
+ coords = feature.querySelector('map-coordinates');
615
+
616
+ feature.setAttribute('zoom', mapEl.zoom);
617
+ geom.setAttribute('cs', 'gcrs');
618
+ caption.textContent = `Copied ${projection} tilematrix location (not implemented yet)`;
619
+ h2.textContent = `Copied ${projection} tilematrix location (not implemented yet)`;
620
+ div.textContent = `${Math.trunc(pt.x / tileSize)} ${Math.trunc(
621
+ pt.y / tileSize
622
+ )}`;
623
+ coords.textContent = `${click.latlng.lng.toFixed(
624
+ 6
625
+ )} ${click.latlng.lat.toFixed(6)}`;
626
+ this.contextMenu._copyData(feature.outerHTML);
627
+ },
628
+
629
+ _copyPCRS: function (e) {
630
+ let mapEl = this.options.mapEl,
631
+ click = this.contextMenu._clickEvent,
632
+ point = mapEl._map.project(click.latlng),
633
+ scale = mapEl._map.options.crs.scale(+mapEl.zoom),
634
+ pcrs = mapEl._map.options.crs.transformation
635
+ .untransform(point, scale)
636
+ .round(),
637
+ projection = mapEl.projection,
638
+ feature = this.contextMenu.t.content.firstElementChild.cloneNode(true),
639
+ caption = feature.querySelector('map-featurecaption'),
640
+ h2 = feature.querySelector('h2'),
641
+ div = feature.querySelector('div'),
642
+ geom = feature.querySelector('map-geometry'),
643
+ coords = feature.querySelector('map-coordinates');
644
+
645
+ feature.setAttribute('zoom', mapEl.zoom);
646
+ geom.setAttribute('cs', 'pcrs');
647
+ caption.textContent = `Copied ${projection} pcrs location`;
648
+ h2.textContent = `Copied ${projection} pcrs location`;
649
+ div.textContent = `${pcrs.x} ${pcrs.y}`;
650
+ coords.textContent = `${pcrs.x} ${pcrs.y}`;
651
+ this.contextMenu._copyData(feature.outerHTML);
652
+ },
653
+
654
+ _copyTile: function (e) {
655
+ let mapEl = this.options.mapEl,
656
+ click = this.contextMenu._clickEvent,
657
+ // the _map.project method returns pixels, while the _map.crs.project
658
+ // method returns meters, confusingly:
659
+ // https://leafletjs.com/reference.html#map-project
660
+ // https://leafletjs.com/reference.html#crs-project
661
+ pt0 = mapEl._map.project(click.latlng),
662
+ tileSize = mapEl._map.options.crs.options.crs.tile.bounds.max.x,
663
+ pointX = pt0.x % tileSize,
664
+ pointY = pt0.y % tileSize,
665
+ pt = point(pointX, pointY).trunc(),
666
+ projection = mapEl.projection,
667
+ feature = this.contextMenu.t.content.firstElementChild.cloneNode(true),
668
+ caption = feature.querySelector('map-featurecaption'),
669
+ h2 = feature.querySelector('h2'),
670
+ div = feature.querySelector('div'),
671
+ geom = feature.querySelector('map-geometry'),
672
+ coords = feature.querySelector('map-coordinates');
673
+
674
+ if (pt.x < 0) pt.x += tileSize;
675
+ if (pt.y < 0) pt.y += tileSize;
676
+
677
+ feature.setAttribute('zoom', mapEl.zoom);
678
+ geom.setAttribute('cs', 'gcrs');
679
+ caption.textContent = `Copied ${projection} tile location (not implemented yet)`;
680
+ h2.textContent = `Copied ${projection} tile location (not implemented yet)`;
681
+ div.textContent = `${pt.x} ${pt.y}`;
682
+ coords.textContent = `${click.latlng.lng.toFixed(
683
+ 6
684
+ )} ${click.latlng.lat.toFixed(6)}`;
685
+ this.contextMenu._copyData(feature.outerHTML);
686
+ },
687
+
688
+ _copyMap: function (e) {
689
+ let mapEl = this.options.mapEl,
690
+ click = this.contextMenu._clickEvent,
691
+ mapPt = click.containerPoint.trunc(),
692
+ projection = mapEl.projection,
693
+ feature = this.contextMenu.t.content.firstElementChild.cloneNode(true),
694
+ caption = feature.querySelector('map-featurecaption'),
695
+ h2 = feature.querySelector('h2'),
696
+ div = feature.querySelector('div'),
697
+ geom = feature.querySelector('map-geometry'),
698
+ coords = feature.querySelector('map-coordinates');
699
+
700
+ feature.setAttribute('zoom', mapEl.zoom);
701
+ geom.setAttribute('cs', 'gcrs');
702
+ caption.textContent = `Copied ${projection} map location (not implemented yet)`;
703
+ h2.textContent = `Copied ${projection} map location (not implemented yet)`;
704
+ div.textContent = `${mapPt.x} ${mapPt.y}`;
705
+ coords.textContent = `${click.latlng.lng.toFixed(
706
+ 6
707
+ )} ${click.latlng.lat.toFixed(6)}`;
708
+ this.contextMenu._copyData(feature.outerHTML);
709
+ },
710
+
711
+ _copyAllCoords: function (e) {
712
+ let mapEl = this.options.mapEl,
713
+ click = this.contextMenu._clickEvent,
714
+ pt0 = mapEl._map.project(click.latlng),
715
+ tileSize = mapEl._map.options.crs.options.crs.tile.bounds.max.x,
716
+ pointX = pt0.x % tileSize,
717
+ pointY = pt0.y % tileSize,
718
+ scale = mapEl._map.options.crs.scale(+mapEl.zoom),
719
+ pcrs = mapEl._map.options.crs.transformation.untransform(pt0, scale);
720
+ let allData = `z:${mapEl.zoom}\n`;
721
+ allData += `tile: i:${Math.trunc(pointX)}, j:${Math.trunc(pointY)}\n`;
722
+ allData += `tilematrix: column:${Math.trunc(
723
+ pt0.x / tileSize
724
+ )}, row:${Math.trunc(pt0.y / tileSize)}\n`;
725
+ allData += `map: i:${Math.trunc(click.containerPoint.x)}, j:${Math.trunc(
726
+ click.containerPoint.y
727
+ )}\n`;
728
+ allData += `tcrs: x:${Math.trunc(pt0.x)}, y:${Math.trunc(pt0.y)}\n`;
729
+ allData += `pcrs: easting:${pcrs.x.toFixed(2)}, northing:${pcrs.y.toFixed(
730
+ 2
731
+ )}\n`;
732
+ allData += `gcrs: lon :${click.latlng.lng.toFixed(
733
+ 6
734
+ )}, lat:${click.latlng.lat.toFixed(6)}`;
735
+ this.contextMenu._copyData(allData);
736
+ },
737
+
738
+ _createItem: function (container, options, index) {
739
+ if (options.spacer) {
740
+ return this._createSeparator(container, index);
741
+ }
742
+
743
+ var itemCls = 'mapml-contextmenu-item',
744
+ el = this._insertElementAt('button', itemCls, container, index),
745
+ callback = this._createEventHandler(
746
+ el,
747
+ options.callback,
748
+ options.context,
749
+ options.hideOnSelect
750
+ ),
751
+ html = '';
752
+
753
+ el.innerHTML = html + options.text;
754
+ el.setAttribute('type', 'button');
755
+ el.classList.add('mapml-button');
756
+ if (options.popup) {
757
+ el.setAttribute('aria-haspopup', 'true');
758
+ el.setAttribute('aria-expanded', 'false');
759
+ el.setAttribute('aria-controls', 'mapml-copy-submenu');
760
+ }
761
+
762
+ DomEvent.on(el, 'mouseover', this._onItemMouseOver, this)
763
+ .on(el, 'mouseout', this._onItemMouseOut, this)
764
+ .on(el, 'mousedown', DomEvent.stopPropagation)
765
+ .on(el, 'click', callback);
766
+
767
+ if (Browser.touch) {
768
+ DomEvent.on(el, this._touchstart, DomEvent.stopPropagation);
769
+ }
770
+
771
+ // Devices without a mouse fire "mouseover" on tap, but never “mouseout"
772
+ if (!Browser.pointer) {
773
+ DomEvent.on(el, 'click', this._onItemMouseOut, this);
774
+ }
775
+
776
+ return {
777
+ id: stamp(el),
778
+ el: el,
779
+ callback: callback
780
+ };
781
+ },
782
+
783
+ _createSeparator: function (container, index) {
784
+ let el = this._insertElementAt(
785
+ 'div',
786
+ 'mapml-contextmenu-separator',
787
+ container,
788
+ index
789
+ );
790
+
791
+ return {
792
+ id: stamp(el),
793
+ el: el
794
+ };
795
+ },
796
+
797
+ _createEventHandler: function (el, func, context, hideOnSelect) {
798
+ let parent = this;
799
+
800
+ hideOnSelect = hideOnSelect !== undefined ? hideOnSelect : true;
801
+
802
+ return function (e) {
803
+ let map = parent._map,
804
+ containerPoint = parent._showLocation.containerPoint,
805
+ layerPoint = map.containerPointToLayerPoint(containerPoint),
806
+ latlng = map.layerPointToLatLng(layerPoint),
807
+ relatedTarget = parent._showLocation.relatedTarget,
808
+ data = {
809
+ containerPoint: containerPoint,
810
+ layerPoint: layerPoint,
811
+ latlng: latlng,
812
+ relatedTarget: relatedTarget
813
+ };
814
+
815
+ if (hideOnSelect) {
816
+ parent._hide();
817
+ }
818
+
819
+ if (func) {
820
+ func.call(context || map, data);
821
+ }
822
+
823
+ parent._map.fire('contextmenu.select', {
824
+ contextmenu: parent,
825
+ el: el
826
+ });
827
+ };
828
+ },
829
+
830
+ _insertElementAt: function (tagName, className, container, index) {
831
+ let refEl,
832
+ el = document.createElement(tagName);
833
+
834
+ el.className = className;
835
+
836
+ if (index !== undefined) {
837
+ refEl = container.children[index];
838
+ }
839
+
840
+ if (refEl) {
841
+ container.insertBefore(el, refEl);
842
+ } else {
843
+ container.appendChild(el);
844
+ }
845
+
846
+ return el;
847
+ },
848
+
849
+ _show: function (e) {
850
+ // don't show a context menu for features
851
+ if (e.originalEvent.target.closest('.mapml-vector-container')) return;
852
+ if (this._mapMenuVisible) this._hide();
853
+ this._clickEvent = e;
854
+ let elem = e.originalEvent.target;
855
+ // Opening contextmenu for layercontrol
856
+ if (elem.closest('fieldset')) {
857
+ elem = elem.closest('fieldset');
858
+ // layer layercontrol
859
+ if (elem.className === 'mapml-layer-item') {
860
+ elem = elem.querySelector('span');
861
+ this._layerMenu.removeAttribute('hidden');
862
+ this._showAtPoint(e.containerPoint, e, this._layerMenu);
863
+ // map-extent layercontrol
864
+ } else if (elem.className === 'mapml-layer-extent') {
865
+ elem = elem.querySelector('span');
866
+ this._extentLayerMenu.removeAttribute('hidden');
867
+ this._showAtPoint(e.containerPoint, e, this._extentLayerMenu);
868
+ }
869
+ this._layerClicked = elem;
870
+ } else if (
871
+ // map contextmenu
872
+ elem.classList.contains('leaflet-container') ||
873
+ elem.classList.contains('mapml-debug-extent') ||
874
+ elem.tagName === 'path'
875
+ ) {
876
+ let layerList = this._map.options.mapEl.layers;
877
+ this._layerClicked = Array.from(layerList).find((el) => el.checked);
878
+ // the 'hidden' attribute must be removed before any attempt to get the size of container
879
+ let pt = e.containerPoint;
880
+ // this is for firefox, which reports the e.containerPoint as x=0 when you
881
+ // use a keyboard Shift+F10 to display the context menu; this appears
882
+ // to be because blink returns a PointerEvent of type==='contextmenu',
883
+ // while gecko returns an object (for e.originalEvent).
884
+ if (Browser.gecko) {
885
+ const getCenter = function (el) {
886
+ let w = el.getBoundingClientRect().width;
887
+ let h = el.getBoundingClientRect().height;
888
+ return { x: Number.parseInt(w / 2), y: Number.parseInt(h / 2) };
889
+ };
890
+ pt = getCenter(this._map.getContainer());
891
+ }
892
+ this._container.removeAttribute('hidden');
893
+ this._showAtPoint(pt, e, this._container);
894
+ this._updateCS();
895
+ }
896
+ // Once contextmenu is opened, focus the first item
897
+ if (e.originalEvent.button === 0 || e.originalEvent.button === -1) {
898
+ this._keyboardEvent = true;
899
+ if (this._layerClicked.className.includes('mapml-layer-item')) {
900
+ let activeEl = document.activeElement;
901
+ this._elementInFocus = activeEl.shadowRoot.activeElement;
902
+ this._layerMenuTabs = 1;
903
+ this._layerMenu.firstChild.focus();
904
+ //
905
+ } else if (this._layerClicked.className.includes('mapml-extent-item')) {
906
+ let activeEl = document.activeElement;
907
+ this._elementInFocus = activeEl.shadowRoot.activeElement;
908
+ this._extentLayerMenuTabs = 1;
909
+ this._extentLayerMenu.firstChild.focus();
910
+ } else {
911
+ this._container.querySelectorAll('button:not([disabled])')[0].focus();
912
+ }
913
+ }
914
+ },
915
+
916
+ _showAtPoint: function (pt, data, container) {
917
+ if (this._items.length) {
918
+ let event = extend(data || {}, { contextmenu: this });
919
+
920
+ this._showLocation = {
921
+ containerPoint: pt
922
+ };
923
+
924
+ if (data && data.relatedTarget) {
925
+ this._showLocation.relatedTarget = data.relatedTarget;
926
+ }
927
+
928
+ this._setPosition(pt, container);
929
+
930
+ if (!this._mapMenuVisible) {
931
+ container.removeAttribute('hidden');
932
+ this._mapMenuVisible = true;
933
+ }
934
+
935
+ this._map.fire('contextmenu.show', event);
936
+ }
937
+ },
938
+
939
+ _hide: function () {
940
+ if (this._mapMenuVisible) {
941
+ this._mapMenuVisible = false;
942
+ this._container.setAttribute('hidden', '');
943
+ this._copySubMenu.setAttribute('hidden', '');
944
+ this._layerMenu.setAttribute('hidden', '');
945
+ this._extentLayerMenu.setAttribute('hidden', '');
946
+ this._map.fire('contextmenu.hide', { contextmenu: this });
947
+ setTimeout(() => this._map._container.focus(), 0);
948
+ this.activeIndex = 0;
949
+ this.isRunned = false;
950
+ }
951
+ },
952
+
953
+ _setPosition: function (pt, container) {
954
+ let mapSize = this._map.getSize(),
955
+ containerSize = this._getElementSize(container),
956
+ anchor;
957
+
958
+ if (this._map.options.contextmenuAnchor) {
959
+ anchor = point(this._map.options.contextmenuAnchor);
960
+ pt = pt.add(anchor);
961
+ }
962
+
963
+ container._leaflet_pos = pt;
964
+
965
+ if (pt.x + containerSize.x > mapSize.x) {
966
+ container.style.left = 'auto';
967
+ container.style.right =
968
+ Math.min(
969
+ Math.max(mapSize.x - pt.x, 0),
970
+ mapSize.x - containerSize.x - 1
971
+ ) + 'px';
972
+ } else {
973
+ container.style.left = Math.max(pt.x, 0) + 'px';
974
+ container.style.right = 'auto';
975
+ }
976
+
977
+ if (pt.y + containerSize.y > mapSize.y) {
978
+ container.style.top = 'auto';
979
+ container.style.bottom =
980
+ Math.min(
981
+ Math.max(mapSize.y - pt.y, 0),
982
+ mapSize.y - containerSize.y - 1
983
+ ) + 'px';
984
+ } else {
985
+ container.style.top = Math.max(pt.y, 0) + 'px';
986
+ container.style.bottom = 'auto';
987
+ }
988
+ },
989
+
990
+ _getElementSize: function (el) {
991
+ let size = this._size;
992
+
993
+ if (!size || this._sizeChanged) {
994
+ size = {};
995
+
996
+ el.style.left = '-999999px';
997
+ el.style.right = 'auto';
998
+
999
+ size.x = el.offsetWidth;
1000
+ size.y = el.offsetHeight;
1001
+
1002
+ el.style.left = 'auto';
1003
+
1004
+ this._sizeChanged = false;
1005
+ }
1006
+
1007
+ return size;
1008
+ },
1009
+
1010
+ // once Esc is clicked on the layer/extent contextMenu, change the focus back to the layer control
1011
+ _focusOnLayerControl: function () {
1012
+ this._mapMenuVisible = false;
1013
+ delete this._layerMenuTabs;
1014
+ delete this._extentLayerMenuTabs;
1015
+ this._layerMenu.setAttribute('hidden', '');
1016
+ this._extentLayerMenu.setAttribute('hidden', '');
1017
+ if (this._elementInFocus) {
1018
+ this._elementInFocus.focus();
1019
+ } else {
1020
+ this._layerClicked.parentElement.firstChild.focus();
1021
+ }
1022
+ delete this._elementInFocus;
1023
+ },
1024
+
1025
+ _setActiveItem: function (index) {
1026
+ if (
1027
+ document.activeElement.shadowRoot === null &&
1028
+ this.noActiveEl === true
1029
+ ) {
1030
+ //bug fix when theres no active element
1031
+ this.noActiveEl = false;
1032
+ //setting this._items[9] is just for preventing some diabled index, it will be override by later code.
1033
+ this._items[9].el.el.focus();
1034
+ }
1035
+ if (
1036
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1037
+ this._items[index].el.el.innerHTML
1038
+ ) {
1039
+ //edge case where pressing shift f10 focuses the first element on contextmenu (if already focused, have to press arrow twice to go down)
1040
+ let next = index + 1;
1041
+ while (this._items[next].el.el.disabled) {
1042
+ next++;
1043
+ if (next >= this._items.length) {
1044
+ next = 0;
1045
+ }
1046
+ }
1047
+ this._setActiveItem(next);
1048
+ } else {
1049
+ if (this.excludedIndices.includes(index)) {
1050
+ // find the next or previous non-excluded item
1051
+ let nextIndex = index + 1;
1052
+ let prevIndex = index - 1;
1053
+ while (
1054
+ this.excludedIndices.includes(nextIndex) ||
1055
+ this._items[nextIndex].el.el.disabled
1056
+ ) {
1057
+ nextIndex++;
1058
+ if (nextIndex >= this._items.length) {
1059
+ nextIndex = 0;
1060
+ }
1061
+ }
1062
+ while (
1063
+ this.excludedIndices.includes(prevIndex) ||
1064
+ this._items[prevIndex].el.el.disabled
1065
+ ) {
1066
+ prevIndex--;
1067
+ if (prevIndex < 0) {
1068
+ prevIndex = this._items.length - 1;
1069
+ }
1070
+ }
1071
+ // set the active item to the next or previous non-excluded item
1072
+ if (this.activeIndex < index) {
1073
+ this._setActiveItem(nextIndex);
1074
+ } else {
1075
+ this._setActiveItem(prevIndex);
1076
+ }
1077
+ } else {
1078
+ // set the focus item
1079
+ this._items[index].el.el.focus();
1080
+ this.activeIndex = index;
1081
+ }
1082
+ }
1083
+ },
1084
+
1085
+ _onKeyDown: function (e) {
1086
+ if (!this._mapMenuVisible || e.key === 'Shift') return;
1087
+
1088
+ if (e.code === 'Enter' || e.code === 'Tab' || e.code.startsWith('Arrow'))
1089
+ e.preventDefault();
1090
+
1091
+ if (e.code === 'ArrowUp' || (e.shiftKey && e.code === 'Tab')) {
1092
+ if (
1093
+ !this._copySubMenu.hasAttribute('hidden') &&
1094
+ (document.activeElement.shadowRoot === null || //null happens when the focus is on submenu and when mouse hovers on main menu, submenu disappears
1095
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1096
+ this._copySubMenu.children[this._menuItems.CPYMENUMAP].innerHTML)
1097
+ ) {
1098
+ //"map" on submenu
1099
+ this._copySubMenu.children[this._menuItems.CPYMENULOC].focus();
1100
+ } else if (
1101
+ !this._copySubMenu.hasAttribute('hidden') &&
1102
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1103
+ this._copySubMenu.children[this._menuItems.CPYMENUEXTENT].innerHTML
1104
+ ) {
1105
+ //"extent" on submenu
1106
+ this._copySubMenu.children[this._menuItems.CPYMENUMAP].focus();
1107
+ } else if (
1108
+ !this._copySubMenu.hasAttribute('hidden') &&
1109
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1110
+ this._copySubMenu.children[this._menuItems.CPYMENULOC].innerHTML
1111
+ ) {
1112
+ //"Location" on submenu
1113
+ this._copySubMenu.children[this._menuItems.CPYMENUEXTENT].focus();
1114
+ } else if (
1115
+ !this._layerMenu.hasAttribute('hidden') &&
1116
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1117
+ this._layerMenu.children[this._menuItems.LYRZOOMTO].innerHTML
1118
+ ) {
1119
+ //"zoom to layer" on layermenu
1120
+ this._layerMenu.children[this._menuItems.LYRCOPY].focus();
1121
+ } else if (!this._layerMenu.hasAttribute('hidden')) {
1122
+ this._layerMenu.children[this._menuItems.LYRZOOMTO].focus();
1123
+ } else if (
1124
+ !this._extentLayerMenu.hasAttribute('hidden') &&
1125
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1126
+ this._extentLayerMenu.children[this._menuItems.LYRZOOMTO].innerHTML
1127
+ ) {
1128
+ //"zoom to extent" on layermenu
1129
+ this._extentLayerMenu.children[this._menuItems.LYRCOPY].focus();
1130
+ } else if (!this._extentLayerMenu.hasAttribute('hidden')) {
1131
+ this._extentLayerMenu.children[this._menuItems.LYRZOOMTO].focus();
1132
+ } else {
1133
+ if (this.activeIndex > 0) {
1134
+ let prevIndex = this.activeIndex - 1;
1135
+ while (this._items[prevIndex].el.el.disabled) {
1136
+ prevIndex--;
1137
+ if (prevIndex < 0) {
1138
+ prevIndex = this._items.length - 1;
1139
+ }
1140
+ }
1141
+ this._setActiveItem(prevIndex);
1142
+ } else {
1143
+ this._setActiveItem(this._items.length - 1);
1144
+ }
1145
+ }
1146
+ } else if (e.code === 'ArrowDown' || e.code === 'Tab') {
1147
+ if (
1148
+ !this._copySubMenu.hasAttribute('hidden') &&
1149
+ (document.activeElement.shadowRoot === null ||
1150
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1151
+ this._copySubMenu.children[this._menuItems.CPYMENULOC].innerHTML)
1152
+ ) {
1153
+ this._copySubMenu.children[this._menuItems.CPYMENUMAP].focus();
1154
+ } else if (
1155
+ !this._copySubMenu.hasAttribute('hidden') &&
1156
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1157
+ this._copySubMenu.children[this._menuItems.CPYMENUEXTENT].innerHTML
1158
+ ) {
1159
+ this._copySubMenu.children[this._menuItems.CPYMENULOC].focus();
1160
+ } else if (
1161
+ !this._copySubMenu.hasAttribute('hidden') &&
1162
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1163
+ this._copySubMenu.children[this._menuItems.CPYMENUMAP].innerHTML
1164
+ ) {
1165
+ this._copySubMenu.children[this._menuItems.CPYMENUEXTENT].focus();
1166
+ } else if (
1167
+ !this._layerMenu.hasAttribute('hidden') &&
1168
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1169
+ this._layerMenu.children[this._menuItems.LYRZOOMTO].innerHTML
1170
+ ) {
1171
+ this._layerMenu.children[this._menuItems.LYRCOPY].focus();
1172
+ } else if (!this._layerMenu.hasAttribute('hidden')) {
1173
+ this._layerMenu.children[this._menuItems.LYRZOOMTO].focus();
1174
+ } else if (
1175
+ !this._extentLayerMenu.hasAttribute('hidden') &&
1176
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1177
+ this._extentLayerMenu.children[this._menuItems.LYRZOOMTO].innerHTML
1178
+ ) {
1179
+ this._extentLayerMenu.children[this._menuItems.LYRCOPY].focus();
1180
+ } else if (!this._extentLayerMenu.hasAttribute('hidden')) {
1181
+ this._extentLayerMenu.children[this._menuItems.LYRZOOMTO].focus();
1182
+ } else {
1183
+ if (this.activeIndex < this._items.length - 1) {
1184
+ //edge case at index 0
1185
+ if (
1186
+ !this.isRunned &&
1187
+ this.activeIndex === 0 &&
1188
+ !this._items[this.activeIndex].el.el.disabled
1189
+ ) {
1190
+ this._setActiveItem(0);
1191
+ this.isRunned = true;
1192
+ } else {
1193
+ //edge case over
1194
+ let nextIndex = this.activeIndex + 1;
1195
+ while (this._items[nextIndex].el.el.disabled) {
1196
+ nextIndex++;
1197
+ if (nextIndex >= this._items.length) {
1198
+ nextIndex = 0;
1199
+ }
1200
+ }
1201
+ this._setActiveItem(nextIndex);
1202
+ }
1203
+ } else {
1204
+ let nextIndex = 0;
1205
+ while (this._items[nextIndex].el.el.disabled) {
1206
+ nextIndex++;
1207
+ if (nextIndex >= this._items.length) {
1208
+ nextIndex = 0;
1209
+ }
1210
+ }
1211
+ this._setActiveItem(nextIndex);
1212
+ }
1213
+ }
1214
+ } else if (e.code === 'ArrowRight') {
1215
+ if (
1216
+ document.activeElement.shadowRoot !== null &&
1217
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1218
+ this._items[this._menuItems.CTXCOPY].el.el.innerHTML && //'copy'
1219
+ this._copySubMenu.hasAttribute('hidden')
1220
+ ) {
1221
+ this._showCopySubMenu();
1222
+ this._copySubMenu.children[0].focus();
1223
+ } else if (
1224
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1225
+ this._items[this._menuItems.CTXCOPY].el.el.innerHTML &&
1226
+ !this._copySubMenu.hasAttribute('hidden')
1227
+ ) {
1228
+ this._copySubMenu.children[0].focus();
1229
+ }
1230
+ } else if (e.code === 'ArrowLeft') {
1231
+ if (
1232
+ !this._copySubMenu.hasAttribute('hidden') &&
1233
+ document.activeElement.shadowRoot !== null
1234
+ ) {
1235
+ if (
1236
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1237
+ this._copySubMenu.children[this._menuItems.CPYMENUMAP].innerHTML ||
1238
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1239
+ this._copySubMenu.children[this._menuItems.CPYMENUEXTENT]
1240
+ .innerHTML ||
1241
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1242
+ this._copySubMenu.children[this._menuItems.CPYMENULOC].innerHTML
1243
+ ) {
1244
+ this._copySubMenu.setAttribute('hidden', '');
1245
+ this._setActiveItem(this._menuItems.CTXCOPY);
1246
+ }
1247
+ }
1248
+ } else if (e.code === 'Escape') {
1249
+ if (this._layerMenuTabs || this._extentLayerMenuTabs) {
1250
+ DomEvent.stop(e);
1251
+ this._focusOnLayerControl();
1252
+ return;
1253
+ }
1254
+ if (document.activeElement.shadowRoot === null) {
1255
+ this._hide();
1256
+ } else {
1257
+ if (!this._copySubMenu.hasAttribute('hidden')) {
1258
+ if (
1259
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1260
+ this._copySubMenu.children[this._menuItems.CPYMENUMAP]
1261
+ .innerHTML ||
1262
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1263
+ this._copySubMenu.children[this._menuItems.CPYMENUEXTENT]
1264
+ .innerHTML ||
1265
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1266
+ this._copySubMenu.children[this._menuItems.CPYMENULOC].innerHTML
1267
+ ) {
1268
+ this._copySubMenu.setAttribute('hidden', '');
1269
+ this._setActiveItem(this._menuItems.CTXCOPY);
1270
+ }
1271
+ } else {
1272
+ this._hide();
1273
+ }
1274
+ }
1275
+ } else if (
1276
+ e.code !== 'KeyC' &&
1277
+ document.activeElement.shadowRoot.activeElement.innerHTML !==
1278
+ this._items[this._menuItems.CTXCOPY].el.el.innerHTML
1279
+ ) {
1280
+ this._hide();
1281
+ }
1282
+ // using KeyboardEvent.code for its mnemonics and case-independence
1283
+ switch (e.code) {
1284
+ case 'Enter':
1285
+ if (
1286
+ document.activeElement.shadowRoot.activeElement.innerHTML ===
1287
+ this._items[this._menuItems.CTXCOPY].el.el.innerHTML
1288
+ ) {
1289
+ this._copyCoords({
1290
+ latlng: this._map.getCenter()
1291
+ });
1292
+ this._copySubMenu.firstChild.focus();
1293
+ } else {
1294
+ if (
1295
+ this._map._container.parentNode.activeElement.parentNode.classList.contains(
1296
+ 'mapml-contextmenu'
1297
+ )
1298
+ )
1299
+ this._map._container.parentNode.activeElement.click();
1300
+ }
1301
+ break;
1302
+ case 'Space':
1303
+ if (
1304
+ this._map._container.parentNode.activeElement.parentNode.classList.contains(
1305
+ 'mapml-contextmenu'
1306
+ )
1307
+ )
1308
+ this._map._container.parentNode.activeElement.click();
1309
+ break;
1310
+ case 'KeyC':
1311
+ this._copyCoords({
1312
+ latlng: this._map.getCenter()
1313
+ });
1314
+ this._copySubMenu.firstChild.focus();
1315
+ break;
1316
+ case 'KeyD':
1317
+ this._toggleDebug(e);
1318
+ break;
1319
+ case 'KeyM':
1320
+ this._copyMapML(e);
1321
+ break;
1322
+ case 'KeyL':
1323
+ if (this._layerClicked.className.includes('mapml-layer-item')) {
1324
+ this._copyLayer(e);
1325
+ } else if (this._layerClicked.className.includes('mapml-extent-item')) {
1326
+ this._copyMapExtent(e);
1327
+ }
1328
+ break;
1329
+ case 'KeyF':
1330
+ this._toggleFullScreen(e);
1331
+ break;
1332
+ case 'KeyP':
1333
+ this._paste(e);
1334
+ break;
1335
+ case 'KeyT':
1336
+ this._toggleControls(e);
1337
+ break;
1338
+ case 'KeyV':
1339
+ this._viewSource(e);
1340
+ break;
1341
+ case 'KeyZ':
1342
+ if (this._layerClicked.className.includes('mapml-layer-item')) {
1343
+ this._zoomToLayer(e);
1344
+ } else if (this._layerClicked.className.includes('mapml-extent-item')) {
1345
+ this._zoomToMapExtent(e);
1346
+ }
1347
+ break;
1348
+ }
1349
+ },
1350
+
1351
+ _showCopySubMenu: function (e) {
1352
+ let mapSize = this._map.getSize(),
1353
+ click = this._clickEvent,
1354
+ menu = this._copySubMenu,
1355
+ copyEl = this._items[5].el.el;
1356
+
1357
+ copyEl.setAttribute('aria-expanded', 'true');
1358
+ menu.removeAttribute('hidden');
1359
+
1360
+ const menuWidth = this._container.offsetWidth,
1361
+ menuHeight = this._container.offsetHeight,
1362
+ submenuWidth = menu.offsetWidth;
1363
+ if (click.containerPoint.x + menuWidth + submenuWidth > mapSize.x) {
1364
+ menu.style.left = 'auto';
1365
+ menu.style.right = menuWidth + 'px';
1366
+ } else {
1367
+ menu.style.left = menuWidth + 'px';
1368
+ menu.style.right = 'auto';
1369
+ }
1370
+
1371
+ menu.style.top = 100 - 22 + 'px';
1372
+ menu.style.bottom = 'auto';
1373
+ },
1374
+
1375
+ _hideCopySubMenu: function (e) {
1376
+ if (
1377
+ !e.relatedTarget ||
1378
+ !e.relatedTarget.parentElement ||
1379
+ e.relatedTarget.parentElement.classList.contains('mapml-submenu') ||
1380
+ e.relatedTarget.classList.contains('mapml-submenu')
1381
+ )
1382
+ return;
1383
+ let menu = this._copySubMenu,
1384
+ copyEl = this._items[4].el.el;
1385
+ copyEl.setAttribute('aria-expanded', 'false');
1386
+ menu.setAttribute('hidden', '');
1387
+ this.noActiveEl = true; //variable to keep track of no focus element on contextmenu, bug fix for arrow key navigation
1388
+ },
1389
+
1390
+ _onItemMouseOver: function (e) {
1391
+ DomUtil.addClass(e.target || e.srcElement, 'over');
1392
+ let locale = e.locale || M.options.locale;
1393
+ if (e.srcElement.innerText === locale.cmCopyCoords + ' (C)')
1394
+ this._showCopySubMenu(e);
1395
+ },
1396
+
1397
+ _onItemMouseOut: function (e) {
1398
+ DomUtil.removeClass(e.target || e.srcElement, 'over');
1399
+ this._hideCopySubMenu(e);
1400
+ },
1401
+
1402
+ toggleContextMenuItem: function (options, state) {
1403
+ options = options.toUpperCase();
1404
+ if (state === 'disabled') {
1405
+ if (options === 'CONTROLS') {
1406
+ this._items[8].el.el.disabled = true;
1407
+ } else if (options === 'BACK') {
1408
+ this._items[0].el.el.disabled = true;
1409
+ } else if (options === 'FORWARD') {
1410
+ this._items[1].el.el.disabled = true;
1411
+ } else if (options === 'RELOAD') {
1412
+ this._items[2].el.el.disabled = true;
1413
+ }
1414
+ } else if (state === 'enabled') {
1415
+ if (options === 'CONTROLS') {
1416
+ this._items[8].el.el.disabled = false;
1417
+ } else if (options === 'BACK') {
1418
+ this._items[0].el.el.disabled = false;
1419
+ } else if (options === 'FORWARD') {
1420
+ this._items[1].el.el.disabled = false;
1421
+ } else if (options === 'RELOAD') {
1422
+ this._items[2].el.el.disabled = false;
1423
+ }
1424
+ }
1425
+ },
1426
+
1427
+ setViewFullScreenInnerHTML: function (options) {
1428
+ if (options === 'view') {
1429
+ this._map.contextMenu._items[3].el.el.innerHTML =
1430
+ this._map.options.mapEl.locale.btnFullScreen + ' (<kbd>F</kbd>)';
1431
+ } else if (options === 'exit') {
1432
+ this._map.contextMenu._items[3].el.el.innerHTML =
1433
+ this._map.options.mapEl.locale.btnExitFullScreen + ' (<kbd>F</kbd>)';
1434
+ }
1435
+ }
1436
+ });