@corpsmap/corpsmap 3.2.98 → 3.2.100

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 (276) hide show
  1. package/.babelrc +7 -0
  2. package/css/corpsmap.css +10179 -0
  3. package/fonts/cm.eot +0 -0
  4. package/fonts/cm.svg +27 -0
  5. package/fonts/cm.ttf +0 -0
  6. package/fonts/cm.woff +0 -0
  7. package/fonts/glyphicons-halflings-regular.eot +0 -0
  8. package/fonts/glyphicons-halflings-regular.svg +288 -0
  9. package/fonts/glyphicons-halflings-regular.ttf +0 -0
  10. package/fonts/glyphicons-halflings-regular.woff +0 -0
  11. package/fonts/glyphicons-halflings-regular.woff2 +0 -0
  12. package/fonts/maki.eot +0 -0
  13. package/fonts/maki.svg +98 -0
  14. package/fonts/maki.ttf +0 -0
  15. package/fonts/maki.woff +0 -0
  16. package/fonts/mapskin.eot +0 -0
  17. package/fonts/mapskin.svg +282 -0
  18. package/fonts/mapskin.ttf +0 -0
  19. package/fonts/mapskin.woff +0 -0
  20. package/fonts/materialdesignicons-webfont.eot +0 -0
  21. package/fonts/materialdesignicons-webfont.svg +7467 -0
  22. package/fonts/materialdesignicons-webfont.ttf +0 -0
  23. package/fonts/materialdesignicons-webfont.woff +0 -0
  24. package/fonts/materialdesignicons-webfont.woff2 +0 -0
  25. package/fonts/roboto/Roboto-Black.ttf +0 -0
  26. package/fonts/roboto/Roboto-BlackItalic.ttf +0 -0
  27. package/fonts/roboto/Roboto-Bold.ttf +0 -0
  28. package/fonts/roboto/Roboto-BoldItalic.ttf +0 -0
  29. package/fonts/roboto/Roboto-Italic.ttf +0 -0
  30. package/fonts/roboto/Roboto-Light.ttf +0 -0
  31. package/fonts/roboto/Roboto-LightItalic.ttf +0 -0
  32. package/fonts/roboto/Roboto-Medium.ttf +0 -0
  33. package/fonts/roboto/Roboto-MediumItalic.ttf +0 -0
  34. package/fonts/roboto/Roboto-Regular.ttf +0 -0
  35. package/fonts/roboto/Roboto-Thin.ttf +0 -0
  36. package/fonts/roboto/Roboto-ThinItalic.ttf +0 -0
  37. package/index.js +5 -0
  38. package/lib/dev.js +171156 -0
  39. package/lib/prod.js +171070 -0
  40. package/package.json +87 -70
  41. package/rollup.config.js +50 -0
  42. package/src/application-bundles/api-bundle.js +74 -76
  43. package/src/application-bundles/basic-toolbar-bundle.js +57 -57
  44. package/src/application-bundles/create-ol-map-bundle.js +257 -0
  45. package/src/application-bundles/identify-bundle.js +119 -119
  46. package/src/application-bundles/index.js +1 -1
  47. package/src/application-bundles/map-basemap-bundle.js +69 -73
  48. package/src/application-bundles/map-layers-bundle.js +35 -42
  49. package/src/application-bundles/map-view-bundle.js +312 -0
  50. package/src/application-bundles/notification-bundle.js +32 -37
  51. package/src/application-bundles/primary-panel-bundle.js +85 -85
  52. package/src/application-bundles/search-bundle.js +122 -122
  53. package/src/application-bundles/south-region-bundle.js +88 -96
  54. package/src/application-bundles/vertical-layout-bundle.js +88 -88
  55. package/src/application-bundles/viewport-bundle.js +18 -19
  56. package/src/application-bundles-old/ui-bundle.js +179 -240
  57. package/src/application-containers/{basic-toolbar.jsx → basic-toolbar.js} +24 -24
  58. package/src/application-containers/{corpsmap.jsx → corpsmap.js} +2 -7
  59. package/src/application-containers/{left-sidebar.jsx → left-sidebar.js} +6 -3
  60. package/src/application-containers/{lower-right-toolbar.jsx → lower-right-toolbar.js} +11 -12
  61. package/src/application-containers/map.js +45 -0
  62. package/src/application-containers/{modal-window.jsx → modal-window.js} +15 -13
  63. package/src/application-containers/{north-region.jsx → north-region.js} +25 -26
  64. package/src/application-containers/{notification-pane.jsx → notification-pane.js} +37 -37
  65. package/src/application-containers/{notification-quadrant.jsx → notification-quadrant.js} +20 -20
  66. package/src/application-containers/{notification.jsx → notification.js} +91 -91
  67. package/src/application-containers/old_corpsmap.js +97 -0
  68. package/src/application-containers/{primary-panel.jsx → primary-panel.js} +94 -94
  69. package/src/application-containers/right-sidebar.js +41 -0
  70. package/src/application-containers/secondary-panel.js +0 -0
  71. package/src/application-containers/{south-region-tab.jsx → south-region-tab.js} +17 -26
  72. package/src/application-containers/south-region.js +79 -0
  73. package/src/application-containers/upper-right-toolbar.js +27 -0
  74. package/src/application-controls/{basic-toolbar-button.jsx → basic-toolbar-button.js} +124 -124
  75. package/src/application-controls/{index.jsx → index.js} +34 -34
  76. package/src/application-controls/{search-results-list-item.jsx → search-results-list-item.js} +50 -50
  77. package/src/application-controls/{sidebar-button.jsx → sidebar-button.js} +69 -69
  78. package/src/application-controls/{sidebar-panel-opener.jsx → sidebar-panel-opener.js} +4 -4
  79. package/src/application-controls/{tree-list-folder.jsx → tree-list-folder.js} +46 -46
  80. package/src/application-controls/tree-list-item.js +71 -0
  81. package/src/application-exports/{map-provider.jsx → map-provider.js} +100 -122
  82. package/src/config/default-config.js +68 -53
  83. package/src/core-plugins/add-data/{add-data-button.jsx → add-data-button.js} +34 -34
  84. package/src/core-plugins/add-data/{add-geojson.jsx → add-geojson.js} +47 -47
  85. package/src/core-plugins/add-data/{add-kmlfile.jsx → add-kmlfile.js} +46 -46
  86. package/src/core-plugins/add-data/add-shapefile.js +43 -0
  87. package/src/core-plugins/add-data/bundle.js +225 -226
  88. package/src/core-plugins/basemap-switcher/basemap-switcher-list-item copy.js +59 -0
  89. package/src/core-plugins/basemap-switcher/{basemap-switcher-list-item.jsx → basemap-switcher-list-item.js} +45 -48
  90. package/src/core-plugins/basemap-switcher/{basemap-switcher-list.jsx → basemap-switcher-list.js} +1 -1
  91. package/src/core-plugins/bookmarks/{bookmark-list-item.jsx → bookmark-list-item.js} +22 -26
  92. package/src/core-plugins/bookmarks/{bookmark-list.jsx → bookmark-list.js} +1 -1
  93. package/src/core-plugins/bookmarks/bookmark-panel.js +157 -0
  94. package/src/core-plugins/catalog/catalog-button.js +36 -0
  95. package/src/core-plugins/catalog/catalog-list-item.js +83 -0
  96. package/src/core-plugins/catalog/catalog-list.js +70 -0
  97. package/src/core-plugins/catalog/{catalog-modal-window.jsx → catalog-modal-window.js} +25 -35
  98. package/src/core-plugins/change-log/bundle.js +2 -2
  99. package/src/core-plugins/change-log/{change-log-button.jsx → change-log-button.js} +44 -40
  100. package/src/core-plugins/change-log/{change-log-modal.jsx → change-log-modal.js} +11 -4
  101. package/src/core-plugins/change-log/index.js +14 -14
  102. package/src/core-plugins/change-log/{select-district.jsx → select-district.js} +73 -73
  103. package/src/core-plugins/contact-form/bundle.js +244 -239
  104. package/src/core-plugins/contact-form/index.js +17 -17
  105. package/src/core-plugins/contact-form/{question-button.jsx → question-button.js} +36 -36
  106. package/src/core-plugins/contact-form/{question-modal.jsx → question-modal.js} +189 -215
  107. package/src/core-plugins/coordinate-display/bundle.js +246 -0
  108. package/src/core-plugins/coordinate-display/{coordinate-display-bar.jsx → coordinate-display-bar.js} +66 -66
  109. package/src/core-plugins/coordinate-display/{coordinate-display-settings.jsx → coordinate-display-settings.js} +7 -3
  110. package/src/core-plugins/coordinate-display/{coordinate-interaction-bar.jsx → coordinate-interaction-bar.js} +1 -1
  111. package/src/core-plugins/coordinate-display/{coordinate-lat-lon-input.jsx → coordinate-lat-lon-input.js} +35 -35
  112. package/src/core-plugins/coordinate-display/{coordinate-popup.jsx → coordinate-popup.js} +27 -27
  113. package/src/core-plugins/draw-tools/create-draw-bundle.js +138 -148
  114. package/src/core-plugins/draw-tools/draw-button.js +192 -0
  115. package/src/core-plugins/draw-tools-old/create-draw-bundle.js +127 -137
  116. package/src/core-plugins/draw-tools-old/draw-button.js +78 -90
  117. package/src/core-plugins/editor/editor-base.js +10 -8
  118. package/src/core-plugins/editor/editor-button.js +92 -122
  119. package/src/core-plugins/editor/editor-table.js +61 -62
  120. package/src/core-plugins/geocoder/{bundle.jsx → bundle.js} +186 -186
  121. package/src/core-plugins/geocoder/index.js +14 -14
  122. package/src/core-plugins/geocoder/{overlay.jsx → overlay.js} +30 -30
  123. package/src/core-plugins/geocoder/{search-bar.jsx → search-bar.js} +122 -121
  124. package/src/core-plugins/geocoder/search-bar.js copy.save +123 -123
  125. package/src/core-plugins/identify/{bundle.jsx → bundle.js} +707 -709
  126. package/src/core-plugins/identify/{identify-buffer-section.jsx → identify-buffer-section.js} +52 -52
  127. package/src/core-plugins/identify/{identify-buffer-settings.jsx → identify-buffer-settings.js} +48 -48
  128. package/src/core-plugins/identify/{identify-button.jsx → identify-button.js} +100 -100
  129. package/src/core-plugins/identify/{identify-details-table.jsx → identify-details-table.js} +118 -121
  130. package/src/core-plugins/identify/identify-details.js +69 -69
  131. package/src/core-plugins/identify/{identify-sidebar-list-item.jsx → identify-sidebar-list-item.js} +99 -106
  132. package/src/core-plugins/identify/{identify-sidebar.jsx → identify-sidebar.js} +99 -103
  133. package/src/core-plugins/identify/{identify-table-cell.jsx → identify-table-cell.js} +49 -49
  134. package/src/core-plugins/identify/{identify-table.jsx → identify-table.js} +334 -319
  135. package/src/core-plugins/identify/index.js +27 -27
  136. package/src/core-plugins/identify/listeners/arcgis.js +158 -158
  137. package/src/core-plugins/identify/listeners/geojson.js +158 -0
  138. package/src/core-plugins/identify/listeners/raster.js +89 -89
  139. package/src/core-plugins/identify/listeners/{vector.jsx → vector.js} +106 -106
  140. package/src/core-plugins/identify-arcgis-rest/bundle.js +169 -169
  141. package/src/core-plugins/identify-cm/bundle.js +82 -82
  142. package/src/core-plugins/identify-geojson/bundle.js +143 -164
  143. package/src/core-plugins/identify-vector/{bundle.jsx → bundle.js} +135 -135
  144. package/src/core-plugins/identify-wms/bundle.js +138 -138
  145. package/src/core-plugins/legend/bundle.js +732 -755
  146. package/src/core-plugins/legend/{legend-header.jsx → legend-header.js} +1 -1
  147. package/src/core-plugins/legend/{legend-item-multiple.jsx → legend-item-multiple.js} +32 -32
  148. package/src/core-plugins/legend/{legend-panel.jsx → legend-panel.js} +1 -1
  149. package/src/core-plugins/login/login-button.js +49 -0
  150. package/src/core-plugins/map-loading-indicator/{loading-indicator.jsx → loading-indicator.js} +1 -1
  151. package/src/core-plugins/measure-tools/{measure-options.jsx → measure-options.js} +8 -5
  152. package/src/core-plugins/measure-tools/{measure-tools-button.jsx → measure-tools-button.js} +1 -1
  153. package/src/core-plugins/permalink/{permalink-button.jsx → permalink-button.js} +13 -13
  154. package/src/core-plugins/permalink/permalink-modal.js +64 -0
  155. package/src/core-plugins/print-map/{bundle.jsx → bundle.js} +316 -316
  156. package/src/core-plugins/print-map/{button.jsx → button.js} +1 -1
  157. package/src/core-plugins/resources/bundle.js +50 -55
  158. package/src/core-plugins/resources/resources-button.js +44 -0
  159. package/src/core-plugins/resources/{resources-modal.jsx → resources-modal.js} +3 -9
  160. package/src/core-plugins/rotate-north/{rotate-north-button.jsx → rotate-north-button.js} +2 -2
  161. package/src/core-plugins/theme-switcher/{theme-list-item.jsx → theme-list-item.js} +3 -3
  162. package/src/core-plugins/theme-switcher/{theme-list.jsx → theme-list.js} +1 -1
  163. package/src/core-plugins/three-d/three-d-button.js +44 -0
  164. package/src/core-plugins/tree-view/bundle.js +513 -513
  165. package/src/core-plugins/tree-view/{dataset-info-modal.jsx → dataset-info-modal.js} +141 -141
  166. package/src/core-plugins/tree-view/{dataset-legend.jsx → dataset-legend.js} +122 -122
  167. package/src/core-plugins/tree-view/{defaults-container.jsx → defaults-container.js} +27 -27
  168. package/src/core-plugins/tree-view/download-bundle.js +156 -156
  169. package/src/core-plugins/tree-view/{favorites-container.jsx → favorites-container.js} +27 -27
  170. package/src/core-plugins/tree-view/index.js +25 -25
  171. package/src/core-plugins/tree-view/layer-subpanel/{defaults-toggle.jsx → defaults-toggle.js} +28 -28
  172. package/src/core-plugins/tree-view/layer-subpanel/{download-layer.jsx → download-layer.js} +54 -54
  173. package/src/core-plugins/tree-view/layer-subpanel/{favorites-toggle.jsx → favorites-toggle.js} +28 -28
  174. package/src/core-plugins/tree-view/layer-subpanel/{label-toggle.jsx → label-toggle.js} +14 -15
  175. package/src/core-plugins/tree-view/layer-subpanel/{layer-subpanel.jsx → layer-subpanel.js} +180 -179
  176. package/src/core-plugins/tree-view/layer-subpanel/{natick-rgb.jsx → natick-rgb.js} +37 -49
  177. package/src/core-plugins/tree-view/layer-subpanel/remove-layer.js +61 -0
  178. package/src/core-plugins/tree-view/{tree-list-container.jsx → tree-list-container.js} +5 -2
  179. package/src/core-plugins/tree-view/{tree-list-item-dataset.jsx → tree-list-item-dataset.js} +1 -1
  180. package/src/core-plugins/tree-view/{tree-list-item-folder.jsx → tree-list-item-folder.js} +163 -161
  181. package/src/core-plugins/tree-view/{tree-list-item.jsx → tree-list-item.js} +2 -2
  182. package/src/core-plugins/tree-view/{tree-list.jsx → tree-list.js} +29 -37
  183. package/src/core-plugins/tree-view/{tree-view-panel.jsx → tree-view-panel.js} +148 -139
  184. package/src/core-plugins/tree-view/tree-view-toolbar/{add-all.jsx → add-all.js} +1 -1
  185. package/src/core-plugins/tree-view/tree-view-toolbar/{defaults.jsx → defaults.js} +40 -40
  186. package/src/core-plugins/tree-view/tree-view-toolbar/{favorites.jsx → favorites.js} +40 -40
  187. package/src/core-plugins/tree-view/tree-view-toolbar/{remove-all.jsx → remove-all.js} +1 -1
  188. package/src/core-plugins/tree-view/tree-view-toolbar/{toggle-expand.jsx → toggle-expand.js} +1 -1
  189. package/src/core-plugins/tree-view/tree-view-toolbar/{toggle-filter.jsx → toggle-filter.js} +1 -1
  190. package/src/core-plugins/zoom-home/bundle.js +22 -28
  191. package/src/core-plugins/zoom-home/index.js +3 -5
  192. package/src/core-plugins/zoom-home/{zoom-home-button.jsx → zoom-home-button.js} +2 -2
  193. package/src/core-plugins/zoom-in-out/index.js +14 -19
  194. package/src/core-plugins/zoom-in-out/{zoom-in-button.jsx → zoom-in-button.js} +10 -7
  195. package/src/core-plugins/zoom-in-out/{zoom-out-button.jsx → zoom-out-button.js} +10 -7
  196. package/src/core-plugins/zoom-level/bundle.js +32 -35
  197. package/src/core-plugins/zoom-level/index.js +16 -17
  198. package/src/core-plugins/zoom-level/{zoom-indicator.jsx → zoom-indicator.js} +35 -34
  199. package/src/core-plugins/zoom-to-box/bundle.js +42 -52
  200. package/src/core-plugins/zoom-to-box/{zoom-to-box-button.jsx → zoom-to-box-button.js} +13 -9
  201. package/src/css/_deprecated_bootstrap/css/bootstrap-paper.css +124 -399
  202. package/src/css/_deprecated_bootstrap/css/bootstrap-paper.min.css +3 -8075
  203. package/src/css/_deprecated_bootstrap/css/bootstrap-simplex.min.css +3 -7320
  204. package/src/css/_deprecated_bootstrap/css/bootstrap.css +202 -582
  205. package/src/css/_deprecated_bootstrap/css/bootstrap.css.map +1 -142
  206. package/src/css/_deprecated_bootstrap/css/bootstrap.min.css +2 -7128
  207. package/src/css/_deprecated_bootstrap/css/bootstrap.min.css.map +1 -143
  208. package/src/css/bg-colors.css +120 -120
  209. package/src/css/corpsmap-namespaced.css +9505 -9505
  210. package/src/css/corpsmap.css +9161 -10067
  211. package/src/css/navigation.css +174 -174
  212. package/src/{index.jsx → index.js} +109 -113
  213. package/src/openlayers-utils/format-utilities.js +71 -87
  214. package/src/openlayers-utils/layer-utilities.js +302 -309
  215. package/src/openlayers-utils/vector-style.js +131 -131
  216. package/src/utils/load-plugins.test.js +35 -35
  217. package/src/utils/scale-to-zoom-level.js +22 -18
  218. package/README.md +0 -33
  219. package/dist/corpsmap.css +0 -1
  220. package/dist/corpsmap.es.js +0 -90955
  221. package/dist/corpsmap.umd.js +0 -401
  222. package/dist/vite.svg +0 -1
  223. package/src/App.css +0 -42
  224. package/src/App.jsx +0 -12
  225. package/src/application-bundles/create-ol-map-bundle.jsx +0 -278
  226. package/src/application-bundles/map-view-bundle.jsx +0 -334
  227. package/src/application-containers/map.jsx +0 -57
  228. package/src/application-containers/right-sidebar.jsx +0 -44
  229. package/src/application-containers/south-region.jsx +0 -75
  230. package/src/application-containers/upper-right-toolbar.jsx +0 -28
  231. package/src/application-controls/tree-list-item.jsx +0 -83
  232. package/src/assets/react.svg +0 -1
  233. package/src/core-plugins/add-data/add-shapefile.jsx +0 -47
  234. package/src/core-plugins/bookmarks/bookmark-panel.jsx +0 -191
  235. package/src/core-plugins/catalog/catalog-button.jsx +0 -33
  236. package/src/core-plugins/catalog/catalog-list-item.jsx +0 -118
  237. package/src/core-plugins/catalog/catalog-list.jsx +0 -78
  238. package/src/core-plugins/coordinate-display/bundle.jsx +0 -269
  239. package/src/core-plugins/draw-tools/draw-button.jsx +0 -204
  240. package/src/core-plugins/identify/listeners/geojson.jsx +0 -164
  241. package/src/core-plugins/login/login-button.jsx +0 -49
  242. package/src/core-plugins/permalink/permalink-modal.jsx +0 -67
  243. package/src/core-plugins/resources/resources-button.jsx +0 -40
  244. package/src/core-plugins/three-d/three-d-button.jsx +0 -44
  245. package/src/core-plugins/tree-view/layer-subpanel/remove-layer.jsx +0 -75
  246. package/src/index.css +0 -68
  247. package/src/main.jsx +0 -3
  248. package/src/utils/redux-bundler-react.jsx +0 -69
  249. /package/src/application-controls/{basic-toolbar-menu-divider.jsx → basic-toolbar-menu-divider.js} +0 -0
  250. /package/src/application-controls/{basic-toolbar-menu-item.jsx → basic-toolbar-menu-item.js} +0 -0
  251. /package/src/application-controls/{basic-toolbar-menu-up.jsx → basic-toolbar-menu-up.js} +0 -0
  252. /package/src/application-controls/{basic-toolbar-menu.jsx → basic-toolbar-menu.js} +0 -0
  253. /package/src/application-controls/{basic-toolbar-submenu.jsx → basic-toolbar-submenu.js} +0 -0
  254. /package/src/application-controls/{loading-indicator.jsx → loading-indicator.js} +0 -0
  255. /package/src/application-controls/{search-input.jsx → search-input.js} +0 -0
  256. /package/src/application-controls/{search-results-list.jsx → search-results-list.js} +0 -0
  257. /package/src/application-controls/{tree-list.jsx → tree-list.js} +0 -0
  258. /package/src/application-controls/{tree-view.jsx → tree-view.js} +0 -0
  259. /package/src/core-plugins/basemap-switcher/{basemap-switcher-button.jsx → basemap-switcher-button.js} +0 -0
  260. /package/src/core-plugins/bookmarks/{bookmark-button.jsx → bookmark-button.js} +0 -0
  261. /package/src/core-plugins/catalog/{catalog-error-item.jsx → catalog-error-item.js} +0 -0
  262. /package/src/core-plugins/catalog/{catalog-list-item-loader.jsx → catalog-list-item-loader.js} +0 -0
  263. /package/src/core-plugins/coordinate-display/{coordinate-display-proj-item.jsx → coordinate-display-proj-item.js} +0 -0
  264. /package/src/core-plugins/draw-tools/{draw-save-bundle.jsx → draw-save-bundle.js} +0 -0
  265. /package/src/core-plugins/draw-tools/{draw-tool-item.jsx → draw-tool-item.js} +0 -0
  266. /package/src/core-plugins/identify/{identify-popup.jsx → identify-popup.js} +0 -0
  267. /package/src/core-plugins/identify/{identify-sidebar-list.jsx → identify-sidebar-list.js} +0 -0
  268. /package/src/core-plugins/legend/{legend-button.jsx → legend-button.js} +0 -0
  269. /package/src/core-plugins/legend/{legend-item.jsx → legend-item.js} +0 -0
  270. /package/src/core-plugins/theme-switcher/{theme-switcher-button.jsx → theme-switcher-button.js} +0 -0
  271. /package/src/core-plugins/tree-view/{boundary-drop-target.jsx → boundary-drop-target.js} +0 -0
  272. /package/src/core-plugins/tree-view/layer-subpanel/{natick-rgb-options.jsx → natick-rgb-options.js} +0 -0
  273. /package/src/core-plugins/tree-view/layer-subpanel/{opacity-slider.jsx → opacity-slider.js} +0 -0
  274. /package/src/core-plugins/tree-view/{tree-view-button.jsx → tree-view-button.js} +0 -0
  275. /package/src/core-plugins/zoom-to-box/{index.jsx → index.js} +0 -0
  276. /package/src/utils/{plugin-region.jsx → plugin-region.js} +0 -0
@@ -32,53 +32,68 @@ export default {
32
32
  }
33
33
  };
34
34
  },
35
- doFetchLegendInfo:
36
- (layers) =>
37
- ({ dispatch, store }) => {
38
- if (req) req.abort();
39
- let legendLayers = store.selectLegendLayers();
40
- let legendCanvases = store.selectLegendCanvases();
41
-
42
- layers.forEach((lyr) => {
43
- const {
44
- url,
45
- type,
46
- layerList,
47
- uid,
48
- displayName,
49
- layerDescription,
50
- attributions,
51
- legendOverride,
52
- } = lyr;
53
- legendCanvases[uid] = {
54
- displayName: displayName,
55
- layerDescription: layerDescription,
56
- attributions: attributions,
57
- canvas: [],
58
- widths: [],
59
- heights: [],
60
- };
61
-
62
- let src = url;
63
- switch (type) {
64
- case "ArcGIS":
35
+ doFetchLegendInfo: (layers) => ({ dispatch, store }) => {
36
+ if (req) req.abort();
37
+ let legendLayers = store.selectLegendLayers();
38
+ let legendCanvases = store.selectLegendCanvases();
39
+
40
+ layers.forEach((lyr) => {
41
+ const { url, type, layerList, uid, displayName, layerDescription, attributions, legendOverride } = lyr;
42
+ legendCanvases[uid] = {
43
+ displayName: displayName,
44
+ layerDescription: layerDescription,
45
+ attributions: attributions,
46
+ canvas: [],
47
+ widths: [],
48
+ heights: [],
49
+ };
50
+
51
+ let src = url;
52
+ switch (type) {
53
+ case "ArcGIS":
54
+ src = `${src}/legend?f=pjson`;
55
+ break;
56
+ case "ArcGISImage":
57
+ src = `${src}/legend?bandIds=&renderingRule=&f=pjson`;
58
+ break;
59
+ case "EsriFeatureService":
60
+ if (legendOverride === true) {
65
61
  src = `${src}/legend?f=pjson`;
66
- break;
67
- case "ArcGISImage":
68
- src = `${src}/legend?bandIds=&renderingRule=&f=pjson`;
69
- break;
70
- case "EsriFeatureService":
71
- if (legendOverride === true) {
72
- src = `${src}/legend?f=pjson`;
62
+ }
63
+ else {
64
+ src = `${src}/${layerList}?f=pjson`;
65
+ }
66
+ break;
67
+ default:
68
+ break;
69
+ }
70
+ req = xhr.get(src, (err, response, body) => {
71
+ if (err || response.statusCode !== 200) {
72
+ legendLayers[uid] = ["Legend not available!"];
73
+
74
+ dispatch({
75
+ type: "LEGEND_LAYERS_UPDATE_ERROR",
76
+ payload: {
77
+ legendLayers: legendLayers,
78
+ legendCanvases: legendCanvases,
79
+ loading: false,
80
+ },
81
+ });
82
+ } else {
83
+ try {
84
+ const data = JSON.parse(body);
85
+ console.log(data)
86
+ if (type === "EsriFeatureService") {
87
+ if (legendOverride === true) {
88
+ store.doGenerateArcImages(data, lyr);
89
+ } else {
90
+ store.doGenerateEsriImages(data, lyr);
91
+ }
73
92
  } else {
74
- src = `${src}/${layerList}?f=pjson`;
93
+ store.doGenerateArcImages(data, lyr);
75
94
  }
76
- break;
77
- default:
78
- break;
79
- }
80
- req = xhr.get(src, (err, response, body) => {
81
- if (err || response.statusCode !== 200) {
95
+ } catch (err) {
96
+ console.log(err);
82
97
  legendLayers[uid] = ["Legend not available!"];
83
98
 
84
99
  dispatch({
@@ -89,179 +104,62 @@ export default {
89
104
  loading: false,
90
105
  },
91
106
  });
92
- } else {
93
- try {
94
- const data = JSON.parse(body);
95
- console.log(data);
96
- if (type === "EsriFeatureService") {
97
- if (legendOverride === true) {
98
- store.doGenerateArcImages(data, lyr);
99
- } else {
100
- store.doGenerateEsriImages(data, lyr);
101
- }
102
- } else {
103
- store.doGenerateArcImages(data, lyr);
104
- }
105
- } catch (err) {
106
- console.log(err);
107
- legendLayers[uid] = ["Legend not available!"];
108
-
109
- dispatch({
110
- type: "LEGEND_LAYERS_UPDATE_ERROR",
111
- payload: {
112
- legendLayers: legendLayers,
113
- legendCanvases: legendCanvases,
114
- loading: false,
115
- },
116
- });
117
- }
118
107
  }
119
- });
120
-
121
- // timeout after 60s.
122
- req.timeout = 60000;
123
- });
124
- },
125
- doGenerateArcImages:
126
- (data, lyr) =>
127
- ({ dispatch, store }) => {
128
- const { uid, layerList, displayName, layerDescription, attributions } =
129
- lyr;
130
- let legendLayers = store.selectLegendLayers();
131
- let legendCanvases = store.selectLegendCanvases();
132
- const activeLayers = layerList
133
- .replace(/show:/g, "")
134
- .split(",")
135
- .map(Number);
136
-
137
- legendCanvases[uid] = {
138
- displayName: displayName,
139
- layerDescription: layerDescription,
140
- attributions: attributions,
141
- canvas: [],
142
- widths: [],
143
- heights: [],
144
- };
145
-
146
- const legends = data.layers.filter((item) => {
147
- return activeLayers.indexOf(item.layerId) !== -1;
148
- });
149
- const items = legends.map((legendLyr) => {
150
- return legendLyr.legend.map((legend) => {
151
- let img = new Image();
152
- img.addEventListener(
153
- "load",
154
- function () {
155
- let canvas = document.createElement("canvas");
156
- let ctx = canvas.getContext("2d");
157
- const labelWidth = Number(ctx.measureText(legend.label).width);
158
-
159
- //set canvas width & height
160
- canvas.width = Number(legend.width) + labelWidth + 4;
161
- canvas.height = legend.height;
162
-
163
- //store width & height for larger canvas calculation
164
- legendCanvases[uid].widths.push(canvas.width);
165
- legendCanvases[uid].heights.push(canvas.height);
166
-
167
- //set background
168
- ctx.fillStyle = "white";
169
- ctx.fillRect(0, 0, canvas.width, canvas.height);
170
-
171
- ctx.drawImage(img, 0, 0); //add image to canvas
172
-
173
- //add label to the right of image
174
- ctx.font = "10px Arial";
175
- ctx.fillStyle = "black";
176
- ctx.fillText(legend.label, legend.width + 2, legend.height / 2);
177
- legendCanvases[uid].canvas.push(canvas);
178
-
179
- dispatch({
180
- type: "LEGEND_CANVAS_ADDED",
181
- payload: {
182
- legendCanvases: legendCanvases,
183
- loading: false,
184
- },
185
- });
186
- },
187
- false
188
- );
189
- img.src = `data:${legend.contentType};base64,${legend.imageData}`;
190
- img.alt = `Style for ${legend.label}`;
191
- img.crossOrigin = "anonymous";
192
- img.title = legend.label;
193
-
194
- return img;
195
- });
108
+ }
196
109
  });
197
- legendLayers[uid] = flatten(items);
198
110
 
199
- dispatch({
200
- type: "LEGEND_LAYERS_UPDATED",
201
- payload: {
202
- legendLayers: legendLayers,
203
- loading: false,
204
- },
205
- });
206
- },
207
-
208
- doGenerateEsriImages:
209
- (data, lyr) =>
210
- ({ dispatch, store }) => {
211
- const { uid, displayName, layerDescription, attributions } = lyr;
212
- let legendLayers = store.selectLegendLayers();
213
- let legendCanvases = store.selectLegendCanvases();
214
- const drawingInfo = data.drawingInfo;
215
- legendCanvases[uid] = {
216
- displayName: displayName,
217
- layerDescription: layerDescription,
218
- attributions: attributions,
219
- canvas: [],
220
- widths: [],
221
- heights: [],
222
- };
223
- legendLayers[uid] = [];
224
- //TODO Logic below is needs to include other Esri styles.
225
- console.log(drawingInfo.renderer);
226
- console.log(drawingInfo.renderer.symbol);
227
- // debugger;
228
- switch (data.geometryType) {
229
- case "esriGeometryPolygon":
230
- if (
231
- drawingInfo.renderer.symbol &&
232
- drawingInfo.renderer.symbol.type === "esriSFS" &&
233
- drawingInfo.renderer.symbol.style === "esriSFSSolid"
234
- ) {
235
- let img = new Image();
236
- const outlineColor = drawingInfo.renderer.symbol.outline.color;
237
- const fillColor = drawingInfo.renderer.symbol.color;
111
+ // timeout after 60s.
112
+ req.timeout = 60000;
113
+ });
114
+ },
115
+ doGenerateArcImages: (data, lyr) => ({ dispatch, store }) => {
116
+ const { uid, layerList, displayName, layerDescription, attributions } = lyr;
117
+ let legendLayers = store.selectLegendLayers();
118
+ let legendCanvases = store.selectLegendCanvases();
119
+ const activeLayers = layerList.replace(/show:/g, "").split(",").map(Number);
120
+
121
+ legendCanvases[uid] = {
122
+ displayName: displayName,
123
+ layerDescription: layerDescription,
124
+ attributions: attributions,
125
+ canvas: [],
126
+ widths: [],
127
+ heights: [],
128
+ };
238
129
 
130
+ const legends = data.layers.filter((item) => {
131
+ return activeLayers.indexOf(item.layerId) !== -1;
132
+ });
133
+ const items = legends.map((legendLyr) => {
134
+ return legendLyr.legend.map((legend) => {
135
+ let img = new Image();
136
+ img.addEventListener(
137
+ "load",
138
+ function () {
239
139
  let canvas = document.createElement("canvas");
240
140
  let ctx = canvas.getContext("2d");
141
+ const labelWidth = Number(ctx.measureText(legend.label).width);
241
142
 
242
- canvas.width = 20;
243
- canvas.height = 20;
143
+ //set canvas width & height
144
+ canvas.width = Number(legend.width) + labelWidth + 4;
145
+ canvas.height = legend.height;
244
146
 
245
147
  //store width & height for larger canvas calculation
246
148
  legendCanvases[uid].widths.push(canvas.width);
247
149
  legendCanvases[uid].heights.push(canvas.height);
248
150
 
249
- // Draw polygon
250
- ctx.beginPath();
251
- ctx.lineWidth = "2";
252
- ctx.strokeStyle = outlineColor
253
- ? `rgba(${outlineColor.join()})`
254
- : null;
255
- ctx.rect(0, 0, 20, 20);
256
- ctx.stroke();
257
- ctx.fillStyle = fillColor ? `rgba(${fillColor.join()})` : null;
258
- ctx.fillRect(1, 1, 18, 18);
151
+ //set background
152
+ ctx.fillStyle = "white";
153
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
259
154
 
260
- img.src = canvas.toDataURL(); //set src using data URI from canvas
261
- img.alt = `Style for ${displayName}`;
262
- img.crossOrigin = "anonymous";
155
+ ctx.drawImage(img, 0, 0); //add image to canvas
263
156
 
157
+ //add label to the right of image
158
+ ctx.font = "10px Arial";
159
+ ctx.fillStyle = "black";
160
+ ctx.fillText(legend.label, legend.width + 2, legend.height / 2);
264
161
  legendCanvases[uid].canvas.push(canvas);
162
+
265
163
  dispatch({
266
164
  type: "LEGEND_CANVAS_ADDED",
267
165
  payload: {
@@ -269,48 +167,198 @@ export default {
269
167
  loading: false,
270
168
  },
271
169
  });
170
+ },
171
+ false
172
+ );
173
+ img.src = `data:${legend.contentType};base64,${legend.imageData}`;
174
+ img.alt = `Style for ${legend.label}`;
175
+ img.crossOrigin = "anonymous";
176
+ img.title = legend.label;
177
+
178
+ return img;
179
+ });
180
+ });
181
+ legendLayers[uid] = flatten(items);
182
+
183
+ dispatch({
184
+ type: "LEGEND_LAYERS_UPDATED",
185
+ payload: {
186
+ legendLayers: legendLayers,
187
+ loading: false,
188
+ },
189
+ });
190
+ },
272
191
 
273
- legendLayers[uid].push(img);
274
- dispatch({
275
- type: "LEGEND_LAYERS_UPDATED",
276
- payload: {
277
- legendLayers: legendLayers,
278
- loading: false,
279
- },
280
- });
281
- } else if (
282
- drawingInfo.renderer.symbol &&
283
- drawingInfo.renderer.symbol.type === "esriSFS" &&
284
- drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal"
285
- ) {
192
+ doGenerateEsriImages: (data, lyr) => ({ dispatch, store }) => {
193
+ const { uid, displayName, layerDescription, attributions } = lyr;
194
+ let legendLayers = store.selectLegendLayers();
195
+ let legendCanvases = store.selectLegendCanvases();
196
+ const drawingInfo = data.drawingInfo;
197
+ legendCanvases[uid] = {
198
+ displayName: displayName,
199
+ layerDescription: layerDescription,
200
+ attributions: attributions,
201
+ canvas: [],
202
+ widths: [],
203
+ heights: [],
204
+ };
205
+ legendLayers[uid] = [];
206
+ //TODO Logic below is needs to include other Esri styles.
207
+ console.log(drawingInfo.renderer);
208
+ console.log(drawingInfo.renderer.symbol)
209
+
210
+ switch (data.geometryType) {
211
+ case "esriGeometryPolygon":
212
+ if (
213
+ drawingInfo.renderer.symbol &&
214
+ drawingInfo.renderer.symbol.type === "esriSFS" &&
215
+ drawingInfo.renderer.symbol.style === "esriSFSSolid"
216
+ ) {
217
+ let img = new Image();
218
+ const outlineColor = drawingInfo.renderer.symbol.outline.color;
219
+ const fillColor = drawingInfo.renderer.symbol.color;
220
+
221
+
222
+ let canvas = document.createElement("canvas");
223
+ let ctx = canvas.getContext("2d");
224
+
225
+ canvas.width = 20;
226
+ canvas.height = 20;
227
+
228
+ //store width & height for larger canvas calculation
229
+ legendCanvases[uid].widths.push(canvas.width);
230
+ legendCanvases[uid].heights.push(canvas.height);
231
+
232
+ // Draw polygon
233
+ ctx.beginPath();
234
+ ctx.lineWidth = "2";
235
+ ctx.strokeStyle = `rgba(${outlineColor.join()})`;
236
+ ctx.rect(0, 0, 20, 20);
237
+ ctx.stroke();
238
+ ctx.fillStyle = `rgba(${fillColor.join()})`;
239
+ ctx.fillRect(1, 1, 18, 18);
240
+
241
+ img.src = canvas.toDataURL(); //set src using data URI from canvas
242
+ img.alt = `Style for ${displayName}`;
243
+ img.crossOrigin = "anonymous";
244
+
245
+ legendCanvases[uid].canvas.push(canvas);
246
+ dispatch({
247
+ type: "LEGEND_CANVAS_ADDED",
248
+ payload: {
249
+ legendCanvases: legendCanvases,
250
+ loading: false,
251
+ },
252
+ });
253
+
254
+ legendLayers[uid].push(img);
255
+ dispatch({
256
+ type: "LEGEND_LAYERS_UPDATED",
257
+ payload: {
258
+ legendLayers: legendLayers,
259
+ loading: false,
260
+ },
261
+ });
262
+ }
263
+ else if(
264
+ drawingInfo.renderer.symbol &&
265
+ drawingInfo.renderer.symbol.type === "esriSFS" &&
266
+ drawingInfo.renderer.symbol.style === "esriSFSBackwardDiagonal"
267
+ ) {
268
+ let img = new Image();
269
+ const outlineColor = drawingInfo.renderer.symbol.outline.color;
270
+ const fillColor = drawingInfo.renderer.symbol.color;
271
+
272
+
273
+ let canvas = document.createElement("canvas");
274
+ let ctx = canvas.getContext("2d");
275
+
276
+ canvas.width = 20;
277
+ canvas.height = 20;
278
+
279
+ //store width & height for larger canvas calculation
280
+ legendCanvases[uid].widths.push(canvas.width);
281
+ legendCanvases[uid].heights.push(canvas.height);
282
+
283
+ // // Draw polygon
284
+ ctx.beginPath();
285
+ ctx.moveTo(0, 10);
286
+ ctx.lineTo(10, 0);
287
+ ctx.moveTo(0, 20);
288
+ ctx.lineTo(20, 0);
289
+ ctx.moveTo(10, 20);
290
+ ctx.lineTo(20, 10);
291
+ ctx.lineWidth = "2";
292
+ ctx.strokeStyle = `rgba(${outlineColor.join()})`;
293
+ ctx.rect(0, 0, 20, 20);
294
+ ctx.stroke();
295
+
296
+ img.src = canvas.toDataURL(); //set src using data URI from canvas
297
+ img.alt = `Style for ${displayName}`;
298
+ img.crossOrigin = "anonymous";
299
+
300
+ legendCanvases[uid].canvas.push(canvas);
301
+ dispatch({
302
+ type: "LEGEND_CANVAS_ADDED",
303
+ payload: {
304
+ legendCanvases: legendCanvases,
305
+ loading: false,
306
+ },
307
+ });
308
+
309
+ legendLayers[uid].push(img);
310
+ dispatch({
311
+ type: "LEGEND_LAYERS_UPDATED",
312
+ payload: {
313
+ legendLayers: legendLayers,
314
+ loading: false,
315
+ },
316
+ });
317
+ }
318
+ //____________________________________________________________________________________________________________________________________
319
+ else if (
320
+ drawingInfo.renderer.type === "uniqueValue" &&
321
+ drawingInfo.renderer.uniqueValueInfos
322
+ ) {
323
+ // Compare
324
+ drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
286
325
  let img = new Image();
287
- const outlineColor = drawingInfo.renderer.symbol.outline.color;
288
- const fillColor = drawingInfo.renderer.symbol.color;
326
+ console.log(val.value)
327
+ if (val.value === 'BOEM') {
328
+ }
329
+
330
+ const fillColor = val.symbol.color;
331
+ const outlineColor = val.symbol.outline && val.symbol.outline.color ? val.symbol.outline.color : fillColor;
332
+
289
333
 
290
334
  let canvas = document.createElement("canvas");
291
335
  let ctx = canvas.getContext("2d");
336
+ const labelWidth = Number(ctx.measureText(val.label).width);
292
337
 
293
- canvas.width = 20;
338
+ //set canvas width & height
339
+ canvas.width = 20 + labelWidth + 4;
294
340
  canvas.height = 20;
295
341
 
296
342
  //store width & height for larger canvas calculation
297
343
  legendCanvases[uid].widths.push(canvas.width);
298
344
  legendCanvases[uid].heights.push(canvas.height);
299
345
 
300
- // // Draw polygon
346
+ // Draw polygon
301
347
  ctx.beginPath();
302
- ctx.moveTo(0, 10);
303
- ctx.lineTo(10, 0);
304
- ctx.moveTo(0, 20);
305
- ctx.lineTo(20, 0);
306
- ctx.moveTo(10, 20);
307
- ctx.lineTo(20, 10);
308
348
  ctx.lineWidth = "2";
309
349
  ctx.strokeStyle = `rgba(${outlineColor.join()})`;
310
350
  ctx.rect(0, 0, 20, 20);
311
351
  ctx.stroke();
352
+ ctx.fillStyle = `rgba(${fillColor.join()})`;
353
+ ctx.fillRect(1, 1, 18, 18);
312
354
 
313
- img.src = canvas.toDataURL(); //set src using data URI from canvas
355
+ //add label to the right of image
356
+ ctx.font = "10px Arial";
357
+ ctx.fillStyle = "black";
358
+ ctx.fillText(val.label, 22, canvas.height / 2);
359
+
360
+ //set img attributes
361
+ img.src = canvas.toDataURL();
314
362
  img.alt = `Style for ${displayName}`;
315
363
  img.crossOrigin = "anonymous";
316
364
 
@@ -324,95 +372,77 @@ export default {
324
372
  });
325
373
 
326
374
  legendLayers[uid].push(img);
327
- dispatch({
328
- type: "LEGEND_LAYERS_UPDATED",
329
- payload: {
330
- legendLayers: legendLayers,
331
- loading: false,
332
- },
333
- });
334
- }
335
- //____________________________________________________________________________________________________________________________________
336
- else if (
337
- drawingInfo.renderer.type === "uniqueValue" &&
338
- drawingInfo.renderer.uniqueValueInfos
339
- ) {
340
- // Compare
341
- drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
342
- let img = new Image();
343
- console.log(val.value);
344
- if (val.value === "BOEM") {
345
- }
346
-
347
- const fillColor = val.symbol.color;
348
- const outlineColor =
349
- val.symbol.outline && val.symbol.outline.color
350
- ? val.symbol.outline.color
351
- : fillColor;
352
-
353
- let canvas = document.createElement("canvas");
354
- let ctx = canvas.getContext("2d");
355
- const labelWidth = Number(ctx.measureText(val.label).width);
356
-
357
- //set canvas width & height
358
- canvas.width = 20 + labelWidth + 4;
359
- canvas.height = 20;
360
-
361
- //store width & height for larger canvas calculation
362
- legendCanvases[uid].widths.push(canvas.width);
363
- legendCanvases[uid].heights.push(canvas.height);
364
-
365
- // Draw polygon
366
- ctx.beginPath();
367
- ctx.lineWidth = "2";
368
- ctx.strokeStyle = `rgba(${outlineColor.join()})`;
369
- ctx.rect(0, 0, 20, 20);
370
- ctx.stroke();
371
- ctx.fillStyle = `rgba(${fillColor.join()})`;
372
- ctx.fillRect(1, 1, 18, 18);
373
-
374
- //add label to the right of image
375
- ctx.font = "10px Arial";
376
- ctx.fillStyle = "black";
377
- ctx.fillText(val.label, 22, canvas.height / 2);
378
-
379
- //set img attributes
380
- img.src = canvas.toDataURL();
381
- img.alt = `Style for ${displayName}`;
382
- img.crossOrigin = "anonymous";
375
+ });
376
+ dispatch({
377
+ type: "LEGEND_LAYERS_UPDATED",
378
+ payload: {
379
+ legendLayers: legendLayers,
380
+ loading: false,
381
+ },
382
+ });
383
+ }
384
+ break;
385
+ case "esriGeometryPolyline":
386
+ if (
387
+ drawingInfo.renderer.symbol &&
388
+ drawingInfo.renderer.symbol.type === "esriSLS" &&
389
+ drawingInfo.renderer.symbol.style === "esriSLSSolid"
390
+ ) {
391
+ let img = new Image();
392
+ let canvas = document.createElement("canvas");
393
+ let ctx = canvas.getContext("2d");
394
+ const lineColor = drawingInfo.renderer.symbol.color;
395
+
396
+ canvas.width = 20;
397
+ canvas.height = 20;
398
+
399
+ //store width & height for larger canvas calculation
400
+ legendCanvases[uid].widths.push(canvas.width);
401
+ legendCanvases[uid].heights.push(canvas.height);
402
+
403
+ // Draw line
404
+ ctx.beginPath();
405
+ ctx.strokeStyle = `rgba(${lineColor.join()})`;
406
+ ctx.moveTo(0, 0);
407
+ ctx.lineTo(20, 20);
408
+ ctx.stroke();
409
+
410
+ //set img attributes
411
+ img.src = canvas.toDataURL(); //set src using data URI from canvas
412
+ img.alt = `Style for ${displayName}`;
413
+ img.crossOrigin = "anonymous";
383
414
 
384
- legendCanvases[uid].canvas.push(canvas);
385
- dispatch({
386
- type: "LEGEND_CANVAS_ADDED",
387
- payload: {
388
- legendCanvases: legendCanvases,
389
- loading: false,
390
- },
391
- });
415
+ legendCanvases[uid].canvas.push(canvas);
416
+ dispatch({
417
+ type: "LEGEND_CANVAS_ADDED",
418
+ payload: {
419
+ legendCanvases: legendCanvases,
420
+ loading: false,
421
+ },
422
+ });
392
423
 
393
- legendLayers[uid].push(img);
394
- });
395
- dispatch({
396
- type: "LEGEND_LAYERS_UPDATED",
397
- payload: {
398
- legendLayers: legendLayers,
399
- loading: false,
400
- },
401
- });
402
- }
403
- break;
404
- case "esriGeometryPolyline":
405
- if (
406
- drawingInfo.renderer.symbol &&
407
- drawingInfo.renderer.symbol.type === "esriSLS" &&
408
- drawingInfo.renderer.symbol.style === "esriSLSSolid"
409
- ) {
424
+ legendLayers[uid].push(img);
425
+ dispatch({
426
+ type: "LEGEND_LAYERS_UPDATED",
427
+ payload: {
428
+ legendLayers: legendLayers,
429
+ loading: false,
430
+ },
431
+ });
432
+ } else if (
433
+ drawingInfo.renderer.type === "uniqueValue" &&
434
+ drawingInfo.renderer.uniqueValueInfos
435
+ ) {
436
+ drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
410
437
  let img = new Image();
438
+
411
439
  let canvas = document.createElement("canvas");
412
440
  let ctx = canvas.getContext("2d");
413
- const lineColor = drawingInfo.renderer.symbol.color;
441
+ const labelWidth = Number(ctx.measureText(val.label).width);
442
+ const lineColor = val.symbol.color;
414
443
 
415
- canvas.width = 20;
444
+ //set canvas width & height
445
+ canvas.width = 20 + labelWidth + 4;
416
446
  canvas.height = 20;
417
447
 
418
448
  //store width & height for larger canvas calculation
@@ -426,8 +456,13 @@ export default {
426
456
  ctx.lineTo(20, 20);
427
457
  ctx.stroke();
428
458
 
459
+ //add label to the right of image
460
+ ctx.font = "10px Arial";
461
+ ctx.fillStyle = "black";
462
+ ctx.fillText(val.label, 22, canvas.height / 2);
463
+
429
464
  //set img attributes
430
- img.src = canvas.toDataURL(); //set src using data URI from canvas
465
+ img.src = canvas.toDataURL();
431
466
  img.alt = `Style for ${displayName}`;
432
467
  img.crossOrigin = "anonymous";
433
468
 
@@ -441,51 +476,41 @@ export default {
441
476
  });
442
477
 
443
478
  legendLayers[uid].push(img);
444
- dispatch({
445
- type: "LEGEND_LAYERS_UPDATED",
446
- payload: {
447
- legendLayers: legendLayers,
448
- loading: false,
449
- },
450
- });
451
- } else if (
452
- drawingInfo.renderer.type === "uniqueValue" &&
453
- drawingInfo.renderer.uniqueValueInfos
454
- ) {
455
- drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
456
- let img = new Image();
457
-
479
+ });
480
+ dispatch({
481
+ type: "LEGEND_LAYERS_UPDATED",
482
+ payload: {
483
+ legendLayers: legendLayers,
484
+ loading: false,
485
+ },
486
+ });
487
+ }
488
+ break;
489
+ case "esriGeometryPoint":
490
+ if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
491
+ let img = new Image();
492
+ img.src = `data:image/png;base64,${data.drawingInfo.renderer.symbol.imageData}`;
493
+ img.addEventListener(
494
+ "load",
495
+ function () {
458
496
  let canvas = document.createElement("canvas");
459
497
  let ctx = canvas.getContext("2d");
460
- const labelWidth = Number(ctx.measureText(val.label).width);
461
- const lineColor = val.symbol.color;
462
498
 
463
- //set canvas width & height
464
- canvas.width = 20 + labelWidth + 4;
465
- canvas.height = 20;
499
+ canvas.width = drawingInfo.renderer.symbol.width;
500
+ canvas.height = drawingInfo.renderer.symbol.height;
466
501
 
467
502
  //store width & height for larger canvas calculation
468
503
  legendCanvases[uid].widths.push(canvas.width);
469
504
  legendCanvases[uid].heights.push(canvas.height);
470
505
 
471
- // Draw line
472
- ctx.beginPath();
473
- ctx.strokeStyle = `rgba(${lineColor.join()})`;
474
- ctx.moveTo(0, 0);
475
- ctx.lineTo(20, 20);
476
- ctx.stroke();
477
-
478
- //add label to the right of image
479
- ctx.font = "10px Arial";
480
- ctx.fillStyle = "black";
481
- ctx.fillText(val.label, 22, canvas.height / 2);
482
-
483
- //set img attributes
484
- img.src = canvas.toDataURL();
485
- img.alt = `Style for ${displayName}`;
486
- img.crossOrigin = "anonymous";
506
+ //set background
507
+ ctx.fillStyle = "white";
508
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
509
+
510
+ ctx.drawImage(img, 0, 0); //add image to canvas
487
511
 
488
512
  legendCanvases[uid].canvas.push(canvas);
513
+
489
514
  dispatch({
490
515
  type: "LEGEND_CANVAS_ADDED",
491
516
  payload: {
@@ -493,72 +518,23 @@ export default {
493
518
  loading: false,
494
519
  },
495
520
  });
496
-
497
- legendLayers[uid].push(img);
498
- });
499
- dispatch({
500
- type: "LEGEND_LAYERS_UPDATED",
501
- payload: {
502
- legendLayers: legendLayers,
503
- loading: false,
504
- },
505
- });
506
- }
507
- break;
508
- case "esriGeometryPoint":
509
- if (
510
- drawingInfo.renderer.symbol &&
511
- drawingInfo.renderer.symbol.type === "esriPMS"
512
- ) {
513
- let img = new Image();
514
- img.src = `data:image/png;base64,${data.drawingInfo.renderer.symbol.imageData}`;
515
- img.addEventListener(
516
- "load",
517
- function () {
518
- let canvas = document.createElement("canvas");
519
- let ctx = canvas.getContext("2d");
520
-
521
- canvas.width = drawingInfo.renderer.symbol.width;
522
- canvas.height = drawingInfo.renderer.symbol.height;
523
-
524
- //store width & height for larger canvas calculation
525
- legendCanvases[uid].widths.push(canvas.width);
526
- legendCanvases[uid].heights.push(canvas.height);
527
-
528
- //set background
529
- ctx.fillStyle = "white";
530
- ctx.fillRect(0, 0, canvas.width, canvas.height);
531
-
532
- ctx.drawImage(img, 0, 0); //add image to canvas
533
-
534
- legendCanvases[uid].canvas.push(canvas);
535
-
536
- dispatch({
537
- type: "LEGEND_CANVAS_ADDED",
538
- payload: {
539
- legendCanvases: legendCanvases,
540
- loading: false,
541
- },
542
- });
543
- },
544
- false
545
- );
546
-
547
- img.alt = `Style for ${displayName}`;
548
- img.crossOrigin = "anonymous";
549
- legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
550
- dispatch({
551
- type: "LEGEND_LAYERS_UPDATED",
552
- payload: {
553
- legendLayers: legendLayers,
554
- loading: false,
555
- },
556
- });
557
- } else if (
558
- drawingInfo.renderer.symbol &&
559
- drawingInfo.renderer.symbol.type === "esriSMS"
560
- ) {
561
- let img = new Image();
521
+ },
522
+ false
523
+ );
524
+
525
+ img.alt = `Style for ${displayName}`;
526
+ img.crossOrigin = "anonymous";
527
+ legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
528
+ dispatch({
529
+ type: "LEGEND_LAYERS_UPDATED",
530
+ payload: {
531
+ legendLayers: legendLayers,
532
+ loading: false,
533
+ },
534
+ });
535
+ } else if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriSMS") {
536
+
537
+ let img = new Image();
562
538
  const outlineColor = drawingInfo.renderer.symbol.outline.color;
563
539
  const outlineWidth = drawingInfo.renderer.symbol.outline.width;
564
540
  const fillColor = drawingInfo.renderer.symbol.color;
@@ -577,7 +553,7 @@ export default {
577
553
  ctx.beginPath();
578
554
  ctx.strokeStyle = `rgba(${outlineColor.join()})`;
579
555
  ctx.lineWidth = outlineWidth;
580
- ctx.arc(size, size, size / 1.5, 0, Math.PI * 2);
556
+ ctx.arc(size, size, size/1.5, 0, Math.PI * 2);
581
557
  ctx.fillStyle = `rgba(${fillColor.join()})`;
582
558
  ctx.fill();
583
559
  ctx.stroke();
@@ -603,164 +579,166 @@ export default {
603
579
  loading: false,
604
580
  },
605
581
  });
606
- }
607
- //___________________________________________________________________________________________________________________________________
608
- else if (drawingInfo.renderer.uniqueValueInfos) {
609
- // let canvas = document.createElement("canvas");
610
- // let ctx = canvas.getContext("2d");
611
- let result = [];
612
- let images = [];
613
- drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
614
- let label = val.label;
615
- let wkCanvas;
616
- let img = new Image();
617
- img.src = `data:image/png;base64,${val.symbol.imageData}`;
618
-
619
- // img.addEventListener(
620
- // "load",
621
- // function () {
622
- let canvas = document.createElement("canvas");
623
- let ctx = canvas.getContext("2d");
624
-
625
- const labelWidth = Number(ctx.measureText(label).width);
626
-
627
- //set canvas width & height
628
- canvas.width = Number(val.symbol.width) + labelWidth + 4;
629
- canvas.height = val.symbol.height;
630
-
631
- //store width & height for larger canvas calculation
632
- // legendCanvases[uid].widths.push(canvas.width);
633
- // legendCanvases[uid].heights.push(canvas.height);
634
-
635
- //set background
636
- ctx.fillStyle = "white";
637
- ctx.fillRect(0, 0, canvas.width, canvas.height);
638
- // // ctx.putImageData(val.symbol.imageData, 0,0)
639
-
640
- ctx.drawImage(img, 0, 0); //add image to canvas
641
-
642
- // //add label to the right of image
643
- // ctx.font = "10px Arial";
644
- // ctx.fillStyle = "black";
645
-
646
- // ctx.fillText(label, canvas.width + 2, canvas.height / 2);
647
-
648
- // legendCanvases[uid].canvas.push(canvas);
649
-
650
- // dispatch({
651
- // type: "LEGEND_CANVAS_ADDED",
652
- // payload: {
653
- // legendCanvases: legendCanvases,
654
- // loading: false,
655
- // },
656
- // });
657
- // result.push(canvas)
582
+ }
583
+ //___________________________________________________________________________________________________________________________________
584
+ else if (drawingInfo.renderer.uniqueValueInfos){
585
+ // let canvas = document.createElement("canvas");
586
+ // let ctx = canvas.getContext("2d");
587
+ let result = []
588
+ let images = []
589
+ drawingInfo.renderer.uniqueValueInfos.forEach((val) => {
590
+
591
+ let label = val.label
592
+ let wkCanvas;
593
+ let img = new Image();
594
+ img.src = `data:image/png;base64,${val.symbol.imageData}`;
595
+
596
+ // img.addEventListener(
597
+ // "load",
598
+ // function () {
599
+ let canvas = document.createElement("canvas");
600
+ let ctx = canvas.getContext("2d")
601
+
602
+ const labelWidth = Number(ctx.measureText(label).width);
603
+
604
+ //set canvas width & height
605
+ canvas.width = Number(val.symbol.width) + labelWidth + 4;
606
+ canvas.height = val.symbol.height;
607
+
608
+ //store width & height for larger canvas calculation
609
+ // legendCanvases[uid].widths.push(canvas.width);
610
+ // legendCanvases[uid].heights.push(canvas.height);
611
+
612
+ //set background
613
+ ctx.fillStyle = "white";
614
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
615
+ // // ctx.putImageData(val.symbol.imageData, 0,0)
616
+
617
+ ctx.drawImage(img, 0, 0); //add image to canvas
618
+
619
+ // //add label to the right of image
620
+ // ctx.font = "10px Arial";
621
+ // ctx.fillStyle = "black";
622
+
623
+ // ctx.fillText(label, canvas.width + 2, canvas.height / 2);
624
+
625
+ // legendCanvases[uid].canvas.push(canvas);
626
+
627
+ // dispatch({
628
+ // type: "LEGEND_CANVAS_ADDED",
629
+ // payload: {
630
+ // legendCanvases: legendCanvases,
631
+ // loading: false,
632
+ // },
633
+ // });
634
+ // result.push(canvas)
658
635
  // },
659
636
  // false
660
- // );
661
- // img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
662
- // img.src = canvas.toDataURL()
663
-
664
- img.alt = `Style for ${label}`;
665
- img.crossOrigin = "anonymous";
666
- img.title = label;
667
- // legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
668
- // images.push(img)
669
-
670
- // dispatch({
671
- // type: "LEGEND_LAYERS_UPDATED",
672
- // payload: {
673
- // legendLayers: legendLayers,
674
- // },
675
- // });
676
- result.push({
677
- canvas: canvas,
678
- image: img,
679
- });
637
+ // );
638
+ // img.src = `data:${val.symbol.url};base64,${val.symbol.imageData}`
639
+ // img.src = canvas.toDataURL()
640
+
641
+ img.alt = `Style for ${label}`;
642
+ img.crossOrigin = "anonymous";
643
+ img.title = label;
644
+ // legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
645
+ // images.push(img)
646
+
647
+ // dispatch({
648
+ // type: "LEGEND_LAYERS_UPDATED",
649
+ // payload: {
650
+ // legendLayers: legendLayers,
651
+ // },
652
+ // });
653
+ result.push({
654
+ canvas: canvas,
655
+ image: img,
680
656
  });
681
- result.forEach((item) => {
682
- item.image.alt = `Style for ${lyr.displayName}`;
683
- legendCanvases[lyr.uid].widths.push(item.canvas.width);
684
- legendCanvases[lyr.uid].heights.push(item.canvas.height);
685
- legendCanvases[lyr.uid].canvas.push(item.canvas);
686
- legendLayers[lyr.uid].push(item.image);
687
657
 
688
- dispatch({
689
- type: "LEGEND_CANVAS_ADDED",
690
- payload: {
691
- legendCanvases: legendCanvases,
692
- loading: false,
693
- },
694
- });
658
+ });
659
+ result.forEach((item) => {
660
+ item.image.alt = `Style for ${lyr.displayName}`;
661
+ legendCanvases[lyr.uid].widths.push(item.canvas.width);
662
+ legendCanvases[lyr.uid].heights.push(item.canvas.height);
663
+ legendCanvases[lyr.uid].canvas.push(item.canvas);
664
+ legendLayers[lyr.uid].push(item.image);
665
+
666
+ dispatch({
667
+ type: "LEGEND_CANVAS_ADDED",
668
+ payload: {
669
+ legendCanvases: legendCanvases,
670
+ loading: false,
671
+ },
695
672
  });
696
- } else if (drawingInfo.renderer.classBreakInfos) {
697
- drawingInfo.renderer.classBreakInfos.forEach((val) => {
698
- let img = new Image();
699
- const outlineColor = val.symbol.outline.color;
700
- const outlineWidth = val.symbol.outline.width;
701
- const fillColor = val.symbol.color;
702
- const size = val.symbol.size;
703
- let canvas = document.createElement("canvas");
704
- let ctx = canvas.getContext("2d");
673
+ });
674
+ }
675
+
676
+ else if (drawingInfo.renderer.classBreakInfos){
677
+ drawingInfo.renderer.classBreakInfos.forEach((val) => {
678
+ let img = new Image();
679
+ const outlineColor = val.symbol.outline.color;
680
+ const outlineWidth = val.symbol.outline.width;
681
+ const fillColor = val.symbol.color;
682
+ const size = val.symbol.size;
683
+ let canvas = document.createElement("canvas");
684
+ let ctx = canvas.getContext("2d");
705
685
 
706
- canvas.width = 20 * 2.5;
707
- canvas.height = 20;
686
+ canvas.width = 20 * 2.5;
687
+ canvas.height = 20;
708
688
 
709
- legendCanvases[uid].widths.push(canvas.width);
710
- legendCanvases[uid].heights.push(canvas.height);
689
+ legendCanvases[uid].widths.push(canvas.width);
690
+ legendCanvases[uid].heights.push(canvas.height);
691
+
692
+ //text
693
+ ctx.font = "11px Arial";
694
+ ctx.fillText(val.label ,size * 3 , size * 2 , 30);
711
695
 
712
- //text
713
- ctx.font = "11px Arial";
714
- ctx.fillText(val.label, size * 3, size * 2, 30);
715
-
716
- // circle
717
- ctx.beginPath();
718
- ctx.strokeStyle = `rgba(${outlineColor.join()})`;
719
- ctx.lineWidth = outlineWidth;
720
- ctx.arc(size, size * 1.5, size / 1.5, 0, Math.PI * 2);
721
- ctx.fillStyle = `rgba(${fillColor.join()})`;
722
- ctx.fill();
723
- ctx.stroke();
724
-
725
- img.src = canvas.toDataURL(); //set src using data URI from canvas
726
- img.alt = `Style for ${displayName}`;
727
- img.crossOrigin = "anonymous";
696
+ // circle
697
+ ctx.beginPath();
698
+ ctx.strokeStyle = `rgba(${outlineColor.join()})`;
699
+ ctx.lineWidth = outlineWidth;
700
+ ctx.arc(size, size * 1.5, size/1.5, 0, Math.PI * 2);
701
+ ctx.fillStyle = `rgba(${fillColor.join()})`;
702
+ ctx.fill();
703
+ ctx.stroke();
728
704
 
729
- legendCanvases[uid].canvas.push(canvas);
730
- dispatch({
731
- type: "LEGEND_CANVAS_ADDED",
732
- payload: {
733
- legendCanvases: legendCanvases,
734
- loading: false,
735
- },
736
- });
705
+ img.src = canvas.toDataURL(); //set src using data URI from canvas
706
+ img.alt = `Style for ${displayName}`;
707
+ img.crossOrigin = "anonymous";
737
708
 
738
- legendLayers[uid].push(img);
739
- dispatch({
740
- type: "LEGEND_LAYERS_UPDATED",
741
- payload: {
742
- legendLayers: legendLayers,
743
- loading: false,
744
- },
745
- });
709
+ legendCanvases[uid].canvas.push(canvas);
710
+ dispatch({
711
+ type: "LEGEND_CANVAS_ADDED",
712
+ payload: {
713
+ legendCanvases: legendCanvases,
714
+ loading: false,
715
+ },
746
716
  });
747
- } else {
748
- legendLayers[uid] = ["Legend not available!"];
717
+
718
+ legendLayers[uid].push(img);
749
719
  dispatch({
750
- type: "LEGEND_LAYERS_UPDATE_ERROR",
720
+ type: "LEGEND_LAYERS_UPDATED",
751
721
  payload: {
752
722
  legendLayers: legendLayers,
753
- legendCanvases: legendCanvases,
754
723
  loading: false,
755
724
  },
756
725
  });
757
- }
758
- break;
759
- case "esriGeometryMultipoint":
760
- if (
761
- drawingInfo.renderer.symbol &&
762
- drawingInfo.renderer.symbol.type === "esriPMS"
763
- ) {
726
+ });
727
+ }
728
+ else {
729
+ legendLayers[uid] = ["Legend not available!"];
730
+ dispatch({
731
+ type: "LEGEND_LAYERS_UPDATE_ERROR",
732
+ payload: {
733
+ legendLayers: legendLayers,
734
+ legendCanvases: legendCanvases,
735
+ loading: false,
736
+ },
737
+ });
738
+ }
739
+ break;
740
+ case "esriGeometryMultipoint" :
741
+ if (drawingInfo.renderer.symbol && drawingInfo.renderer.symbol.type === "esriPMS") {
764
742
  let img = new Image();
765
743
  img.src = `data:image/png;base64,${data.drawingInfo.renderer.symbol.imageData}`;
766
744
  img.addEventListener(
@@ -768,22 +746,22 @@ export default {
768
746
  function () {
769
747
  let canvas = document.createElement("canvas");
770
748
  let ctx = canvas.getContext("2d");
771
-
749
+
772
750
  canvas.width = drawingInfo.renderer.symbol.width;
773
751
  canvas.height = drawingInfo.renderer.symbol.height;
774
-
752
+
775
753
  //store width & height for larger canvas calculation
776
754
  legendCanvases[uid].widths.push(canvas.width);
777
755
  legendCanvases[uid].heights.push(canvas.height);
778
-
756
+
779
757
  //set background
780
758
  ctx.fillStyle = "white";
781
759
  ctx.fillRect(0, 0, canvas.width, canvas.height);
782
-
760
+
783
761
  ctx.drawImage(img, 0, 0); //add image to canvas
784
-
762
+
785
763
  legendCanvases[uid].canvas.push(canvas);
786
-
764
+
787
765
  dispatch({
788
766
  type: "LEGEND_CANVAS_ADDED",
789
767
  payload: {
@@ -794,7 +772,7 @@ export default {
794
772
  },
795
773
  false
796
774
  );
797
-
775
+
798
776
  img.alt = `Style for ${displayName}`;
799
777
  img.crossOrigin = "anonymous";
800
778
  legendLayers[uid] = [img]; //TODO: Update to possibly push multiple images into array
@@ -808,54 +786,106 @@ export default {
808
786
  }
809
787
  break;
810
788
 
811
- default:
812
- break;
813
- }
814
- },
815
- doFetchLegendImages:
816
- () =>
817
- ({ dispatch, store }) => {
818
- dispatch({
819
- type: "LEGEND_FETCH_START",
820
- payload: {
821
- _shouldGetLegends: false,
822
- loading: true,
823
- },
824
- });
789
+ default:
790
+ break;
791
+ }
792
+ },
793
+ doFetchLegendImages: () => ({ dispatch, store }) => {
794
+ dispatch({
795
+ type: "LEGEND_FETCH_START",
796
+ payload: {
797
+ _shouldGetLegends: false,
798
+ loading: true,
799
+ },
800
+ });
801
+
802
+ const visibleLayers = store.selectVisibleLayers();
803
+ let legendLayers = store.selectLegendLayers();
804
+ let legendCanvases = store.selectLegendCanvases();
805
+ let queuedLayers = [];
806
+
807
+ visibleLayers.forEach((layer) => {
808
+ //check if layer already added legendLayers object.
809
+ if (!legendLayers.hasOwnProperty(layer.uid)) {
810
+ switch (layer.type) {
811
+ case "ArcGIS":
812
+ case "ArcGISImage":
813
+ case "EsriFeatureService":
814
+ if(layer.styleFn && layer.type === "EsriFeatureService") {
815
+ legendCanvases[layer.uid] = {
816
+ displayName: layer.displayName,
817
+ layerDescription: layer.layerDescription,
818
+ attributions: layer.attributions,
819
+ canvas: [],
820
+ widths: [],
821
+ heights: [],
822
+ };
823
+ legendLayers[layer.uid] = [];
824
+
825
+ //Get canvases and images for legend
826
+ let legendFunction = eval(layer.styleFn)[1];
827
+ let legendItems = legendFunction();
828
+
829
+ legendItems.forEach((item) => {
830
+ item.image.alt = `Style for ${layer.displayName}`;
831
+ legendCanvases[layer.uid].widths.push(item.canvas.width);
832
+ legendCanvases[layer.uid].heights.push(item.canvas.height);
833
+ legendCanvases[layer.uid].canvas.push(item.canvas);
834
+ legendLayers[layer.uid].push(item.image);
835
+
836
+ dispatch({
837
+ type: "LEGEND_CANVAS_ADDED",
838
+ payload: {
839
+ legendCanvases: legendCanvases,
840
+ loading: false,
841
+ },
842
+ });
843
+ });
844
+
845
+ dispatch({
846
+ type: "LEGEND_LAYERS_UPDATED",
847
+ payload: {
848
+ legendLayers: legendLayers,
849
+ },
850
+ });
851
+ }
852
+ else {
853
+ queuedLayers.push(layer);
854
+ }
855
+ break;
856
+ case "WMS":
857
+ legendCanvases[layer.uid] = {
858
+ displayName: layer.displayName,
859
+ attributions: layer.attributions,
860
+ layerDescription: layer.layerDescription,
861
+ canvas: [],
862
+ widths: [],
863
+ heights: [],
864
+ };
865
+ let activeLayers = layer.layerList.replace(/ /g, "").split(",");
866
+ const images = activeLayers.map((lyr, i) => {
867
+ let img = new Image();
868
+ img.addEventListener(
869
+ "load",
870
+ function () {
871
+ let canvas = document.createElement("canvas");
872
+ let ctx = canvas.getContext("2d");
825
873
 
826
- const visibleLayers = store.selectVisibleLayers();
827
- let legendLayers = store.selectLegendLayers();
828
- let legendCanvases = store.selectLegendCanvases();
829
- let queuedLayers = [];
830
-
831
- visibleLayers.forEach((layer) => {
832
- //check if layer already added legendLayers object.
833
- if (!legendLayers.hasOwnProperty(layer.uid)) {
834
- switch (layer.type) {
835
- case "ArcGIS":
836
- case "ArcGISImage":
837
- case "EsriFeatureService":
838
- if (layer.styleFn && layer.type === "EsriFeatureService") {
839
- legendCanvases[layer.uid] = {
840
- displayName: layer.displayName,
841
- layerDescription: layer.layerDescription,
842
- attributions: layer.attributions,
843
- canvas: [],
844
- widths: [],
845
- heights: [],
846
- };
847
- legendLayers[layer.uid] = [];
848
-
849
- //Get canvases and images for legend
850
- let legendFunction = eval(layer.styleFn)[1];
851
- let legendItems = legendFunction();
852
-
853
- legendItems.forEach((item) => {
854
- item.image.alt = `Style for ${layer.displayName}`;
855
- legendCanvases[layer.uid].widths.push(item.canvas.width);
856
- legendCanvases[layer.uid].heights.push(item.canvas.height);
857
- legendCanvases[layer.uid].canvas.push(item.canvas);
858
- legendLayers[layer.uid].push(item.image);
874
+ //set canvas width & height
875
+ canvas.width = Number(img.width) + 2;
876
+ canvas.height = img.height;
877
+
878
+ //store width & height for larger canvas calculation
879
+ legendCanvases[layer.uid].widths.push(canvas.width);
880
+ legendCanvases[layer.uid].heights.push(canvas.height);
881
+
882
+ //set background
883
+ ctx.fillStyle = "white";
884
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
885
+
886
+ ctx.drawImage(img, 0, 0); //add image to canvas
887
+
888
+ legendCanvases[layer.uid].canvas.push(canvas);
859
889
 
860
890
  dispatch({
861
891
  type: "LEGEND_CANVAS_ADDED",
@@ -864,170 +894,117 @@ export default {
864
894
  loading: false,
865
895
  },
866
896
  });
867
- });
868
-
869
- dispatch({
870
- type: "LEGEND_LAYERS_UPDATED",
871
- payload: {
872
- legendLayers: legendLayers,
873
- },
874
- });
897
+ },
898
+ false
899
+ );
900
+ let legendParams = `service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png&sld_version=1.1.0&layer=${lyr}`;
901
+ if (layer.url.indexOf(".map") !== -1) {
902
+ img.src = `${layer.url}&${legendParams}`;
875
903
  } else {
876
- queuedLayers.push(layer);
904
+ img.src = `${layer.url}?${legendParams}`;
877
905
  }
878
- break;
879
- case "WMS":
880
- legendCanvases[layer.uid] = {
881
- displayName: layer.displayName,
882
- attributions: layer.attributions,
883
- layerDescription: layer.layerDescription,
884
- canvas: [],
885
- widths: [],
886
- heights: [],
887
- };
888
- let activeLayers = layer.layerList.replace(/ /g, "").split(",");
889
- const images = activeLayers.map((lyr, i) => {
890
- let img = new Image();
891
- img.addEventListener(
892
- "load",
893
- function () {
894
- let canvas = document.createElement("canvas");
895
- let ctx = canvas.getContext("2d");
896
-
897
- //set canvas width & height
898
- canvas.width = Number(img.width) + 2;
899
- canvas.height = img.height;
900
-
901
- //store width & height for larger canvas calculation
902
- legendCanvases[layer.uid].widths.push(canvas.width);
903
- legendCanvases[layer.uid].heights.push(canvas.height);
904
-
905
- //set background
906
- ctx.fillStyle = "white";
907
- ctx.fillRect(0, 0, canvas.width, canvas.height);
908
-
909
- ctx.drawImage(img, 0, 0); //add image to canvas
910
-
911
- legendCanvases[layer.uid].canvas.push(canvas);
912
-
913
- dispatch({
914
- type: "LEGEND_CANVAS_ADDED",
915
- payload: {
916
- legendCanvases: legendCanvases,
917
- loading: false,
918
- },
919
- });
920
- },
921
- false
922
- );
923
- let legendParams = `service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png&sld_version=1.1.0&layer=${lyr}`;
924
- if (layer.url.indexOf(".map") !== -1) {
925
- img.src = `${layer.url}&${legendParams}`;
926
- } else {
927
- img.src = `${layer.url}?${legendParams}`;
928
- }
929
-
930
- img.alt = `Style for ${layer.displayName}`;
931
- img.crossOrigin = "anonymous";
932
-
933
- return img;
934
- });
935
- legendLayers[layer.uid] = images;
936
906
 
907
+ img.alt = `Style for ${layer.displayName}`;
908
+ img.crossOrigin = "anonymous";
909
+
910
+ return img;
911
+ });
912
+ legendLayers[layer.uid] = images;
913
+
914
+ dispatch({
915
+ type: "LEGEND_LAYERS_UPDATED",
916
+ payload: {
917
+ legendLayers: legendLayers,
918
+ },
919
+ });
920
+ break;
921
+ case "LocalVector":
922
+ default:
923
+ legendCanvases[layer.uid] = {
924
+ displayName: layer.displayName,
925
+ layerDescription: layer.layerDescription,
926
+ attributions: layer.attributions,
927
+ canvas: [],
928
+ widths: [],
929
+ heights: [],
930
+ };
931
+ if (layer.src) {
932
+ let img = new Image();
933
+ img.addEventListener(
934
+ "load",
935
+ function () {
936
+ let canvas = document.createElement("canvas");
937
+ let ctx = canvas.getContext("2d");
938
+
939
+ //set canvas width & height
940
+ canvas.width = Number(img.width) + 2;
941
+ canvas.height = img.height;
942
+
943
+ //store width & height for larger canvas calculation
944
+ legendCanvases[layer.uid].widths.push(canvas.width);
945
+ legendCanvases[layer.uid].heights.push(canvas.height);
946
+
947
+ //set background
948
+ ctx.fillStyle = "white";
949
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
950
+
951
+ ctx.drawImage(img, 0, 0); //add image to canvas
952
+
953
+ legendCanvases[layer.uid].canvas.push(canvas);
954
+
955
+ dispatch({
956
+ type: "LEGEND_CANVAS_ADDED",
957
+ payload: {
958
+ legendCanvases: legendCanvases,
959
+ loading: false,
960
+ },
961
+ });
962
+ },
963
+ false
964
+ );
965
+ img.src = layer.src;
966
+ img.alt = `Style for ${layer.displayName}`;
967
+ img.crossOrigin = "anonymous";
968
+ legendLayers[layer.uid] = [img];
937
969
  dispatch({
938
970
  type: "LEGEND_LAYERS_UPDATED",
939
971
  payload: {
940
972
  legendLayers: legendLayers,
941
973
  },
942
974
  });
943
- break;
944
- case "LocalVector":
945
- default:
946
- legendCanvases[layer.uid] = {
947
- displayName: layer.displayName,
948
- layerDescription: layer.layerDescription,
949
- attributions: layer.attributions,
950
- canvas: [],
951
- widths: [],
952
- heights: [],
953
- };
954
- if (layer.src) {
955
- let img = new Image();
956
- img.addEventListener(
957
- "load",
958
- function () {
959
- let canvas = document.createElement("canvas");
960
- let ctx = canvas.getContext("2d");
961
-
962
- //set canvas width & height
963
- canvas.width = Number(img.width) + 2;
964
- canvas.height = img.height;
965
-
966
- //store width & height for larger canvas calculation
967
- legendCanvases[layer.uid].widths.push(canvas.width);
968
- legendCanvases[layer.uid].heights.push(canvas.height);
969
-
970
- //set background
971
- ctx.fillStyle = "white";
972
- ctx.fillRect(0, 0, canvas.width, canvas.height);
973
-
974
- ctx.drawImage(img, 0, 0); //add image to canvas
975
-
976
- legendCanvases[layer.uid].canvas.push(canvas);
977
-
978
- dispatch({
979
- type: "LEGEND_CANVAS_ADDED",
980
- payload: {
981
- legendCanvases: legendCanvases,
982
- loading: false,
983
- },
984
- });
985
- },
986
- false
987
- );
988
- img.src = layer.src;
989
- img.alt = `Style for ${layer.displayName}`;
990
- img.crossOrigin = "anonymous";
991
- legendLayers[layer.uid] = [img];
992
- dispatch({
993
- type: "LEGEND_LAYERS_UPDATED",
994
- payload: {
995
- legendLayers: legendLayers,
996
- },
997
- });
998
- } else {
999
- legendLayers[layer.uid] = ["Legend not available!"];
1000
- dispatch({
1001
- type: "LEGEND_LAYERS_UPDATE_ERROR",
1002
- payload: {
1003
- legendLayers: legendLayers,
1004
- legendCanvases: legendCanvases,
1005
- loading: false,
1006
- },
1007
- });
1008
- }
1009
- break;
1010
- }
1011
- } else {
1012
- dispatch({
1013
- type: "LEGEND_LOADED",
1014
- payload: {
1015
- loading: false,
1016
- },
1017
- });
975
+ } else {
976
+ legendLayers[layer.uid] = ["Legend not available!"];
977
+ dispatch({
978
+ type: "LEGEND_LAYERS_UPDATE_ERROR",
979
+ payload: {
980
+ legendLayers: legendLayers,
981
+ legendCanvases: legendCanvases,
982
+ loading: false,
983
+ },
984
+ });
985
+ }
986
+ break;
1018
987
  }
1019
- });
1020
-
1021
- if (queuedLayers.length) store.doFetchLegendInfo(queuedLayers);
1022
- if (!visibleLayers.length) {
988
+ } else {
1023
989
  dispatch({
1024
- type: "LEGEND_HAS_NO_VISIBLE_LAYERS",
990
+ type: "LEGEND_LOADED",
1025
991
  payload: {
1026
992
  loading: false,
1027
993
  },
1028
994
  });
1029
995
  }
1030
- },
996
+ });
997
+
998
+ if (queuedLayers.length) store.doFetchLegendInfo(queuedLayers);
999
+ if (!visibleLayers.length) {
1000
+ dispatch({
1001
+ type: "LEGEND_HAS_NO_VISIBLE_LAYERS",
1002
+ payload: {
1003
+ loading: false,
1004
+ },
1005
+ });
1006
+ }
1007
+ },
1031
1008
  selectLegendLayers: (state) => {
1032
1009
  return state.legend.legendLayers;
1033
1010
  },