@macallumharvey/first-test-wet 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. package/dist/WetButton.d.ts +9 -0
  2. package/dist/WetModal.d.ts +6 -0
  3. package/dist/first-test-wet.cjs.development.js +26 -0
  4. package/dist/first-test-wet.cjs.development.js.map +1 -1
  5. package/dist/first-test-wet.cjs.production.min.js +1 -1
  6. package/dist/first-test-wet.cjs.production.min.js.map +1 -1
  7. package/dist/first-test-wet.esm.js +26 -1
  8. package/dist/first-test-wet.esm.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/package.json +1 -1
  11. package/src/WetButton.tsx +19 -0
  12. package/src/WetModal.tsx +25 -0
  13. package/src/index.tsx +2 -2
  14. package/src/wet-boew-cdn-4.0.81.1/Licence-fr.txt +1 -0
  15. package/src/wet-boew-cdn-4.0.81.1/License-en.txt +1 -0
  16. package/src/wet-boew-cdn-4.0.81.1/assets/cloud-popup-relative.png +0 -0
  17. package/src/wet-boew-cdn-4.0.81.1/assets/fd-slider-sprite.png +0 -0
  18. package/src/wet-boew-cdn-4.0.81.1/assets/loading.png +0 -0
  19. package/src/wet-boew-cdn-4.0.81.1/assets/mediacontrols.html +33 -0
  20. package/src/wet-boew-cdn-4.0.81.1/assets/sprites_share.png +0 -0
  21. package/src/wet-boew-cdn-4.0.81.1/assets/zoom-minus-mini.png +0 -0
  22. package/src/wet-boew-cdn-4.0.81.1/assets/zoom-plus-mini.png +0 -0
  23. package/src/wet-boew-cdn-4.0.81.1/assets/zoom-world-mini.png +0 -0
  24. package/src/wet-boew-cdn-4.0.81.1/css/noscript.css +112 -0
  25. package/src/wet-boew-cdn-4.0.81.1/css/noscript.min.css +6 -0
  26. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/datalist.css +32 -0
  27. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/datalist.min.css +1 -0
  28. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/datepicker.css +47 -0
  29. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/datepicker.min.css +1 -0
  30. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/details.css +28 -0
  31. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/details.min.css +1 -0
  32. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/mathml.css +16 -0
  33. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/mathml.min.css +1 -0
  34. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/meter.css +24 -0
  35. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/meter.min.css +1 -0
  36. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/progress.css +8 -0
  37. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/progress.min.css +1 -0
  38. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/slider.css +229 -0
  39. package/src/wet-boew-cdn-4.0.81.1/css/polyfills/slider.min.css +1 -0
  40. package/src/wet-boew-cdn-4.0.81.1/fonts/glyphicons-halflings-regular.eot +0 -0
  41. package/src/wet-boew-cdn-4.0.81.1/fonts/glyphicons-halflings-regular.svg +288 -0
  42. package/src/wet-boew-cdn-4.0.81.1/fonts/glyphicons-halflings-regular.ttf +0 -0
  43. package/src/wet-boew-cdn-4.0.81.1/fonts/glyphicons-halflings-regular.woff +0 -0
  44. package/src/wet-boew-cdn-4.0.81.1/fonts/glyphicons-halflings-regular.woff2 +0 -0
  45. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/mml-chtml.js +1 -0
  46. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff +0 -0
  47. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff +0 -0
  48. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff +0 -0
  49. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff +0 -0
  50. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff +0 -0
  51. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff +0 -0
  52. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff +0 -0
  53. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff +0 -0
  54. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff +0 -0
  55. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff +0 -0
  56. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff +0 -0
  57. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff +0 -0
  58. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff +0 -0
  59. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff +0 -0
  60. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff +0 -0
  61. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff +0 -0
  62. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff +0 -0
  63. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff +0 -0
  64. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff +0 -0
  65. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff +0 -0
  66. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff +0 -0
  67. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff +0 -0
  68. package/src/wet-boew-cdn-4.0.81.1/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Zero.woff +0 -0
  69. package/src/wet-boew-cdn-4.0.81.1/js/deps/additional-methods.js +1512 -0
  70. package/src/wet-boew-cdn-4.0.81.1/js/deps/additional-methods.min.js +9 -0
  71. package/src/wet-boew-cdn-4.0.81.1/js/deps/geomap-lib.js +3770 -0
  72. package/src/wet-boew-cdn-4.0.81.1/js/deps/geomap-lib.min.js +1 -0
  73. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.dataTables.js +15733 -0
  74. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.dataTables.min.js +4 -0
  75. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.canvas.js +345 -0
  76. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.canvas.min.js +1 -0
  77. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.js +3168 -0
  78. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.min.js +1 -0
  79. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.orderBars.js +282 -0
  80. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.orderBars.min.js +1 -0
  81. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.pie.js +820 -0
  82. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.flot.pie.min.js +1 -0
  83. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.magnific-popup.js +2061 -0
  84. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.magnific-popup.min.js +4 -0
  85. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.validate.js +1661 -0
  86. package/src/wet-boew-cdn-4.0.81.1/js/deps/jquery.validate.min.js +9 -0
  87. package/src/wet-boew-cdn-4.0.81.1/js/deps/json-patch.js +315 -0
  88. package/src/wet-boew-cdn-4.0.81.1/js/deps/json-patch.min.js +1 -0
  89. package/src/wet-boew-cdn-4.0.81.1/js/deps/jsonpointer.js +349 -0
  90. package/src/wet-boew-cdn-4.0.81.1/js/deps/jsonpointer.min.js +1 -0
  91. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-apollo.js +53 -0
  92. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-apollo.min.js +1 -0
  93. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-basic.js +49 -0
  94. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-basic.min.js +1 -0
  95. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-clj.js +64 -0
  96. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-clj.min.js +1 -0
  97. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-css.js +160 -0
  98. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-css.min.js +1 -0
  99. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-dart.js +92 -0
  100. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-dart.min.js +1 -0
  101. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-erlang.js +94 -0
  102. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-erlang.min.js +1 -0
  103. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-go.js +59 -0
  104. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-go.min.js +1 -0
  105. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-hs.js +102 -0
  106. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-hs.min.js +1 -0
  107. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-lasso.js +67 -0
  108. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-lasso.min.js +1 -0
  109. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-lisp.js +95 -0
  110. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-lisp.min.js +1 -0
  111. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-llvm.js +63 -0
  112. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-llvm.min.js +1 -0
  113. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-logtalk.js +50 -0
  114. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-logtalk.min.js +1 -0
  115. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-lua.js +60 -0
  116. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-lua.min.js +1 -0
  117. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-matlab.js +183 -0
  118. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-matlab.min.js +1 -0
  119. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-ml.js +57 -0
  120. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-ml.min.js +1 -0
  121. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-mumps.js +140 -0
  122. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-mumps.min.js +1 -0
  123. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-n.js +67 -0
  124. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-n.min.js +1 -0
  125. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-pascal.js +49 -0
  126. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-pascal.min.js +1 -0
  127. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-proto.js +37 -0
  128. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-proto.min.js +1 -0
  129. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-r.js +59 -0
  130. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-r.min.js +1 -0
  131. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-rd.js +50 -0
  132. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-rd.min.js +1 -0
  133. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-rust.js +81 -0
  134. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-rust.min.js +1 -0
  135. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-scala.js +56 -0
  136. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-scala.min.js +1 -0
  137. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-sql.js +59 -0
  138. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-sql.min.js +1 -0
  139. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-swift.js +60 -0
  140. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-swift.min.js +1 -0
  141. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-tcl.js +63 -0
  142. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-tcl.min.js +1 -0
  143. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-tex.js +49 -0
  144. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-tex.min.js +1 -0
  145. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-vb.js +67 -0
  146. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-vb.min.js +1 -0
  147. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-vhdl.js +51 -0
  148. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-vhdl.min.js +1 -0
  149. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-wiki.js +55 -0
  150. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-wiki.min.js +1 -0
  151. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-xq.js +71 -0
  152. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-xq.min.js +1 -0
  153. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-yaml.js +45 -0
  154. package/src/wet-boew-cdn-4.0.81.1/js/deps/lang-yaml.min.js +1 -0
  155. package/src/wet-boew-cdn-4.0.81.1/js/deps/ol.js +1008 -0
  156. package/src/wet-boew-cdn-4.0.81.1/js/deps/ol.min.js +1 -0
  157. package/src/wet-boew-cdn-4.0.81.1/js/deps/prettify.js +1742 -0
  158. package/src/wet-boew-cdn-4.0.81.1/js/deps/prettify.min.js +1 -0
  159. package/src/wet-boew-cdn-4.0.81.1/js/deps/proj4.js +3 -0
  160. package/src/wet-boew-cdn-4.0.81.1/js/deps/proj4.min.js +1 -0
  161. package/src/wet-boew-cdn-4.0.81.1/js/deps/run_prettify.js +1998 -0
  162. package/src/wet-boew-cdn-4.0.81.1/js/deps/run_prettify.min.js +1 -0
  163. package/src/wet-boew-cdn-4.0.81.1/js/deps/tableparser.js +2216 -0
  164. package/src/wet-boew-cdn-4.0.81.1/js/deps/tableparser.min.js +1 -0
  165. package/src/wet-boew-cdn-4.0.81.1/js/deps/unorm.js +452 -0
  166. package/src/wet-boew-cdn-4.0.81.1/js/deps/unorm.min.js +1 -0
  167. package/src/wet-boew-cdn-4.0.81.1/js/i18n/af.js +254 -0
  168. package/src/wet-boew-cdn-4.0.81.1/js/i18n/af.min.js +7 -0
  169. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ar.js +293 -0
  170. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ar.min.js +7 -0
  171. package/src/wet-boew-cdn-4.0.81.1/js/i18n/bg.js +293 -0
  172. package/src/wet-boew-cdn-4.0.81.1/js/i18n/bg.min.js +7 -0
  173. package/src/wet-boew-cdn-4.0.81.1/js/i18n/cs.js +294 -0
  174. package/src/wet-boew-cdn-4.0.81.1/js/i18n/cs.min.js +7 -0
  175. package/src/wet-boew-cdn-4.0.81.1/js/i18n/de.js +363 -0
  176. package/src/wet-boew-cdn-4.0.81.1/js/i18n/de.min.js +7 -0
  177. package/src/wet-boew-cdn-4.0.81.1/js/i18n/el.js +293 -0
  178. package/src/wet-boew-cdn-4.0.81.1/js/i18n/el.min.js +7 -0
  179. package/src/wet-boew-cdn-4.0.81.1/js/i18n/en.js +254 -0
  180. package/src/wet-boew-cdn-4.0.81.1/js/i18n/en.min.js +7 -0
  181. package/src/wet-boew-cdn-4.0.81.1/js/i18n/es.js +296 -0
  182. package/src/wet-boew-cdn-4.0.81.1/js/i18n/es.min.js +7 -0
  183. package/src/wet-boew-cdn-4.0.81.1/js/i18n/et.js +291 -0
  184. package/src/wet-boew-cdn-4.0.81.1/js/i18n/et.min.js +7 -0
  185. package/src/wet-boew-cdn-4.0.81.1/js/i18n/fr.js +322 -0
  186. package/src/wet-boew-cdn-4.0.81.1/js/i18n/fr.min.js +7 -0
  187. package/src/wet-boew-cdn-4.0.81.1/js/i18n/hi.js +254 -0
  188. package/src/wet-boew-cdn-4.0.81.1/js/i18n/hi.min.js +7 -0
  189. package/src/wet-boew-cdn-4.0.81.1/js/i18n/hu.js +293 -0
  190. package/src/wet-boew-cdn-4.0.81.1/js/i18n/hu.min.js +7 -0
  191. package/src/wet-boew-cdn-4.0.81.1/js/i18n/hy.js +254 -0
  192. package/src/wet-boew-cdn-4.0.81.1/js/i18n/hy.min.js +7 -0
  193. package/src/wet-boew-cdn-4.0.81.1/js/i18n/id.js +292 -0
  194. package/src/wet-boew-cdn-4.0.81.1/js/i18n/id.min.js +7 -0
  195. package/src/wet-boew-cdn-4.0.81.1/js/i18n/is.js +291 -0
  196. package/src/wet-boew-cdn-4.0.81.1/js/i18n/is.min.js +7 -0
  197. package/src/wet-boew-cdn-4.0.81.1/js/i18n/it.js +320 -0
  198. package/src/wet-boew-cdn-4.0.81.1/js/i18n/it.min.js +7 -0
  199. package/src/wet-boew-cdn-4.0.81.1/js/i18n/iu.js +254 -0
  200. package/src/wet-boew-cdn-4.0.81.1/js/i18n/iu.min.js +7 -0
  201. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ja.js +294 -0
  202. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ja.min.js +7 -0
  203. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ko.js +293 -0
  204. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ko.min.js +7 -0
  205. package/src/wet-boew-cdn-4.0.81.1/js/i18n/lt.js +293 -0
  206. package/src/wet-boew-cdn-4.0.81.1/js/i18n/lt.min.js +7 -0
  207. package/src/wet-boew-cdn-4.0.81.1/js/i18n/lv.js +293 -0
  208. package/src/wet-boew-cdn-4.0.81.1/js/i18n/lv.min.js +7 -0
  209. package/src/wet-boew-cdn-4.0.81.1/js/i18n/nl.js +327 -0
  210. package/src/wet-boew-cdn-4.0.81.1/js/i18n/nl.min.js +7 -0
  211. package/src/wet-boew-cdn-4.0.81.1/js/i18n/pl.js +296 -0
  212. package/src/wet-boew-cdn-4.0.81.1/js/i18n/pl.min.js +7 -0
  213. package/src/wet-boew-cdn-4.0.81.1/js/i18n/pt-BR.js +254 -0
  214. package/src/wet-boew-cdn-4.0.81.1/js/i18n/pt-BR.min.js +7 -0
  215. package/src/wet-boew-cdn-4.0.81.1/js/i18n/pt.js +279 -0
  216. package/src/wet-boew-cdn-4.0.81.1/js/i18n/pt.min.js +7 -0
  217. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ru.js +293 -0
  218. package/src/wet-boew-cdn-4.0.81.1/js/i18n/ru.min.js +7 -0
  219. package/src/wet-boew-cdn-4.0.81.1/js/i18n/sk.js +291 -0
  220. package/src/wet-boew-cdn-4.0.81.1/js/i18n/sk.min.js +7 -0
  221. package/src/wet-boew-cdn-4.0.81.1/js/i18n/sq.js +254 -0
  222. package/src/wet-boew-cdn-4.0.81.1/js/i18n/sq.min.js +7 -0
  223. package/src/wet-boew-cdn-4.0.81.1/js/i18n/th.js +293 -0
  224. package/src/wet-boew-cdn-4.0.81.1/js/i18n/th.min.js +7 -0
  225. package/src/wet-boew-cdn-4.0.81.1/js/i18n/tr.js +295 -0
  226. package/src/wet-boew-cdn-4.0.81.1/js/i18n/tr.min.js +7 -0
  227. package/src/wet-boew-cdn-4.0.81.1/js/i18n/uk.js +293 -0
  228. package/src/wet-boew-cdn-4.0.81.1/js/i18n/uk.min.js +7 -0
  229. package/src/wet-boew-cdn-4.0.81.1/js/i18n/vi.js +293 -0
  230. package/src/wet-boew-cdn-4.0.81.1/js/i18n/vi.min.js +7 -0
  231. package/src/wet-boew-cdn-4.0.81.1/js/i18n/zh-Hans.js +254 -0
  232. package/src/wet-boew-cdn-4.0.81.1/js/i18n/zh-Hans.min.js +7 -0
  233. package/src/wet-boew-cdn-4.0.81.1/js/i18n/zh.js +294 -0
  234. package/src/wet-boew-cdn-4.0.81.1/js/i18n/zh.min.js +7 -0
  235. package/src/wet-boew-cdn-4.0.81.1/js/ie8-wet-boew.js +10 -0
  236. package/src/wet-boew-cdn-4.0.81.1/js/ie8-wet-boew.min.js +7 -0
  237. package/src/wet-boew-cdn-4.0.81.1/js/ie8-wet-boew.min.js.map +1 -0
  238. package/src/wet-boew-cdn-4.0.81.1/js/ie8-wet-boew2.js +10 -0
  239. package/src/wet-boew-cdn-4.0.81.1/js/ie8-wet-boew2.min.js +7 -0
  240. package/src/wet-boew-cdn-4.0.81.1/js/ie8-wet-boew2.min.js.map +1 -0
  241. package/src/wet-boew-cdn-4.0.81.1/js/jquery/2.2.4/jquery.js +9814 -0
  242. package/src/wet-boew-cdn-4.0.81.1/js/jquery/2.2.4/jquery.min.js +4 -0
  243. package/src/wet-boew-cdn-4.0.81.1/js/jquery/2.2.4/jquery.min.map +1 -0
  244. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datalist.js +419 -0
  245. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datalist.min.js +8 -0
  246. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datalist.min.js.map +1 -0
  247. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datalist_dynamic.js +50 -0
  248. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datalist_dynamic.min.js +8 -0
  249. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datalist_dynamic.min.js.map +1 -0
  250. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datepicker.js +338 -0
  251. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datepicker.min.js +8 -0
  252. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/datepicker.min.js.map +1 -0
  253. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/details.js +126 -0
  254. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/details.min.js +8 -0
  255. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/details.min.js.map +1 -0
  256. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/jawsariafixes.js +47 -0
  257. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/jawsariafixes.min.js +16 -0
  258. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/jawsariafixes.min.js.map +1 -0
  259. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/meter.js +140 -0
  260. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/meter.min.js +8 -0
  261. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/meter.min.js.map +1 -0
  262. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/mobile.js +784 -0
  263. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/mobile.min.js +8 -0
  264. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/mobile.min.js.map +1 -0
  265. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/progress.js +107 -0
  266. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/progress.min.js +8 -0
  267. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/progress.min.js.map +1 -0
  268. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/slider.js +1343 -0
  269. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/slider.min.js +9 -0
  270. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/slider.min.js.map +1 -0
  271. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/slider_wrapper.js +73 -0
  272. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/slider_wrapper.min.js +8 -0
  273. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/slider_wrapper.min.js.map +1 -0
  274. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/svg.js +29 -0
  275. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/svg.min.js +8 -0
  276. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/svg.min.js.map +1 -0
  277. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/test.js +603 -0
  278. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/test.min.js +8 -0
  279. package/src/wet-boew-cdn-4.0.81.1/js/polyfills/test.min.js.map +1 -0
  280. package/src/wet-boew-cdn-4.0.81.1/js/wet-boew.js +20264 -0
  281. package/src/wet-boew-cdn-4.0.81.1/js/wet-boew.min.js +9 -0
  282. package/src/wet-boew-cdn-4.0.81.1/js/wet-boew.min.js.map +1 -0
  283. package/src/wet-boew-cdn-4.0.81.1/package.json +15 -0
  284. package/src/wet-boew-cdn-4.0.81.1/payload.json +1722 -0
@@ -0,0 +1,3770 @@
1
+
2
+ /*
3
+ * @title WET-BOEW Geomap
4
+ * @overview Displays a dynamic map over which information from additional sources can be overlaid.
5
+ * @license wet-boew.github.io/wet-boew/License-en.html / wet-boew.github.io/wet-boew/Licence-fr.html
6
+ * @author @pjackson28
7
+ */
8
+ /*global wet_boew_geomap: false, ol: false, proj4: false*/
9
+ ( function( $, window, document, wb ) {
10
+ "use strict";
11
+
12
+ var componentName = "wb-geomap",
13
+ selector = "." + componentName,
14
+ $document = wb.doc,
15
+ colourIndex = 0,
16
+ mapArray = [],
17
+ mobile = false,
18
+ i18n, i18nText, tooltip,
19
+
20
+ /*
21
+ * Plugin users can override these defaults by setting attributes on the html elements that the
22
+ * selector matches.
23
+ * For example, adding the attribute data-option1="false", will override option1 for that plugin instance.
24
+ */
25
+ defaults = {
26
+ overlays: [],
27
+ tables: [],
28
+ useScaleLine: false,
29
+ useMousePosition: false,
30
+ useLegend: false,
31
+ useMapControls: true,
32
+ useGeocoder: false,
33
+ useGeolocation: false,
34
+ useAOI: false
35
+ },
36
+
37
+ /**
38
+ * @method init
39
+ * @param {jQuery Event} event Event that triggered this handler
40
+ */
41
+ init = function( event ) {
42
+
43
+ var elm = event.target,
44
+ className = elm.className.split( /\s+/ ),
45
+ settings = {},
46
+ $elm, overrides;
47
+
48
+ if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ) ) {
49
+ mobile = true;
50
+ }
51
+
52
+ // Filter out any events triggered by descendants
53
+ if ( event.currentTarget === elm ) {
54
+ $elm = $( elm );
55
+
56
+ // Only initialize the i18nText once
57
+ if ( !i18nText ) {
58
+ i18n = wb.i18n;
59
+ i18nText = {
60
+ add: i18n( "add" ),
61
+ close: i18n( "close" ),
62
+ colon: i18n( "colon" ),
63
+ err: i18n( "err" ),
64
+ hiddenLayer: i18n( "geo-hdnlyr" ),
65
+ toggleLayer: i18n( "geo-tgllyr" ),
66
+ labelSelect: i18n( "geo-lblsel" ),
67
+ select: i18n( "geo-sel" ),
68
+ zoomFeature: i18n( "geo-zmfeat" ),
69
+ zoomin: i18n( "geo-zmin" ),
70
+ zoomout: i18n( "geo-zmout" ),
71
+ zoomworld: i18n( "geo-zmwrld" ),
72
+ baseMapTitle: i18n( "geo-bmapttl" ),
73
+ baseMapURL: i18n( "geo-bmap-url" ),
74
+ baseMapMatrixSet: i18n( "geo-bmap-matrix-set" ),
75
+ scaleline: i18n( "geo-sclln" ),
76
+ mouseposition: i18n( "geo-msepos" ),
77
+ access: i18n( "geo-ally" ),
78
+ accessTitle: i18n( "geo-allyttl" ),
79
+ attribLink: i18n( "geo-attrlnk" ),
80
+ attribTitle: i18n( "geo-attrttl" ),
81
+ ariaMap: i18n( "geo-ariamap" ),
82
+ geoLocationURL: i18n( "geo-locurl-geogratis" ),
83
+ geoCoderPlaceholder: i18n( "geo-loc-placeholder" ),
84
+ geoCoderLabel: i18n( "geo-loc-label" ),
85
+ aoiNorth: i18n( "geo-aoi-north" ),
86
+ aoiEast: i18n( "geo-aoi-east" ),
87
+ aoiSouth: i18n( "geo-aoi-south" ),
88
+ aoiWest: i18n( "geo-aoi-west" ),
89
+ aoiInstructions: i18n( "geo-aoi-instructions" ),
90
+ aoiTitle: i18n( "geo-aoi-title" ),
91
+ aoiBtnDraw: i18n( "geo-aoi-btndraw" ),
92
+ aoiBtnClear: i18n( "geo-aoi-btnclear" ),
93
+ aoiBtnClose: i18n( "close" ),
94
+ geolocBtn: i18n( "geo-geoloc-btn" ),
95
+ geolocFail: i18n( "geo-geoloc-fail" ),
96
+ geolocUncapable: i18n( "geo-geoloc-uncapable" ),
97
+ geoLgndGrphc: i18n( "geo-lgnd-grphc" ),
98
+ dismiss: i18n( "dismiss" )
99
+ };
100
+ }
101
+
102
+ // Class-based overrides - use undefined where no override should occur
103
+ overrides = {
104
+ useScaleLine: className.indexOf( "scaleline" ) !== -1 ? true : undefined,
105
+ useMousePosition: className.indexOf( "position" ) !== -1 ? true : undefined,
106
+ useLegend: className.indexOf( "legend" ) !== -1,
107
+ useMapControls: className.indexOf( "static" ) !== -1 ? false : true,
108
+ useGeocoder: className.indexOf( "geocoder" ) !== -1 ? true : false,
109
+ useGeolocation: className.indexOf( "geolocation" ) !== -1 ? true : false,
110
+ useAOI: className.indexOf( "aoi" ) !== -1 ? true : false,
111
+ useAOIOpen: className.indexOf( "aoi-open" ) !== -1 ? true : false
112
+ };
113
+
114
+ // Merge default settings with overrides from the selected plugin element.
115
+ $.extend( settings, defaults, overrides, wb.getData( $elm, componentName ) );
116
+
117
+ // Load configuration file
118
+ if ( settings.layersFile ) {
119
+
120
+ $.ajax( {
121
+ url: settings.layersFile,
122
+ async: true,
123
+ dataType: "script",
124
+ success: function() {
125
+
126
+ // Extend settings with data loaded from the
127
+ // configuration file (through wet_boew_geomap)
128
+ settings = $.extend( settings, wet_boew_geomap );
129
+
130
+ // Support OSM basemap as defined prior v4.0.30, to be removed in v5.0
131
+ // Check if the basemap type is defined to xyz, if so change it to osm
132
+ if ( settings && settings.basemap && settings.basemap.type && settings.basemap.type === "xyz" ) {
133
+ settings.basemap.type = "osm";
134
+ }
135
+
136
+ // Create Geomap Object and add to map array
137
+ elm.geomap = new Geomap( { target: $elm, settings: settings } );
138
+ mapArray.push( elm.geomap );
139
+
140
+ }
141
+ } );
142
+
143
+ } else {
144
+
145
+ // Create Geomap Object and add to map array
146
+ elm.geomap = new Geomap( { target: $elm, settings: settings } );
147
+ mapArray.push( elm.geomap );
148
+ }
149
+
150
+ }
151
+
152
+ // Provide for easy access to OpenLayers olMap object
153
+ wb.getMap = function( id ) {
154
+ return getMapById( id );
155
+ };
156
+
157
+ //Provide for easy access to OpenLayers olLayer object
158
+ wb.getLayer = function( map, id ) {
159
+ return getLayerById( map, id );
160
+ };
161
+
162
+ },
163
+
164
+ /**
165
+ * Geomap Object
166
+ */
167
+ Geomap = function( options ) {
168
+
169
+ var $elm = options.target,
170
+ viewOptions = {};
171
+
172
+ this.id = $elm.attr( "id" );
173
+ this.mapLayers = [];
174
+ this.layerDiv = $elm.find( ".wb-geomap-layers" ).attr( "id", "geomap-layers-" + this.id );
175
+ this.legendDiv = $elm.find( ".wb-geomap-legend" ).attr( "id", "geomap-legend-" + this.id );
176
+ this.mapDiv = $elm.find( ".wb-geomap-map" ).attr( "id", "geomap-map-" + this.id );
177
+ this.settings = options.settings;
178
+ this.settings.aspectRatio = ( this.settings.basemap &&
179
+ this.settings.basemap.mapOptions &&
180
+ this.settings.basemap.mapOptions.aspectRatio !== undefined ) ?
181
+ this.settings.basemap.mapOptions.aspectRatio : 0.8;
182
+
183
+ this.map = createOLMap( this );
184
+ this.legend = new MapLegend( this );
185
+
186
+ // Add basemap data
187
+ viewOptions = this.addBasemap();
188
+
189
+ // The map view is set from the basedata
190
+ this.map.setView( new ol.View( viewOptions ) );
191
+
192
+ // Add map layers
193
+ this.addMapLayers();
194
+
195
+ // If an extent was configured, fit the map to it (use mapExtent property, then basemap.extent)
196
+ if ( this.settings.mapExtent ) {
197
+ this.zoomAOI( this.settings.mapExtent );
198
+ } else if ( viewOptions.extent ) {
199
+ this.map.getView().fit( viewOptions.extent, this.map.getSize() );
200
+ }
201
+
202
+ // Get layer(s) by name
203
+ // Build a layer object containing features with "OL2 friendly" properties
204
+ // (( To be removed on next major version ))
205
+ var mapLayersCached = this.mapLayers;
206
+ this.map.getLayersByName = function( layerName ) {
207
+ var i, i_lyr,
208
+ i_len = mapLayersCached.length,
209
+ feature = {
210
+ popup: {
211
+ visible: function() {
212
+ return true;
213
+ }
214
+ },
215
+ geometry: {
216
+ bounds: ol.proj.transform( this.getOverlays().getArray()[ 0 ].getPosition(), "EPSG:3978", "EPSG:4326" )
217
+ }
218
+ };
219
+
220
+ for ( i = 0; i !== i_len; i += 1 ) {
221
+ i_lyr = mapLayersCached[ i ];
222
+ if ( i_lyr.id && i_lyr.id === layerName ) {
223
+ return [ { features: [ feature ] } ];
224
+ }
225
+ }
226
+ };
227
+
228
+ // Load Controls
229
+ this.loadControls();
230
+
231
+ // Set the title and aria-label text
232
+ this.accessibilize();
233
+
234
+ // Add the popup
235
+ this.createPopup();
236
+
237
+ // Do some housekeeping once map is ready
238
+ $document.on( "wb-ready.wb-geomap", "#" + this.id, function() {
239
+
240
+ // Remove the loader
241
+ $( "#" + this.id ).find( ".geomap-progress" ).remove();
242
+
243
+ } );
244
+
245
+ }, // End Geomap Object
246
+
247
+ /**
248
+ * MapLayer Object
249
+ *
250
+ * @param Object {Geomap}
251
+ * @param Object {options} MapLayer options
252
+ * @return Object {MapLayer}
253
+ */
254
+ MapLayer = function( map, options ) {
255
+
256
+ var _this = this,
257
+ visibilytyCallBackArr = [];
258
+
259
+ this.map = map;
260
+ this.settings = options;
261
+ this.id = this.settings.tableId ? this.settings.tableId : generateGuid();
262
+ this.layer = this.createOLLayer();
263
+ this.settings.accessible = ( typeof this.settings.accessible === "undefined" ) ? true : this.settings.accessible;
264
+ this.settings.visible = ( typeof this.settings.visible === "undefined" ) ? true : this.settings.visible;
265
+ this.settings.zoom = typeof this.settings.zoom === "undefined" ? true : this.settings.zoom;
266
+
267
+ // Add a section to hold the data table
268
+ if ( this.settings.accessible ) {
269
+ this.map.layerDiv.append( "<div class='panel panel-default'><div class='panel-heading'><div class='panel-title' role='heading'>" +
270
+ this.settings.title + "</div></div><div class='panel-body'><div data-layer='" +
271
+ this.id + "' class='geomap-table-wrapper' style='display:none;'></div></div></div>" );
272
+ }
273
+
274
+ // Make isVisibile Reactive
275
+ Object.defineProperty( _this, "isVisible", {
276
+ get: function get() {
277
+ return _this.visibilityState;
278
+ },
279
+ set: function set( newVal ) {
280
+ _this.visibilityState = newVal;
281
+
282
+ // Notify
283
+ visibilytyCallBackArr.forEach( function( signalHandler ) {
284
+
285
+ return signalHandler( newVal );
286
+ } );
287
+ }
288
+ } );
289
+
290
+ // Skip if layer is null
291
+ if ( !_this.layer ) {
292
+ return null;
293
+ }
294
+
295
+ // Allow the properties to be observed
296
+ this.observeVisibility = function( callback ) {
297
+ visibilytyCallBackArr.push( callback );
298
+ };
299
+
300
+ this.observeVisibility( function( vis ) {
301
+
302
+ var $table = $( "div[ data-layer='" + _this.id + "' ].geomap-table-wrapper" );
303
+
304
+ if ( !vis ) {
305
+ $table.fadeOut();
306
+ $table.parent().append( "<div class='layer-msg'><p>" + i18nText.hiddenLayer + "</p></div>" ).fadeIn();
307
+ } else {
308
+ $table.fadeIn();
309
+ $table.parent().find( ".layer-msg" ).remove();
310
+ }
311
+
312
+ _this.layer.setVisible( _this.isVisible );
313
+ } );
314
+
315
+
316
+ // Add to legend if legend is configured
317
+ if ( this.map.legendDiv.length !== 0 ) {
318
+ this.addToLegend();
319
+ }
320
+
321
+ this.isVisible = this.settings.visible;
322
+
323
+ return this;
324
+ },
325
+
326
+ /**
327
+ * MapLegend Object
328
+ *
329
+ * @param {Geomap}
330
+ * @return {MapLegend}
331
+ */
332
+ MapLegend = function( map ) {
333
+
334
+ this.map = map;
335
+ this.symbolMapArray = [];
336
+ this.target = $( "#" + map.id + ".wb-geomap" ).find( ".wb-geomap-legend" );
337
+ this.target.attr( "id", "geomap-legend-" + map.id );
338
+
339
+ // remove the placehoders
340
+ this.target.empty();
341
+
342
+ return this;
343
+ },
344
+
345
+ /**
346
+ * Get ol.interaction.Interaction
347
+ */
348
+ getMapInteraction = function( map, interactionType ) {
349
+ var intrctn;
350
+ map.getInteractions().forEach( function( interaction ) {
351
+ if ( interaction instanceof interactionType ) {
352
+ intrctn = interaction;
353
+ }
354
+ } );
355
+ return intrctn;
356
+ },
357
+
358
+ setRendererDimensions = function( id, map, feature, symbolWidth, symbolHeight ) {
359
+
360
+ var gb = feature.getGeometry().getExtent(),
361
+ gw = ol.extent.getWidth( gb ),
362
+ gh = ol.extent.getHeight( gb ),
363
+ el = $( "#" + id ),
364
+ bhalfw, bhalfh, bounds, center, resolution, height, width;
365
+
366
+ /*
367
+ * Determine resolution based on the following rules:
368
+ * 1) always use value specified in config
369
+ * 2) if not specified, use max res based on width or height of element
370
+ * 3) if no width or height, assume a resolution of 1
371
+ */
372
+ resolution = 1;
373
+ if ( !resolution ) {
374
+ resolution = Math.max(
375
+ gw / symbolWidth || 0,
376
+ gh / symbolHeight || 0
377
+ ) || 1;
378
+ }
379
+ map.setView( new ol.View( {
380
+ minResolution: resolution,
381
+ maxResolution: resolution,
382
+ projection: new ol.proj.Projection( {
383
+ code: "",
384
+ units: "pixels"
385
+ } )
386
+ } ) );
387
+
388
+ // determine height and width of element
389
+ width = Math.max( symbolWidth, gw / resolution );
390
+ height = Math.max( symbolHeight, gh / resolution );
391
+
392
+ // determine bounds of renderer
393
+ center = ol.extent.getCenter( gb );
394
+ bhalfw = width * resolution / 2;
395
+ bhalfh = height * resolution / 2;
396
+ bounds = [ center[ 0 ] - bhalfw, center[ 1 ] - bhalfh, center[ 0 ] + bhalfw, center[ 1 ] + bhalfh ];
397
+ el.width( Math.round( width ) );
398
+ el.height( Math.round( height ) );
399
+
400
+ map.updateSize();
401
+ map.getView().fit( bounds, map.getSize() );
402
+
403
+ },
404
+
405
+ defaultColors = function() {
406
+
407
+ var fill = hexToRGB( wb.drawColours[ colourIndex ], 0.5 ),
408
+ stroke = hexToRGB( wb.drawColours[ colourIndex ], 1.0 ),
409
+ colors = { fill: fill, stroke: stroke, transparent: [ 0, 0, 0, 0 ] };
410
+
411
+ // Increment the colour index
412
+ colourIndex += 1;
413
+ if ( colourIndex === wb.drawColours.length ) {
414
+ colourIndex = 0;
415
+ }
416
+
417
+ return colors;
418
+ },
419
+
420
+ StyleFactory = function() {
421
+
422
+ var colors = defaultColors(),
423
+ externalGraphic, graphicHeight, graphicWidth, graphicName, style, styleType,
424
+ fillColor, opacity, radius, strokeColor, strokeDash, strokeWidth;
425
+
426
+ this.createStyleFunction = function( theStyle, featureType ) {
427
+ style = theStyle;
428
+ styleType = style && style.type ? style.type : "default";
429
+
430
+ // called on each feature
431
+ return function( feature ) {
432
+
433
+ if ( styleType === "rule" ) {
434
+
435
+ return new RuleStyle( feature, featureType );
436
+
437
+ } else if ( styleType === "symbol" ) {
438
+
439
+ return new SymbolStyle();
440
+
441
+ } else if ( styleType === "default" ) {
442
+
443
+ return new DefaultStyle( feature, featureType );
444
+
445
+ } else if ( styleType === "unique" ) {
446
+
447
+ return new UniqueStyle( feature, featureType );
448
+
449
+ } else if ( styleType === "select" ) {
450
+
451
+ return new SelectStyle( feature, featureType );
452
+
453
+ }
454
+
455
+ };
456
+
457
+ };
458
+
459
+ var RuleStyle = function( feature ) {
460
+
461
+ var styleRule = style.rule,
462
+ len = styleRule.length,
463
+ operators = {
464
+ "EQUAL_TO": function( a, b ) {
465
+ return String( a ) === String( b[ 0 ] );
466
+ },
467
+ "GREATER_THAN": function( a, b ) {
468
+ return a > b[ 0 ];
469
+ },
470
+ "LESS_THAN": function( a, b ) {
471
+ return a < b[ 0 ];
472
+ },
473
+ "BETWEEN": function( a, b ) {
474
+ return a >= b[ 0 ] && a <= b[ 1 ];
475
+ }
476
+ },
477
+ featureType = feature && feature.getGeometry() ? feature.getGeometry().getType() : "Polygon",
478
+ rule, ruleFilter;
479
+
480
+ for ( var i = 0; i !== len; i += 1 ) {
481
+
482
+ // Set the filter
483
+ rule = styleRule[ i ];
484
+ ruleFilter = rule.filter;
485
+
486
+ // Set the style elements
487
+ strokeDash = rule.init.strokeDash ? rule.init.strokeDash : [ 1, 0 ];
488
+ strokeWidth = rule.init.strokeWidth ? rule.init.strokeWidth : 1.0;
489
+ opacity = rule.init.fillOpacity ? rule.init.fillOpacity : rule.init.graphicOpacity ? rule.init.graphicOpacity : 0.5;
490
+ radius = rule.init.pointRadius ? rule.init.pointRadius : 5;
491
+ strokeColor = rule.init.strokeColor ? hexToRGB( rule.init.strokeColor, opacity ) : colors.transparent;
492
+ fillColor = hexToRGB( rule.init.fillColor, opacity );
493
+ graphicName = rule.init.graphicName ? rule.init.graphicName : null;
494
+ externalGraphic = rule.init.externalGraphic ? rule.init.externalGraphic : null;
495
+ graphicHeight = rule.init.graphicHeight ? rule.init.graphicHeight : 25;
496
+ graphicWidth = rule.init.graphicWidth ? rule.init.graphicWidth : 25;
497
+
498
+ if ( operators[ ruleFilter ]( feature.attributes[ rule.field ], rule.value ) ) {
499
+ switch ( featureType ) {
500
+ case "Polygon" || "MultiPolygon":
501
+ return getPolygonStyle( {
502
+ fill: new ol.style.Fill( { color: fillColor } ),
503
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
504
+ } );
505
+ case "Point" || "MultiPoint":
506
+ if ( graphicName ) {
507
+ return getSymbolStyle( {
508
+ symbol: graphicName,
509
+ fill: new ol.style.Fill( { color: fillColor } ),
510
+ stroke: new ol.style.Stroke( { color: strokeColor, lineDash: strokeDash } ),
511
+ radius: radius
512
+ } );
513
+ } else if ( externalGraphic ) {
514
+ return getIconStyle( {
515
+ src: externalGraphic,
516
+ opacity: opacity,
517
+ size: [ graphicWidth, graphicHeight ]
518
+ } );
519
+ } else {
520
+ return getPointStyle( {
521
+ radius: radius,
522
+ fill: new ol.style.Fill( { color: fillColor } ),
523
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
524
+ } );
525
+ }
526
+ case "LineString" || "MultiLineString":
527
+ return getLineStyle( {
528
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
529
+ } );
530
+ default:
531
+ return getPolygonStyle( {
532
+ fill: new ol.style.Fill( { color: fillColor } ),
533
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
534
+ } );
535
+ }
536
+
537
+ }
538
+ }
539
+
540
+ };
541
+
542
+ var SymbolStyle = function() {
543
+
544
+ // Set the style elements
545
+ opacity = style.init.fillOpacity ? style.init.fillOpacity : style.init.graphicOpacity ? style.init.graphicOpacity : 1.0;
546
+ radius = style.init.pointRadius ? style.init.pointRadius : 5;
547
+ strokeColor = style.init.strokeColor ? hexToRGB( style.init.strokeColor, opacity ) : colors.transparent;
548
+ fillColor = hexToRGB( style.init.fillColor, opacity );
549
+ graphicName = style.init.graphicName ? style.init.graphicName : null;
550
+ externalGraphic = style.init.externalGraphic ? style.init.externalGraphic : null;
551
+ graphicHeight = style.init.graphicHeight ? style.init.graphicHeight : 25;
552
+ graphicWidth = style.init.graphicWidth ? style.init.graphicWidth : 25;
553
+
554
+ if ( graphicName ) {
555
+ return getSymbolStyle( {
556
+ symbol: style.init.graphicName,
557
+ fill: new ol.style.Fill( { color: fillColor } ),
558
+ stroke: new ol.style.Stroke( { color: strokeColor, lineDash: strokeDash } ),
559
+ radius: radius
560
+ } );
561
+ } else if ( externalGraphic ) {
562
+ return getIconStyle( {
563
+ src: externalGraphic,
564
+ opacity: opacity,
565
+ size: [ graphicWidth, graphicHeight ]
566
+ } );
567
+ } else {
568
+ return getPointStyle( {
569
+ radius: radius,
570
+ fill: new ol.style.Fill( { color: fillColor } ),
571
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth } )
572
+ } );
573
+ }
574
+
575
+ };
576
+
577
+ var DefaultStyle = function() {
578
+
579
+ opacity = style.fillOpacity ? style.fillOpacity : style.graphicOpacity ? style.graphicOpacity : 1.0;
580
+ fillColor = style.fillColor ? hexToRGB( style.fillColor, opacity ) : colors.transparent;
581
+ strokeColor = style.strokeColor ? hexToRGB( style.strokeColor, opacity ) : colors.transparent;
582
+ strokeWidth = style.strokeWidth ? style.strokeWidth : 1.0;
583
+ strokeDash = style.strokeDash ? style.strokeDash : [ 1, 0 ];
584
+
585
+ return [ new ol.style.Style( {
586
+ image: new ol.style.Circle( {
587
+ fill: new ol.style.Fill( { color: fillColor } ),
588
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } ),
589
+ radius: 5
590
+ } ),
591
+ fill: new ol.style.Fill( { color: fillColor } ),
592
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
593
+ } ) ];
594
+
595
+ };
596
+
597
+ var UniqueStyle = function( feature, featureType ) {
598
+
599
+ var field = style.field,
600
+ obj, objStyle;
601
+
602
+ for ( obj in style.init ) {
603
+ objStyle = style.init[ obj ];
604
+
605
+ strokeDash = objStyle.strokeDash ? objStyle.strokeDash : [ 1, 0 ];
606
+ strokeWidth = objStyle.strokeWidth ? objStyle.strokeWidth : 1.0;
607
+ opacity = objStyle.fillOpacity ? objStyle.fillOpacity : objStyle.graphicOpacity ? objStyle.graphicOpacity : 0.5;
608
+ radius = objStyle.pointRadius ? objStyle.pointRadius : 5;
609
+ strokeColor = objStyle.strokeColor ? hexToRGB( objStyle.strokeColor, opacity ) : colors.transparent;
610
+ fillColor = objStyle.fillColor ? hexToRGB( objStyle.fillColor, opacity ) : null;
611
+ graphicHeight = objStyle.graphicHeight ? objStyle.graphicHeight : 25;
612
+ externalGraphic = objStyle.externalGraphic;
613
+ graphicWidth = objStyle.graphicWidth ? objStyle.graphicWidth : 25;
614
+
615
+ switch ( featureType ) {
616
+ case "Polygon" || "MultiPolygon":
617
+ if ( feature.attributes && feature.attributes[ field ] === obj ) {
618
+ return getPolygonStyle( {
619
+ fill: new ol.style.Fill( { color: fillColor } ),
620
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
621
+ } );
622
+ }
623
+ break;
624
+ case "Point" || "MultiPoint":
625
+ if ( externalGraphic ) {
626
+ if ( feature.attributes && feature.attributes[ field ] === obj ) {
627
+ return getIconStyle( {
628
+ src: externalGraphic,
629
+ opacity: opacity,
630
+ size: [ graphicWidth, graphicHeight ]
631
+ } );
632
+ }
633
+ } else {
634
+ if ( feature.attributes && feature.attributes[ field ] === obj ) {
635
+ return getPointStyle( {
636
+ radius: radius,
637
+ fill: new ol.style.Fill( { color: fillColor } ),
638
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
639
+ } );
640
+ }
641
+ }
642
+ break;
643
+ case "LineString" || "MultiLineString":
644
+ if ( feature.attributes && feature.attributes[ field ] === obj ) {
645
+ return getLineStyle( {
646
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
647
+ } );
648
+ }
649
+ break;
650
+ default:
651
+ if ( feature.attributes && feature.attributes[ field ] === obj ) {
652
+ return getPolygonStyle( {
653
+ fill: new ol.style.Fill( { color: fillColor } ),
654
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
655
+ } );
656
+ }
657
+ break;
658
+ }
659
+
660
+ }
661
+
662
+ };
663
+
664
+ var SelectStyle = function( feature, featureType ) {
665
+
666
+ strokeDash = style.strokeDash ? style.strokeDash : [ 1, 0 ];
667
+ strokeWidth = style.strokeWidth ? style.strokeWidth : 1.0;
668
+ opacity = style.fillOpacity ? style.fillOpacity : style.graphicOpacity ? style.graphicOpacity : 0.5;
669
+ radius = style.pointRadius ? style.pointRadius : 5;
670
+ strokeColor = style.strokeColor ? hexToRGB( style.strokeColor, opacity ) : colors.transparent;
671
+ fillColor = style.fillColor ? hexToRGB( style.fillColor, opacity ) : null;
672
+ graphicHeight = style.graphicHeight ? style.graphicHeight : 25;
673
+ externalGraphic = style.externalGraphic;
674
+ graphicWidth = style.graphicWidth ? style.graphicWidth : 25;
675
+
676
+ switch ( featureType ) {
677
+ case "Polygon" || "MultiPolygon":
678
+ return getPolygonStyle( {
679
+ fill: new ol.style.Fill( { color: fillColor } ),
680
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
681
+ } );
682
+ case "Point" || "MultiPoint":
683
+ if ( externalGraphic ) {
684
+ return getIconStyle( {
685
+ src: externalGraphic,
686
+ opacity: opacity,
687
+ size: [ graphicWidth, graphicHeight ]
688
+ } );
689
+ } else {
690
+ return getPointStyle( {
691
+ radius: radius,
692
+ fill: new ol.style.Fill( { color: fillColor } ),
693
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
694
+ } );
695
+ }
696
+
697
+ case "LineString" || "MultiLineString":
698
+ return getLineStyle( {
699
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
700
+ } );
701
+
702
+ default:
703
+ return getPolygonStyle( {
704
+ fill: new ol.style.Fill( { color: fillColor } ),
705
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
706
+ } );
707
+ }
708
+
709
+ };
710
+
711
+ },
712
+
713
+ /**
714
+ * Symbol Style
715
+ * @param symbolizer { obj } - style attributes
716
+ */
717
+
718
+ //TODO: add stroke width
719
+ getSymbolStyle = function( symbolizer ) {
720
+
721
+ var symbols = {
722
+ "square": [ new ol.style.Style( {
723
+ image: new ol.style.RegularShape( {
724
+ fill: symbolizer.fill,
725
+ stroke: symbolizer.stroke,
726
+ points: 4,
727
+ radius: symbolizer.radius,
728
+ angle: Math.PI / 4
729
+ } )
730
+ } ) ],
731
+ "triangle": [ new ol.style.Style( {
732
+ image: new ol.style.RegularShape( {
733
+ fill: symbolizer.fill,
734
+ stroke: symbolizer.stroke,
735
+ points: 3,
736
+ radius: symbolizer.radius,
737
+ rotation: Math.PI / 4,
738
+ angle: 0
739
+ } )
740
+ } ) ],
741
+ "star": [ new ol.style.Style( {
742
+ image: new ol.style.RegularShape( {
743
+ fill: symbolizer.fill,
744
+ stroke: symbolizer.stroke,
745
+ points: 5,
746
+ radius: symbolizer.radius,
747
+ radius2: symbolizer.radius * 0.4,
748
+ angle: 0
749
+ } )
750
+ } ) ],
751
+ "cross": [ new ol.style.Style( {
752
+ image: new ol.style.RegularShape( {
753
+ fill: symbolizer.fill,
754
+ stroke: symbolizer.stroke,
755
+ points: 4,
756
+ radius: symbolizer.radius,
757
+ radius2: 0,
758
+ angle: 0
759
+ } )
760
+ } ) ],
761
+ "x": [ new ol.style.Style( {
762
+ image: new ol.style.RegularShape( {
763
+ fill: symbolizer.fill,
764
+ stroke: symbolizer.stroke,
765
+ points: 4,
766
+ radius: symbolizer.radius,
767
+ radius2: 0,
768
+ angle: Math.PI / 4
769
+ } )
770
+ } ) ]
771
+ };
772
+
773
+ return symbols[ symbolizer.symbol ];
774
+ },
775
+
776
+ /**
777
+ * Icon Style
778
+ * @param symbolizer { obj } - style attributes
779
+ */
780
+ getIconStyle = function( symbolizer ) {
781
+
782
+ return [ new ol.style.Style( {
783
+ image: new ol.style.Icon( ( {
784
+ opacity: symbolizer.opacity,
785
+ src: symbolizer.src,
786
+ size: symbolizer.size
787
+ } ) )
788
+ } ) ];
789
+
790
+ },
791
+
792
+ /**
793
+ * Point Style
794
+ * @param symbolizer { obj } - style attributes
795
+ */
796
+ getPointStyle = function( symbolizer ) {
797
+
798
+ return [ new ol.style.Style( {
799
+ image: new ol.style.Circle( ( {
800
+ radius: symbolizer.radius,
801
+ fill: symbolizer.fill,
802
+ stroke: symbolizer.stroke
803
+ } ) )
804
+ } ) ];
805
+
806
+ },
807
+
808
+ /**
809
+ * Polygon Style
810
+ * @param symbolizer { obj } - style attributes
811
+ */
812
+ getPolygonStyle = function( symbolizer ) {
813
+ return [ new ol.style.Style( {
814
+ fill: symbolizer.fill,
815
+ stroke: symbolizer.stroke
816
+ } ) ];
817
+ },
818
+
819
+ /**
820
+ * Line Style
821
+ * @param symbolizer { obj } - style attributes
822
+ */
823
+ getLineStyle = function( symbolizer ) {
824
+ return [ new ol.style.Style( {
825
+ stroke: symbolizer.stroke
826
+ } ) ];
827
+ },
828
+
829
+ // Convert a hexidecimal color string to 0..255 R,G,B for backwards compatibility
830
+ hexToRGB = function( code, alpha ) {
831
+
832
+ var hex = ( code + "" ).trim(),
833
+ rgb = null,
834
+ match = hex.match( /^#?(([0-9a-zA-Z]{3}){1,3})$/ ),
835
+ a = alpha ? alpha : 1.0;
836
+
837
+ if ( !match ) {
838
+ return code;
839
+ }
840
+
841
+ hex = match[ 1 ];
842
+
843
+ if ( hex.length === 6 ) {
844
+ rgb = [ parseInt( hex.substring( 0, 2 ), 16 ), parseInt( hex.substring( 2, 4 ), 16 ), parseInt( hex.substring( 4, 6 ), 16 ), a ];
845
+ } else if ( hex.length === 3 ) {
846
+ rgb = [ parseInt( hex.substring( 0, 1 ) + hex.substring( 0, 1 ), 16 ), parseInt( hex.substring( 1, 2 ) + hex.substring( 1, 2 ), 16 ), parseInt( hex.substring( 2, 3 ) + hex.substring( 2, 3 ), 16 ), a ];
847
+ }
848
+
849
+ return rgb;
850
+ },
851
+
852
+ /**
853
+ * Add the checkbox to the column
854
+ *
855
+ */
856
+ addChkBox = function( mapLayer, feature ) {
857
+
858
+ return "<label class='wb-inv' for='cb_" + feature.getId() + "'>" +
859
+ i18nText.labelSelect + "</label><input type='checkbox' id='cb_" +
860
+ feature.getId() + "' class='geomap-cbx' data-map='" + mapLayer.map.id +
861
+ "' data-layer='" + feature.layerId + "' data-feature='" +
862
+ feature.getId() + "' />";
863
+ },
864
+
865
+ /**
866
+ * Add zoom button to table columns
867
+ */
868
+ addZoomTo = function( mapLayer, feature ) {
869
+ return "<a href='javascript:;' data-map='" + mapLayer.map.id +
870
+ "' data-layer='" + feature.layerId + "' data-feature='" + feature.getId() +
871
+ "' class='btn btn-link geomap-zoomto' alt='" + i18nText.zoomFeature + "' role='button'><span class='glyphicon glyphicon-zoom-in'></span></a>";
872
+ },
873
+
874
+ /**
875
+ * Show popup
876
+ */
877
+ showPopup = function( evt, feature, map ) {
878
+
879
+ if ( !feature ) {
880
+ return;
881
+ }
882
+
883
+ var overlay = map.getOverlays().getArray()[ 0 ],
884
+ $popup = $( document.getElementById( "popup-geomap-map-" + map.id ) ),
885
+ content = "",
886
+ layer = getLayerById( map, feature.layerId );
887
+
888
+ if ( feature && feature.attributes ) {
889
+ var geometry = feature.getGeometry(),
890
+ coord = geometry.getType() === "Point" ? geometry.getCoordinates() : event.mapBrowserEvent.coordinate,
891
+ obj = feature.attributes,
892
+ key, regex;
893
+
894
+ if ( layer.popupsInfo ) {
895
+
896
+ content += layer.popupsInfo.content;
897
+
898
+ for ( key in obj ) {
899
+ if ( Object.prototype.hasOwnProperty.call( obj, key ) ) {
900
+ regex = new RegExp( "_" + key, "igm" );
901
+ content = content.replace( regex, obj[ key ] );
902
+ }
903
+ }
904
+
905
+ } else {
906
+
907
+ for ( key in obj ) {
908
+ if ( Object.prototype.hasOwnProperty.call( obj, key ) ) {
909
+ content += "<tr><th><strong>" + key + "</strong></th><td> " + obj[ key ] + "</td></tr>";
910
+ }
911
+ }
912
+
913
+ }
914
+
915
+ $popup.find( ".popup-content" ).html( "<h5>" + feature.layerTitle + "</h5><table style='width:100%;'>" + content + "</table>" );
916
+ overlay.setPosition( coord );
917
+
918
+ } else {
919
+ overlay.setPosition( undefined );
920
+ }
921
+
922
+ },
923
+
924
+ /**
925
+ * Parse layer configuration keys
926
+ */
927
+ getLayerKeys = function( obj ) {
928
+ var key, keys = {};
929
+ for ( key in obj ) {
930
+ if ( Object.prototype.hasOwnProperty.call( obj, key ) ) {
931
+ if ( key !== "type" && key !== "caption" && key !== "url" && key !== "title" ) {
932
+ keys[ key ] = obj[ key ];
933
+ }
934
+ }
935
+ }
936
+ return keys;
937
+ },
938
+
939
+ /**
940
+ * Remove key
941
+ */
942
+ removeKeys = function( obj, k ) {
943
+ var key, keys = {};
944
+ for ( key in obj ) {
945
+ if ( Object.prototype.hasOwnProperty.call( obj, key ) ) {
946
+ if ( $.inArray( key, k ) < 0 ) {
947
+ keys[ key ] = obj[ key ];
948
+ }
949
+ }
950
+ }
951
+ return keys;
952
+ },
953
+
954
+ /*
955
+ * Remove null keys
956
+ */
957
+ removeNullKeys = function( obj ) {
958
+ var key, keys = {};
959
+ for ( key in obj ) {
960
+ if ( Object.prototype.hasOwnProperty.call( obj, key ) ) {
961
+ if ( obj[ key ] !== null ) {
962
+ keys[ key ] = obj[ key ];
963
+ }
964
+ }
965
+ }
966
+ return keys;
967
+ },
968
+
969
+ /**
970
+ * Create map
971
+ *
972
+ * @return {ol.map} an OpenLayers map.
973
+ */
974
+ createOLMap = function( geomap ) {
975
+
976
+ var controls = geomap.settings.useMapControls ? ol.control.defaults( {
977
+ attributionOptions: ( {
978
+ collapsible: false
979
+ } )
980
+ } ) : [],
981
+ interactions = geomap.settings.useMapControls ? ol.interaction.defaults( {
982
+ mouseWheelZoom: true
983
+ } ) : [],
984
+ intrctn;
985
+
986
+ // Add projection for default base map
987
+ proj4.defs( "EPSG:3978", "+proj=lcc +lat_1=49 +lat_2=77 +lat_0=49 +lon_0=-95 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs" );
988
+
989
+ // Add projection alias
990
+ proj4.defs( "urn:ogc:def:crs:OGC:1.3:CRS84", proj4.defs( "EPSG:4326" ) );
991
+
992
+ // Create the OpenLayers Map Object
993
+ var map = new ol.Map( {
994
+ controls: controls,
995
+ interactions: interactions,
996
+ logo: false,
997
+ target: geomap.mapDiv.attr( "id" )
998
+ } );
999
+
1000
+ intrctn = getMapInteraction( map, ol.interaction.MouseWheelZoom );
1001
+
1002
+ // Disable the mouseWheelZoom until the user focuses on the map
1003
+ if ( geomap.settings.useMapControls && intrctn ) {
1004
+ intrctn.setActive( false );
1005
+ }
1006
+
1007
+ geomap.mapDiv.height( geomap.mapDiv.width() * geomap.settings.aspectRatio );
1008
+ map.set( "aspectRatio", geomap.settings.aspectRatio );
1009
+ map.id = geomap.id;
1010
+
1011
+ // Once the map is rendered fire ready event
1012
+ map.once( "postrender", function() {
1013
+
1014
+ // v4.0.x transition function to support static map.
1015
+ // The following makes assumption the geometry only inlude a point and it is WKT format
1016
+ // The following should be removed in WET 5
1017
+ map.getLayer = function( strSelector ) {
1018
+
1019
+ var geometryElm = document.querySelector( strSelector + " [data-geometry][data-type]" ),
1020
+ geometry = geometryElm.dataset.geometry,
1021
+ geometryType = geometryElm.dataset.type,
1022
+ latitudes, longitudes;
1023
+
1024
+ // Provide support wkt with a POINT geometry, like the demo of the Static map with open layer 2
1025
+ if ( geometryType === "wkt" && geometry.indexOf( "POINT" ) !== -1 ) {
1026
+ geometry = geometry.replace( /,/, "" );
1027
+ geometry = geometry.substring( geometry.indexOf( "(" ) + 1, geometry.indexOf( ")" ) );
1028
+ geometry = geometry.split( " " );
1029
+
1030
+ latitudes = parseFloat( geometry[ 0 ] );
1031
+ longitudes = parseFloat( geometry[ 1 ] );
1032
+
1033
+ }
1034
+ return {
1035
+ getDataExtent: function() {
1036
+ return [ latitudes, longitudes ];
1037
+ }
1038
+ };
1039
+ };
1040
+
1041
+ map.zoomToExtent = function( layerCoordinates ) {
1042
+ map.getView().setCenter( ol.proj.transform( [ layerCoordinates[ 0 ], layerCoordinates[ 1 ] ], "EPSG:4326", "EPSG:3978" ) );
1043
+ map.getView().setZoom( 5 );
1044
+ };
1045
+
1046
+ wb.ready( $( "#" + geomap.id ), componentName, [ map ] );
1047
+ } );
1048
+
1049
+ // Everytime the map view is changed, fire the updated event
1050
+ map.on( "moveend", function() {
1051
+ $( geomap.id ).trigger( "wb-updated" + selector, [ geomap.map ] );
1052
+ } );
1053
+
1054
+ geomap.mapDiv.append( "<div id='tooltip_" + geomap.id + "' style='display:none;'><span class='tooltip-txt'></span></div>" );
1055
+
1056
+ var displayFeatureInfo = function( pixel ) {
1057
+
1058
+ tooltip = $( "#tooltip_" + geomap.id );
1059
+
1060
+ var tooltipTxt = $( "#tooltip_" + geomap.id + " span.tooltip-txt" ),
1061
+ feature;
1062
+
1063
+ tooltip.css( {
1064
+ left: pixel[ 0 ] + "px",
1065
+ top: ( pixel[ 1 ] - 15 ) + "px",
1066
+ position: "absolute"
1067
+ } );
1068
+
1069
+ feature = map.forEachFeatureAtPixel( pixel, function( feature ) {
1070
+ return feature;
1071
+ } );
1072
+
1073
+ if ( feature && feature.tooltip ) {
1074
+ tooltip.hide();
1075
+ tooltipTxt.html( feature.tooltip );
1076
+ tooltip.show();
1077
+ } else {
1078
+ tooltip.hide();
1079
+ }
1080
+ };
1081
+
1082
+ map.on( "pointermove", function( event ) {
1083
+
1084
+ tooltip = $( "#tooltip_" + geomap.id );
1085
+
1086
+ if ( event.dragging ) {
1087
+ tooltip.hide();
1088
+ return;
1089
+ }
1090
+ displayFeatureInfo( map.getEventPixel( event.originalEvent ) );
1091
+
1092
+ return;
1093
+ } );
1094
+
1095
+ return map;
1096
+
1097
+ },
1098
+
1099
+ /**
1100
+ * Get the OpenLayers map object by id
1101
+ *
1102
+ * @return {Geomap}
1103
+ */
1104
+ getMapById = function( id ) {
1105
+
1106
+ var mapArrayItem, len;
1107
+
1108
+ for ( len = mapArray.length - 1; len !== -1; len -= 1 ) {
1109
+ mapArrayItem = mapArray[ len ];
1110
+ if ( mapArrayItem.id === id ) {
1111
+ return mapArrayItem;
1112
+ }
1113
+ }
1114
+ return;
1115
+ },
1116
+
1117
+ /**
1118
+ * Area of Interest (AOI) Widget
1119
+ */
1120
+ AOIWidget = function( geomap ) {
1121
+
1122
+ var interaction = new ol.interaction.DragBox(),
1123
+ projLatLon = new ol.proj.Projection( { code: "EPSG:4326" } ),
1124
+ projMap = geomap.map.getView().getProjection();
1125
+
1126
+ // Handle the draw end event
1127
+ interaction.on( "boxend", function() {
1128
+
1129
+ var extent = interaction.getGeometry().transform( projMap, projLatLon ).getExtent();
1130
+
1131
+ geomProj = drawAOI( geomap, extent );
1132
+
1133
+ // zoom to extent of feature
1134
+ geomap.map.getView().fit( geomProj.getGeometry().getExtent(), geomap.map.getSize() );
1135
+
1136
+ // Round extent to step value of input controls
1137
+ $( "#geomap-aoi-minx-" + geomap.id ).val( extent[ 0 ].toFixed( 6 ) );
1138
+ $( "#geomap-aoi-maxx-" + geomap.id ).val( extent[ 2 ].toFixed( 6 ) );
1139
+ $( "#geomap-aoi-maxy-" + geomap.id ).val( extent[ 3 ].toFixed( 6 ) );
1140
+ $( "#geomap-aoi-miny-" + geomap.id ).val( extent[ 1 ].toFixed( 6 ) );
1141
+
1142
+ $( "#geomap-aoi-extent-" + geomap.id ).val( geomProj.getGeometry().getExtent() ).trigger( "change" );
1143
+ $( "#geomap-aoi-extent-lonlat-" + geomap.id ).val( extent[ 0 ] + ", " + extent[ 1 ] + ", " + extent[ 2 ] + ", " + extent[ 3 ] ).trigger( "change" );
1144
+
1145
+ } );
1146
+
1147
+ // Clear selection when drawing a new box and when clicking on the map
1148
+ interaction.on( "boxstart", function() {
1149
+ getLayerById( geomap.map, "locLayer" ).getSource().clear( true );
1150
+ } );
1151
+
1152
+ geomap.map.addInteraction( interaction );
1153
+
1154
+ interaction.setActive( false );
1155
+
1156
+ if ( geomap.settings.useAOIOpen ) {
1157
+ geomap.mapDiv.before( "<div class='geomap-aoi panel panel-default'><div id='geomap-aoi-" + geomap.id + "' class='panel-body'></div></div>" );
1158
+ } else {
1159
+ geomap.mapDiv.before( "<details class='geomap-aoi'><summary>" + i18nText.aoiTitle + "</summary><div id='geomap-aoi-" + geomap.id + "'></div></details>" );
1160
+ }
1161
+
1162
+ var aoiDiv = $( "#geomap-aoi-" + geomap.id ),
1163
+ extent, left, bottom, right, top, geomProj;
1164
+
1165
+ aoiDiv.append( "<fieldset id='form-aoi-" + geomap.id + "'>" +
1166
+ "<legend tabindex='-1'>" + i18nText.aoiInstructions + "</legend>" +
1167
+ "<div class='row'>" +
1168
+ "<div class='col-md-2 form-group'>" +
1169
+ "<label for='geomap-aoi-maxy-" + geomap.id + "' class='wb-inv'>" + i18nText.aoiNorth + "</label>" +
1170
+ "<div class='input-group input-group-sm'>" +
1171
+ "<span class='input-group-addon'>" + i18nText.aoiNorth.charAt( 0 ) + "</span>" +
1172
+ "<input type='number' id='geomap-aoi-maxy-" + geomap.id + "' placeholder='90' class='form-control input-sm' min='-90' max='90' step='0.000001'></input>" +
1173
+ "</div>" +
1174
+ "</div>" +
1175
+ "<div class='col-md-2 form-group'>" +
1176
+ "<label for='geomap-aoi-maxx-" + geomap.id + "' class='wb-inv'>" + i18nText.aoiEast + "</label>" +
1177
+ "<div class='input-group input-group-sm'>" +
1178
+ "<span class='input-group-addon'>" + i18nText.aoiEast.charAt( 0 ) + "</span>" +
1179
+ "<input type='number' id='geomap-aoi-maxx-" + geomap.id + "' placeholder='180' class='form-control input-sm' min='-180' max='180' step='0.000001'></input> " +
1180
+ "</div>" +
1181
+ "</div>" +
1182
+ "<div class='col-md-2 form-group'>" +
1183
+ "<label for='geomap-aoi-miny-" + geomap.id + "' class='wb-inv'>" + i18nText.aoiSouth + "</label>" +
1184
+ "<div class='input-group input-group-sm'>" +
1185
+ "<span class='input-group-addon'>" + i18nText.aoiSouth.charAt( 0 ) + "</span>" +
1186
+ "<input type='number' id='geomap-aoi-miny-" + geomap.id + "' placeholder='-90' class='form-control input-sm' min='-90' max='90' step='0.000001'></input> " +
1187
+ "</div>" +
1188
+ "</div>" +
1189
+ "<div class='col-md-2 form-group'>" +
1190
+ "<label for='geomap-aoi-minx-" + geomap.id + "' class='wb-inv'>" + i18nText.aoiWest + "</label>" +
1191
+ "<div class='input-group input-group-sm'>" +
1192
+ "<span class='input-group-addon'>" + i18nText.aoiWest.charAt( 0 ) + "</span>" +
1193
+ "<input type='number' id='geomap-aoi-minx-" + geomap.id + "' placeholder='-180' class='form-control input-sm' min='-180' max='180' step='0.000001'></input> " +
1194
+ "</div>" +
1195
+ "</div>" +
1196
+ "<div class='col-md-4'>" +
1197
+ "<button class='btn btn-default btn-sm' id='geomap-aoi-btn-draw-" + geomap.id + "'>" + i18nText.add + "</button> " +
1198
+ "<button class='btn btn-default btn-sm' id='geomap-aoi-btn-clear-" + geomap.id + "'>" + i18nText.aoiBtnClear + "</button> " +
1199
+ "</div>" +
1200
+ "</div>" +
1201
+ "<input type='hidden' id='geomap-aoi-extent-" + geomap.id + "'></input>" +
1202
+ "<input type='hidden' id='geomap-aoi-extent-lonlat-" + geomap.id + "'></input>" +
1203
+ "</fieldset>" );
1204
+
1205
+ $( "#geomap-aoi-btn-clear-" + geomap.id ).after( "<button id='geomap-aoi-toggle-mode-draw-" + geomap.id +
1206
+ "' href='#' class='btn btn-sm btn-default geomap-geoloc-aoi-btn' title='" + i18nText.aoiBtnDraw +
1207
+ "'><i class='glyphicon glyphicon-edit'></i> " +
1208
+ i18nText.aoiBtnDraw + "</button>" );
1209
+
1210
+ // toggle draw mode
1211
+ $document.on( "click", "#geomap-aoi-toggle-mode-draw-" + geomap.id, function( event ) {
1212
+
1213
+ event.preventDefault();
1214
+
1215
+ var drawInteraction = getMapInteraction( geomap.map, ol.interaction.DragBox ),
1216
+ selectInteraction = getMapInteraction( geomap.map, ol.interaction.Select ),
1217
+ active = interaction.getActive(),
1218
+ $aoiElm = $( "#geomap-aoi-" + geomap.id );
1219
+
1220
+ $( this ).toggleClass( "active" );
1221
+
1222
+ if ( !active ) {
1223
+ $aoiElm.find( "legend" ).trigger( "setfocus.wb" );
1224
+ }
1225
+
1226
+ drawInteraction.setActive( !active );
1227
+ selectInteraction.setActive( active );
1228
+
1229
+ } );
1230
+
1231
+ // clear drawn features
1232
+ $document.on( "click", "#geomap-aoi-btn-clear-" + geomap.id, function( event ) {
1233
+
1234
+ event.preventDefault();
1235
+
1236
+ $( "#geomap-aoi-extent-" + geomap.id ).val( "" );
1237
+ $( "#geomap-aoi-extent-lonlat-" + geomap.id ).val( "" );
1238
+ $( "#geomap-aoi-minx-" + geomap.id ).val( "" ).parent().removeClass( "has-error" );
1239
+ $( "#geomap-aoi-miny-" + geomap.id ).val( "" ).parent().removeClass( "has-error" );
1240
+ $( "#geomap-aoi-maxx-" + geomap.id ).val( "" ).parent().removeClass( "has-error" );
1241
+ $( "#geomap-aoi-maxy-" + geomap.id ).val( "" ).parent().removeClass( "has-error" );
1242
+
1243
+ getLayerById( geomap.map, "locLayer" ).getSource().clear( true );
1244
+
1245
+ } );
1246
+
1247
+ // draw feature from input coordinates
1248
+ $document.on( "click", "#geomap-aoi-btn-draw-" + geomap.id, function( event ) {
1249
+
1250
+ event.preventDefault();
1251
+
1252
+ $( "#geomap-aoi-extent-" + geomap.id ).val( "" );
1253
+ $( "#geomap-aoi-extent-lonlat-" + geomap.id ).val( "" );
1254
+ $( "#geomap-aoi-minx-" + geomap.id ).parent().removeClass( "has-error" );
1255
+ $( "#geomap-aoi-maxx-" + geomap.id ).parent().removeClass( "has-error" );
1256
+ $( "#geomap-aoi-maxy-" + geomap.id ).parent().removeClass( "has-error" );
1257
+ $( "#geomap-aoi-miny-" + geomap.id ).parent().removeClass( "has-error" );
1258
+
1259
+ getLayerById( geomap.map, "locLayer" ).getSource().clear( true );
1260
+
1261
+ var left = parseFloat( $( "#geomap-aoi-minx-" + geomap.id ).val() ),
1262
+ bottom = parseFloat( $( "#geomap-aoi-miny-" + geomap.id ).val() ),
1263
+ right = parseFloat( $( "#geomap-aoi-maxx-" + geomap.id ).val() ),
1264
+ top = parseFloat( $( "#geomap-aoi-maxy-" + geomap.id ).val() ),
1265
+ isValid = true,
1266
+ geomProj,
1267
+ extent;
1268
+
1269
+ if ( !left || left < -180 || left > 180 ) {
1270
+ $( "#geomap-aoi-minx-" + geomap.id ).parent().addClass( "has-error" );
1271
+ isValid = false;
1272
+ }
1273
+
1274
+ if ( !right || right < -180 || right > 180 ) {
1275
+ $( "#geomap-aoi-maxx-" + geomap.id ).parent().addClass( "has-error" );
1276
+ isValid = false;
1277
+ }
1278
+
1279
+ if ( !top || top < -90 || top > 90 ) {
1280
+ $( "#geomap-aoi-maxy-" + geomap.id ).parent().addClass( "has-error" );
1281
+ isValid = false;
1282
+ }
1283
+
1284
+ if ( !bottom || bottom < -90 || bottom > 90 ) {
1285
+ $( "#geomap-aoi-miny-" + geomap.id ).parent().addClass( "has-error" );
1286
+ isValid = false;
1287
+ }
1288
+
1289
+ if ( isValid === false ) {
1290
+ return false;
1291
+ }
1292
+
1293
+ extent = [ left, bottom, right, top ];
1294
+
1295
+ geomProj = drawAOI( geomap, extent );
1296
+
1297
+ // zoom to extent of feature
1298
+ geomap.map.getView().fit( geomProj.getGeometry().getExtent(), geomap.map.getSize() );
1299
+
1300
+ $( "#geomap-aoi-extent-" + geomap.id ).val( geomProj.getGeometry().getExtent() ).trigger( "change" );
1301
+ $( "#geomap-aoi-extent-lonlat-" + geomap.id ).val( left + ", " + bottom + ", " + right + ", " + top ).trigger( "change" );
1302
+
1303
+ } );
1304
+
1305
+ // if a default AOI is provided add it to the map and zoom to it
1306
+ if ( geomap.aoiExtent ) {
1307
+
1308
+ extent = geomap.aoiExtent.split( "," );
1309
+ left = extent[ 0 ].trim();
1310
+ bottom = extent[ 1 ].trim();
1311
+ right = extent[ 2 ].trim();
1312
+ top = extent[ 3 ].trim();
1313
+ geomProj = drawAOI( geomap, extent );
1314
+
1315
+ // zoom to extent of feature
1316
+ geomap.map.getView().fit( geomProj.getGeometry().getExtent(), geomap.map.getSize() );
1317
+
1318
+ $( "#geomap-aoi-minx-" + geomap.id ).val( left );
1319
+ $( "#geomap-aoi-maxx-" + geomap.id ).val( right );
1320
+ $( "#geomap-aoi-maxy-" + geomap.id ).val( top );
1321
+ $( "#geomap-aoi-miny-" + geomap.id ).val( bottom );
1322
+ $( "#geomap-aoi-extent-" + geomap.id ).val( geomProj.getBounds().toBBOX() );
1323
+ $( "#geomap-aoi-extent-lonlat-" + geomap.id ).val( left + ", " + bottom + ", " + right + ", " + top );
1324
+
1325
+ }
1326
+ },
1327
+
1328
+ //
1329
+ // Param:
1330
+ // - geomap = geomap Object
1331
+ // - extext = array with 4 point ( West, South, East, North)
1332
+ // - dontAddFeat = boolean (default:false) if true, no delimiter box would be added to the map
1333
+ //
1334
+ drawAOI = function( geomap, extent, dontAddFeat ) {
1335
+
1336
+ var coords = [],
1337
+ dens, len, feat,
1338
+ projLatLon = new ol.proj.Projection( { code: "EPSG:4326" } ),
1339
+ projMap = geomap.map.getView().getProjection();
1340
+
1341
+ dens = densifyBBox( parseFloat( extent[ 0 ] ), parseFloat( extent[ 1 ] ), parseFloat( extent[ 2 ] ), parseFloat( extent[ 3 ] ) );
1342
+
1343
+ for ( len = dens.length - 1; len !== -1; len -= 1 ) {
1344
+ coords.push( [ dens[ len ].getCoordinates()[ 0 ], dens[ len ].getCoordinates()[ 1 ] ] );
1345
+ }
1346
+
1347
+ feat = new ol.Feature( {
1348
+ geometry: new ol.geom.Polygon( [ coords ] ).transform( projLatLon, projMap )
1349
+ } );
1350
+
1351
+ if ( !dontAddFeat ) {
1352
+ getLayerById( geomap.map, "locLayer" ).getSource().addFeature( feat );
1353
+ }
1354
+
1355
+ return feat;
1356
+
1357
+ },
1358
+
1359
+ /**
1360
+ * Help Control - displays navigation help popup
1361
+ */
1362
+ HelpControl = function( geomap ) {
1363
+
1364
+ var button = document.createElement( "button" ),
1365
+ element = document.createElement( "div" );
1366
+
1367
+ button.innerHTML = "?";
1368
+ button.title = i18nText.accessTitle;
1369
+ button.setAttribute( "type", "button" );
1370
+
1371
+ button.addEventListener( "click", function() {
1372
+
1373
+ var dialog = document.createElement( "div" ),
1374
+ header = document.createElement( "header" ),
1375
+ h3 = document.createElement( "h3" ),
1376
+ closeButton = document.createElement( "a" ),
1377
+ panel = document.createElement( "div" ),
1378
+ role = document.createAttribute( "role" ),
1379
+ title = document.createAttribute( "title" ),
1380
+ href = document.createAttribute( "href" );
1381
+
1382
+ dialog.className = "panel panel-default geomap-help-dialog ol-control ";
1383
+ header.className = "panel-heading";
1384
+
1385
+ h3.innerHTML = i18nText.accessTitle;
1386
+ h3.className = "panel-title";
1387
+
1388
+ header.appendChild( h3 );
1389
+
1390
+ title.value = i18nText.dismiss;
1391
+ closeButton.setAttributeNode( title );
1392
+ href.value = "#";
1393
+ closeButton.setAttributeNode( href );
1394
+ role.value = "button";
1395
+ closeButton.setAttributeNode( role );
1396
+ closeButton.innerHTML = "&#xd7;<span class='wb-inv'>" + i18nText.dismiss + "</span>";
1397
+ closeButton.className = "btn btn-link";
1398
+
1399
+ dialog.appendChild( closeButton );
1400
+
1401
+ panel.innerHTML = "<p>" + i18nText.access + "</p>";
1402
+ panel.className = "panel-body";
1403
+
1404
+ dialog.appendChild( header );
1405
+ dialog.appendChild( panel );
1406
+
1407
+ var myControl = new ol.control.Control( { element: dialog } );
1408
+
1409
+ // Handle the close button event
1410
+ closeButton.addEventListener( "click", function( event ) {
1411
+
1412
+ event.preventDefault();
1413
+
1414
+ $( event.target ).closest( ".geomap-help-dialog" ).fadeOut( function() {
1415
+ geomap.map.removeControl( myControl );
1416
+ } );
1417
+
1418
+ } );
1419
+
1420
+ geomap.map.addControl( myControl );
1421
+
1422
+ }, false );
1423
+
1424
+ element.className = "geomap-help-btn ol-unselectable ol-control";
1425
+ element.appendChild( button );
1426
+
1427
+ ol.control.Control.call( this, {
1428
+ element: element
1429
+ } );
1430
+
1431
+ geomap.map.addControl( this );
1432
+
1433
+ },
1434
+
1435
+ /*
1436
+ * Geocoder Widget - search for place names (e.g. cities/towns, addresses,
1437
+ * streets, postal codes)
1438
+ */
1439
+ GeocodeControl = function( geomap ) {
1440
+
1441
+ var element = document.createElement( "div" ),
1442
+ setFocusEvent = "setfocus.wb",
1443
+ url = i18nText.geoLocationURL,
1444
+ mapObj = {
1445
+ "quebec": "<abbr title='Quebec'>QC</abbr>",
1446
+ "québec": "<abbr title='Québec'>QC</abbr>",
1447
+ "british columbia": "<abbr title='British Columbia'>BC</abbr>",
1448
+ "colombie-britannique": "<abbr title='Colombie-Britannique'>BC</abbr>",
1449
+ "alberta": "<abbr title='Alberta'>AB</abbr>",
1450
+ "saskatchewan": "<abbr title='Saskatchewan'>SK</abbr>",
1451
+ "manitoba": "<abbr title='Manitoba'>MB</abbr>",
1452
+ "ontario": "<abbr title='Ontario'>ON</abbr>",
1453
+ "newfoundland and labrador": "<abbr title='Newfoundland and Labrador'>NL</abbr>",
1454
+ "terre-neuve-et-labrador": "<abbr title='Terre-Neuve-et-Labrador'>NL</abbr>",
1455
+ "prince edward island": "<abbr title='Prince Edward Island'>PE</abbr>",
1456
+ "île-du-prince-édouard": "<abbr title='Île-du-prince-Édouard'>PE</abbr>",
1457
+ "nova scotia": "<abbr title='Nova Scotia'>NS</abbr>",
1458
+ "nouvelle-écosse": "<abbr title='Nouvelle-Écosse'>NS</abbr>",
1459
+ "new brunswick": "<abbr title='New Brunswick'>NB</abbr>",
1460
+ "nouveau-brunswick": "<abbr title='Nouveau-Brunswick'>NB</abbr>",
1461
+ "yukon": "<abbr title='Yukon'>YT</abbr>",
1462
+ "northwest territories": "<abbr title='Northwest Territories'>NT</abbr>",
1463
+ "territoires du nord-ouest": "<abbr title='Territoires du Nord-Ouest'>NT</abbr>",
1464
+ "nunavut": "<abbr title='Nunavut'>NU</abbr>"
1465
+ },
1466
+ iconObj = {
1467
+ "ca.gc.nrcan.geoloc.data.model.Street": "<span class='glyphicon glyphicon-road' aria-hidden='true'></span>",
1468
+ "ca.gc.nrcan.geoloc.data.model.Intersection": "<span class='glyphicon glyphicon-road' aria-hidden='true'></span>",
1469
+ "ca.gc.nrcan.geoloc.data.model.Geoname": "<span class='glyphicon glyphicon-map-marker' aria-hidden='true'></span>",
1470
+ "ca.gc.nrcan.geoloc.data.model.PostalCode": "<span class='glyphicon glyphicon-envelope' aria-hidden='true'></span>",
1471
+ "ca.gc.nrcan.geoloc.data.model.NTS": "<span class='glyphicon glyphicon-globe' aria-hidden='true'></span>"
1472
+ },
1473
+ width, x;
1474
+
1475
+ element.innerHTML =
1476
+ "<label for='wb-geomap-geocode-search-" + geomap.id + "' class='wb-inv'>" + i18nText.geoCoderLabel + "</label>" +
1477
+ "<input type='text' class='form-control' id='wb-geomap-geocode-search-" + geomap.id + "' placeholder='" + i18nText.geoCoderPlaceholder + "' ></input>" +
1478
+ "<div class='wb-geomap-geoloc-al-cnt'><ul role='listbox' id='wb-geomap-geoloc-al-" + geomap.id + "' class='wb-geomap-geoloc-al hide' aria-hidden='true' aria-live='polite'></ul></div>";
1479
+
1480
+ element.className = "geomap-geoloc ol-unselectable ol-control";
1481
+
1482
+ ol.control.Control.call( this, {
1483
+ element: element
1484
+ } );
1485
+
1486
+ geomap.map.addControl( this );
1487
+
1488
+ // Adds WAI-ARIA
1489
+ $( "#wb-geomap-geocode-search-" + geomap.id ).attr( "autocomplete", "off" );
1490
+ $( "#wb-geomap-geocode-search-" + geomap.id ).attr( "role", "textbox" );
1491
+ $( "#wb-geomap-geocode-search-" + geomap.id ).attr( "aria-haspopup", "true" );
1492
+ $( "#wb-geomap-geocode-search-" + geomap.id ).attr( "aria-autocomplete", "list" );
1493
+ $( "#wb-geomap-geocode-search-" + geomap.id ).attr( "aria-owns", "wb-geomap-geoloc-al-" + geomap.id );
1494
+ $( "#wb-geomap-geocode-search-" + geomap.id ).attr( "aria-activedescendent", "" );
1495
+
1496
+ width = parseFloat( $( ".geomap-geoloc" ).parent().width() );
1497
+ x = width > 768 ? .6 : .8;
1498
+
1499
+ if ( !mobile ) {
1500
+ $( ".geomap-geoloc" ).css( { "width": width * x } );
1501
+ $( ".wb-geomap-geoloc-al-cnt" ).css( { "width": width * x } );
1502
+ } else {
1503
+ $( ".geomap-geoloc" ).css( { "width": width - 10 + "px" } );
1504
+ $( ".wb-geomap-geoloc-al-cnt" ).css( { "width": width - 10 + "px" } );
1505
+ }
1506
+
1507
+ function panZoomToFeature( bbox, ll ) {
1508
+
1509
+ var bnds,
1510
+ coords = [],
1511
+ dens,
1512
+ feat,
1513
+ len,
1514
+ projLatLon = new ol.proj.Projection( { code: "EPSG:4326" } ),
1515
+ projMap = geomap.map.getView().getProjection(),
1516
+ zoom;
1517
+
1518
+ getLayerById( geomap.map, "locLayer" ).getSource().clear( true );
1519
+
1520
+ if ( bbox && typeof bbox !== "undefined" ) {
1521
+
1522
+ bnds = bbox.split( "," );
1523
+ dens = densifyBBox( parseFloat( bnds[ 0 ] ), parseFloat( bnds[ 1 ] ), parseFloat( bnds[ 2 ] ), parseFloat( bnds[ 3 ] ) );
1524
+
1525
+ for ( len = dens.length - 1; len !== -1; len -= 1 ) {
1526
+ coords.push( [ dens[ len ].getCoordinates()[ 0 ], dens[ len ].getCoordinates()[ 1 ] ] );
1527
+ }
1528
+
1529
+ feat = new ol.Feature( {
1530
+ geometry: new ol.geom.Polygon( [ coords ] ).transform( projLatLon, projMap )
1531
+ } );
1532
+
1533
+ getLayerById( geomap.map, "locLayer" ).getSource().addFeature( feat );
1534
+
1535
+ // zoom to extent of feature
1536
+ geomap.map.getView().fit( feat.getGeometry().getExtent(), geomap.map.getSize() );
1537
+
1538
+ } else if ( ll && typeof ll !== "undefined" ) {
1539
+
1540
+ zoom = geomap.map.getView().getZoom() === 0 ? 12 : geomap.map.getView().getZoom();
1541
+ feat = new ol.Feature( {
1542
+ geometry: new ol.geom.Point( ll.split( "," ) ).transform( projLatLon, projMap )
1543
+ } );
1544
+ getLayerById( geomap.map, "locLayer" ).getSource().addFeature( feat );
1545
+
1546
+ // zoom to feature
1547
+ geomap.map.getView().setZoom( zoom );
1548
+ geomap.map.getView().setCenter( feat.getGeometry().getCoordinates() );
1549
+
1550
+ }
1551
+
1552
+ }
1553
+
1554
+ $document.on( "keydown", "#wb-geomap-geocode-search-" + geomap.id, function( event ) {
1555
+
1556
+ // TODO: find another way to do this, maybe setting negative tabindex
1557
+ getMapInteraction( geomap.map, ol.interaction.KeyboardPan ).setActive( false );
1558
+
1559
+ var which = event.which;
1560
+
1561
+ if ( !( event.ctrlKey || event.metaKey ) ) {
1562
+ return keyboardHandlerInput( which, event );
1563
+ }
1564
+
1565
+ } );
1566
+
1567
+ /**
1568
+ * Hides all the options
1569
+ * @method closeOptions
1570
+ * @param {DOM element} input The polyfilled input field
1571
+ */
1572
+ function closeOptions( input ) {
1573
+ var autolist = input.nextSibling.firstChild;
1574
+
1575
+ // TODO: find another way to do this, maybe setting negative tabindex
1576
+ getMapInteraction( geomap.map, ol.interaction.KeyboardPan ).setActive( true );
1577
+
1578
+ autolist.className += " hide";
1579
+ autolist.innerHTML = "";
1580
+ autolist.setAttribute( "aria-hidden", "true" );
1581
+ input.setAttribute( "aria-expanded", "false" );
1582
+ input.setAttribute( "aria-activedescendent", "" );
1583
+ }
1584
+
1585
+ /**
1586
+ * Returns the available options based upon the input in the input field.
1587
+ * @method showOptions
1588
+ * @param {DOM element} input The input field
1589
+ */
1590
+ function showOptions( input, value ) {
1591
+
1592
+ var options = "",
1593
+ $input = $( "#wb-geomap-geocode-search-" + geomap.id ),
1594
+ $autolist = $( "#wb-geomap-geoloc-al-" + geomap.id ),
1595
+ abbrProv = function( str, mapObj ) {
1596
+ var re = new RegExp( Object.keys( mapObj ).join( "|" ), "gi" );
1597
+ return str.replace( re, function( matched ) {
1598
+ return mapObj[ matched.toLowerCase() ];
1599
+ } );
1600
+ };
1601
+
1602
+ if ( !value || value.length < 3 ) {
1603
+ $autolist.empty();
1604
+ }
1605
+
1606
+ $.ajax( {
1607
+ type: "GET",
1608
+ url: url,
1609
+ data: { q: value + "*" },
1610
+ success: function( data ) {
1611
+
1612
+ if ( data.length > 0 ) {
1613
+
1614
+ var len = data.length,
1615
+ icon = "",
1616
+ i, item, label, title, bnd, ll;
1617
+
1618
+ for ( i = 0; i !== len; i += 1 ) {
1619
+
1620
+ item = data[ i ];
1621
+ title = item.title
1622
+ .replace( /&/g, "&amp;" )
1623
+ .replace( /"/g, "&quot;" )
1624
+ .replace( /'/g, "&#39;" )
1625
+ .replace( /</g, "&lt;" )
1626
+ .replace( />/g, "&gt;" );
1627
+ bnd = item.bbox ? item.bbox[ 0 ] + ", " + item.bbox[ 1 ] + ", " + item.bbox[ 2 ] + ", " + item.bbox[ 3 ] : "";
1628
+ ll = item.geometry && item.geometry.type === "Point" ? item.geometry.coordinates[ 0 ] + ", " + item.geometry.coordinates[ 1 ] : "";
1629
+ icon = iconObj[ item.type ] ? iconObj[ item.type ] : "<span class='glyphicon glyphicon-map-marker' aria-hidden='true'></span>";
1630
+ title = abbrProv( title, mapObj );
1631
+ label = title.replace( /<(?:.|\n)*?>/gm, "" );
1632
+
1633
+ options += "<li id='al-opt-" + geomap.id + "-" + i +
1634
+ "' class='al-opt' data-lat-lon='" + ll +
1635
+ "' data-bbox='" + bnd +
1636
+ "' data-type='" + item.type + "'>" +
1637
+ "<a href='javascript:;' tabindex='-1'>" + icon +
1638
+ "<span class='al-val'>" + title + "</span>" +
1639
+ "<span class='al-lbl wb-inv' aria-hidden='true'>" + label + "</span>" +
1640
+ "</a></li>";
1641
+
1642
+ }
1643
+
1644
+ $autolist.empty().append( options );
1645
+ $autolist.removeClass( "hide" ).attr( "aria-hidden", "false" );
1646
+ $input.attr( "aria-expanded", "true" );
1647
+
1648
+ // bind events to the options
1649
+ // TODO: do this in the wb-update event
1650
+ $( ".al-opt a" ).on( "keydown click", function( event ) {
1651
+ var link = event.target,
1652
+ eventType = event.type,
1653
+ which = event.which;
1654
+
1655
+ switch ( eventType ) {
1656
+ case "keydown":
1657
+ if ( !( event.ctrlKey || event.metaKey ) ) {
1658
+ return keyboardHandlerAutolist( which, link );
1659
+ }
1660
+ break;
1661
+ case "click":
1662
+
1663
+ // Ignore middle/right mouse buttons
1664
+ if ( !which || which === 1 ) {
1665
+ return clickHandlerAutolist( link );
1666
+ }
1667
+ break;
1668
+ }
1669
+
1670
+ } );
1671
+
1672
+ } else {
1673
+ $autolist.empty();
1674
+ $autolist.addClass( "hide" ).attr( "aria-hidden", "true" );
1675
+ $autolist.attr( "aria-expanded", "false" );
1676
+ }
1677
+
1678
+ },
1679
+ dataType: "json",
1680
+ cache: false
1681
+ } );
1682
+
1683
+ }
1684
+
1685
+ /**
1686
+ * Keyboard event handler for the polyfilled input field
1687
+ * @param {integer} which Value for event.which
1688
+ * @param {jQuery Event} event The event that triggered this method call
1689
+ */
1690
+ function keyboardHandlerInput( which, event ) {
1691
+
1692
+ var input = event.target,
1693
+ autolist = input.nextSibling.firstChild,
1694
+ autolistHidden = ( autolist.className.indexOf( "hide" ) !== -1 ),
1695
+ options, dest, value, len;
1696
+
1697
+ // Unmodified keystrokes only
1698
+ if ( !( event.ctrlKey || event.altKey || event.metaKey ) ) {
1699
+
1700
+ // Spacebar, a - z keys, 0 - 9 keys punctuation, and symbols
1701
+ if ( which === 32 || ( which > 47 && which < 91 ) ||
1702
+ ( which > 95 && which < 112 ) || ( which > 159 && which < 177 ) ||
1703
+ ( which > 187 && which < 223 ) ) {
1704
+ if ( !event.altKey ) {
1705
+ showOptions( input, input.value + String.fromCharCode( which ) );
1706
+ }
1707
+
1708
+ // Backspace
1709
+ } else if ( which === 8 && !event.altKey ) {
1710
+ value = input.value;
1711
+ len = value.length;
1712
+
1713
+ if ( len !== 0 ) {
1714
+ showOptions( input, value.substring( 0, len - 1 ) );
1715
+ }
1716
+
1717
+ // Up / down arrow
1718
+ } else if ( ( which === 38 || which === 40 ) && input.getAttribute( "aria-activedescendent" ) === "" ) {
1719
+
1720
+ if ( autolistHidden ) {
1721
+ showOptions( input );
1722
+ }
1723
+
1724
+ options = autolist.getElementsByTagName( "a" );
1725
+
1726
+ if ( options.length === 0 ) {
1727
+ return false;
1728
+ }
1729
+
1730
+ dest = options[ ( which === 38 ? options.length - 1 : 0 ) ];
1731
+
1732
+ input.setAttribute( "aria-activedescendent", dest.parentNode.getAttribute( "id" ) );
1733
+
1734
+ // Assign focus to dest
1735
+ $( dest ).trigger( setFocusEvent );
1736
+
1737
+ return false;
1738
+
1739
+ } else if ( !autolistHidden ) {
1740
+
1741
+ // Tab or Escape key
1742
+ if ( ( which === 9 || which === 27 ) || ( which === 27 && !event.altKey ) ) {
1743
+ closeOptions( input );
1744
+ }
1745
+ }
1746
+ }
1747
+ }
1748
+
1749
+ /**
1750
+ * Click / Touch event handler for the autolist of the polyfilled input field
1751
+ * @param {integer} eventTarget Value for event.target
1752
+ */
1753
+ function clickHandlerAutolist( eventTarget ) {
1754
+
1755
+ var nodeName = eventTarget.nodeName.toLowerCase(),
1756
+ link = nodeName === "a" ? eventTarget : eventTarget.parentNode,
1757
+ autolist = link.parentNode.parentNode,
1758
+ input = autolist.parentNode.previousSibling,
1759
+ $input = $( input ),
1760
+ span = link.getElementsByTagName( "span" ),
1761
+ value = span[ 2 ].innerHTML;
1762
+
1763
+ input.value = value;
1764
+
1765
+ panZoomToFeature( link.parentNode.getAttribute( "data-bbox" ), link.parentNode.getAttribute( "data-lat-lon" ) );
1766
+
1767
+ $input.trigger( setFocusEvent );
1768
+ closeOptions( input );
1769
+
1770
+ return false;
1771
+ }
1772
+
1773
+ /**
1774
+ * Keyboard event handler for the autolist of the polyfilled input field
1775
+ * @param {integer} which Value for event.which
1776
+ * @param {DOM element} link Link element that is the target of the event
1777
+ */
1778
+ function keyboardHandlerAutolist( which, link ) {
1779
+ var autolist = link.parentNode.parentNode,
1780
+ input = autolist.parentNode.previousSibling,
1781
+ $input = $( input ),
1782
+ span, dest, value, len, children;
1783
+
1784
+ // Unmodified keystrokes only
1785
+ if ( !( event.ctrlKey || event.altKey || event.metaKey ) ) {
1786
+
1787
+ // Spacebar, a - z keys, 0 - 9 keys punctuation, and symbols
1788
+ if ( which === 32 || ( which > 47 && which < 91 ) ||
1789
+ ( which > 95 && which < 112 ) || ( which > 159 && which < 177 ) ||
1790
+ ( which > 187 && which < 223 ) ) {
1791
+
1792
+ input.value += String.fromCharCode( which );
1793
+ $input.trigger( setFocusEvent );
1794
+ showOptions( input, input.value );
1795
+
1796
+ return false;
1797
+
1798
+ // Backspace
1799
+ } else if ( which === 8 ) {
1800
+ value = input.value;
1801
+ len = value.length;
1802
+
1803
+ if ( len !== 0 ) {
1804
+ input.value = value.substring( 0, len - 1 );
1805
+ showOptions( input, input.value );
1806
+ }
1807
+
1808
+ $input.trigger( setFocusEvent );
1809
+
1810
+ return false;
1811
+
1812
+ // Enter key
1813
+ } else if ( which === 13 ) {
1814
+ span = link.getElementsByTagName( "span" );
1815
+ value = span[ 2 ].innerHTML;
1816
+
1817
+ input.value = value;
1818
+
1819
+ panZoomToFeature( link.parentNode.getAttribute( "data-bbox" ), link.parentNode.getAttribute( "data-lat-lon" ) );
1820
+
1821
+ $input.trigger( setFocusEvent );
1822
+ closeOptions( input );
1823
+
1824
+ return false;
1825
+
1826
+ // Tab or Escape key
1827
+ } else if ( which === 9 || which === 27 ) {
1828
+ $input.trigger( setFocusEvent );
1829
+ closeOptions( input );
1830
+
1831
+ return false;
1832
+
1833
+ // Up or down arrow
1834
+ } else if ( which === 38 || which === 40 ) {
1835
+
1836
+ // Up arrow
1837
+ if ( which === 38 ) {
1838
+ dest = link.parentNode.previousSibling;
1839
+ if ( !dest ) {
1840
+ children = autolist.getElementsByTagName( "li" );
1841
+ dest = children[ children.length - 1 ];
1842
+ }
1843
+
1844
+ // Down arrow
1845
+ } else {
1846
+ dest = link.parentNode.nextSibling;
1847
+ if ( !dest ) {
1848
+ dest = autolist.getElementsByTagName( "li" )[ 0 ];
1849
+ }
1850
+ }
1851
+ dest = dest.getElementsByTagName( "a" )[ 0 ];
1852
+
1853
+ input.setAttribute( "aria-activedescendent", dest.parentNode.getAttribute( "id" ) );
1854
+ $( dest ).trigger( setFocusEvent );
1855
+
1856
+ return false;
1857
+ }
1858
+ }
1859
+
1860
+ }
1861
+
1862
+ },
1863
+
1864
+ /*
1865
+ * Geolocation control - locate client and display icon on map
1866
+ */
1867
+ GeolocationControl = function( options ) {
1868
+
1869
+ var opts = options || {},
1870
+ _this = this,
1871
+ accuracyFeature, positionFeature,
1872
+ button, coordinates, element;
1873
+
1874
+ $( "body" ).append(
1875
+ "<section id='overlay-location-error' class='wb-overlay modal-content overlay-def wb-bar-t bg-danger'>" +
1876
+ "<header><h2 class='modal-title'>Geolocation error.</h2></header>" +
1877
+ "</section>"
1878
+ );
1879
+
1880
+ $( "#overlay-location-error" ).trigger( "wb-init.wb-overlay" );
1881
+
1882
+ button = document.createElement( "button" );
1883
+ button.setAttribute( "type", "button" );
1884
+ button.setAttribute( "title", i18nText.geolocBtn );
1885
+ button.innerHTML = "<span class='glyphicon glyphicon-screenshot'></span>";
1886
+
1887
+ element = document.createElement( "div" );
1888
+ element.className = "ol-geolocate ol-unselectable ol-control";
1889
+
1890
+ element.appendChild( button );
1891
+
1892
+ _this.geolocation = new ol.Geolocation( opts );
1893
+
1894
+ function createFeatures() {
1895
+
1896
+ positionFeature = new ol.Feature();
1897
+ accuracyFeature = new ol.Feature();
1898
+
1899
+ positionFeature.setStyle( getPointStyle( {
1900
+ radius: 6,
1901
+ fill: new ol.style.Fill( {
1902
+ color: "#3399CC"
1903
+ } ),
1904
+ stroke: new ol.style.Stroke( {
1905
+ color: "#fff",
1906
+ width: 2
1907
+ } ) } )
1908
+ );
1909
+
1910
+ return [ accuracyFeature, positionFeature ];
1911
+ }
1912
+
1913
+ ol.control.Control.call( this, {
1914
+ element: element,
1915
+ target: opts.target
1916
+ } );
1917
+
1918
+ _this.geolocation.on( "change:accuracyGeometry", function() {
1919
+ accuracyFeature.setGeometry( _this.geolocation.getAccuracyGeometry() );
1920
+ } );
1921
+
1922
+ _this.geolocation.on( "change:position", function() {
1923
+ coordinates = _this.geolocation.getPosition();
1924
+ positionFeature.setGeometry( coordinates ?
1925
+ new ol.geom.Point( coordinates ) : null );
1926
+
1927
+ // zoom to feature
1928
+ var extent = _this.featuresOverlay.getSource().getExtent();
1929
+ _this.getMap().getView().fit( extent, _this.getMap().getSize() );
1930
+
1931
+ $( button ).html( "<span style='color:#3399CC;' class='glyphicon glyphicon-screenshot'></span>" );
1932
+
1933
+ } );
1934
+
1935
+ /* Handle errors.
1936
+ * Codes:
1937
+ PERMISSION_DENIED: 1
1938
+ POSITION_UNAVAILABLE: 2
1939
+ TIMEOUT: 3
1940
+ */
1941
+ _this.geolocation.on( "error", function( error ) {
1942
+ if ( error.code === 2 ) {
1943
+ $( "#overlay-location-error h2.modal-title" ).text( i18nText.geolocUncapable );
1944
+ $( "#overlay-location-error" ).trigger( "open.wb-overlay" );
1945
+ } else {
1946
+ $( "#overlay-location-error h2.modal-title" ).text( i18nText.geolocFail );
1947
+ $( "#overlay-location-error" ).trigger( "open.wb-overlay" );
1948
+ }
1949
+ } );
1950
+
1951
+ button.addEventListener( "click", function() {
1952
+
1953
+ $( this ).html( "<span style='font-size:.9em;' class='glyphicon glyphicon-refresh glyphicon-spin'></span>" );
1954
+
1955
+ if ( typeof _this.featuresOverlay === "undefined" ) {
1956
+
1957
+ _this.featuresOverlay = new ol.layer.Vector( {
1958
+ map: _this.getMap(),
1959
+ source: new ol.source.Vector( { } )
1960
+ } );
1961
+
1962
+ _this.featuresOverlay.getSource().addFeatures( createFeatures() );
1963
+ _this.geolocation.setTracking( true );
1964
+
1965
+ } else if ( _this.featuresOverlay.getSource().getFeatures().length === 0 ) {
1966
+
1967
+ _this.featuresOverlay.getSource().addFeatures( createFeatures() );
1968
+ _this.geolocation.setTracking( true );
1969
+
1970
+ } else {
1971
+
1972
+ _this.geolocation.setTracking( false );
1973
+ _this.featuresOverlay.getSource().clear();
1974
+
1975
+ $( this ).html( "<span class='glyphicon glyphicon-screenshot'></span>" );
1976
+
1977
+ }
1978
+
1979
+ }, false );
1980
+
1981
+ },
1982
+
1983
+ /*
1984
+ * Construct a polygon and densify the latitudes to show the curvature
1985
+ */
1986
+ densifyBBox = function( minX, minY, maxX, maxY ) {
1987
+
1988
+ var left = parseFloat( minX ),
1989
+ bottom = parseFloat( minY ),
1990
+ right = parseFloat( maxX ),
1991
+ top = parseFloat( maxY ),
1992
+ newbounds = [ ],
1993
+ j;
1994
+
1995
+ if ( left.length === 0 || bottom.length === 0 ||
1996
+ right.length === 0 || top.length === 0 ) {
1997
+
1998
+ return false;
1999
+ }
2000
+
2001
+ // If default BBOX, make it fit in view showing Canada and not the world.
2002
+ if ( left === -180.0 ) {
2003
+ left += 0.1;
2004
+ }
2005
+ if ( right === 180.0 ) {
2006
+ right = -5.0;
2007
+ }
2008
+ if ( top === 90.0 ) {
2009
+ top -= 3;
2010
+ }
2011
+ if ( bottom === -90.0 ) {
2012
+ bottom = 35.0;
2013
+ }
2014
+
2015
+ for ( j = left; j < right; j += 0.5 ) {
2016
+ newbounds.push( new ol.geom.Point( [ j, bottom ] ) );
2017
+ }
2018
+
2019
+ newbounds.push( new ol.geom.Point( [ right, bottom ] ) );
2020
+
2021
+ for ( j = right; j > left; j -= 0.5 ) {
2022
+ newbounds.push( new ol.geom.Point( [ j, top ] ) );
2023
+ }
2024
+
2025
+ newbounds.push( new ol.geom.Point( [ left, top ] ) );
2026
+ newbounds.push( new ol.geom.Point( [ left, bottom ] ) );
2027
+
2028
+ return newbounds;
2029
+ },
2030
+
2031
+ /*
2032
+ * Refresh WET plugins
2033
+ */
2034
+ refreshPlugins = function() {
2035
+ $( ".wb-tables" ).trigger( "wb-init.wb-tables" );
2036
+ },
2037
+
2038
+ getLayerById = function( map, id ) {
2039
+ var layer;
2040
+
2041
+ map.getLayers().forEach( function( lyr ) {
2042
+ if ( id === lyr.id ) {
2043
+ layer = lyr;
2044
+ return;
2045
+ }
2046
+ } );
2047
+
2048
+ return layer;
2049
+ },
2050
+
2051
+ // Retrieve the map, layer and feature using data attributes on an element
2052
+ getMapLayerFeature = function( elm ) {
2053
+
2054
+ var geomap = getMapById( elm.getAttribute( "data-map" ) ),
2055
+ layer;
2056
+
2057
+ if ( elm.getAttribute( "data-layer" ) ) {
2058
+ layer = getLayerById( geomap.map, elm.getAttribute( "data-layer" ) );
2059
+
2060
+ return [
2061
+ geomap.map,
2062
+ layer,
2063
+ elm.getAttribute( "data-feature" ) ? layer.getSource().getFeatureById( elm.getAttribute( "data-feature" ) ) : null
2064
+ ];
2065
+
2066
+ } else {
2067
+ return [ geomap.map, null, null ];
2068
+ }
2069
+ },
2070
+
2071
+ /**
2072
+ * Create a random Guid.
2073
+ *
2074
+ * @return {String} a random Guid value.
2075
+ */
2076
+ generateGuid = function() {
2077
+ return Math.random().toString( 36 ).slice( 2 );
2078
+ };
2079
+
2080
+ // Handle the Zoom to button events
2081
+ $document.on( "click", ".geomap-zoomto", function( event ) {
2082
+ var which = event.which,
2083
+ target = ( event.target.tagName === "A" ) ? event.target : $( event.target ).closest( "a" )[ 0 ],
2084
+ mapId, mapLayerFeature, geometry, extent, view;
2085
+
2086
+ // Ignore middle/right mouse buttons
2087
+ if ( !which || which === 1 ) {
2088
+ event.preventDefault();
2089
+ mapId = target.getAttribute( "data-map" );
2090
+ mapLayerFeature = getMapLayerFeature( target );
2091
+ geometry = mapLayerFeature[ 2 ].getGeometry();
2092
+ extent = geometry.getExtent();
2093
+ view = mapLayerFeature[ 0 ].getView();
2094
+
2095
+ //TODO: rework, using undocumented function
2096
+ if ( geometry.getType() === "Point" ) {
2097
+ view.fit( extent, mapLayerFeature[ 0 ].getSize() );
2098
+ view.setZoom( 10 );
2099
+ } else {
2100
+ view.fit( extent, mapLayerFeature[ 0 ].getSize() );
2101
+ }
2102
+
2103
+ $( "#" + mapId + " .wb-geomap-map" ).trigger( "setfocus.wb" );
2104
+ }
2105
+ } );
2106
+
2107
+ // Bind the init function to the geomap.wb event
2108
+ $document.on( "geomap.wb", selector, init );
2109
+
2110
+ // Update the map when the window is resized
2111
+ $document.on( wb.resizeEvents, function( event ) {
2112
+
2113
+ mapArray.forEach( function( geomap ) {
2114
+
2115
+ var $mapDiv = $( geomap.map.getTargetElement() ),
2116
+ $myDiv = $mapDiv.find( ".geomap-geoloc" ),
2117
+ width = $mapDiv.width();
2118
+
2119
+ $mapDiv.height( width * geomap.map.get( "aspectRatio" ) );
2120
+
2121
+ geomap.map.updateSize();
2122
+
2123
+ if ( $myDiv ) {
2124
+ if ( event.type === "mediumview" || event.type === "largeview" || event.type === "xlargeview" ) {
2125
+ $myDiv.css( { "width": "60%" } );
2126
+ } else {
2127
+ $myDiv.css( { "width": "80%" } );
2128
+ }
2129
+ }
2130
+
2131
+ } );
2132
+
2133
+ } );
2134
+
2135
+ // Handle clicking of checkboxes within the tables
2136
+ $document.on( "change", ".geomap-cbx", function( event ) {
2137
+
2138
+ var target = event.target,
2139
+ feature = getMapLayerFeature( target )[ 2 ],
2140
+ map = getMapLayerFeature( target )[ 0 ],
2141
+ selectInteraction = getMapInteraction( map, ol.interaction.Select ),
2142
+ checked = target.checked;
2143
+
2144
+ if ( checked ) {
2145
+ selectInteraction.getFeatures().push( feature );
2146
+ } else {
2147
+ selectInteraction.getFeatures().remove( feature );
2148
+ }
2149
+
2150
+ } );
2151
+
2152
+ /**
2153
+ * Add/remove map border based on mouse pointer location
2154
+ */
2155
+ $document.on( "focusin focusout mouseover mouseout", ".wb-geomap-map", function( event ) {
2156
+
2157
+ var target = event.currentTarget,
2158
+ type = event.type,
2159
+ isActive = target.className.indexOf( "active" ),
2160
+ geomap = getMapById( target.getAttribute( "data-map" ) ),
2161
+ mouseWheelZoom = getMapInteraction( geomap.map, ol.interaction.MouseWheelZoom );
2162
+
2163
+ // disable mouseWheelZoom so that page scrolling isn't interupted
2164
+ if ( geomap.settings.useMapControls ) {
2165
+ mouseWheelZoom.setActive( false );
2166
+ }
2167
+
2168
+ if ( type === "mouseover" || type === "focusin" ) {
2169
+ if ( isActive ) {
2170
+ $( target ).addClass( "active" );
2171
+ }
2172
+
2173
+ // enable mouseWheelZoom if using map controls and user has focused in on map
2174
+ if ( type === "focusin" && geomap.settings.useMapControls ) {
2175
+ mouseWheelZoom.setActive( true );
2176
+ }
2177
+ } else if ( isActive > 0 ) {
2178
+ $( target ).removeClass( "active" );
2179
+ }
2180
+
2181
+ } );
2182
+
2183
+ /*
2184
+ * Add basemap data
2185
+ */
2186
+ Geomap.prototype.addBasemap = function() {
2187
+
2188
+ var _this = this,
2189
+ basemap = _this.settings.basemap,
2190
+ hasBasemap = basemap && basemap.length !== 0,
2191
+ viewOptions = {},
2192
+ urls = [],
2193
+ mapOpts = {},
2194
+ olLayers = [],
2195
+ params, z,
2196
+ projection, resolutions, mapWidth, zoomOffset, offset, matrixIds;
2197
+
2198
+ if ( _this.settings.attribution ) {
2199
+ mapOpts.attributions = [ new ol.Attribution( {
2200
+ html: _this.settings.attribution.text
2201
+ } ) ];
2202
+ }
2203
+
2204
+ // Check to see if a base map has been configured. If not add the
2205
+ // default base map (the Canada Transportation Base Map (CBMT))
2206
+ if ( hasBasemap ) {
2207
+
2208
+ // map OL2 params to OL3 view properties
2209
+ viewOptions.extent = ( basemap.mapOptions && basemap.mapOptions.maxExtent ) ? basemap.mapOptions.maxExtent.split( "," ).map( Number ) : null;
2210
+ viewOptions.projection = ( basemap.mapOptions && basemap.mapOptions.projection ) ? basemap.mapOptions.projection : "EPSG:3857";
2211
+ viewOptions.center = ( _this.settings && _this.settings.center ) ? ol.proj.transform( _this.settings.center, "EPSG:4326", viewOptions.projection ) : ( basemap.mapOptions && basemap.mapOptions.center ) ? ol.proj.transform( basemap.mapOptions.center, "EPSG:4326", viewOptions.projection ) : ( basemap.mapOptions && basemap.mapOptions.maxExtent ) ? ol.extent.getCenter( viewOptions.extent ) : [ 0, 0 ];
2212
+ viewOptions.zoom = ( _this.settings && _this.settings.zoom ) ? _this.settings.zoom : ( basemap.mapOptions && basemap.mapOptions.zoomLevel ) ? basemap.mapOptions.zoomLevel : 2;
2213
+
2214
+ if ( basemap.type === "wms" ) {
2215
+
2216
+ params = removeKeys( basemap, [ "mapOptions", "url" ] );
2217
+ params.srs = viewOptions.projection;
2218
+ params.crs = viewOptions.projection;
2219
+
2220
+ olLayers.push(
2221
+ new ol.layer.Image( {
2222
+ extent: viewOptions.extent,
2223
+ source: new ol.source.ImageWMS( {
2224
+ url: basemap.url,
2225
+ params: params
2226
+ } )
2227
+ } )
2228
+ );
2229
+
2230
+ } else if ( basemap.type === "esri" ) {
2231
+
2232
+ // Backwards compatibility with OL2 configurations
2233
+ // TODO: this should only be tried if resource is not found
2234
+ mapOpts.url = basemap.url.replace( "/MapServer/export", "/MapServer" );
2235
+
2236
+ olLayers.push(
2237
+ new ol.layer.Tile( {
2238
+ extent: viewOptions.extent,
2239
+ source: new ol.source.TileArcGISRest( mapOpts )
2240
+ } )
2241
+ );
2242
+
2243
+ } else if ( basemap.type === "xyz" ) {
2244
+
2245
+ // Backwards compatibility with OL2 configurations
2246
+ // TODO: test with known configurations
2247
+ if ( $.isArray( basemap.url ) ) {
2248
+ $.each( basemap.url, function( index, url ) {
2249
+ urls.push( url.replace( /\${/g, "{" ) );
2250
+ } );
2251
+ mapOpts.urls = urls;
2252
+ } else {
2253
+ mapOpts.url = basemap.url.replace( /\${/g, "{" );
2254
+ }
2255
+
2256
+ olLayers.push(
2257
+ new ol.layer.Tile( {
2258
+ source: new ol.source.XYZ( mapOpts )
2259
+ } )
2260
+ );
2261
+
2262
+ } else if ( basemap.type === "osm" ) {
2263
+
2264
+ olLayers.push(
2265
+ new ol.layer.Tile( {
2266
+ source: new ol.source.OSM( { attributions: [ ol.source.OSM.ATTRIBUTION ] } )
2267
+ } )
2268
+ );
2269
+
2270
+ } else if ( basemap.type === "mapquest" ) {
2271
+ olLayers.push(
2272
+ new ol.layer.Tile( {
2273
+ source: new ol.source.MapQuest( { layer: "sat" } )
2274
+ } )
2275
+ );
2276
+ }
2277
+
2278
+ // No basemap configured so use default
2279
+ } else {
2280
+
2281
+ projection = ol.proj.get( "EPSG:3978" );
2282
+
2283
+ resolutions = [
2284
+ 38364.660062653464,
2285
+ 22489.62831258996,
2286
+ 13229.193125052918,
2287
+ 7937.5158750317505,
2288
+ 4630.2175937685215,
2289
+ 2645.8386250105837,
2290
+ 1587.5031750063501,
2291
+ 926.0435187537042,
2292
+ 529.1677250021168,
2293
+ 317.50063500127004,
2294
+ 185.20870375074085,
2295
+ 111.12522225044451,
2296
+ 66.1459656252646,
2297
+ 38.36466006265346,
2298
+ 22.48962831258996,
2299
+ 13.229193125052918,
2300
+ 7.9375158750317505,
2301
+ 4.6302175937685215
2302
+ ];
2303
+
2304
+ mapWidth = this.mapDiv.width();
2305
+ zoomOffset = 5;
2306
+
2307
+ // In function of map width size, set the proper resolution and zoom offset
2308
+ if ( mapWidth > 260 && mapWidth <= 500 ) {
2309
+ zoomOffset = 1;
2310
+ } else if ( mapWidth > 500 && mapWidth <= 725 ) {
2311
+ zoomOffset = 2;
2312
+ } else if ( mapWidth > 725 && mapWidth <= 1175 ) {
2313
+ zoomOffset = 3;
2314
+ } else if ( mapWidth > 1175 && mapWidth <= 2300 ) {
2315
+ zoomOffset = 4;
2316
+ }
2317
+
2318
+ for ( offset = zoomOffset - 1; offset !== -1; offset -= 1 ) {
2319
+ resolutions.shift();
2320
+ }
2321
+
2322
+ matrixIds = new Array( resolutions.length );
2323
+
2324
+ for ( z = 0; z < resolutions.length; ++z ) {
2325
+ matrixIds[ z ] = zoomOffset + z;
2326
+ }
2327
+
2328
+ viewOptions = {
2329
+ extent: [ -2750000.0, -900000.0, 3600000.0, 4630000.0 ],
2330
+ resolutions: resolutions,
2331
+ projection: projection
2332
+ };
2333
+
2334
+ olLayers.push( new ol.layer.Tile( {
2335
+ source: new ol.source.WMTS( {
2336
+ attributions: [ new ol.Attribution( {
2337
+ html: "<a href='" + i18nText.attribLink + "'>" + i18nText.attribTitle + "</a>"
2338
+ } ) ],
2339
+ url: i18nText.baseMapURL,
2340
+ layer: i18nText.baseMapTitle,
2341
+ matrixSet: i18nText.baseMapMatrixSet,
2342
+ projection: projection,
2343
+ tileGrid: new ol.tilegrid.WMTS( {
2344
+ extent: [ -2750000.0, -900000.0, 3600000.0, 4630000.0 ],
2345
+ origin: [ -3.46558E7, 3.931E7 ],
2346
+ resolutions: resolutions,
2347
+ matrixIds: matrixIds
2348
+ } ),
2349
+ style: "default"
2350
+ } )
2351
+ } ) );
2352
+
2353
+ }
2354
+
2355
+ // Add the base layers to the map
2356
+ for ( var lyrLen = olLayers.length - 1; lyrLen !== -1; lyrLen -= 1 ) {
2357
+ _this.map.addLayer( olLayers[ lyrLen ] );
2358
+ }
2359
+
2360
+ return removeNullKeys( viewOptions );
2361
+
2362
+ };
2363
+
2364
+ /**
2365
+ * Create Legend
2366
+ */
2367
+ MapLayer.prototype.addToLegend = function() {
2368
+
2369
+ var _this = this,
2370
+ legendDiv = this.map.legend.target,
2371
+ $fieldset, $ul, checked, $chkBox, $label, $li;
2372
+
2373
+ // If no legend or fieldset add them
2374
+ $fieldset = legendDiv.find( "fieldset" );
2375
+ if ( $fieldset.length === 0 ) {
2376
+ $fieldset = $( "<fieldset name='legend'><legend class='wb-inv'>" +
2377
+ i18nText.toggleLayer + "</legend></fieldset>" ).appendTo( legendDiv );
2378
+ }
2379
+
2380
+ checked = this.isVisibile ? "checked='checked'" : "";
2381
+
2382
+ $ul = legendDiv.find( "ul.geomap-lgnd" );
2383
+ if ( $ul.length === 0 ) {
2384
+ $ul = $( "<ul class='list-unstyled geomap-lgnd'></ul>" ).appendTo( $fieldset );
2385
+ }
2386
+
2387
+ // display labels over 2 columns if "two-cols-legend" class is present
2388
+ if ( $ul.closest( ".wb-geomap" ).hasClass( "two-cols-legend" ) ) {
2389
+ $ul.addClass( "colcount-md-2" );
2390
+ }
2391
+
2392
+ $chkBox = $( "<input type='checkbox' id='cb_" + this.id +
2393
+ "' class='geomap-lgnd-cbx' value='" + this.id +
2394
+ "' " + checked + " data-map='" + this.map.id +
2395
+ "' data-layer='" + this.id + "' />" );
2396
+
2397
+ _this.observeVisibility( function( visibility ) {
2398
+
2399
+ // Show/hide legend symbols
2400
+ $( "#sb_" + _this.id ).toggle( visibility );
2401
+
2402
+ // Refresh the legend
2403
+ _this.map.legend.refresh();
2404
+
2405
+ $chkBox.get( 0 ).checked = visibility;
2406
+ } );
2407
+
2408
+ // Handle the change event to Show/hide layer
2409
+ $chkBox.change( function() {
2410
+ _this.isVisible = $( this ).is( ":checked" );
2411
+ } );
2412
+
2413
+ $label = $( "<label>", {
2414
+ "for": "cb_" + this.id,
2415
+ text: this.settings.title
2416
+ } ).prepend( $chkBox );
2417
+
2418
+ $li = $( "<li class='checkbox geomap-lgnd-layer'>" )
2419
+ .append( $label, "<div id='sb_" + this.id + "'></div>" );
2420
+
2421
+ $ul.append( $li );
2422
+
2423
+ if ( this.settings.options && this.settings.options.legendUrl ) {
2424
+ $( "#sb_" + this.id ).append( "<img src='" + this.settings.options.legendUrl + "' alt='" + i18nText.geoLgndGrphc + "'/>" );
2425
+ } else if ( this.settings.options && this.settings.options.legendHTML ) {
2426
+ $( "#sb_" + this.id ).append( this.settings.options.legendHTML );
2427
+ } else if ( this.settings.type !== "wms" && this.settings.type !== "esritile" ) {
2428
+ this.map.legend.symbolize( this );
2429
+ }
2430
+
2431
+ };
2432
+
2433
+ /**
2434
+ * Add tabluar data
2435
+ */
2436
+ Geomap.prototype.addTabularData = function() {
2437
+
2438
+ var $table, table, featureTable, featureArray, attr, theadTr, tdChkBox, tdZoomTo, thElms, thLen,
2439
+ trElms, trLen, useMapControls, attrMap, trElmsInd, geomType,
2440
+ feat, feature, features, vectorFeature, wktFeature,
2441
+ script, bbox, vertices, len, vertLen, lenTable,
2442
+ thZoom = "<span class='wb-inv'>" + i18nText.zoomFeature + "</span>",
2443
+ thSelect = "<span class='wb-inv'>" + i18nText.select + "</span>",
2444
+ thElmZoom, thElmSelect,
2445
+ wktParser = new ol.format.WKT(),
2446
+ thRegex = /<\/?[^>]+>/gi,
2447
+ vectRegex = /\W/g,
2448
+ visibility,
2449
+ style, colors, mapLayer;
2450
+
2451
+ for ( lenTable = this.settings.tables.length - 1; lenTable !== -1; lenTable -= 1 ) {
2452
+
2453
+ table = document.getElementById( this.settings.tables[ lenTable ].id );
2454
+
2455
+ // If the table is not found continue
2456
+ if ( !table ) {
2457
+ continue;
2458
+ }
2459
+
2460
+ $table = $( table ).wrap( "<div data-layer='" + this.settings.tables[ lenTable ].id + "' class='geomap-table-wrapper'></div>" );
2461
+
2462
+ featureTable = this.settings.tables[ lenTable ];
2463
+ featureArray = [];
2464
+ attr = [];
2465
+ thElms = table.getElementsByTagName( "th" );
2466
+ trElms = table.getElementsByTagName( "tr" );
2467
+ trLen = trElms.length;
2468
+ useMapControls = this.settings.useMapControls;
2469
+
2470
+ if ( $table.hasClass( "wb-tables" ) && typeof $table.attr( "data-wb-tables" ) === "undefined" ) {
2471
+ $table.attr( "data-wb-tables", "{ \"order\": [], \"columnDefs\": [ { \"targets\": [ 0, " + ( thElms.length + 1 ) + " ], \"orderable\": false } ] }" );
2472
+ }
2473
+
2474
+ // If visibility is not set to false, show the layer
2475
+ visibility = this.settings.tables[ lenTable ].visible === false ? false : true;
2476
+
2477
+ // Get the attributes from table header
2478
+ for ( thLen = thElms.length - 1; thLen !== -1; thLen -= 1 ) {
2479
+ attr[ thLen ] = thElms[ thLen ].innerHTML.replace( thRegex, "" );
2480
+ }
2481
+
2482
+ // If zoomTo add the header column headers
2483
+ theadTr = $table.find( "thead tr" ).get( 0 );
2484
+ if ( featureTable.zoom && useMapControls ) {
2485
+ thElmZoom = document.createElement( "th" );
2486
+ thElmZoom.innerHTML = thZoom;
2487
+ theadTr.insertBefore( thElmZoom, theadTr.firstChild );
2488
+ }
2489
+
2490
+ // Add select checkbox
2491
+ thElmSelect = document.createElement( "th" );
2492
+ thElmSelect.innerHTML = thSelect;
2493
+ theadTr.appendChild( thElmSelect );
2494
+
2495
+ colors = defaultColors();
2496
+
2497
+ style = typeof featureTable.style === "undefined" ?
2498
+ { "strokeColor": colors.stroke, "fillColor": colors.fill } :
2499
+ featureTable.style;
2500
+
2501
+ // Loop through each row
2502
+ for ( trLen = trElms.length - 1; trLen !== -1; trLen -= 1 ) {
2503
+
2504
+ // Create an array of attributes: value
2505
+ attrMap = {};
2506
+
2507
+ trElmsInd = trElms[ trLen ];
2508
+
2509
+ // Get the geometry type
2510
+ geomType = trElmsInd.getAttribute( "data-type" );
2511
+ features = trElmsInd.getElementsByTagName( "td" );
2512
+
2513
+ for ( len = 0; len < features.length; len += 1 ) {
2514
+
2515
+ // Use innerHTML instead of innerText or textContent because they react differently in different browser
2516
+ // remove script tag from the attribute
2517
+ feature = features[ len ];
2518
+ script = feature.getElementsByTagName( "script" )[ 0 ];
2519
+ if ( script ) {
2520
+ script.parentNode.removeChild( script );
2521
+ }
2522
+ attrMap[ attr[ len ] ] = feature.innerHTML;
2523
+ }
2524
+
2525
+ if ( geomType !== null ) {
2526
+ if ( geomType === "bbox" ) {
2527
+ bbox = trElmsInd.getAttribute( "data-geometry" ).split( "," );
2528
+
2529
+ feat = densifyBBox(
2530
+ bbox[ 0 ],
2531
+ bbox[ 1 ],
2532
+ bbox[ 2 ],
2533
+ bbox[ 3 ]
2534
+ );
2535
+
2536
+ vertices = "";
2537
+
2538
+ for ( vertLen = feat.length - 1; vertLen !== -1; vertLen -= 1 ) {
2539
+ vertices += feat[ vertLen ].getCoordinates()[ 0 ] + " " + feat[ vertLen ].getCoordinates()[ 1 ] + ", ";
2540
+ }
2541
+
2542
+ vertices = vertices.slice( 0, -2 );
2543
+ wktFeature = "POLYGON ((" + vertices + "))";
2544
+
2545
+ } else if ( geomType === "wkt" ) {
2546
+ wktFeature = trElmsInd.getAttribute( "data-geometry" );
2547
+
2548
+ // Backward compatibility fix
2549
+ // REMOVE in next major version of WET
2550
+ if ( wktFeature.indexOf( "POINT" ) !== -1 ) {
2551
+ wktFeature = wktFeature.replace( ",", "" );
2552
+ }
2553
+ }
2554
+
2555
+ vectorFeature = wktParser.readFeature( wktFeature, {
2556
+ dataProjection: "EPSG:4326",
2557
+ featureProjection: this.map.getView().getProjection()
2558
+ } );
2559
+
2560
+ vectorFeature.setId( generateGuid() );
2561
+ vectorFeature.layerId = featureTable.id;
2562
+ vectorFeature.layerTitle = $table.attr( "aria-label" );
2563
+
2564
+ if ( featureTable.tooltips ) {
2565
+ vectorFeature.tooltip = featureTable.tooltipText ? attrMap[ featureTable.tooltipText ] : attrMap[ Object.keys( attrMap )[ 0 ] ];
2566
+ }
2567
+
2568
+ // Set the table row id
2569
+ trElmsInd.setAttribute( "id", vectorFeature.getId().replace( vectRegex, "_" ) );
2570
+
2571
+ // Add the checkboxes and zoom controls
2572
+ tdChkBox = trElmsInd.insertCell( 0 );
2573
+ tdChkBox.innerHTML = addChkBox( this, vectorFeature );
2574
+ if ( useMapControls && featureTable.zoom ) {
2575
+ tdZoomTo = trElmsInd.insertCell( -1 );
2576
+ tdZoomTo.classList.add( "text-right" );
2577
+ tdZoomTo.innerHTML = addZoomTo( this, vectorFeature );
2578
+ }
2579
+
2580
+ // Add the attributes to the feature then add it to the feature array
2581
+ vectorFeature.attributes = attrMap;
2582
+ featureArray.push( vectorFeature );
2583
+
2584
+ }
2585
+ }
2586
+
2587
+ mapLayer = new MapLayer( this, {
2588
+ tableId: $table.attr( "id" ),
2589
+ type: "wkt",
2590
+ visible: visibility,
2591
+ datatable: featureTable.datatable,
2592
+ popupsInfo: featureTable.popupsInfo,
2593
+ popups: featureTable.popups,
2594
+ tooltips: featureTable.tooltips,
2595
+ tooltipText: featureTable.tooltipText,
2596
+ name: featureTable.id,
2597
+ title: $table.attr( "aria-label" ),
2598
+ features: featureArray,
2599
+ style: style
2600
+ } );
2601
+
2602
+ this.mapLayers.push( mapLayer );
2603
+
2604
+ }
2605
+ };
2606
+
2607
+ /**
2608
+ * Create layers
2609
+ */
2610
+ Geomap.prototype.addMapLayers = function() {
2611
+
2612
+ var _this = this,
2613
+ olLayer, mapLayer;
2614
+
2615
+ // Add tabular data first
2616
+ _this.addTabularData();
2617
+
2618
+ // Add overlays second
2619
+ $.each( _this.settings.overlays, function( index, layer ) {
2620
+ mapLayer = new MapLayer( _this, layer );
2621
+ _this.mapLayers.push( mapLayer );
2622
+ } );
2623
+
2624
+ // Add geocoder and AOI layer
2625
+ olLayer = new ol.layer.Vector( {
2626
+ source: new ol.source.Vector(),
2627
+ style: new ol.style.Style( {
2628
+ fill: new ol.style.Fill( {
2629
+ color: "rgba( 255, 0, 20, 0.1 )"
2630
+ } ),
2631
+ stroke: new ol.style.Stroke( {
2632
+ color: "#ff0033",
2633
+ width: 2
2634
+ } ),
2635
+ image: new ol.style.RegularShape( {
2636
+ fill: new ol.style.Fill( {
2637
+ color: "#ff0033"
2638
+ } ),
2639
+ stroke: new ol.style.Stroke( {
2640
+ color: "#ff0033",
2641
+ width: 5
2642
+ } ),
2643
+ points: 4,
2644
+ radius: 10,
2645
+ radius2: 0,
2646
+ angle: 0
2647
+ } )
2648
+ } )
2649
+ } );
2650
+
2651
+ olLayer.id = "locLayer";
2652
+ _this.map.addLayer( olLayer );
2653
+
2654
+ // Finally add the layers to the map
2655
+ for ( var lyrLen = _this.mapLayers.length - 1; lyrLen !== -1; lyrLen -= 1 ) {
2656
+ if ( _this.mapLayers[ lyrLen ].layer ) {
2657
+ _this.map.addLayer( _this.mapLayers[ lyrLen ].layer );
2658
+ }
2659
+ }
2660
+
2661
+ };
2662
+
2663
+ /**
2664
+ * Create a table for vector features
2665
+ * @return { table }
2666
+ */
2667
+ MapLayer.prototype.populateDataTable = function() {
2668
+
2669
+ if ( !this.settings.accessible ) {
2670
+ return;
2671
+ }
2672
+
2673
+ var _this = this,
2674
+ attributes = _this.settings.attributes,
2675
+ len = attributeLen(),
2676
+ $table,
2677
+ sTable = "<table aria-label='" + _this.settings.title + "' id='" + _this.id + "' " +
2678
+ "data-wb-tables='{ \"order\": [], \"columnDefs\": [ { \"targets\": [ 0, " + ( len + 1 ) + " ], \"orderable\": false } ] }'" +
2679
+ "class='table",
2680
+ sCaption = "'><caption>" + _this.settings.caption + "</caption>",
2681
+ head = "<th><span class='wb-inv'>" + i18nText.select + "</span></th>",
2682
+ body = "",
2683
+ features = _this.layer.getSource().getFeatures(),
2684
+ key, attKey;
2685
+
2686
+ if ( _this.settings.datatable ) {
2687
+ sTable = sTable + " wb-tables";
2688
+ } else {
2689
+ sTable = sTable + " table-condensed";
2690
+ }
2691
+
2692
+ // Create the header row
2693
+ for ( key in attributes ) {
2694
+ if ( Object.prototype.hasOwnProperty.call( attributes, key ) ) {
2695
+ attKey = attributes[ key ].alias ? attributes[ key ].alias : attributes[ key ];
2696
+ head += "<th>" + attKey + "</th>";
2697
+ }
2698
+ }
2699
+
2700
+ head = "<thead><tr>" + head + ( _this.map.settings.useMapControls && _this.settings.zoom ? "<th><span class='wb-inv'>" + i18nText.zoomFeature + "</span></th>" : "" ) + "</tr></thead>";
2701
+
2702
+ // Create the table body rows
2703
+ // for ( var i = 0; i < features.length || ( function() { refreshPlugins( _this.map ); return false; }() ); i += 1 ) {
2704
+ for ( var i = 0; i < features.length; i += 1 ) {
2705
+
2706
+ body += "<tr><td>" + addChkBox( _this, features[ i ] );
2707
+
2708
+ attributes = features[ i ].attributes;
2709
+
2710
+ for ( key in attributes ) {
2711
+ if ( Object.prototype.hasOwnProperty.call( attributes, key ) ) {
2712
+ body += "<td>" + attributes[ key ] + "</td>";
2713
+ }
2714
+ }
2715
+
2716
+ body += _this.map.settings.useMapControls && _this.settings.zoom ? "<td class='text-right'>" + addZoomTo( _this.map, features[ i ] ) : "";
2717
+
2718
+ }
2719
+
2720
+ $table = $( sTable + sCaption + head + "<tbody>" + body + "</tbody>" + "</table>" );
2721
+
2722
+ $( "div[ data-layer='" + _this.id + "'].geomap-table-wrapper" ).append( $table );
2723
+
2724
+ function attributeLen() {
2725
+ var len = 0;
2726
+ for ( var key in attributes ) {
2727
+ if ( Object.prototype.hasOwnProperty.call( attributes, key ) ) {
2728
+ len += 1;
2729
+ }
2730
+ }
2731
+ return len;
2732
+ }
2733
+
2734
+ refreshPlugins( _this.map );
2735
+
2736
+ return $table;
2737
+ };
2738
+
2739
+ /**
2740
+ * Create OpenLayers Layer
2741
+ * @returns {ol.Layer}
2742
+ */
2743
+ MapLayer.prototype.createOLLayer = function() {
2744
+
2745
+ var _this = this,
2746
+ layerAttributes = _this.settings.attributes,
2747
+ colors, olLayer, styleFactory, atts, featureGeometry, key, source;
2748
+
2749
+ if ( _this.settings.type === "wms" ) {
2750
+
2751
+ var keys = getLayerKeys( _this.settings ),
2752
+ opacity = keys.options.opacity ? keys.options.opacity : 1;
2753
+
2754
+ olLayer = new ol.layer.Image( {
2755
+ opacity: opacity,
2756
+ visible: _this.settings.visible,
2757
+ source: new ol.source.ImageWMS( {
2758
+ url: _this.settings.url,
2759
+ params: keys
2760
+ } )
2761
+ } );
2762
+
2763
+ // Image layers don't have features, so don't create table
2764
+ _this.settings.accessible = false;
2765
+
2766
+ } else if ( _this.settings.type === "esritile" ) {
2767
+
2768
+ var mapOpts = {
2769
+ url: _this.settings.url,
2770
+ params: _this.settings.params
2771
+ };
2772
+
2773
+ olLayer = new ol.layer.Tile( {
2774
+ visible: _this.settings.visible,
2775
+ source: new ol.source.TileArcGISRest( mapOpts )
2776
+ } );
2777
+
2778
+ _this.settings.accessible = false;
2779
+
2780
+ } else if ( _this.settings.type === "wkt" ) {
2781
+
2782
+ styleFactory = new StyleFactory();
2783
+
2784
+ // TODO pass data into this rather than taking features from mapLayer
2785
+ // create a new layer with the feature array
2786
+ olLayer = new ol.layer.Vector( {
2787
+ visible: _this.settings.visible,
2788
+ source: new ol.source.Vector( {
2789
+ features: _this.settings.features
2790
+ } ),
2791
+ style: styleFactory.createStyleFunction( _this.settings.style, _this.settings.featureType )
2792
+ } );
2793
+
2794
+ // TODO set this in the addTabular data stream
2795
+ _this.settings.accessible = false;
2796
+
2797
+ } else if ( _this.settings.type === "kml" ) {
2798
+
2799
+ var extractStyles = !_this.settings.style;
2800
+
2801
+ styleFactory = new StyleFactory();
2802
+ colors = defaultColors();
2803
+
2804
+ //TODO: KML styles are getting overridden, don't do this
2805
+ olLayer = new ol.layer.Vector( {
2806
+ visible: _this.settings.visible,
2807
+ source: new ol.source.Vector( {
2808
+ url: _this.settings.url,
2809
+ format: new ol.format.KML( {
2810
+ extractStyles: extractStyles
2811
+ } )
2812
+ } )
2813
+ } );
2814
+
2815
+ // TODO: this overrides style in KML - please fix
2816
+ if ( typeof _this.settings.style === "undefined" ) {
2817
+
2818
+ // TODO: create a defaultStyle object
2819
+ _this.settings.style = { "strokeColor": colors.stroke, "fillColor": colors.fill };
2820
+ }
2821
+
2822
+ // Set the style
2823
+ olLayer.getSource().once( "addfeature", function( event ) {
2824
+ featureGeometry = event.feature.getGeometry().getType();
2825
+
2826
+ if ( !extractStyles ) {
2827
+ var style = styleFactory.createStyleFunction(
2828
+ _this.settings.style,
2829
+ featureGeometry
2830
+ );
2831
+ olLayer.setStyle( style );
2832
+ }
2833
+ } );
2834
+
2835
+ source = olLayer.getSource();
2836
+
2837
+ key = source.on( "change", function() {
2838
+
2839
+ if ( source.getState() === "ready" ) {
2840
+ source.unByKey( key );
2841
+
2842
+ var features = this.getFeatures();
2843
+
2844
+ for ( var i = 0, len = features.length; i < len; i += 1 ) {
2845
+
2846
+ var feature = features[ i ];
2847
+
2848
+ if ( _this.settings.style.select ) {
2849
+ _this.settings.style.select.type = "select";
2850
+ var selStyleFactory = new StyleFactory(),
2851
+ selStyle = selStyleFactory.createStyleFunction(
2852
+ _this.settings.style.select,
2853
+ feature.getGeometry().getType()
2854
+ );
2855
+ feature.selectStyle = selStyle;
2856
+ }
2857
+
2858
+ feature.setId( generateGuid() );
2859
+ feature.layerId = olLayer.id;
2860
+ feature.layerTitle = olLayer.title;
2861
+
2862
+ atts = {};
2863
+
2864
+ //TODO: densify coordinates
2865
+
2866
+ // Parse and store the attributes
2867
+ // TODO: test on nested attributes
2868
+ for ( var name in layerAttributes ) {
2869
+ if ( Object.prototype.hasOwnProperty.call( layerAttributes, name ) ) {
2870
+ atts[ layerAttributes[ name ] ] = feature.getProperties()[ name ];
2871
+ }
2872
+ }
2873
+ feature.attributes = atts;
2874
+
2875
+ if ( _this.settings.tooltips ) {
2876
+ feature.tooltip = _this.settings.tooltipText ? atts[ _this.settings.tooltipText ] : atts[ Object.keys( atts )[ 0 ] ];
2877
+ }
2878
+
2879
+ }
2880
+
2881
+ // Populate table with feature data
2882
+ _this.populateDataTable();
2883
+
2884
+ _this.map.legend.symbolize( _this );
2885
+ }
2886
+ }, source );
2887
+
2888
+
2889
+ } else if ( _this.settings.type === "json" ) {
2890
+
2891
+ var olSource = new ol.source.Vector();
2892
+
2893
+ styleFactory = new StyleFactory();
2894
+ colors = defaultColors();
2895
+
2896
+ if ( typeof _this.settings.style === "undefined" ) {
2897
+
2898
+ // TODO: create a defaultStyle object
2899
+ _this.settings.style = { "strokeColor": colors.stroke, "fillColor": colors.fill };
2900
+ }
2901
+
2902
+ if ( _this.settings.cluster ) {
2903
+ olLayer = new ol.layer.Vector( {
2904
+ visible: _this.settings.visible,
2905
+ source: new ol.source.Cluster( {
2906
+ distance: 40,
2907
+ source: olSource
2908
+ } )
2909
+ } );
2910
+ } else {
2911
+ olLayer = new ol.layer.Vector( {
2912
+ visible: _this.settings.visible,
2913
+ source: olSource
2914
+ } );
2915
+ }
2916
+
2917
+ // Set the style
2918
+ olSource.once( "addfeature", function() {
2919
+ olLayer.setStyle( styleFactory.createStyleFunction( _this.settings.style, featureGeometry ) );
2920
+ } );
2921
+
2922
+ var getCoordKey = function( feature ) {
2923
+
2924
+ var geomKey;
2925
+
2926
+ $.each( feature, function( k, v ) {
2927
+ if ( v.coordinates ) {
2928
+ geomKey = k;
2929
+ }
2930
+ } );
2931
+
2932
+ return geomKey;
2933
+ };
2934
+
2935
+ var successHandler = function( data ) {
2936
+
2937
+ var layerRoot = _this.settings.root,
2938
+ features = data[ layerRoot ] ? data[ layerRoot ] : data.features ? data.features : data,
2939
+ atts, bnds, feature, firstComponent, geom, geomProj, geomKey, i, len, path;
2940
+
2941
+ // in some cases an array is not returned, so create one
2942
+ if ( features instanceof Array === false ) {
2943
+ features = $.map( features, function( obj ) {
2944
+ return obj;
2945
+ } );
2946
+ }
2947
+
2948
+ for ( i = 0, len = features.length; i < len; i += 1 ) {
2949
+
2950
+ feature = features[ i ];
2951
+
2952
+ // look for a property named "coordinates" - lots to go wrong here
2953
+ // TODO: use regex to find something that looks like coordinates
2954
+ if ( !geomKey ) {
2955
+ geomKey = getCoordKey( feature );
2956
+ }
2957
+
2958
+ if ( !feature[ geomKey ] ) {
2959
+ continue;
2960
+ }
2961
+
2962
+ firstComponent = feature[ geomKey ].coordinates[ 0 ];
2963
+
2964
+ // if we have a bounding box polygon, densify the coordinates
2965
+ if ( Object.values( feature[ geomKey ] ).includes( "Polygon" ) &&
2966
+ firstComponent.length === 5 ) {
2967
+
2968
+ bnds = densifyBBox(
2969
+ firstComponent[ 1 ][ 0 ],
2970
+ firstComponent[ 1 ][ 1 ],
2971
+ firstComponent[ 3 ][ 0 ],
2972
+ firstComponent[ 3 ][ 1 ]
2973
+ );
2974
+
2975
+ var coordinates = [];
2976
+
2977
+ for ( var j = 0, len2 = bnds.length; j < len2; j += 1 ) {
2978
+ var point = bnds[ j ];
2979
+ coordinates.push( point.getCoordinates() );
2980
+ }
2981
+
2982
+ geom = new ol.geom.Polygon( [ coordinates ] );
2983
+
2984
+ } else if ( Object.values( feature[ geomKey ] ).includes( "Point" ) ) {
2985
+
2986
+ // TODO: if creating point fails, try reversing the coordinate order. Perhaps a configuration parameter would be best.
2987
+ geom = new ol.geom.Point( [ feature[ geomKey ].coordinates[ 0 ], feature[ geomKey ].coordinates[ 1 ] ] );
2988
+
2989
+ } else if ( Object.values( feature[ geomKey ] ).includes( "LineString" ) ) {
2990
+
2991
+ geom = new ol.geom.LineString( feature[ geomKey ].coordinates );
2992
+
2993
+ }
2994
+
2995
+ // transform the feature
2996
+ // TODO: support GeoJSON projections via OGC CRS URNs such as:
2997
+ // "urn:ogc:def:crs:OGC:1.3:CRS84"
2998
+ geomProj = geom.transform( "EPSG:4326", _this.map.map.getView().getProjection() );
2999
+
3000
+ // Parse and store the attributes
3001
+ // TODO: test on nested attributes
3002
+ // NOTE: it is possible that a feature is missing a value, in
3003
+ // which case we show an empty string in it's place
3004
+ atts = {};
3005
+
3006
+ for ( var name in layerAttributes ) {
3007
+ path = null;
3008
+ if ( Object.prototype.hasOwnProperty.call( layerAttributes, name ) ) {
3009
+ path = layerAttributes[ name ].path;
3010
+ if ( path ) {
3011
+ atts[ layerAttributes[ name ].alias ] = feature[ path ] ? feature[ path ][ name ] : "";
3012
+ } else {
3013
+ atts[ layerAttributes[ name ] ] = feature[ name ] ? feature[ name ] : "";
3014
+ }
3015
+ }
3016
+ }
3017
+
3018
+ feature = new ol.Feature();
3019
+ feature.setId( generateGuid() );
3020
+ feature.layerId = olLayer.id;
3021
+ feature.layerTitle = olLayer.title;
3022
+ feature.attributes = atts;
3023
+ feature.setGeometry( geomProj );
3024
+ olSource.addFeature( feature );
3025
+
3026
+ if ( _this.settings.tooltips ) {
3027
+ feature.tooltip = _this.settings.tooltipText ? atts[ _this.settings.tooltipText ] : atts[ Object.keys( atts )[ 0 ] ];
3028
+ }
3029
+
3030
+ }
3031
+
3032
+ // Populate table with feature data
3033
+ _this.populateDataTable();
3034
+
3035
+ _this.map.legend.symbolize( _this );
3036
+ };
3037
+
3038
+ // Get the file
3039
+ $.getJSON( _this.settings.url, _this.settings.params, successHandler );
3040
+
3041
+ } else if ( _this.settings.type === "geojson" || _this.settings.type === "esrijson" || _this.settings.type === "topojson" ) {
3042
+
3043
+ var layerURL;
3044
+
3045
+ styleFactory = new StyleFactory();
3046
+ colors = defaultColors();
3047
+
3048
+ if ( typeof _this.settings.style === "undefined" ) {
3049
+
3050
+ // TODO: create a defaultStyle object
3051
+ _this.settings.style = { "strokeColor": colors.stroke, "fillColor": colors.fill };
3052
+ }
3053
+
3054
+ layerURL = _this.settings.params ? _this.settings.url + "?" + $.param( _this.settings.params ) : _this.settings.url;
3055
+
3056
+ if ( _this.settings.type === "geojson" ) {
3057
+ olLayer = new ol.layer.Vector( {
3058
+ visible: _this.settings.visible,
3059
+ source: new ol.source.Vector( {
3060
+ url: layerURL,
3061
+ format: new ol.format.GeoJSON(),
3062
+ strategy: ol.loadingstrategy.bbox
3063
+ } )
3064
+ } );
3065
+ } else if ( _this.settings.type === "topojson" ) {
3066
+ olLayer = new ol.layer.Vector( {
3067
+ visible: _this.settings.visible,
3068
+ source: new ol.source.Vector( {
3069
+ url: layerURL,
3070
+ format: new ol.format.TopoJSON()
3071
+ } )
3072
+ } );
3073
+ } else {
3074
+ olLayer = new ol.layer.Vector( {
3075
+ visible: _this.settings.visible,
3076
+ source: new ol.source.Vector( {
3077
+ url: layerURL,
3078
+ format: new ol.format.EsriJSON(),
3079
+ strategy: ol.loadingstrategy.bbox
3080
+ } )
3081
+ } );
3082
+ }
3083
+
3084
+ // Set the style
3085
+ olLayer.getSource().once( "addfeature", function( event ) {
3086
+ featureGeometry = event.feature.getGeometry().getType();
3087
+ var style = styleFactory.createStyleFunction(
3088
+ _this.settings.style,
3089
+ featureGeometry
3090
+ );
3091
+ olLayer.setStyle( style );
3092
+ } );
3093
+
3094
+ // Wait until all features are loaded, then build table and symbolize legend
3095
+ source = olLayer.getSource();
3096
+
3097
+ key = source.on( "change", function() {
3098
+
3099
+ if ( source.getState() === "ready" ) {
3100
+ source.unByKey( key );
3101
+
3102
+ var features = this.getFeatures();
3103
+
3104
+ for ( var i = 0, len = features.length; i < len; i += 1 ) {
3105
+
3106
+ var feature = features[ i ];
3107
+
3108
+ feature.setId( generateGuid() );
3109
+ feature.layerId = olLayer.id;
3110
+ feature.layerTitle = olLayer.title;
3111
+ atts = {};
3112
+
3113
+ //TODO: densify coordinates
3114
+
3115
+ // Parse and store the attributes
3116
+ // TODO: test on nested attributes
3117
+ for ( var name in layerAttributes ) {
3118
+ if ( Object.prototype.hasOwnProperty.call( layerAttributes, name ) ) {
3119
+ atts[ layerAttributes[ name ] ] = feature.getProperties()[ name ];
3120
+ }
3121
+ }
3122
+
3123
+ feature.attributes = atts;
3124
+
3125
+ if ( _this.settings.tooltips ) {
3126
+ feature.tooltip = _this.settings.tooltipText ? atts[ _this.settings.tooltipText ] : atts[ Object.keys( atts )[ 0 ] ];
3127
+ }
3128
+
3129
+ }
3130
+
3131
+ // Populate table with feature data
3132
+ _this.populateDataTable();
3133
+
3134
+ _this.map.legend.symbolize( _this );
3135
+ }
3136
+
3137
+ }, source );
3138
+
3139
+ }
3140
+
3141
+ if ( olLayer ) {
3142
+ olLayer.id = _this.id;
3143
+ olLayer.title = _this.settings.title;
3144
+ olLayer.datatable = _this.settings.datatable;
3145
+ olLayer.popupsInfo = _this.settings.popupsInfo;
3146
+ olLayer.popups = _this.settings.popups;
3147
+
3148
+ return olLayer;
3149
+
3150
+ } else {
3151
+
3152
+ return null;
3153
+
3154
+ }
3155
+
3156
+ };
3157
+
3158
+
3159
+ /**
3160
+ * Load controls and interactions
3161
+ */
3162
+ Geomap.prototype.loadControls = function() {
3163
+
3164
+ var _this = this,
3165
+ map = _this.map,
3166
+ popups = false,
3167
+ extentCtrl, mouseCtrl, scaleCtrl, selectInteraction;
3168
+
3169
+ // Add a select interaction
3170
+ selectInteraction = new ol.interaction.Select( {
3171
+ layers: _this.layers
3172
+ } );
3173
+
3174
+ selectInteraction.getFeatures().on( "remove", function( event ) {
3175
+ var feature = event.element;
3176
+ feature.setStyle( null );
3177
+ $( "#cb_" + feature.getId() ).prop( "checked", false ).closest( "tr" ).removeClass( "active" );
3178
+ } );
3179
+
3180
+ selectInteraction.getFeatures().on( "add", function( event ) {
3181
+ var feature = event.element;
3182
+ if ( feature.selectStyle ) {
3183
+ feature.setStyle( feature.selectStyle );
3184
+ }
3185
+ $( "#cb_" + feature.getId() ).prop( "checked", true ).closest( "tr" ).addClass( "active" );
3186
+ } );
3187
+
3188
+ // Add select event handler
3189
+ selectInteraction.on( "select", function( event ) {
3190
+
3191
+ var _this = this,
3192
+ selected = event.selected ? event.selected : _this.getFeatures();
3193
+
3194
+ if ( selected && selected.length > 0 && typeof selected[ 0 ].layerTitle !== "undefined" ) {
3195
+ popups = getLayerById( _this.getMap(), selected[ 0 ].layerId ).popups;
3196
+
3197
+ selected[ 0 ].layerTitle = _this.getLayer( event.selected[ 0 ] ).title;
3198
+
3199
+ if ( popups ) {
3200
+ showPopup( event, selected[ 0 ], map );
3201
+ }
3202
+ }
3203
+
3204
+ // if there are no selected features then hide the popup
3205
+ if ( selected && selected.length === 0 ) {
3206
+ showPopup( event, null, map );
3207
+ }
3208
+
3209
+ }, selectInteraction );
3210
+
3211
+ // Add the interaction to the map
3212
+ map.getInteractions().extend( [ selectInteraction ] );
3213
+
3214
+ if ( _this.settings.useMapControls ) {
3215
+
3216
+ var element = document.createElement( "span" );
3217
+
3218
+ element.className = "glyphicon glyphicon-home";
3219
+
3220
+ extentCtrl = new ol.control.ZoomToExtent( {
3221
+ extent: map.getView().calculateExtent( map.getSize() ),
3222
+ label: element
3223
+ } );
3224
+
3225
+ map.addControl( extentCtrl );
3226
+
3227
+ extentCtrl.element.setAttribute( "aria-label", i18nText.zoomworld );
3228
+ extentCtrl.element.setAttribute( "title", i18nText.zoomworld );
3229
+
3230
+ if ( _this.settings.useMousePosition ) {
3231
+ mouseCtrl = new ol.control.MousePosition( {
3232
+ coordinateFormat: ol.coordinate.createStringXY( 4 ),
3233
+ projection: "EPSG:4326",
3234
+ undefinedHTML: ""
3235
+ } );
3236
+ map.addControl( mouseCtrl );
3237
+ mouseCtrl.element.setAttribute( "aria-label", i18nText.mouseposition );
3238
+ mouseCtrl.element.setAttribute( "title", i18nText.mouseposition );
3239
+ }
3240
+
3241
+ if ( _this.settings.useScaleLine ) {
3242
+ scaleCtrl = new ol.control.ScaleLine();
3243
+ map.addControl( scaleCtrl );
3244
+ scaleCtrl.element.setAttribute( "aria-label", i18nText.scaleline );
3245
+ scaleCtrl.element.setAttribute( "title", i18nText.scaleline );
3246
+ }
3247
+
3248
+ }
3249
+
3250
+ // Add the geocoder widget
3251
+ if ( _this.settings.useGeocoder ) {
3252
+ new GeocodeControl( _this );
3253
+ }
3254
+
3255
+ // Add the AOI widget
3256
+ if ( _this.settings.useAOI ) {
3257
+ new AOIWidget( _this );
3258
+ }
3259
+
3260
+ // Add the geolocation widget
3261
+ if ( _this.settings.useGeolocation ) {
3262
+ _this.map.addControl( new GeolocationControl( { projection: _this.map.getView().getProjection() } ) );
3263
+ }
3264
+
3265
+ };
3266
+
3267
+ /**
3268
+ * Create an overlay to anchor the popup to the map.
3269
+ */
3270
+ Geomap.prototype.createPopup = function() {
3271
+
3272
+ var _this = this,
3273
+ $closer, overlay, $popup;
3274
+
3275
+ $popup = $( "<div id='popup-" + _this.mapDiv.attr( "id" ) + "' class='ol-popup'></div>" );
3276
+ $closer = $( "<a href='#' title='" + i18nText.dismiss + "' class='ol-popup-closer' role='button'>&#xd7;<span class='wb-inv'>" + i18nText.dismiss + "</span></a>" );
3277
+ $popup.append( $closer, "<div class='popup-content'></div>" );
3278
+
3279
+ // Add the popup container
3280
+ $( "#" + _this.mapDiv.attr( "id" ) ).append( $popup );
3281
+
3282
+ overlay = new ol.Overlay( {
3283
+ element: document.getElementById( "popup-" + _this.mapDiv.attr( "id" ) ),
3284
+ autoPan: true,
3285
+ autoPanAnimation: {
3286
+ duration: 250
3287
+ }
3288
+ } );
3289
+
3290
+ // Add a click handler to hide the popup
3291
+ $closer.on( "click", function( event ) {
3292
+ event.preventDefault();
3293
+ overlay.setPosition( undefined );
3294
+ this.blur();
3295
+ return false;
3296
+ } );
3297
+
3298
+ _this.map.addOverlay( overlay );
3299
+ };
3300
+
3301
+ /**
3302
+ * Add accessibility enhancements
3303
+ */
3304
+ Geomap.prototype.accessibilize = function() {
3305
+
3306
+ var _this = this,
3307
+ $ctrlZoomIn = _this.mapDiv.find( ".ol-zoom-in" ),
3308
+ $ctrlZoomOut = _this.mapDiv.find( ".ol-zoom-out" );
3309
+
3310
+ $ctrlZoomIn.attr( "aria-label", i18nText.zoomin );
3311
+ $ctrlZoomIn.attr( "title", i18nText.zoomin );
3312
+ $ctrlZoomOut.attr( "aria-label", i18nText.zoomout );
3313
+ $ctrlZoomOut.attr( "title", i18nText.zoomout );
3314
+
3315
+ // Add the map div to the tabbing order
3316
+ _this.mapDiv.attr( {
3317
+ tabindex: "0",
3318
+ "data-map": _this.id
3319
+ } );
3320
+
3321
+ // Add WCAG element for the map div
3322
+ _this.mapDiv.attr( {
3323
+ role: "dialog",
3324
+ "aria-label": i18nText.ariaMap
3325
+ } );
3326
+
3327
+ if ( _this.settings.useMapControls ) {
3328
+
3329
+ // Add the map instructions
3330
+ new HelpControl( _this );
3331
+ }
3332
+
3333
+ };
3334
+
3335
+ /**
3336
+ * Zoom to an area of interest
3337
+ *
3338
+ * Param
3339
+ * -----
3340
+ * top = North || space separated list with all of them || WKT || empty
3341
+ * right = East
3342
+ * bottom = South
3343
+ * left = West
3344
+ */
3345
+ Geomap.prototype.zoomAOI = function( top, right, bottom, left ) {
3346
+
3347
+ var _this = this,
3348
+ OLmap = _this.map,
3349
+ olView = OLmap.getView(),
3350
+ extentCoordinate,
3351
+ extent,
3352
+ vectorFeature,
3353
+ isTopString = ( typeof top === "string" );
3354
+
3355
+ if ( isTopString && !top.length ) {
3356
+
3357
+ // Reset the zoom and center the map
3358
+ olView.setZoom( olView.getMaxZoom );
3359
+ return;
3360
+
3361
+ } else if ( isTopString && top.substring( 0, 1 ).match( /[a-z]/gi ) !== null ) {
3362
+
3363
+ // This is wkt type
3364
+ var wktParser = new ol.format.WKT();
3365
+
3366
+ vectorFeature = wktParser.readFeature( top, {
3367
+ dataProjection: "EPSG:4326",
3368
+ featureProjection: olView.getProjection()
3369
+ } );
3370
+
3371
+ } else {
3372
+
3373
+ // Just 4 cardinal point was given
3374
+ if ( !right && isTopString ) {
3375
+ extentCoordinate = top.split( " " );
3376
+ if ( extentCoordinate.length !== 4 ) {
3377
+ throw "4 cardinal point must be provided";
3378
+ }
3379
+ top = extentCoordinate[ 0 ];
3380
+ right = extentCoordinate[ 1 ];
3381
+ bottom = extentCoordinate[ 2 ];
3382
+ left = extentCoordinate[ 3 ];
3383
+ } else if ( !right || !bottom || !left ) {
3384
+ throw "Cardinal point must be provided";
3385
+ }
3386
+ extentCoordinate = [ parseFloat( left ), parseFloat( bottom ), parseFloat( right ), parseFloat( top ) ];
3387
+
3388
+ vectorFeature = drawAOI( _this, extentCoordinate, true );
3389
+ }
3390
+
3391
+ extent = vectorFeature.getGeometry().getExtent();
3392
+
3393
+ olView.fit( extent, OLmap.getSize() );
3394
+ };
3395
+
3396
+ /*
3397
+ * Select a layer
3398
+ *
3399
+ * layerName = String or []<string>: Layer name to apply a state
3400
+ * state = Boolean, default false: Visibility state that are going to be set
3401
+ * onlyThose = Boolean, default false: If true, the inverse visibility state would be set for all the other layers.
3402
+ *
3403
+ */
3404
+ Geomap.prototype.showLayer = function( layerName, state ) {
3405
+
3406
+ var layerNameArray = [],
3407
+ geomapLayers = this.mapLayers,
3408
+ i, i_len = geomapLayers.length,
3409
+ i_lyr, i_lyr_title;
3410
+
3411
+ state = !!state;
3412
+
3413
+ if ( Array.isArray( layerName ) ) {
3414
+ layerNameArray = layerName;
3415
+ } else {
3416
+ layerNameArray.push( layerName );
3417
+ }
3418
+
3419
+ for ( i = 0; i !== i_len; i = i + 1 ) {
3420
+ i_lyr = geomapLayers[ i ];
3421
+ i_lyr_title = i_lyr.layer.title;
3422
+
3423
+ if ( !layerName || layerNameArray.indexOf( i_lyr_title ) !== -1 ) {
3424
+ i_lyr.isVisible = state;
3425
+ } else if ( i_lyr_title ) {
3426
+ i_lyr.isVisible = !state;
3427
+ }
3428
+ }
3429
+ };
3430
+
3431
+ /**
3432
+ * Add the layer symbology to the legend
3433
+ */
3434
+ MapLegend.prototype.symbolize = function( mapLayer ) {
3435
+
3436
+ if ( !mapLayer.layer ) {
3437
+ return;
3438
+ }
3439
+
3440
+ var _this = this,
3441
+ style = mapLayer.settings.style,
3442
+ layerName = mapLayer.id,
3443
+ feature = mapLayer.layer.getSource().getFeatures()[ 0 ],
3444
+ symbolItems = [],
3445
+ symbolList = "",
3446
+ title = "",
3447
+ filter, ruleLen, symbolizer, i, j, len, rule, spanId;
3448
+
3449
+ if ( typeof style !== "undefined" && style.rule ) {
3450
+
3451
+ ruleLen = style.rule.length;
3452
+
3453
+ if ( ruleLen ) {
3454
+
3455
+ for ( j = 0; j !== ruleLen; j += 1 ) {
3456
+ rule = style.rule[ j ];
3457
+ filter = rule.filter;
3458
+ symbolizer = rule.init;
3459
+ title = "";
3460
+ spanId = "ls_" + layerName + "_" + j;
3461
+
3462
+ if ( filter && !rule.name ) {
3463
+ if ( filter.name ) {
3464
+ title = filter.name;
3465
+ } else {
3466
+ switch ( filter ) {
3467
+ case "EQUAL_TO":
3468
+ title = rule.field + " = " + rule.value[ 0 ];
3469
+ break;
3470
+ case "GREATER_THAN":
3471
+ title = rule.field + " > " + rule.value[ 0 ];
3472
+ break;
3473
+ case "LESS_THAN":
3474
+ title = rule.field + " < " + rule.value[ 0 ];
3475
+ break;
3476
+ case "BETWEEN":
3477
+ title = rule.field + " " + rule.value[ 0 ] + " - " + rule.value[ 1 ];
3478
+ break;
3479
+ }
3480
+ }
3481
+ } else if ( rule && rule.name ) {
3482
+ title = rule.name;
3483
+ }
3484
+
3485
+ symbolList += "<li>" +
3486
+ "<div class='geomap-legend-element'>" +
3487
+ "<div id='" + spanId + "' class='geomap-legend-symbol'></div>" +
3488
+ "<span class='geomap-legend-symbol-text'><small>" + title + "</small></span>" +
3489
+ "</div>" +
3490
+ "</li>";
3491
+
3492
+ symbolItems.push( { "id": spanId, "feature": feature, "symbolizer": symbolizer } );
3493
+ }
3494
+
3495
+ }
3496
+
3497
+ } else if ( typeof style !== "undefined" && style.type === "unique" ) {
3498
+
3499
+ j = 0;
3500
+
3501
+ for ( var obj in style.init ) {
3502
+ spanId = "ls_" + layerName + "_" + j;
3503
+ symbolizer = style.init[ obj ];
3504
+ title = symbolizer.name ? symbolizer.name : obj;
3505
+
3506
+ symbolList += "<li>" +
3507
+ "<div class='geomap-legend-element'>" +
3508
+ "<div id='" + spanId + "' class='geomap-legend-symbol'></div>" +
3509
+ "<span class='geomap-legend-symbol-text'><small>" + title + "</small></span>" +
3510
+ "</div>" +
3511
+ "</li>";
3512
+
3513
+ symbolItems.push( { "id": spanId, "feature": feature, "symbolizer": symbolizer } );
3514
+
3515
+ j += 1;
3516
+ }
3517
+ } else if ( typeof style !== "undefined" && style.type === "symbol" ) {
3518
+
3519
+ spanId = "ls_" + layerName + "_0";
3520
+ symbolizer = style.init;
3521
+ title = symbolizer.name ? symbolizer.name : "";
3522
+
3523
+ symbolList += "<li>" +
3524
+ "<div class='geomap-legend-element'>" +
3525
+ "<div id='" + spanId + "' class='geomap-legend-symbol'></div>" +
3526
+ "<span class='geomap-legend-symbol-text'><small>" + title + "</small></span>" +
3527
+ "</div>" +
3528
+ "</li>";
3529
+
3530
+ symbolItems.push( { "id": spanId, "feature": feature, "symbolizer": symbolizer } );
3531
+
3532
+ } else {
3533
+
3534
+ spanId = "ls_" + layerName + "_0";
3535
+ symbolizer = {
3536
+ "fillColor": style.fillColor,
3537
+ "strokeColor": style.strokeColor,
3538
+ "strokeWidth": style.strokeWidth,
3539
+ "strokeDash": style.strokeDash
3540
+ };
3541
+
3542
+ symbolList += "<li>" +
3543
+ "<div class='geomap-legend-element'>" +
3544
+ "<div id='" + spanId + "' class='geomap-legend-symbol'></div>" +
3545
+ "<span class='geomap-legend-symbol-text'><small>" + title + "</small></span>" +
3546
+ "</div>" +
3547
+ "</li>";
3548
+
3549
+ symbolItems.push( { "id": spanId, "feature": feature, "symbolizer": symbolizer } );
3550
+
3551
+ }
3552
+
3553
+ // append the list to the legend
3554
+ if ( $( "#sb_" + layerName ).closest( ".wb-geomap" ).hasClass( "legend-label-only" ) && symbolList.match( /<li>/g ) && symbolList.match( /<li>/g ).length === 1 ) {
3555
+
3556
+ // role="presentation" added here because there is only one item and the icon is now only there for styling purposes
3557
+ $( "#sb_" + layerName ).html( "<ul class='list-unstyled' role='presentation'>" + symbolList + "</ul>" );
3558
+ $( "#sb_" + layerName + " li" ).attr( "role", "presentation" );
3559
+ } else {
3560
+ $( "#sb_" + layerName ).html( "<ul class='list-unstyled'>" + symbolList + "</ul>" );
3561
+ }
3562
+
3563
+ // create the legend symbols
3564
+ for ( i = 0, len = symbolItems.length; i !== len; i += 1 ) {
3565
+ var symbol = symbolItems[ i ];
3566
+ _this.getSymbol( symbol.id, symbol.feature, symbol.symbolizer );
3567
+ }
3568
+
3569
+ };
3570
+
3571
+ /**
3572
+ * Get legend symbols
3573
+ */
3574
+ MapLegend.prototype.getSymbol = function( id, feature, symbolizer ) {
3575
+
3576
+ var colors = defaultColors(), //TODO: symbolizer must have colors else legend won't match
3577
+
3578
+ featureType = feature && feature.getGeometry() ? feature.getGeometry().getType() : "Polygon",
3579
+ opacity = symbolizer.fillOpacity ? symbolizer.fillOpacity : symbolizer.graphicOpacity ? symbolizer.graphicOpacity : 1.0,
3580
+ fillColor = symbolizer.fillColor ? hexToRGB( symbolizer.fillColor, opacity ) : colors.transparent,
3581
+ radius = symbolizer.pointRadius ? symbolizer.pointRadius : 5,
3582
+ strokeColor = symbolizer.strokeColor ? hexToRGB( symbolizer.strokeColor ) : colors.transparent,
3583
+ strokeWidth = symbolizer.strokeWidth ? symbolizer.strokeWidth : 1,
3584
+ strokeDash = symbolizer.strokeDash ? symbolizer.strokeDash : [ 1, 0 ],
3585
+ externalGraphic = symbolizer.externalGraphic ? symbolizer.externalGraphic : null,
3586
+ graphicName = symbolizer.graphicName ? symbolizer.graphicName : null,
3587
+ graphicHeight = symbolizer.graphicHeight ? symbolizer.graphicHeight : 30,
3588
+ graphicWidth = symbolizer.graphicWidth ? symbolizer.graphicWidth : 30,
3589
+ height = graphicHeight < radius * 2 ? radius * 2 : graphicHeight,
3590
+ width = graphicWidth < radius * 2 ? radius * 2 : graphicWidth,
3591
+ pseudoFeature, rendererMap, source, style;
3592
+
3593
+ switch ( featureType ) {
3594
+ case "Polygon" || "MultiPolygon":
3595
+ pseudoFeature = new ol.Feature( {
3596
+ geometry: new ol.geom.Polygon( [ [ [ -10, -7 ], [ 10, -7 ],
3597
+ [ 10, 7 ], [ -10, 7 ] ] ] )
3598
+ } );
3599
+ style = getPolygonStyle( {
3600
+ fill: new ol.style.Fill( {
3601
+ color: fillColor
3602
+ } ),
3603
+ stroke: new ol.style.Stroke( {
3604
+ color: strokeColor,
3605
+ width: strokeWidth,
3606
+ lineDash: strokeDash
3607
+ } )
3608
+ } );
3609
+ pseudoFeature.setStyle( style );
3610
+ break;
3611
+ case "Point" || "MultiPoint":
3612
+ pseudoFeature = new ol.Feature( {
3613
+ geometry: new ol.geom.Point( [ 0, 0 ] )
3614
+ } );
3615
+ if ( graphicName ) {
3616
+ style = getSymbolStyle( {
3617
+ symbol: graphicName,
3618
+ fill: new ol.style.Fill( { color: fillColor } ),
3619
+ stroke: new ol.style.Stroke( { color: strokeColor, lineDash: strokeDash } ),
3620
+ radius: radius
3621
+ } );
3622
+ } else if ( externalGraphic ) {
3623
+ style = getIconStyle( {
3624
+ src: externalGraphic,
3625
+ opacity: opacity,
3626
+ size: [ graphicWidth, graphicHeight ]
3627
+ } );
3628
+ } else {
3629
+ style = getPointStyle( {
3630
+ radius: radius,
3631
+ fill: new ol.style.Fill( { color: fillColor } ),
3632
+ stroke: new ol.style.Stroke( { color: strokeColor, width: strokeWidth, lineDash: strokeDash } )
3633
+ } );
3634
+ }
3635
+ pseudoFeature.setStyle( style );
3636
+ break;
3637
+ case "LineString" || "MultiLineString":
3638
+ pseudoFeature = new ol.Feature( {
3639
+ geometry: new ol.geom.LineString( [ [ -9, -4 ], [ -4, 4 ], [ 4, -4 ], [ 9, 4 ] ] )
3640
+ } );
3641
+ style = getLineStyle( {
3642
+ stroke: new ol.style.Stroke( {
3643
+ color: strokeColor,
3644
+ width: strokeWidth,
3645
+ lineDash: strokeDash
3646
+ } )
3647
+ } );
3648
+ pseudoFeature.setStyle( style );
3649
+ break;
3650
+ default:
3651
+ pseudoFeature = new ol.Feature( {
3652
+ geometry: new ol.geom.Polygon( [ [ [ -10, -7 ], [ 10, -7 ], [ 10, 7 ], [ -10, 7 ] ] ] )
3653
+ } );
3654
+ style = getPolygonStyle( {
3655
+ fill: new ol.style.Fill( {
3656
+ color: fillColor
3657
+ } ),
3658
+ stroke: new ol.style.Stroke( {
3659
+ color: strokeColor,
3660
+ width: strokeWidth,
3661
+ lineDash: strokeDash
3662
+ } )
3663
+ } );
3664
+ pseudoFeature.setStyle( style );
3665
+ break;
3666
+ }
3667
+
3668
+ // create a map for the symbol
3669
+ rendererMap = new ol.Map( {
3670
+ controls: [],
3671
+ interactions: [],
3672
+ layers: [ new ol.layer.Vector( {
3673
+ source: new ol.source.Vector()
3674
+ } ) ]
3675
+ } );
3676
+
3677
+ if ( rendererMap ) {
3678
+ this.symbolMapArray.push( rendererMap );
3679
+ source = rendererMap.getLayers().item( 0 ).getSource();
3680
+ source.clear();
3681
+ source.addFeature( pseudoFeature );
3682
+ }
3683
+
3684
+ rendererMap.setTarget( id );
3685
+ setRendererDimensions( id, rendererMap, pseudoFeature, width, height );
3686
+
3687
+ };
3688
+
3689
+ /**
3690
+ * Refresh the legend symbols
3691
+ */
3692
+ MapLegend.prototype.refresh = function() {
3693
+
3694
+ if ( this.symbolMapArray.length !== 0 ) {
3695
+ var len, map;
3696
+ for ( len = this.symbolMapArray.length - 1; len !== -1; len -= 1 ) {
3697
+ map = this.symbolMapArray[ len ];
3698
+ if ( $( "#" + map.getTarget() ).is( ":visible" ) ) {
3699
+ map.updateSize();
3700
+ }
3701
+ }
3702
+ }
3703
+
3704
+ };
3705
+
3706
+ ol.inherits( GeolocationControl, ol.control.Control );
3707
+ ol.inherits( HelpControl, ol.control.Control );
3708
+ ol.inherits( GeocodeControl, ol.control.Control );
3709
+
3710
+
3711
+ /**
3712
+ * Event Geomap filter
3713
+ *
3714
+ * Apply AOI and Layer filter
3715
+ * - only the <select> element is currently supported
3716
+ *
3717
+ */
3718
+ wb.doc.on( "submit", ".wb-geomap-filter", function( event ) {
3719
+
3720
+ event.preventDefault();
3721
+
3722
+ var $form = $( this ),
3723
+ map = document.getElementById( $form.data( "bind-to" ) ).geomap;
3724
+
3725
+ // Loops though the form group
3726
+ $form.find( "select[data-filter]" ).each( function() {
3727
+ var $elm = $( this ),
3728
+ $optSelected = $elm.find( "option:selected" ),
3729
+ value = $optSelected.val(),
3730
+ tpFilter = $elm.attr( "data-filter" ); // "layer || aoi"
3731
+
3732
+ // if aoi => There will be 4 coordinate space separated (Sequence: N E S W)
3733
+ if ( tpFilter === "aoi" ) {
3734
+ map.zoomAOI( value );
3735
+ }
3736
+
3737
+ // if layer => The layer name
3738
+ if ( tpFilter === "layer" ) {
3739
+ map.showLayer( value, true );
3740
+ }
3741
+ } );
3742
+ } );
3743
+
3744
+ /*
3745
+ * Reset the view on the map and manually reset the layer filter
3746
+ *
3747
+ */
3748
+ wb.doc.on( "click", ".wb-geomap-filter [type=reset]", function( ) {
3749
+
3750
+ var $form = $( this.form ),
3751
+ geomap = document.getElementById( $form.data( "bind-to" ) ).geomap,
3752
+ OLmap = geomap.map,
3753
+ mapGetView = OLmap.getView();
3754
+
3755
+ OLmap.getView().fit( mapGetView.calculateExtent( OLmap.getSize() ), OLmap.getSize() );
3756
+
3757
+ $form.find( "select[data-filter=layer] option" ).each( function() {
3758
+ if ( this.defaultSelected ) {
3759
+ geomap.showLayer( this.value, true );
3760
+ }
3761
+ } );
3762
+ $form.find( "select[data-filter=aoi] option" ).each( function() {
3763
+ if ( this.defaultSelected ) {
3764
+ geomap.zoomAOI( this.value );
3765
+ }
3766
+ } );
3767
+ } );
3768
+
3769
+
3770
+ } )( jQuery, window, document, wb );