geoblacklight 4.0.0.pre.alpha.1 → 4.0.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +1 -1
  3. data/.github/workflows/ruby.yml +32 -64
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +6 -6
  6. data/.rubocop_todo.yml +0 -3
  7. data/.solr_wrapper +1 -0
  8. data/README.md +1 -4
  9. data/Rakefile +0 -1
  10. data/app/assets/images/blacklight/child-item.svg +3 -0
  11. data/app/assets/images/blacklight/collections.svg +4 -0
  12. data/app/assets/images/blacklight/datasets.svg +7 -0
  13. data/app/assets/images/blacklight/geoblacklight-icons.json +363 -332
  14. data/app/assets/images/blacklight/imagery.svg +4 -0
  15. data/app/assets/images/blacklight/maps.svg +4 -0
  16. data/app/assets/images/blacklight/michigan-state-university.svg +0 -1
  17. data/app/assets/images/blacklight/parent-item.svg +3 -0
  18. data/app/assets/images/blacklight/pennsylvania-state-university.svg +0 -1
  19. data/app/assets/images/blacklight/purdue-university.svg +0 -1
  20. data/app/assets/images/blacklight/the-ohio-state-university.svg +0 -1
  21. data/app/assets/images/blacklight/university-of-chicago.svg +0 -1
  22. data/app/assets/images/blacklight/university-of-colorado-boulder.svg +6 -0
  23. data/app/assets/images/blacklight/university-of-illinois-urbana-champaign.svg +0 -1
  24. data/app/assets/images/blacklight/university-of-iowa.svg +0 -1
  25. data/app/assets/images/blacklight/university-of-maryland.svg +0 -1
  26. data/app/assets/images/blacklight/university-of-michigan.svg +0 -1
  27. data/app/assets/images/blacklight/university-of-minnesota.svg +0 -1
  28. data/app/assets/images/blacklight/university-of-nebraska-lincoln.svg +0 -1
  29. data/app/assets/images/blacklight/university-of-wisconsin-madison.svg +0 -1
  30. data/app/assets/images/blacklight/websites.svg +4 -0
  31. data/app/assets/javascripts/geoblacklight/controls/fullscreen.js +8 -0
  32. data/app/assets/javascripts/geoblacklight/geoblacklight.js +2 -1
  33. data/app/assets/javascripts/geoblacklight/viewers/esri.js +1 -0
  34. data/app/assets/javascripts/geoblacklight/viewers/index_map.js +1 -0
  35. data/app/assets/javascripts/geoblacklight/viewers/tilejson.js +33 -0
  36. data/app/assets/javascripts/geoblacklight/viewers/tms.js +2 -2
  37. data/app/assets/javascripts/geoblacklight/viewers/viewer.js +3 -0
  38. data/app/assets/javascripts/geoblacklight/viewers/wms.js +2 -2
  39. data/app/assets/javascripts/geoblacklight/viewers/wmts.js +85 -0
  40. data/app/assets/javascripts/geoblacklight/viewers/xyz.js +10 -0
  41. data/app/assets/stylesheets/geoblacklight/geoblacklight.scss +1 -0
  42. data/app/assets/stylesheets/geoblacklight/modules/_base.scss +0 -1
  43. data/app/assets/stylesheets/geoblacklight/modules/_styles.scss +5 -1
  44. data/app/assets/stylesheets/geoblacklight/modules/downloads.scss +20 -47
  45. data/app/assets/stylesheets/geoblacklight/modules/index_maps.scss +68 -0
  46. data/app/assets/stylesheets/geoblacklight/modules/item.scss +16 -0
  47. data/app/assets/stylesheets/geoblacklight/modules/modal.scss +6 -0
  48. data/app/assets/stylesheets/geoblacklight/modules/sidebar.scss +4 -0
  49. data/app/components/geoblacklight/icon_facet_item_component.rb +33 -0
  50. data/app/helpers/geoblacklight_helper.rb +6 -45
  51. data/app/models/concerns/geoblacklight/bbox_filter_field.rb +45 -0
  52. data/app/models/concerns/geoblacklight/bbox_filter_query.rb +50 -0
  53. data/app/models/concerns/geoblacklight/solr_document.rb +1 -1
  54. data/app/models/concerns/geoblacklight/suppressed_records_search_behavior.rb +26 -0
  55. data/app/presenters/geoblacklight/bbox_item_presenter.rb +9 -0
  56. data/app/views/catalog/_downloads_collapse.html.erb +27 -0
  57. data/app/views/catalog/_header_icons.html.erb +2 -2
  58. data/app/views/catalog/_index_split_default.html.erb +2 -2
  59. data/app/views/catalog/_show_default_viewer_container.html.erb +17 -0
  60. data/app/views/catalog/_show_downloads.html.erb +10 -21
  61. data/app/views/catalog/_show_sidebar.html.erb +3 -0
  62. data/app/views/catalog/_show_web_services.html.erb +11 -0
  63. data/app/views/catalog/_web_services.html.erb +3 -2
  64. data/app/views/catalog/web_services.html.erb +1 -1
  65. data/app/views/relation/_relations.html.erb +1 -1
  66. data/app/views/relation/index.html.erb +1 -1
  67. data/config/locales/geoblacklight.en.yml +4 -1
  68. data/geoblacklight.gemspec +6 -6
  69. data/lib/generators/geoblacklight/install_generator.rb +1 -1
  70. data/lib/generators/geoblacklight/templates/assets/_customizations.scss +5 -4
  71. data/lib/generators/geoblacklight/templates/assets/application.scss +0 -3
  72. data/lib/generators/geoblacklight/templates/catalog_controller.rb +74 -56
  73. data/lib/generators/geoblacklight/templates/settings.gbl_v1.yml +5 -5
  74. data/lib/generators/geoblacklight/templates/settings.yml +36 -23
  75. data/lib/geoblacklight/bounding_box.rb +4 -0
  76. data/lib/geoblacklight/constants.rb +3 -0
  77. data/lib/geoblacklight/engine.rb +3 -2
  78. data/lib/geoblacklight/faraday_middleware/follow_redirects.rb +176 -0
  79. data/lib/geoblacklight/item_viewer.rb +13 -1
  80. data/lib/geoblacklight/metadata/base.rb +2 -1
  81. data/lib/geoblacklight/version.rb +1 -1
  82. data/lib/geoblacklight/view_helper_override.rb +2 -28
  83. data/lib/geoblacklight.rb +0 -10
  84. data/lib/tasks/geoblacklight.rake +1 -1
  85. data/schema/geoblacklight-schema-aardvark.json +3 -23
  86. data/solr/conf/schema.xml +37 -43
  87. data/solr/conf/solrconfig.xml +17 -17
  88. data/spec/components/geoblacklight/icon_facet_item_component_spec.rb +17 -0
  89. data/spec/controllers/catalog_controller_spec.rb +1 -1
  90. data/spec/features/download_layer_spec.rb +31 -14
  91. data/spec/features/esri_viewer_spec.rb +5 -1
  92. data/spec/features/full_screen_controll_spec.rb +15 -0
  93. data/spec/features/home_page_spec.rb +2 -2
  94. data/spec/features/index_map_spec.rb +2 -2
  95. data/spec/features/missing_metadata_spec.rb +1 -1
  96. data/spec/features/multiple_downloads_spec.rb +2 -1
  97. data/spec/features/relations_spec.rb +1 -1
  98. data/spec/features/saved_searches_spec.rb +1 -1
  99. data/spec/features/search_results_complex_geometry_spec.rb +24 -0
  100. data/spec/features/search_results_icons_spec.rb +16 -0
  101. data/spec/features/search_results_map_spec.rb +2 -2
  102. data/spec/features/search_spec.rb +22 -0
  103. data/spec/features/show_page_download_spec.rb +29 -0
  104. data/spec/features/show_page_metadata_spec.rb +2 -2
  105. data/spec/features/split_view.html.erb_spec.rb +12 -1
  106. data/spec/features/tilejson_spec.rb +22 -0
  107. data/spec/features/tms_spec.rb +2 -2
  108. data/spec/features/web_services_modal_spec.rb +35 -2
  109. data/spec/features/wmts_spec.rb +34 -0
  110. data/spec/features/xyz_spec.rb +10 -0
  111. data/spec/fixtures/manifests/tilejson.json +21 -0
  112. data/spec/fixtures/manifests/wmts-multiple.xml +813 -0
  113. data/spec/fixtures/manifests/wmts-single.xml +126 -0
  114. data/spec/fixtures/solr_documents/README.md +46 -43
  115. data/spec/fixtures/solr_documents/actual-papermap1.json +2 -1
  116. data/spec/fixtures/solr_documents/actual-point1.json +2 -1
  117. data/spec/fixtures/solr_documents/actual-polygon1.json +2 -1
  118. data/spec/fixtures/solr_documents/actual-raster1.json +3 -2
  119. data/spec/fixtures/solr_documents/baruch_ancestor1.json +2 -1
  120. data/spec/fixtures/solr_documents/baruch_ancestor2.json +2 -1
  121. data/spec/fixtures/solr_documents/baruch_documentation_download.json +1 -1
  122. data/spec/fixtures/solr_documents/bbox-spans-180.json +2 -1
  123. data/spec/fixtures/solr_documents/cornell_html_metadata.json +4 -3
  124. data/spec/fixtures/solr_documents/esri-dynamic-layer-all-layers.json +3 -2
  125. data/spec/fixtures/solr_documents/esri-dynamic-layer-single-layer.json +3 -2
  126. data/spec/fixtures/solr_documents/esri-feature-layer.json +2 -1
  127. data/spec/fixtures/solr_documents/esri-image-map-layer.json +3 -2
  128. data/spec/fixtures/solr_documents/esri-tiled_map_layer.json +2 -1
  129. data/spec/fixtures/solr_documents/esri-wms-layer.json +2 -1
  130. data/spec/fixtures/solr_documents/harvard_raster.json +3 -2
  131. data/spec/fixtures/solr_documents/iiif-eastern-hemisphere.json +3 -2
  132. data/spec/fixtures/solr_documents/index-map-polygon-no-downloadurl.json +2 -1
  133. data/spec/fixtures/solr_documents/index-map-polygon.json +2 -1
  134. data/spec/fixtures/solr_documents/index-map-stanford.json +2 -1
  135. data/spec/fixtures/solr_documents/index_map_point.json +3 -2
  136. data/spec/fixtures/solr_documents/metadata_no_provider.json +2 -1
  137. data/spec/fixtures/solr_documents/multiple-downloads.json +3 -2
  138. data/spec/fixtures/solr_documents/no_spatial.json +1 -4
  139. data/spec/fixtures/solr_documents/oembed.json +2 -1
  140. data/spec/fixtures/solr_documents/princeton-child1.json +3 -2
  141. data/spec/fixtures/solr_documents/princeton-child2.json +3 -2
  142. data/spec/fixtures/solr_documents/princeton-child3.json +2 -1
  143. data/spec/fixtures/solr_documents/princeton-child4.json +3 -2
  144. data/spec/fixtures/solr_documents/princeton-parent.json +5 -3
  145. data/spec/fixtures/solr_documents/public_direct_download.json +2 -1
  146. data/spec/fixtures/solr_documents/public_iiif_princeton.json +3 -2
  147. data/spec/fixtures/solr_documents/public_polygon_mit.json +2 -1
  148. data/spec/fixtures/solr_documents/restricted-line.json +2 -1
  149. data/spec/fixtures/solr_documents/tilejson.json +48 -0
  150. data/spec/fixtures/solr_documents/tms.json +15 -18
  151. data/spec/fixtures/solr_documents/umn_metro_result1.json +5 -3
  152. data/spec/fixtures/solr_documents/umn_state_result1.json +3 -2
  153. data/spec/fixtures/solr_documents/umn_state_result2.json +3 -5
  154. data/spec/fixtures/solr_documents/uva_slug_colon.json +2 -1
  155. data/spec/fixtures/solr_documents/wmts-multiple.json +41 -0
  156. data/spec/fixtures/solr_documents/wmts-single-layer.json +48 -0
  157. data/spec/fixtures/solr_documents/xyz.json +46 -0
  158. data/spec/helpers/geoblacklight_helper_spec.rb +12 -35
  159. data/spec/lib/geoblacklight/document_presenter_spec.rb +3 -3
  160. data/spec/lib/geoblacklight/download/geojson_download_spec.rb +1 -1
  161. data/spec/lib/geoblacklight/download/geotiff_download_spec.rb +1 -1
  162. data/spec/lib/geoblacklight/download/kmz_download_spec.rb +1 -1
  163. data/spec/lib/geoblacklight/download/shapefile_download_spec.rb +1 -1
  164. data/spec/lib/geoblacklight/download_spec.rb +2 -2
  165. data/spec/lib/geoblacklight/metadata/base_spec.rb +19 -1
  166. data/spec/lib/geoblacklight/references_spec.rb +1 -1
  167. data/spec/lib/geoblacklight/relation/relation_response_spec.rb +5 -0
  168. data/spec/lib/geoblacklight/view_helper_override_spec.rb +0 -10
  169. data/spec/models/concerns/geoblacklight/bbox_filter_field_spec.rb +77 -0
  170. data/spec/models/concerns/geoblacklight/bbox_filter_query_spec.rb +105 -0
  171. data/spec/models/concerns/geoblacklight/solr_document/inspection_spec.rb +2 -1
  172. data/spec/models/concerns/geoblacklight/suppressed_records_search_behavior_spec.rb +31 -0
  173. data/spec/presenters/geoblacklight/bbox_item_presenter_spec.rb +36 -0
  174. data/spec/spec_helper.rb +6 -1
  175. data/spec/test_app_templates/Gemfile.extra +1 -0
  176. data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -4
  177. data/spec/views/catalog/_show_downloads.html.erb_spec.rb +5 -5
  178. data/template.rb +2 -4
  179. data/vendor/assets/images/fullscreen.png +0 -0
  180. data/vendor/assets/images/fullscreen@2x.png +0 -0
  181. data/vendor/assets/javascripts/Leaflet.fullscreen.js +152 -0
  182. data/vendor/assets/javascripts/esri-leaflet.js +10 -3
  183. data/vendor/assets/javascripts/esri-leaflet.js.map +1 -1
  184. data/vendor/assets/javascripts/leaflet-iiif.js +39 -18
  185. data/vendor/assets/javascripts/leaflet-src.js.erb +14062 -0
  186. data/vendor/assets/javascripts/leaflet-src.js.map +1 -1
  187. data/vendor/assets/stylesheets/leaflet.css +640 -634
  188. data/vendor/assets/stylesheets/leaflet.fullscreen.css +40 -0
  189. metadata +91 -46
  190. data/app/models/concerns/geoblacklight/spatial_search_behavior.rb +0 -71
  191. data/app/views/catalog/_download_generated_link.html.erb +0 -4
  192. data/app/views/catalog/_download_link.html.erb +0 -3
  193. data/app/views/catalog/_downloads_generated.html.erb +0 -6
  194. data/app/views/catalog/_downloads_primary.html.erb +0 -21
  195. data/app/views/catalog/_downloads_secondary.html.erb +0 -39
  196. data/app/views/catalog/_icon_facet.html.erb +0 -16
  197. data/bin/coverage.rb +0 -36
  198. data/lib/generators/geoblacklight/templates/Procfile +0 -3
  199. data/lib/generators/geoblacklight/templates/package.json +0 -14
  200. data/lib/generators/geoblacklight/templates/webpacker.yml +0 -67
  201. data/lib/generators/geoblacklight/webpacker_generator.rb +0 -36
  202. data/lib/geoblacklight/catalog_helper_override.rb +0 -14
  203. data/spec/models/concerns/geoblacklight/spatial_search_behavior_spec.rb +0 -97
  204. data/vendor/assets/javascripts/leaflet.js.erb +0 -13922
  205. data/vendor/assets/stylesheets/leaflet-label.css +0 -54
@@ -1 +1 @@
1
- {"version":3,"file":"esri-leaflet.js","sources":["../src/Support.js","../src/Options.js","../src/Request.js","../node_modules/@esri/arcgis-to-geojson-utils/index.js","../src/Util.js","../src/Tasks/Task.js","../src/Tasks/Query.js","../src/Tasks/Find.js","../src/Tasks/Identify.js","../src/Tasks/IdentifyFeatures.js","../src/Tasks/IdentifyImage.js","../src/Services/Service.js","../src/Services/MapService.js","../src/Services/ImageService.js","../src/Services/FeatureLayerService.js","../src/Layers/BasemapLayer.js","../src/Layers/TiledMapLayer.js","../src/Layers/RasterLayer.js","../src/Layers/ImageMapLayer.js","../src/Layers/DynamicMapLayer.js","../node_modules/leaflet-virtual-grid/src/virtual-grid.js","../node_modules/tiny-binary-search/index.js","../src/Layers/FeatureLayer/FeatureManager.js","../src/Layers/FeatureLayer/FeatureLayer.js"],"sourcesContent":["export var cors = ((window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()));\nexport var pointerEvents = document.documentElement.style.pointerEvents === '';\n\nexport var Support = {\n cors: cors,\n pointerEvents: pointerEvents\n};\n\nexport default Support;\n","export var options = {\n attributionWidthOffset: 55\n};\n\nexport default options;\n","import { Util, DomUtil } from 'leaflet';\nimport Support from './Support';\nimport { warn } from './Util';\n\nvar callbacks = 0;\n\nfunction serialize (params) {\n var data = '';\n\n params.f = params.f || 'json';\n\n for (var key in params) {\n if (params.hasOwnProperty(key)) {\n var param = params[key];\n var type = Object.prototype.toString.call(param);\n var value;\n\n if (data.length) {\n data += '&';\n }\n\n if (type === '[object Array]') {\n value = (Object.prototype.toString.call(param[0]) === '[object Object]') ? JSON.stringify(param) : param.join(',');\n } else if (type === '[object Object]') {\n value = JSON.stringify(param);\n } else if (type === '[object Date]') {\n value = param.valueOf();\n } else {\n value = param;\n }\n\n data += encodeURIComponent(key) + '=' + encodeURIComponent(value);\n }\n }\n\n return data;\n}\n\nfunction createRequest (callback, context) {\n var httpRequest = new window.XMLHttpRequest();\n\n httpRequest.onerror = function (e) {\n httpRequest.onreadystatechange = Util.falseFn;\n\n callback.call(context, {\n error: {\n code: 500,\n message: 'XMLHttpRequest error'\n }\n }, null);\n };\n\n httpRequest.onreadystatechange = function () {\n var response;\n var error;\n\n if (httpRequest.readyState === 4) {\n try {\n response = JSON.parse(httpRequest.responseText);\n } catch (e) {\n response = null;\n error = {\n code: 500,\n message: 'Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error.'\n };\n }\n\n if (!error && response.error) {\n error = response.error;\n response = null;\n }\n\n httpRequest.onerror = Util.falseFn;\n\n callback.call(context, error, response);\n }\n };\n\n httpRequest.ontimeout = function () {\n this.onerror();\n };\n\n return httpRequest;\n}\n\nfunction xmlHttpPost (url, params, callback, context) {\n var httpRequest = createRequest(callback, context);\n httpRequest.open('POST', url);\n\n if (typeof context !== 'undefined' && context !== null) {\n if (typeof context.options !== 'undefined') {\n httpRequest.timeout = context.options.timeout;\n }\n }\n httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');\n httpRequest.send(serialize(params));\n\n return httpRequest;\n}\n\nfunction xmlHttpGet (url, params, callback, context) {\n var httpRequest = createRequest(callback, context);\n httpRequest.open('GET', url + '?' + serialize(params), true);\n\n if (typeof context !== 'undefined' && context !== null) {\n if (typeof context.options !== 'undefined') {\n httpRequest.timeout = context.options.timeout;\n }\n }\n httpRequest.send(null);\n\n return httpRequest;\n}\n\n// AJAX handlers for CORS (modern browsers) or JSONP (older browsers)\nexport function request (url, params, callback, context) {\n var paramString = serialize(params);\n var httpRequest = createRequest(callback, context);\n var requestLength = (url + '?' + paramString).length;\n\n // ie10/11 require the request be opened before a timeout is applied\n if (requestLength <= 2000 && Support.cors) {\n httpRequest.open('GET', url + '?' + paramString);\n } else if (requestLength > 2000 && Support.cors) {\n httpRequest.open('POST', url);\n httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');\n }\n\n if (typeof context !== 'undefined' && context !== null) {\n if (typeof context.options !== 'undefined') {\n httpRequest.timeout = context.options.timeout;\n }\n }\n\n // request is less than 2000 characters and the browser supports CORS, make GET request with XMLHttpRequest\n if (requestLength <= 2000 && Support.cors) {\n httpRequest.send(null);\n\n // request is more than 2000 characters and the browser supports CORS, make POST request with XMLHttpRequest\n } else if (requestLength > 2000 && Support.cors) {\n httpRequest.send(paramString);\n\n // request is less than 2000 characters and the browser does not support CORS, make a JSONP request\n } else if (requestLength <= 2000 && !Support.cors) {\n return jsonp(url, params, callback, context);\n\n // request is longer then 2000 characters and the browser does not support CORS, log a warning\n } else {\n warn('a request to ' + url + ' was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html');\n return;\n }\n\n return httpRequest;\n}\n\nexport function jsonp (url, params, callback, context) {\n window._EsriLeafletCallbacks = window._EsriLeafletCallbacks || {};\n var callbackId = 'c' + callbacks;\n params.callback = 'window._EsriLeafletCallbacks.' + callbackId;\n\n window._EsriLeafletCallbacks[callbackId] = function (response) {\n if (window._EsriLeafletCallbacks[callbackId] !== true) {\n var error;\n var responseType = Object.prototype.toString.call(response);\n\n if (!(responseType === '[object Object]' || responseType === '[object Array]')) {\n error = {\n error: {\n code: 500,\n message: 'Expected array or object as JSONP response'\n }\n };\n response = null;\n }\n\n if (!error && response.error) {\n error = response;\n response = null;\n }\n\n callback.call(context, error, response);\n window._EsriLeafletCallbacks[callbackId] = true;\n }\n };\n\n var script = DomUtil.create('script', null, document.body);\n script.type = 'text/javascript';\n script.src = url + '?' + serialize(params);\n script.id = callbackId;\n script.onerror = function (error) {\n if (error && window._EsriLeafletCallbacks[callbackId] !== true) {\n // Can't get true error code: it can be 404, or 401, or 500\n var err = {\n error: {\n code: 500,\n message: 'An unknown error occurred'\n }\n };\n\n callback.call(context, err);\n window._EsriLeafletCallbacks[callbackId] = true;\n }\n };\n DomUtil.addClass(script, 'esri-leaflet-jsonp');\n\n callbacks++;\n\n return {\n id: callbackId,\n url: script.src,\n abort: function () {\n window._EsriLeafletCallbacks._callback[callbackId]({\n code: 0,\n message: 'Request aborted.'\n });\n }\n };\n}\n\nvar get = ((Support.cors) ? xmlHttpGet : jsonp);\nget.CORS = xmlHttpGet;\nget.JSONP = jsonp;\n\n// choose the correct AJAX handler depending on CORS support\nexport { get };\n\n// always use XMLHttpRequest for posts\nexport { xmlHttpPost as post };\n\n// export the Request object to call the different handlers for debugging\nexport var Request = {\n request: request,\n get: get,\n post: xmlHttpPost\n};\n\nexport default Request;\n","/*\n * Copyright 2017 Esri\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// checks if 2 x,y points are equal\nfunction pointsEqual (a, b) {\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\n// checks if the first and last points of a ring are equal and closes the ring\nfunction closeRing (coordinates) {\n if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) {\n coordinates.push(coordinates[0]);\n }\n return coordinates;\n}\n\n// determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring\n// or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-\n// points-are-in-clockwise-order\nfunction ringIsClockwise (ringToTest) {\n var total = 0;\n var i = 0;\n var rLength = ringToTest.length;\n var pt1 = ringToTest[i];\n var pt2;\n for (i; i < rLength - 1; i++) {\n pt2 = ringToTest[i + 1];\n total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);\n pt1 = pt2;\n }\n return (total >= 0);\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L504-L519\nfunction vertexIntersectsVertex (a1, a2, b1, b2) {\n var uaT = ((b2[0] - b1[0]) * (a1[1] - b1[1])) - ((b2[1] - b1[1]) * (a1[0] - b1[0]));\n var ubT = ((a2[0] - a1[0]) * (a1[1] - b1[1])) - ((a2[1] - a1[1]) * (a1[0] - b1[0]));\n var uB = ((b2[1] - b1[1]) * (a2[0] - a1[0])) - ((b2[0] - b1[0]) * (a2[1] - a1[1]));\n\n if (uB !== 0) {\n var ua = uaT / uB;\n var ub = ubT / uB;\n\n if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {\n return true;\n }\n }\n\n return false;\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L521-L531\nfunction arrayIntersectsArray (a, b) {\n for (var i = 0; i < a.length - 1; i++) {\n for (var j = 0; j < b.length - 1; j++) {\n if (vertexIntersectsVertex(a[i], a[i + 1], b[j], b[j + 1])) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L470-L480\nfunction coordinatesContainPoint (coordinates, point) {\n var contains = false;\n for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) {\n if (((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1]) ||\n (coordinates[j][1] <= point[1] && point[1] < coordinates[i][1])) &&\n (point[0] < (((coordinates[j][0] - coordinates[i][0]) * (point[1] - coordinates[i][1])) / (coordinates[j][1] - coordinates[i][1])) + coordinates[i][0])) {\n contains = !contains;\n }\n }\n return contains;\n}\n\n// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L106-L113\nfunction coordinatesContainCoordinates (outer, inner) {\n var intersects = arrayIntersectsArray(outer, inner);\n var contains = coordinatesContainPoint(outer, inner[0]);\n if (!intersects && contains) {\n return true;\n }\n return false;\n}\n\n// do any polygons in this array contain any other polygons in this array?\n// used for checking for holes in arcgis rings\n// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L117-L172\nfunction convertRingsToGeoJSON (rings) {\n var outerRings = [];\n var holes = [];\n var x; // iterator\n var outerRing; // current outer ring being evaluated\n var hole; // current hole being evaluated\n\n // for each ring\n for (var r = 0; r < rings.length; r++) {\n var ring = closeRing(rings[r].slice(0));\n if (ring.length < 4) {\n continue;\n }\n // is this ring an outer ring? is it clockwise?\n if (ringIsClockwise(ring)) {\n var polygon = [ ring.slice().reverse() ]; // wind outer rings counterclockwise for RFC 7946 compliance\n outerRings.push(polygon); // push to outer rings\n } else {\n holes.push(ring.slice().reverse()); // wind inner rings clockwise for RFC 7946 compliance\n }\n }\n\n var uncontainedHoles = [];\n\n // while there are holes left...\n while (holes.length) {\n // pop a hole off out stack\n hole = holes.pop();\n\n // loop over all outer rings and see if they contain our hole.\n var contained = false;\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n if (coordinatesContainCoordinates(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n contained = true;\n break;\n }\n }\n\n // ring is not contained in any outer ring\n // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320\n if (!contained) {\n uncontainedHoles.push(hole);\n }\n }\n\n // if we couldn't match any holes using contains we can try intersects...\n while (uncontainedHoles.length) {\n // pop a hole off out stack\n hole = uncontainedHoles.pop();\n\n // loop over all outer rings and see if any intersect our hole.\n var intersects = false;\n\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n if (arrayIntersectsArray(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n intersects = true;\n break;\n }\n }\n\n if (!intersects) {\n outerRings.push([hole.reverse()]);\n }\n }\n\n if (outerRings.length === 1) {\n return {\n type: 'Polygon',\n coordinates: outerRings[0]\n };\n } else {\n return {\n type: 'MultiPolygon',\n coordinates: outerRings\n };\n }\n}\n\n// This function ensures that rings are oriented in the right directions\n// outer rings are clockwise, holes are counterclockwise\n// used for converting GeoJSON Polygons to ArcGIS Polygons\nfunction orientRings (poly) {\n var output = [];\n var polygon = poly.slice(0);\n var outerRing = closeRing(polygon.shift().slice(0));\n if (outerRing.length >= 4) {\n if (!ringIsClockwise(outerRing)) {\n outerRing.reverse();\n }\n\n output.push(outerRing);\n\n for (var i = 0; i < polygon.length; i++) {\n var hole = closeRing(polygon[i].slice(0));\n if (hole.length >= 4) {\n if (ringIsClockwise(hole)) {\n hole.reverse();\n }\n output.push(hole);\n }\n }\n }\n\n return output;\n}\n\n// This function flattens holes in multipolygons to one array of polygons\n// used for converting GeoJSON Polygons to ArcGIS Polygons\nfunction flattenMultiPolygonRings (rings) {\n var output = [];\n for (var i = 0; i < rings.length; i++) {\n var polygon = orientRings(rings[i]);\n for (var x = polygon.length - 1; x >= 0; x--) {\n var ring = polygon[x].slice(0);\n output.push(ring);\n }\n }\n return output;\n}\n\n// shallow object clone for feature properties and attributes\n// from http://jsperf.com/cloning-an-object/2\nfunction shallowClone (obj) {\n var target = {};\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) {\n target[i] = obj[i];\n }\n }\n return target;\n}\n\nfunction getId (attributes, idAttribute) {\n var keys = idAttribute ? [idAttribute, 'OBJECTID', 'FID'] : ['OBJECTID', 'FID'];\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (\n key in attributes &&\n (typeof attributes[key] === 'string' ||\n typeof attributes[key] === 'number')\n ) {\n return attributes[key];\n }\n }\n throw Error('No valid id attribute found');\n}\n\nexport function arcgisToGeoJSON (arcgis, idAttribute) {\n var geojson = {};\n\n if (arcgis.features) {\n geojson.type = 'FeatureCollection';\n geojson.features = [];\n for (var i = 0; i < arcgis.features.length; i++) {\n geojson.features.push(arcgisToGeoJSON(arcgis.features[i], idAttribute));\n }\n }\n\n if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') {\n geojson.type = 'Point';\n geojson.coordinates = [arcgis.x, arcgis.y];\n if (typeof arcgis.z === 'number') {\n geojson.coordinates.push(arcgis.z);\n }\n }\n\n if (arcgis.points) {\n geojson.type = 'MultiPoint';\n geojson.coordinates = arcgis.points.slice(0);\n }\n\n if (arcgis.paths) {\n if (arcgis.paths.length === 1) {\n geojson.type = 'LineString';\n geojson.coordinates = arcgis.paths[0].slice(0);\n } else {\n geojson.type = 'MultiLineString';\n geojson.coordinates = arcgis.paths.slice(0);\n }\n }\n\n if (arcgis.rings) {\n geojson = convertRingsToGeoJSON(arcgis.rings.slice(0));\n }\n\n if (\n typeof arcgis.xmin === 'number' &&\n typeof arcgis.ymin === 'number' &&\n typeof arcgis.xmax === 'number' &&\n typeof arcgis.ymax === 'number'\n ) {\n geojson.type = 'Polygon';\n geojson.coordinates = [[\n [arcgis.xmax, arcgis.ymax],\n [arcgis.xmin, arcgis.ymax],\n [arcgis.xmin, arcgis.ymin],\n [arcgis.xmax, arcgis.ymin],\n [arcgis.xmax, arcgis.ymax]\n ]];\n }\n\n if (arcgis.geometry || arcgis.attributes) {\n geojson.type = 'Feature';\n geojson.geometry = (arcgis.geometry) ? arcgisToGeoJSON(arcgis.geometry) : null;\n geojson.properties = (arcgis.attributes) ? shallowClone(arcgis.attributes) : null;\n if (arcgis.attributes) {\n try {\n geojson.id = getId(arcgis.attributes, idAttribute);\n } catch (err) {\n // don't set an id\n }\n }\n }\n\n // if no valid geometry was encountered\n if (JSON.stringify(geojson.geometry) === JSON.stringify({})) {\n geojson.geometry = null;\n }\n\n if (\n arcgis.spatialReference &&\n arcgis.spatialReference.wkid &&\n arcgis.spatialReference.wkid !== 4326\n ) {\n console.warn('Object converted in non-standard crs - ' + JSON.stringify(arcgis.spatialReference));\n }\n\n return geojson;\n}\n\nexport function geojsonToArcGIS (geojson, idAttribute) {\n idAttribute = idAttribute || 'OBJECTID';\n var spatialReference = { wkid: 4326 };\n var result = {};\n var i;\n\n switch (geojson.type) {\n case 'Point':\n result.x = geojson.coordinates[0];\n result.y = geojson.coordinates[1];\n result.spatialReference = spatialReference;\n break;\n case 'MultiPoint':\n result.points = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n case 'LineString':\n result.paths = [geojson.coordinates.slice(0)];\n result.spatialReference = spatialReference;\n break;\n case 'MultiLineString':\n result.paths = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n case 'Polygon':\n result.rings = orientRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n case 'MultiPolygon':\n result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n case 'Feature':\n if (geojson.geometry) {\n result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);\n }\n result.attributes = (geojson.properties) ? shallowClone(geojson.properties) : {};\n if (geojson.id) {\n result.attributes[idAttribute] = geojson.id;\n }\n break;\n case 'FeatureCollection':\n result = [];\n for (i = 0; i < geojson.features.length; i++) {\n result.push(geojsonToArcGIS(geojson.features[i], idAttribute));\n }\n break;\n case 'GeometryCollection':\n result = [];\n for (i = 0; i < geojson.geometries.length; i++) {\n result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute));\n }\n break;\n }\n\n return result;\n}\n\nexport default { arcgisToGeoJSON: arcgisToGeoJSON, geojsonToArcGIS: geojsonToArcGIS };\n","import { latLng, latLngBounds, LatLng, LatLngBounds, Util, DomUtil, GeoJSON } from 'leaflet';\nimport { jsonp } from './Request';\nimport { options } from './Options';\n\nimport {\n geojsonToArcGIS as g2a,\n arcgisToGeoJSON as a2g\n} from '@esri/arcgis-to-geojson-utils';\n\nexport function geojsonToArcGIS (geojson, idAttr) {\n return g2a(geojson, idAttr);\n}\n\nexport function arcgisToGeoJSON (arcgis, idAttr) {\n return a2g(arcgis, idAttr);\n}\n\n// convert an extent (ArcGIS) to LatLngBounds (Leaflet)\nexport function extentToBounds (extent) {\n // \"NaN\" coordinates from ArcGIS Server indicate a null geometry\n if (extent.xmin !== 'NaN' && extent.ymin !== 'NaN' && extent.xmax !== 'NaN' && extent.ymax !== 'NaN') {\n var sw = latLng(extent.ymin, extent.xmin);\n var ne = latLng(extent.ymax, extent.xmax);\n return latLngBounds(sw, ne);\n } else {\n return null;\n }\n}\n\n// convert an LatLngBounds (Leaflet) to extent (ArcGIS)\nexport function boundsToExtent (bounds) {\n bounds = latLngBounds(bounds);\n return {\n 'xmin': bounds.getSouthWest().lng,\n 'ymin': bounds.getSouthWest().lat,\n 'xmax': bounds.getNorthEast().lng,\n 'ymax': bounds.getNorthEast().lat,\n 'spatialReference': {\n 'wkid': 4326\n }\n };\n}\n\nvar knownFieldNames = /^(OBJECTID|FID|OID|ID)$/i;\n\n// Attempts to find the ID Field from response\nexport function _findIdAttributeFromResponse (response) {\n var result;\n\n if (response.objectIdFieldName) {\n // Find Id Field directly\n result = response.objectIdFieldName;\n } else if (response.fields) {\n // Find ID Field based on field type\n for (var j = 0; j <= response.fields.length - 1; j++) {\n if (response.fields[j].type === 'esriFieldTypeOID') {\n result = response.fields[j].name;\n break;\n }\n }\n if (!result) {\n // If no field was marked as being the esriFieldTypeOID try well known field names\n for (j = 0; j <= response.fields.length - 1; j++) {\n if (response.fields[j].name.match(knownFieldNames)) {\n result = response.fields[j].name;\n break;\n }\n }\n }\n }\n return result;\n}\n\n// This is the 'last' resort, find the Id field from the specified feature\nexport function _findIdAttributeFromFeature (feature) {\n for (var key in feature.attributes) {\n if (key.match(knownFieldNames)) {\n return key;\n }\n }\n}\n\nexport function responseToFeatureCollection (response, idAttribute) {\n var objectIdField;\n var features = response.features || response.results;\n var count = features.length;\n\n if (idAttribute) {\n objectIdField = idAttribute;\n } else {\n objectIdField = _findIdAttributeFromResponse(response);\n }\n\n var featureCollection = {\n type: 'FeatureCollection',\n features: []\n };\n\n if (count) {\n for (var i = features.length - 1; i >= 0; i--) {\n var feature = arcgisToGeoJSON(features[i], objectIdField || _findIdAttributeFromFeature(features[i]));\n featureCollection.features.push(feature);\n }\n }\n\n return featureCollection;\n}\n\n // trim url whitespace and add a trailing slash if needed\nexport function cleanUrl (url) {\n // trim leading and trailing spaces, but not spaces inside the url\n url = Util.trim(url);\n\n // add a trailing slash to the url if the user omitted it\n if (url[url.length - 1] !== '/') {\n url += '/';\n }\n\n return url;\n}\n\n/* Extract url params if any and store them in requestParams attribute.\n Return the options params updated */\nexport function getUrlParams (options) {\n if (options.url.indexOf('?') !== -1) {\n options.requestParams = options.requestParams || {};\n var queryString = options.url.substring(options.url.indexOf('?') + 1);\n options.url = options.url.split('?')[0];\n options.requestParams = JSON.parse('{\"' + decodeURI(queryString).replace(/\"/g, '\\\\\"').replace(/&/g, '\",\"').replace(/=/g, '\":\"') + '\"}');\n }\n options.url = cleanUrl(options.url.split('?')[0]);\n return options;\n}\n\nexport function isArcgisOnline (url) {\n /* hosted feature services support geojson as an output format\n utility.arcgis.com services are proxied from a variety of ArcGIS Server vintages, and may not */\n return (/^(?!.*utility\\.arcgis\\.com).*\\.arcgis\\.com.*FeatureServer/i).test(url);\n}\n\nexport function geojsonTypeToArcGIS (geoJsonType) {\n var arcgisGeometryType;\n switch (geoJsonType) {\n case 'Point':\n arcgisGeometryType = 'esriGeometryPoint';\n break;\n case 'MultiPoint':\n arcgisGeometryType = 'esriGeometryMultipoint';\n break;\n case 'LineString':\n arcgisGeometryType = 'esriGeometryPolyline';\n break;\n case 'MultiLineString':\n arcgisGeometryType = 'esriGeometryPolyline';\n break;\n case 'Polygon':\n arcgisGeometryType = 'esriGeometryPolygon';\n break;\n case 'MultiPolygon':\n arcgisGeometryType = 'esriGeometryPolygon';\n break;\n }\n\n return arcgisGeometryType;\n}\n\nexport function warn () {\n if (console && console.warn) {\n console.warn.apply(console, arguments);\n }\n}\n\nexport function calcAttributionWidth (map) {\n // either crop at 55px or user defined buffer\n return (map.getSize().x - options.attributionWidthOffset) + 'px';\n}\n\nexport function setEsriAttribution (map) {\n if (map.attributionControl && !map.attributionControl._esriAttributionAdded) {\n map.attributionControl.setPrefix('<a href=\"http://leafletjs.com\" title=\"A JS library for interactive maps\">Leaflet</a> | Powered by <a href=\"https://www.esri.com\">Esri</a>');\n\n var hoverAttributionStyle = document.createElement('style');\n hoverAttributionStyle.type = 'text/css';\n hoverAttributionStyle.innerHTML = '.esri-truncated-attribution:hover {' +\n 'white-space: normal;' +\n '}';\n\n document.getElementsByTagName('head')[0].appendChild(hoverAttributionStyle);\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution:hover');\n\n // define a new css class in JS to trim attribution into a single line\n var attributionStyle = document.createElement('style');\n attributionStyle.type = 'text/css';\n attributionStyle.innerHTML = '.esri-truncated-attribution {' +\n 'vertical-align: -3px;' +\n 'white-space: nowrap;' +\n 'overflow: hidden;' +\n 'text-overflow: ellipsis;' +\n 'display: inline-block;' +\n 'transition: 0s white-space;' +\n 'transition-delay: 1s;' +\n 'max-width: ' + calcAttributionWidth(map) + ';' +\n '}';\n\n document.getElementsByTagName('head')[0].appendChild(attributionStyle);\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution');\n\n // update the width used to truncate when the map itself is resized\n map.on('resize', function (e) {\n map.attributionControl._container.style.maxWidth = calcAttributionWidth(e.target);\n });\n\n // remove injected scripts and style tags\n map.on('unload', function () {\n hoverAttributionStyle.parentNode.removeChild(hoverAttributionStyle);\n attributionStyle.parentNode.removeChild(attributionStyle);\n var nodeList = document.querySelectorAll('.esri-leaflet-jsonp');\n for (var i = 0; i < nodeList.length; i++) {\n nodeList.item(i).parentNode.removeChild(nodeList.item(i));\n }\n });\n\n map.attributionControl._esriAttributionAdded = true;\n }\n}\n\nexport function _setGeometry (geometry) {\n var params = {\n geometry: null,\n geometryType: null\n };\n\n // convert bounds to extent and finish\n if (geometry instanceof LatLngBounds) {\n // set geometry + geometryType\n params.geometry = boundsToExtent(geometry);\n params.geometryType = 'esriGeometryEnvelope';\n return params;\n }\n\n // convert L.Marker > L.LatLng\n if (geometry.getLatLng) {\n geometry = geometry.getLatLng();\n }\n\n // convert L.LatLng to a geojson point and continue;\n if (geometry instanceof LatLng) {\n geometry = {\n type: 'Point',\n coordinates: [geometry.lng, geometry.lat]\n };\n }\n\n // handle L.GeoJSON, pull out the first geometry\n if (geometry instanceof GeoJSON) {\n // reassign geometry to the GeoJSON value (we are assuming that only one feature is present)\n geometry = geometry.getLayers()[0].feature.geometry;\n params.geometry = geojsonToArcGIS(geometry);\n params.geometryType = geojsonTypeToArcGIS(geometry.type);\n }\n\n // Handle L.Polyline and L.Polygon\n if (geometry.toGeoJSON) {\n geometry = geometry.toGeoJSON();\n }\n\n // handle GeoJSON feature by pulling out the geometry\n if (geometry.type === 'Feature') {\n // get the geometry of the geojson feature\n geometry = geometry.geometry;\n }\n\n // confirm that our GeoJSON is a point, line or polygon\n if (geometry.type === 'Point' || geometry.type === 'LineString' || geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {\n params.geometry = geojsonToArcGIS(geometry);\n params.geometryType = geojsonTypeToArcGIS(geometry.type);\n return params;\n }\n\n // warn the user if we havn't found an appropriate object\n warn('invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object');\n\n return;\n}\n\nexport function _getAttributionData (url, map) {\n jsonp(url, {}, Util.bind(function (error, attributions) {\n if (error) { return; }\n map._esriAttributions = [];\n for (var c = 0; c < attributions.contributors.length; c++) {\n var contributor = attributions.contributors[c];\n\n for (var i = 0; i < contributor.coverageAreas.length; i++) {\n var coverageArea = contributor.coverageAreas[i];\n var southWest = latLng(coverageArea.bbox[0], coverageArea.bbox[1]);\n var northEast = latLng(coverageArea.bbox[2], coverageArea.bbox[3]);\n map._esriAttributions.push({\n attribution: contributor.attribution,\n score: coverageArea.score,\n bounds: latLngBounds(southWest, northEast),\n minZoom: coverageArea.zoomMin,\n maxZoom: coverageArea.zoomMax\n });\n }\n }\n\n map._esriAttributions.sort(function (a, b) {\n return b.score - a.score;\n });\n\n // pass the same argument as the map's 'moveend' event\n var obj = { target: map };\n _updateMapAttribution(obj);\n }, this));\n}\n\nexport function _updateMapAttribution (evt) {\n var map = evt.target;\n var oldAttributions = map._esriAttributions;\n var attributionElement = map.attributionControl._container.querySelector('.esri-dynamic-attribution');\n\n if (map && map.attributionControl && attributionElement && oldAttributions) {\n var newAttributions = '';\n var bounds = map.getBounds();\n var wrappedBounds = latLngBounds(\n bounds.getSouthWest().wrap(),\n bounds.getNorthEast().wrap()\n );\n var zoom = map.getZoom();\n\n for (var i = 0; i < oldAttributions.length; i++) {\n var attribution = oldAttributions[i];\n var text = attribution.attribution;\n\n if (!newAttributions.match(text) && attribution.bounds.intersects(wrappedBounds) && zoom >= attribution.minZoom && zoom <= attribution.maxZoom) {\n newAttributions += (', ' + text);\n }\n }\n\n newAttributions = newAttributions.substr(2);\n attributionElement.innerHTML = newAttributions;\n attributionElement.style.maxWidth = calcAttributionWidth(map);\n\n map.fire('attributionupdated', {\n attribution: newAttributions\n });\n }\n}\n\nexport var EsriUtil = {\n warn: warn,\n cleanUrl: cleanUrl,\n getUrlParams: getUrlParams,\n isArcgisOnline: isArcgisOnline,\n geojsonTypeToArcGIS: geojsonTypeToArcGIS,\n responseToFeatureCollection: responseToFeatureCollection,\n geojsonToArcGIS: geojsonToArcGIS,\n arcgisToGeoJSON: arcgisToGeoJSON,\n boundsToExtent: boundsToExtent,\n extentToBounds: extentToBounds,\n calcAttributionWidth: calcAttributionWidth,\n setEsriAttribution: setEsriAttribution,\n _setGeometry: _setGeometry,\n _getAttributionData: _getAttributionData,\n _updateMapAttribution: _updateMapAttribution,\n _findIdAttributeFromFeature: _findIdAttributeFromFeature,\n _findIdAttributeFromResponse: _findIdAttributeFromResponse\n};\n\nexport default EsriUtil;\n","import { Class, Util } from 'leaflet';\nimport {cors} from '../Support';\nimport { cleanUrl, getUrlParams } from '../Util';\nimport Request from '../Request';\n\nexport var Task = Class.extend({\n\n options: {\n proxy: false,\n useCors: cors\n },\n\n // Generate a method for each methodName:paramName in the setters for this task.\n generateSetter: function (param, context) {\n return Util.bind(function (value) {\n this.params[param] = value;\n return this;\n }, context);\n },\n\n initialize: function (endpoint) {\n // endpoint can be either a url (and options) for an ArcGIS Rest Service or an instance of EsriLeaflet.Service\n if (endpoint.request && endpoint.options) {\n this._service = endpoint;\n Util.setOptions(this, endpoint.options);\n } else {\n Util.setOptions(this, endpoint);\n this.options.url = cleanUrl(endpoint.url);\n }\n\n // clone default params into this object\n this.params = Util.extend({}, this.params || {});\n\n // generate setter methods based on the setters object implimented a child class\n if (this.setters) {\n for (var setter in this.setters) {\n var param = this.setters[setter];\n this[setter] = this.generateSetter(param, this);\n }\n }\n },\n\n token: function (token) {\n if (this._service) {\n this._service.authenticate(token);\n } else {\n this.params.token = token;\n }\n return this;\n },\n\n // ArcGIS Server Find/Identify 10.5+\n format: function (boolean) {\n // use double negative to expose a more intuitive positive method name\n this.params.returnUnformattedValues = !boolean;\n return this;\n },\n\n request: function (callback, context) {\n if (this.options.requestParams) {\n Util.extend(this.params, this.options.requestParams);\n }\n if (this._service) {\n return this._service.request(this.path, this.params, callback, context);\n }\n\n return this._request('request', this.path, this.params, callback, context);\n },\n\n _request: function (method, path, params, callback, context) {\n var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\n\n if ((method === 'get' || method === 'request') && !this.options.useCors) {\n return Request.get.JSONP(url, params, callback, context);\n }\n\n return Request[method](url, params, callback, context);\n }\n});\n\nexport function task (options) {\n options = getUrlParams(options);\n return new Task(options);\n}\n\nexport default task;\n","import { point, latLng } from 'leaflet';\nimport { Task } from './Task';\nimport {\n warn,\n responseToFeatureCollection,\n isArcgisOnline,\n extentToBounds,\n _setGeometry\n} from '../Util';\n\nexport var Query = Task.extend({\n setters: {\n 'offset': 'resultOffset',\n 'limit': 'resultRecordCount',\n 'fields': 'outFields',\n 'precision': 'geometryPrecision',\n 'featureIds': 'objectIds',\n 'returnGeometry': 'returnGeometry',\n 'returnM': 'returnM',\n 'transform': 'datumTransformation',\n 'token': 'token'\n },\n\n path: 'query',\n\n params: {\n returnGeometry: true,\n where: '1=1',\n outSr: 4326,\n outFields: '*'\n },\n\n // Returns a feature if its shape is wholly contained within the search geometry. Valid for all shape type combinations.\n within: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelContains'; // to the REST api this reads geometry **contains** layer\n return this;\n },\n\n // Returns a feature if any spatial relationship is found. Applies to all shape type combinations.\n intersects: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelIntersects';\n return this;\n },\n\n // Returns a feature if its shape wholly contains the search geometry. Valid for all shape type combinations.\n contains: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelWithin'; // to the REST api this reads geometry **within** layer\n return this;\n },\n\n // Returns a feature if the intersection of the interiors of the two shapes is not empty and has a lower dimension than the maximum dimension of the two shapes. Two lines that share an endpoint in common do not cross. Valid for Line/Line, Line/Area, Multi-point/Area, and Multi-point/Line shape type combinations.\n crosses: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelCrosses';\n return this;\n },\n\n // Returns a feature if the two shapes share a common boundary. However, the intersection of the interiors of the two shapes must be empty. In the Point/Line case, the point may touch an endpoint only of the line. Applies to all combinations except Point/Point.\n touches: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelTouches';\n return this;\n },\n\n // Returns a feature if the intersection of the two shapes results in an object of the same dimension, but different from both of the shapes. Applies to Area/Area, Line/Line, and Multi-point/Multi-point shape type combinations.\n overlaps: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelOverlaps';\n return this;\n },\n\n // Returns a feature if the envelope of the two shapes intersects.\n bboxIntersects: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelEnvelopeIntersects';\n return this;\n },\n\n // if someone can help decipher the ArcObjects explanation and translate to plain speak, we should mention this method in the doc\n indexIntersects: function (geometry) {\n this._setGeometryParams(geometry);\n this.params.spatialRel = 'esriSpatialRelIndexIntersects'; // Returns a feature if the envelope of the query geometry intersects the index entry for the target geometry\n return this;\n },\n\n // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online\n nearby: function (latlng, radius) {\n latlng = latLng(latlng);\n this.params.geometry = [latlng.lng, latlng.lat];\n this.params.geometryType = 'esriGeometryPoint';\n this.params.spatialRel = 'esriSpatialRelIntersects';\n this.params.units = 'esriSRUnit_Meter';\n this.params.distance = radius;\n this.params.inSr = 4326;\n return this;\n },\n\n where: function (string) {\n // instead of converting double-quotes to single quotes, pass as is, and provide a more informative message if a 400 is encountered\n this.params.where = string;\n return this;\n },\n\n between: function (start, end) {\n this.params.time = [start.valueOf(), end.valueOf()];\n return this;\n },\n\n simplify: function (map, factor) {\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\n return this;\n },\n\n orderBy: function (fieldName, order) {\n order = order || 'ASC';\n this.params.orderByFields = (this.params.orderByFields) ? this.params.orderByFields + ',' : '';\n this.params.orderByFields += ([fieldName, order]).join(' ');\n return this;\n },\n\n run: function (callback, context) {\n this._cleanParams();\n\n // services hosted on ArcGIS Online and ArcGIS Server 10.3.1+ support requesting geojson directly\n if (this.options.isModern || isArcgisOnline(this.options.url)) {\n this.params.f = 'geojson';\n\n return this.request(function (error, response) {\n this._trapSQLerrors(error);\n callback.call(context, error, response, response);\n }, this);\n\n // otherwise convert it in the callback then pass it on\n } else {\n return this.request(function (error, response) {\n this._trapSQLerrors(error);\n callback.call(context, error, (response && responseToFeatureCollection(response)), response);\n }, this);\n }\n },\n\n count: function (callback, context) {\n this._cleanParams();\n this.params.returnCountOnly = true;\n return this.request(function (error, response) {\n callback.call(this, error, (response && response.count), response);\n }, context);\n },\n\n ids: function (callback, context) {\n this._cleanParams();\n this.params.returnIdsOnly = true;\n return this.request(function (error, response) {\n callback.call(this, error, (response && response.objectIds), response);\n }, context);\n },\n\n // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online\n bounds: function (callback, context) {\n this._cleanParams();\n this.params.returnExtentOnly = true;\n return this.request(function (error, response) {\n if (response && response.extent && extentToBounds(response.extent)) {\n callback.call(context, error, extentToBounds(response.extent), response);\n } else {\n error = {\n message: 'Invalid Bounds'\n };\n callback.call(context, error, null, response);\n }\n }, context);\n },\n\n distinct: function () {\n // geometry must be omitted for queries requesting distinct values\n this.params.returnGeometry = false;\n this.params.returnDistinctValues = true;\n return this;\n },\n\n // only valid for image services\n pixelSize: function (rawPoint) {\n var castPoint = point(rawPoint);\n this.params.pixelSize = [castPoint.x, castPoint.y];\n return this;\n },\n\n // only valid for map services\n layer: function (layer) {\n this.path = layer + '/query';\n return this;\n },\n\n _trapSQLerrors: function (error) {\n if (error) {\n if (error.code === '400') {\n warn('one common syntax error in query requests is encasing string values in double quotes instead of single quotes');\n }\n }\n },\n\n _cleanParams: function () {\n delete this.params.returnIdsOnly;\n delete this.params.returnExtentOnly;\n delete this.params.returnCountOnly;\n },\n\n _setGeometryParams: function (geometry) {\n this.params.inSr = 4326;\n var converted = _setGeometry(geometry);\n this.params.geometry = converted.geometry;\n this.params.geometryType = converted.geometryType;\n }\n\n});\n\nexport function query (options) {\n return new Query(options);\n}\n\nexport default query;\n","import { Task } from './Task';\nimport { responseToFeatureCollection } from '../Util';\n\nexport var Find = Task.extend({\n setters: {\n // method name > param name\n 'contains': 'contains',\n 'text': 'searchText',\n 'fields': 'searchFields', // denote an array or single string\n 'spatialReference': 'sr',\n 'sr': 'sr',\n 'layers': 'layers',\n 'returnGeometry': 'returnGeometry',\n 'maxAllowableOffset': 'maxAllowableOffset',\n 'precision': 'geometryPrecision',\n 'dynamicLayers': 'dynamicLayers',\n 'returnZ': 'returnZ',\n 'returnM': 'returnM',\n 'gdbVersion': 'gdbVersion',\n // skipped implementing this (for now) because the REST service implementation isnt consistent between operations\n // 'transform': 'datumTransformations',\n 'token': 'token'\n },\n\n path: 'find',\n\n params: {\n sr: 4326,\n contains: true,\n returnGeometry: true,\n returnZ: true,\n returnM: false\n },\n\n layerDefs: function (id, where) {\n this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\n this.params.layerDefs += ([id, where]).join(':');\n return this;\n },\n\n simplify: function (map, factor) {\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\n return this;\n },\n\n run: function (callback, context) {\n return this.request(function (error, response) {\n callback.call(context, error, (response && responseToFeatureCollection(response)), response);\n }, context);\n }\n});\n\nexport function find (options) {\n return new Find(options);\n}\n\nexport default find;\n","import { Task } from './Task';\n\nexport var Identify = Task.extend({\n path: 'identify',\n\n between: function (start, end) {\n this.params.time = [start.valueOf(), end.valueOf()];\n return this;\n }\n});\n\nexport function identify (options) {\n return new Identify(options);\n}\n\nexport default identify;\n","import { latLng } from 'leaflet';\nimport { Identify } from './Identify';\nimport { responseToFeatureCollection,\n boundsToExtent,\n _setGeometry\n} from '../Util';\n\nexport var IdentifyFeatures = Identify.extend({\n setters: {\n 'layers': 'layers',\n 'precision': 'geometryPrecision',\n 'tolerance': 'tolerance',\n // skipped implementing this (for now) because the REST service implementation isnt consistent between operations.\n // 'transform': 'datumTransformations'\n 'returnGeometry': 'returnGeometry'\n },\n\n params: {\n sr: 4326,\n layers: 'all',\n tolerance: 3,\n returnGeometry: true\n },\n\n on: function (map) {\n var extent = boundsToExtent(map.getBounds());\n var size = map.getSize();\n this.params.imageDisplay = [size.x, size.y, 96];\n this.params.mapExtent = [extent.xmin, extent.ymin, extent.xmax, extent.ymax];\n return this;\n },\n\n at: function (geometry) {\n // cast lat, long pairs in raw array form manually\n if (geometry.length === 2) {\n geometry = latLng(geometry);\n }\n this._setGeometryParams(geometry);\n return this;\n },\n\n layerDef: function (id, where) {\n this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\n this.params.layerDefs += ([id, where]).join(':');\n return this;\n },\n\n simplify: function (map, factor) {\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\n return this;\n },\n\n run: function (callback, context) {\n return this.request(function (error, response) {\n // immediately invoke with an error\n if (error) {\n callback.call(context, error, undefined, response);\n return;\n\n // ok no error lets just assume we have features...\n } else {\n var featureCollection = responseToFeatureCollection(response);\n response.results = response.results.reverse();\n for (var i = 0; i < featureCollection.features.length; i++) {\n var feature = featureCollection.features[i];\n feature.layerId = response.results[i].layerId;\n }\n callback.call(context, undefined, featureCollection, response);\n }\n });\n },\n\n _setGeometryParams: function (geometry) {\n var converted = _setGeometry(geometry);\n this.params.geometry = converted.geometry;\n this.params.geometryType = converted.geometryType;\n }\n});\n\nexport function identifyFeatures (options) {\n return new IdentifyFeatures(options);\n}\n\nexport default identifyFeatures;\n","import { latLng } from 'leaflet';\nimport { Identify } from './Identify';\nimport { responseToFeatureCollection } from '../Util';\n\nexport var IdentifyImage = Identify.extend({\n setters: {\n 'setMosaicRule': 'mosaicRule',\n 'setRenderingRule': 'renderingRule',\n 'setPixelSize': 'pixelSize',\n 'returnCatalogItems': 'returnCatalogItems',\n 'returnGeometry': 'returnGeometry'\n },\n\n params: {\n returnGeometry: false\n },\n\n at: function (latlng) {\n latlng = latLng(latlng);\n this.params.geometry = JSON.stringify({\n x: latlng.lng,\n y: latlng.lat,\n spatialReference: {\n wkid: 4326\n }\n });\n this.params.geometryType = 'esriGeometryPoint';\n return this;\n },\n\n getMosaicRule: function () {\n return this.params.mosaicRule;\n },\n\n getRenderingRule: function () {\n return this.params.renderingRule;\n },\n\n getPixelSize: function () {\n return this.params.pixelSize;\n },\n\n run: function (callback, context) {\n return this.request(function (error, response) {\n callback.call(context, error, (response && this._responseToGeoJSON(response)), response);\n }, this);\n },\n\n // get pixel data and return as geoJSON point\n // populate catalog items (if any)\n // merging in any catalogItemVisibilities as a propery of each feature\n _responseToGeoJSON: function (response) {\n var location = response.location;\n var catalogItems = response.catalogItems;\n var catalogItemVisibilities = response.catalogItemVisibilities;\n var geoJSON = {\n 'pixel': {\n 'type': 'Feature',\n 'geometry': {\n 'type': 'Point',\n 'coordinates': [location.x, location.y]\n },\n 'crs': {\n 'type': 'EPSG',\n 'properties': {\n 'code': location.spatialReference.wkid\n }\n },\n 'properties': {\n 'OBJECTID': response.objectId,\n 'name': response.name,\n 'value': response.value\n },\n 'id': response.objectId\n }\n };\n\n if (response.properties && response.properties.Values) {\n geoJSON.pixel.properties.values = response.properties.Values;\n }\n\n if (catalogItems && catalogItems.features) {\n geoJSON.catalogItems = responseToFeatureCollection(catalogItems);\n if (catalogItemVisibilities && catalogItemVisibilities.length === geoJSON.catalogItems.features.length) {\n for (var i = catalogItemVisibilities.length - 1; i >= 0; i--) {\n geoJSON.catalogItems.features[i].properties.catalogItemVisibility = catalogItemVisibilities[i];\n }\n }\n }\n return geoJSON;\n }\n\n});\n\nexport function identifyImage (params) {\n return new IdentifyImage(params);\n}\n\nexport default identifyImage;\n","import { Util, Evented } from 'leaflet';\nimport {cors} from '../Support';\nimport {cleanUrl, getUrlParams} from '../Util';\nimport Request from '../Request';\n\nexport var Service = Evented.extend({\n\n options: {\n proxy: false,\n useCors: cors,\n timeout: 0\n },\n\n initialize: function (options) {\n options = options || {};\n this._requestQueue = [];\n this._authenticating = false;\n Util.setOptions(this, options);\n this.options.url = cleanUrl(this.options.url);\n },\n\n get: function (path, params, callback, context) {\n return this._request('get', path, params, callback, context);\n },\n\n post: function (path, params, callback, context) {\n return this._request('post', path, params, callback, context);\n },\n\n request: function (path, params, callback, context) {\n return this._request('request', path, params, callback, context);\n },\n\n metadata: function (callback, context) {\n return this._request('get', '', {}, callback, context);\n },\n\n authenticate: function (token) {\n this._authenticating = false;\n this.options.token = token;\n this._runQueue();\n return this;\n },\n\n getTimeout: function () {\n return this.options.timeout;\n },\n\n setTimeout: function (timeout) {\n this.options.timeout = timeout;\n },\n\n _request: function (method, path, params, callback, context) {\n this.fire('requeststart', {\n url: this.options.url + path,\n params: params,\n method: method\n }, true);\n\n var wrappedCallback = this._createServiceCallback(method, path, params, callback, context);\n\n if (this.options.token) {\n params.token = this.options.token;\n }\n if (this.options.requestParams) {\n Util.extend(params, this.options.requestParams);\n }\n if (this._authenticating) {\n this._requestQueue.push([method, path, params, callback, context]);\n return;\n } else {\n var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\n\n if ((method === 'get' || method === 'request') && !this.options.useCors) {\n return Request.get.JSONP(url, params, wrappedCallback, context);\n } else {\n return Request[method](url, params, wrappedCallback, context);\n }\n }\n },\n\n _createServiceCallback: function (method, path, params, callback, context) {\n return Util.bind(function (error, response) {\n if (error && (error.code === 499 || error.code === 498)) {\n this._authenticating = true;\n\n this._requestQueue.push([method, path, params, callback, context]);\n\n // fire an event for users to handle and re-authenticate\n this.fire('authenticationrequired', {\n authenticate: Util.bind(this.authenticate, this)\n }, true);\n\n // if the user has access to a callback they can handle the auth error\n error.authenticate = Util.bind(this.authenticate, this);\n }\n\n callback.call(context, error, response);\n\n if (error) {\n this.fire('requesterror', {\n url: this.options.url + path,\n params: params,\n message: error.message,\n code: error.code,\n method: method\n }, true);\n } else {\n this.fire('requestsuccess', {\n url: this.options.url + path,\n params: params,\n response: response,\n method: method\n }, true);\n }\n\n this.fire('requestend', {\n url: this.options.url + path,\n params: params,\n method: method\n }, true);\n }, this);\n },\n\n _runQueue: function () {\n for (var i = this._requestQueue.length - 1; i >= 0; i--) {\n var request = this._requestQueue[i];\n var method = request.shift();\n this[method].apply(this, request);\n }\n this._requestQueue = [];\n }\n});\n\nexport function service (options) {\n options = getUrlParams(options);\n return new Service(options);\n}\n\nexport default service;\n","import { Service } from './Service';\nimport identifyFeatures from '../Tasks/IdentifyFeatures';\nimport query from '../Tasks/Query';\nimport find from '../Tasks/Find';\n\nexport var MapService = Service.extend({\n\n identify: function () {\n return identifyFeatures(this);\n },\n\n find: function () {\n return find(this);\n },\n\n query: function () {\n return query(this);\n }\n\n});\n\nexport function mapService (options) {\n return new MapService(options);\n}\n\nexport default mapService;\n","import { Service } from './Service';\nimport identifyImage from '../Tasks/IdentifyImage';\nimport query from '../Tasks/Query';\n\nexport var ImageService = Service.extend({\n\n query: function () {\n return query(this);\n },\n\n identify: function () {\n return identifyImage(this);\n }\n});\n\nexport function imageService (options) {\n return new ImageService(options);\n}\n\nexport default imageService;\n","import { Service } from './Service';\nimport query from '../Tasks/Query';\nimport { geojsonToArcGIS } from '../Util';\n\nexport var FeatureLayerService = Service.extend({\n\n options: {\n idAttribute: 'OBJECTID'\n },\n\n query: function () {\n return query(this);\n },\n\n addFeature: function (feature, callback, context) {\n this.addFeatures(feature, callback, context);\n },\n\n addFeatures: function (features, callback, context) {\n var featuresArray = features.features ? features.features : [features];\n for (var i = featuresArray.length - 1; i >= 0; i--) {\n delete featuresArray[i].id;\n }\n features = geojsonToArcGIS(features);\n features = featuresArray.length > 1 ? features : [features];\n return this.post('addFeatures', {\n features: features\n }, function (error, response) {\n // For compatibility reason with former addFeature function,\n // we return the object in the array and not the array itself\n var result = (response && response.addResults) ? response.addResults.length > 1 ? response.addResults : response.addResults[0] : undefined;\n if (callback) {\n callback.call(context, error || response.addResults[0].error, result);\n }\n }, context);\n },\n\n updateFeature: function (feature, callback, context) {\n this.updateFeatures(feature, callback, context);\n },\n\n updateFeatures: function (features, callback, context) {\n var featuresArray = features.features ? features.features : [features];\n features = geojsonToArcGIS(features, this.options.idAttribute);\n features = featuresArray.length > 1 ? features : [features];\n\n return this.post('updateFeatures', {\n features: features\n }, function (error, response) {\n // For compatibility reason with former updateFeature function,\n // we return the object in the array and not the array itself\n var result = (response && response.updateResults) ? response.updateResults.length > 1 ? response.updateResults : response.updateResults[0] : undefined;\n if (callback) {\n callback.call(context, error || response.updateResults[0].error, result);\n }\n }, context);\n },\n\n deleteFeature: function (id, callback, context) {\n this.deleteFeatures(id, callback, context);\n },\n\n deleteFeatures: function (ids, callback, context) {\n return this.post('deleteFeatures', {\n objectIds: ids\n }, function (error, response) {\n // For compatibility reason with former deleteFeature function,\n // we return the object in the array and not the array itself\n var result = (response && response.deleteResults) ? response.deleteResults.length > 1 ? response.deleteResults : response.deleteResults[0] : undefined;\n if (callback) {\n callback.call(context, error || response.deleteResults[0].error, result);\n }\n }, context);\n }\n});\n\nexport function featureLayerService (options) {\n return new FeatureLayerService(options);\n}\n\nexport default featureLayerService;\n","import { TileLayer, Util } from 'leaflet';\nimport { pointerEvents } from '../Support';\nimport {\n setEsriAttribution,\n _getAttributionData,\n _updateMapAttribution\n} from '../Util';\n\nvar tileProtocol = (window.location.protocol !== 'https:') ? 'http:' : 'https:';\n\nexport var BasemapLayer = TileLayer.extend({\n statics: {\n TILES: {\n Streets: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 19,\n subdomains: ['server', 'services'],\n attribution: 'USGS, NOAA',\n attributionUrl: 'https://static.arcgis.com/attribution/World_Street_Map'\n }\n },\n Topographic: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 19,\n subdomains: ['server', 'services'],\n attribution: 'USGS, NOAA',\n attributionUrl: 'https://static.arcgis.com/attribution/World_Topo_Map'\n }\n },\n Oceans: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 16,\n subdomains: ['server', 'services'],\n attribution: 'USGS, NOAA',\n attributionUrl: 'https://static.arcgis.com/attribution/Ocean_Basemap'\n }\n },\n OceansLabels: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 16,\n subdomains: ['server', 'services'],\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\n attribution: ''\n }\n },\n NationalGeographic: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 16,\n subdomains: ['server', 'services'],\n attribution: 'National Geographic, DeLorme, HERE, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, increment P Corp.'\n }\n },\n DarkGray: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 16,\n subdomains: ['server', 'services'],\n attribution: 'HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors'\n }\n },\n DarkGrayLabels: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 16,\n subdomains: ['server', 'services'],\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\n attribution: ''\n\n }\n },\n Gray: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 16,\n subdomains: ['server', 'services'],\n attribution: 'HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors'\n }\n },\n GrayLabels: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 16,\n subdomains: ['server', 'services'],\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\n attribution: ''\n }\n },\n Imagery: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 19,\n subdomains: ['server', 'services'],\n attribution: 'DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community',\n attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery'\n }\n },\n ImageryLabels: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 19,\n subdomains: ['server', 'services'],\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\n attribution: ''\n }\n },\n ImageryTransportation: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 19,\n subdomains: ['server', 'services'],\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\n attribution: ''\n }\n },\n ShadedRelief: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 13,\n subdomains: ['server', 'services'],\n attribution: 'USGS'\n }\n },\n ShadedReliefLabels: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 12,\n subdomains: ['server', 'services'],\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\n attribution: ''\n }\n },\n Terrain: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 13,\n subdomains: ['server', 'services'],\n attribution: 'USGS, NOAA'\n }\n },\n TerrainLabels: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 13,\n subdomains: ['server', 'services'],\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\n attribution: ''\n }\n },\n USATopo: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 15,\n subdomains: ['server', 'services'],\n attribution: 'USGS, National Geographic Society, i-cubed'\n }\n },\n ImageryClarity: {\n urlTemplate: tileProtocol + '//clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 19,\n attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community'\n }\n },\n Physical: {\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 8,\n subdomains: ['server', 'services'],\n attribution: 'U.S. National Park Service'\n }\n },\n ImageryFirefly: {\n urlTemplate: tileProtocol + '//fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{z}/{y}/{x}',\n options: {\n minZoom: 1,\n maxZoom: 19,\n attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community',\n attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery'\n }\n }\n }\n },\n\n initialize: function (key, options) {\n var config;\n\n // set the config variable with the appropriate config object\n if (typeof key === 'object' && key.urlTemplate && key.options) {\n config = key;\n } else if (typeof key === 'string' && BasemapLayer.TILES[key]) {\n config = BasemapLayer.TILES[key];\n } else {\n throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of \"Streets\", \"Topographic\", \"Oceans\", \"OceansLabels\", \"NationalGeographic\", \"Physical\", \"Gray\", \"GrayLabels\", \"DarkGray\", \"DarkGrayLabels\", \"Imagery\", \"ImageryLabels\", \"ImageryTransportation\", \"ImageryClarity\", \"ImageryFirefly\", ShadedRelief\", \"ShadedReliefLabels\", \"Terrain\", \"TerrainLabels\" or \"USATopo\"');\n }\n\n // merge passed options into the config options\n var tileOptions = Util.extend(config.options, options);\n\n Util.setOptions(this, tileOptions);\n\n if (this.options.token && config.urlTemplate.indexOf('token=') === -1) {\n config.urlTemplate += ('?token=' + this.options.token);\n }\n\n // call the initialize method on L.TileLayer to set everything up\n TileLayer.prototype.initialize.call(this, config.urlTemplate, tileOptions);\n },\n\n onAdd: function (map) {\n // include 'Powered by Esri' in map attribution\n setEsriAttribution(map);\n\n if (this.options.pane === 'esri-labels') {\n this._initPane();\n }\n // some basemaps can supply dynamic attribution\n if (this.options.attributionUrl) {\n _getAttributionData(this.options.attributionUrl, map);\n }\n\n map.on('moveend', _updateMapAttribution);\n\n TileLayer.prototype.onAdd.call(this, map);\n },\n\n onRemove: function (map) {\n map.off('moveend', _updateMapAttribution);\n TileLayer.prototype.onRemove.call(this, map);\n },\n\n _initPane: function () {\n if (!this._map.getPane(this.options.pane)) {\n var pane = this._map.createPane(this.options.pane);\n pane.style.pointerEvents = 'none';\n pane.style.zIndex = 500;\n }\n },\n\n getAttribution: function () {\n if (this.options.attribution) {\n var attribution = '<span class=\"esri-dynamic-attribution\">' + this.options.attribution + '</span>';\n }\n return attribution;\n }\n});\n\nexport function basemapLayer (key, options) {\n return new BasemapLayer(key, options);\n}\n\nexport default basemapLayer;\n","import { CRS, DomEvent, TileLayer, Util } from 'leaflet';\nimport { warn, getUrlParams, setEsriAttribution } from '../Util';\nimport mapService from '../Services/MapService';\n\nexport var TiledMapLayer = TileLayer.extend({\n options: {\n zoomOffsetAllowance: 0.1,\n errorTileUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEABAMAAACuXLVVAAAAA1BMVEUzNDVszlHHAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAAAAAAAAAB6mUWpAAAADZJREFUeJztwQEBAAAAgiD/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7waBAAABw08RwAAAAABJRU5ErkJggg=='\n },\n\n statics: {\n MercatorZoomLevels: {\n '0': 156543.03392799999,\n '1': 78271.516963999893,\n '2': 39135.758482000099,\n '3': 19567.879240999901,\n '4': 9783.9396204999593,\n '5': 4891.9698102499797,\n '6': 2445.9849051249898,\n '7': 1222.9924525624899,\n '8': 611.49622628138002,\n '9': 305.74811314055802,\n '10': 152.874056570411,\n '11': 76.437028285073197,\n '12': 38.218514142536598,\n '13': 19.109257071268299,\n '14': 9.5546285356341496,\n '15': 4.7773142679493699,\n '16': 2.38865713397468,\n '17': 1.1943285668550501,\n '18': 0.59716428355981699,\n '19': 0.29858214164761698,\n '20': 0.14929107082381,\n '21': 0.07464553541191,\n '22': 0.0373227677059525,\n '23': 0.0186613838529763\n }\n },\n\n initialize: function (options) {\n options = Util.setOptions(this, options);\n\n // set the urls\n options = getUrlParams(options);\n this.tileUrl = (options.proxy ? options.proxy + '?' : '') + options.url + 'tile/{z}/{y}/{x}' + (options.requestParams && Object.keys(options.requestParams).length > 0 ? Util.getParamString(options.requestParams) : '');\n // Remove subdomain in url\n // https://github.com/Esri/esri-leaflet/issues/991\n if (options.url.indexOf('{s}') !== -1 && options.subdomains) {\n options.url = options.url.replace('{s}', options.subdomains[0]);\n }\n this.service = mapService(options);\n this.service.addEventParent(this);\n\n var arcgisonline = new RegExp(/tiles.arcgis(online)?\\.com/g);\n if (arcgisonline.test(options.url)) {\n this.tileUrl = this.tileUrl.replace('://tiles', '://tiles{s}');\n options.subdomains = ['1', '2', '3', '4'];\n }\n\n if (this.options.token) {\n this.tileUrl += ('?token=' + this.options.token);\n }\n\n // init layer by calling TileLayers initialize method\n TileLayer.prototype.initialize.call(this, this.tileUrl, options);\n },\n\n getTileUrl: function (tilePoint) {\n var zoom = this._getZoomForUrl();\n\n return Util.template(this.tileUrl, Util.extend({\n s: this._getSubdomain(tilePoint),\n x: tilePoint.x,\n y: tilePoint.y,\n // try lod map first, then just default to zoom level\n z: (this._lodMap && this._lodMap[zoom]) ? this._lodMap[zoom] : zoom\n }, this.options));\n },\n\n createTile: function (coords, done) {\n var tile = document.createElement('img');\n\n DomEvent.on(tile, 'load', Util.bind(this._tileOnLoad, this, done, tile));\n DomEvent.on(tile, 'error', Util.bind(this._tileOnError, this, done, tile));\n\n if (this.options.crossOrigin) {\n tile.crossOrigin = '';\n }\n\n /*\n Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons\n http://www.w3.org/TR/WCAG20-TECHS/H67\n */\n tile.alt = '';\n\n // if there is no lod map or an lod map with a proper zoom load the tile\n // otherwise wait for the lod map to become available\n if (!this._lodMap || (this._lodMap && this._lodMap[this._getZoomForUrl()])) {\n tile.src = this.getTileUrl(coords);\n } else {\n this.once('lodmap', function () {\n tile.src = this.getTileUrl(coords);\n }, this);\n }\n\n return tile;\n },\n\n onAdd: function (map) {\n // include 'Powered by Esri' in map attribution\n setEsriAttribution(map);\n\n if (!this._lodMap) {\n this.metadata(function (error, metadata) {\n if (!error && metadata.spatialReference) {\n var sr = metadata.spatialReference.latestWkid || metadata.spatialReference.wkid;\n // display the copyright text from the service using leaflet's attribution control\n if (!this.options.attribution && map.attributionControl && metadata.copyrightText) {\n this.options.attribution = metadata.copyrightText;\n map.attributionControl.addAttribution(this.getAttribution());\n }\n\n // if the service tiles were published in web mercator using conventional LODs but missing levels, we can try and remap them\n if (map.options.crs === CRS.EPSG3857 && (sr === 102100 || sr === 3857)) {\n this._lodMap = {};\n // create the zoom level data\n var arcgisLODs = metadata.tileInfo.lods;\n var correctResolutions = TiledMapLayer.MercatorZoomLevels;\n\n for (var i = 0; i < arcgisLODs.length; i++) {\n var arcgisLOD = arcgisLODs[i];\n for (var ci in correctResolutions) {\n var correctRes = correctResolutions[ci];\n\n if (this._withinPercentage(arcgisLOD.resolution, correctRes, this.options.zoomOffsetAllowance)) {\n this._lodMap[ci] = arcgisLOD.level;\n break;\n }\n }\n }\n\n this.fire('lodmap');\n } else if (map.options.crs && map.options.crs.code && (map.options.crs.code.indexOf(sr) > -1)) {\n // if the projection is WGS84, or the developer is using Proj4 to define a custom CRS, no action is required\n } else {\n // if the service was cached in a custom projection and an appropriate LOD hasn't been defined in the map, guide the developer to our Proj4 sample\n warn('L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html');\n }\n }\n }, this);\n }\n\n TileLayer.prototype.onAdd.call(this, map);\n },\n\n metadata: function (callback, context) {\n this.service.metadata(callback, context);\n return this;\n },\n\n identify: function () {\n return this.service.identify();\n },\n\n find: function () {\n return this.service.find();\n },\n\n query: function () {\n return this.service.query();\n },\n\n authenticate: function (token) {\n var tokenQs = '?token=' + token;\n this.tileUrl = (this.options.token) ? this.tileUrl.replace(/\\?token=(.+)/g, tokenQs) : this.tileUrl + tokenQs;\n this.options.token = token;\n this.service.authenticate(token);\n return this;\n },\n\n _withinPercentage: function (a, b, percentage) {\n var diff = Math.abs((a / b) - 1);\n return diff < percentage;\n }\n});\n\nexport function tiledMapLayer (url, options) {\n return new TiledMapLayer(url, options);\n}\n\nexport default tiledMapLayer;\n","import { ImageOverlay, CRS, DomUtil, Util, Layer, popup, latLng, bounds } from 'leaflet';\nimport { cors } from '../Support';\nimport { setEsriAttribution } from '../Util';\n\nvar Overlay = ImageOverlay.extend({\n onAdd: function (map) {\n this._topLeft = map.getPixelBounds().min;\n ImageOverlay.prototype.onAdd.call(this, map);\n },\n _reset: function () {\n if (this._map.options.crs === CRS.EPSG3857) {\n ImageOverlay.prototype._reset.call(this);\n } else {\n DomUtil.setPosition(this._image, this._topLeft.subtract(this._map.getPixelOrigin()));\n }\n }\n});\n\nexport var RasterLayer = Layer.extend({\n options: {\n opacity: 1,\n position: 'front',\n f: 'image',\n useCors: cors,\n attribution: null,\n interactive: false,\n alt: ''\n },\n\n onAdd: function (map) {\n // include 'Powered by Esri' in map attribution\n setEsriAttribution(map);\n\n this._update = Util.throttle(this._update, this.options.updateInterval, this);\n\n map.on('moveend', this._update, this);\n\n // if we had an image loaded and it matches the\n // current bounds show the image otherwise remove it\n if (this._currentImage && this._currentImage._bounds.equals(this._map.getBounds())) {\n map.addLayer(this._currentImage);\n } else if (this._currentImage) {\n this._map.removeLayer(this._currentImage);\n this._currentImage = null;\n }\n\n this._update();\n\n if (this._popup) {\n this._map.on('click', this._getPopupData, this);\n this._map.on('dblclick', this._resetPopupState, this);\n }\n\n // add copyright text listed in service metadata\n this.metadata(function (err, metadata) {\n if (!err && !this.options.attribution && map.attributionControl && metadata.copyrightText) {\n this.options.attribution = metadata.copyrightText;\n map.attributionControl.addAttribution(this.getAttribution());\n }\n }, this);\n },\n\n onRemove: function (map) {\n if (this._currentImage) {\n this._map.removeLayer(this._currentImage);\n }\n\n if (this._popup) {\n this._map.off('click', this._getPopupData, this);\n this._map.off('dblclick', this._resetPopupState, this);\n }\n\n this._map.off('moveend', this._update, this);\n },\n\n bindPopup: function (fn, popupOptions) {\n this._shouldRenderPopup = false;\n this._lastClick = false;\n this._popup = popup(popupOptions);\n this._popupFunction = fn;\n if (this._map) {\n this._map.on('click', this._getPopupData, this);\n this._map.on('dblclick', this._resetPopupState, this);\n }\n return this;\n },\n\n unbindPopup: function () {\n if (this._map) {\n this._map.closePopup(this._popup);\n this._map.off('click', this._getPopupData, this);\n this._map.off('dblclick', this._resetPopupState, this);\n }\n this._popup = false;\n return this;\n },\n\n bringToFront: function () {\n this.options.position = 'front';\n if (this._currentImage) {\n this._currentImage.bringToFront();\n }\n return this;\n },\n\n bringToBack: function () {\n this.options.position = 'back';\n if (this._currentImage) {\n this._currentImage.bringToBack();\n }\n return this;\n },\n\n getAttribution: function () {\n return this.options.attribution;\n },\n\n getOpacity: function () {\n return this.options.opacity;\n },\n\n setOpacity: function (opacity) {\n this.options.opacity = opacity;\n if (this._currentImage) {\n this._currentImage.setOpacity(opacity);\n }\n return this;\n },\n\n getTimeRange: function () {\n return [this.options.from, this.options.to];\n },\n\n setTimeRange: function (from, to) {\n this.options.from = from;\n this.options.to = to;\n this._update();\n return this;\n },\n\n metadata: function (callback, context) {\n this.service.metadata(callback, context);\n return this;\n },\n\n authenticate: function (token) {\n this.service.authenticate(token);\n return this;\n },\n\n redraw: function () {\n this._update();\n },\n\n _renderImage: function (url, bounds, contentType) {\n if (this._map) {\n // if no output directory has been specified for a service, MIME data will be returned\n if (contentType) {\n url = 'data:' + contentType + ';base64,' + url;\n }\n\n // if server returns an inappropriate response, abort.\n if (!url) return;\n\n // create a new image overlay and add it to the map\n // to start loading the image\n // opacity is 0 while the image is loading\n var image = new Overlay(url, bounds, {\n opacity: 0,\n crossOrigin: this.options.useCors,\n alt: this.options.alt,\n pane: this.options.pane || this.getPane(),\n interactive: this.options.interactive\n }).addTo(this._map);\n\n var onOverlayError = function () {\n this._map.removeLayer(image);\n this.fire('error');\n image.off('load', onOverlayLoad, this);\n };\n\n var onOverlayLoad = function (e) {\n image.off('error', onOverlayLoad, this);\n if (this._map) {\n var newImage = e.target;\n var oldImage = this._currentImage;\n\n // if the bounds of this image matches the bounds that\n // _renderImage was called with and we have a map with the same bounds\n // hide the old image if there is one and set the opacity\n // of the new image otherwise remove the new image\n if (newImage._bounds.equals(bounds) && newImage._bounds.equals(this._map.getBounds())) {\n this._currentImage = newImage;\n\n if (this.options.position === 'front') {\n this.bringToFront();\n } else {\n this.bringToBack();\n }\n\n if (this._map && this._currentImage._map) {\n this._currentImage.setOpacity(this.options.opacity);\n } else {\n this._currentImage._map.removeLayer(this._currentImage);\n }\n\n if (oldImage && this._map) {\n this._map.removeLayer(oldImage);\n }\n\n if (oldImage && oldImage._map) {\n oldImage._map.removeLayer(oldImage);\n }\n } else {\n this._map.removeLayer(newImage);\n }\n }\n\n this.fire('load', {\n bounds: bounds\n });\n };\n\n // If loading the image fails\n image.once('error', onOverlayError, this);\n\n // once the image loads\n image.once('load', onOverlayLoad, this);\n\n this.fire('loading', {\n bounds: bounds\n });\n }\n },\n\n _update: function () {\n if (!this._map) {\n return;\n }\n\n var zoom = this._map.getZoom();\n var bounds = this._map.getBounds();\n\n if (this._animatingZoom) {\n return;\n }\n\n if (this._map._panTransition && this._map._panTransition._inProgress) {\n return;\n }\n\n if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\n if (this._currentImage) {\n this._currentImage._map.removeLayer(this._currentImage);\n this._currentImage = null;\n }\n return;\n }\n\n var params = this._buildExportParams();\n Util.extend(params, this.options.requestParams);\n\n if (params) {\n this._requestExport(params, bounds);\n } else if (this._currentImage) {\n this._currentImage._map.removeLayer(this._currentImage);\n this._currentImage = null;\n }\n },\n\n _renderPopup: function (latlng, error, results, response) {\n latlng = latLng(latlng);\n if (this._shouldRenderPopup && this._lastClick.equals(latlng)) {\n // add the popup to the map where the mouse was clicked at\n var content = this._popupFunction(error, results, response);\n if (content) {\n this._popup.setLatLng(latlng).setContent(content).openOn(this._map);\n }\n }\n },\n\n _resetPopupState: function (e) {\n this._shouldRenderPopup = false;\n this._lastClick = e.latlng;\n },\n\n _calculateBbox: function () {\n var pixelBounds = this._map.getPixelBounds();\n\n var sw = this._map.unproject(pixelBounds.getBottomLeft());\n var ne = this._map.unproject(pixelBounds.getTopRight());\n\n var neProjected = this._map.options.crs.project(ne);\n var swProjected = this._map.options.crs.project(sw);\n\n // this ensures ne/sw are switched in polar maps where north/top bottom/south is inverted\n var boundsProjected = bounds(neProjected, swProjected);\n\n return [boundsProjected.getBottomLeft().x, boundsProjected.getBottomLeft().y, boundsProjected.getTopRight().x, boundsProjected.getTopRight().y].join(',');\n },\n\n _calculateImageSize: function () {\n // ensure that we don't ask ArcGIS Server for a taller image than we have actual map displaying within the div\n var bounds = this._map.getPixelBounds();\n var size = this._map.getSize();\n\n var sw = this._map.unproject(bounds.getBottomLeft());\n var ne = this._map.unproject(bounds.getTopRight());\n\n var top = this._map.latLngToLayerPoint(ne).y;\n var bottom = this._map.latLngToLayerPoint(sw).y;\n\n if (top > 0 || bottom < size.y) {\n size.y = bottom - top;\n }\n\n return size.x + ',' + size.y;\n }\n});\n","import { Util } from 'leaflet';\nimport { RasterLayer } from './RasterLayer';\nimport { getUrlParams } from '../Util';\nimport imageService from '../Services/ImageService';\n\nexport var ImageMapLayer = RasterLayer.extend({\n\n options: {\n updateInterval: 150,\n format: 'jpgpng',\n transparent: true,\n f: 'image'\n },\n\n query: function () {\n return this.service.query();\n },\n\n identify: function () {\n return this.service.identify();\n },\n\n initialize: function (options) {\n options = getUrlParams(options);\n this.service = imageService(options);\n this.service.addEventParent(this);\n\n Util.setOptions(this, options);\n },\n\n setPixelType: function (pixelType) {\n this.options.pixelType = pixelType;\n this._update();\n return this;\n },\n\n getPixelType: function () {\n return this.options.pixelType;\n },\n\n setBandIds: function (bandIds) {\n if (Util.isArray(bandIds)) {\n this.options.bandIds = bandIds.join(',');\n } else {\n this.options.bandIds = bandIds.toString();\n }\n this._update();\n return this;\n },\n\n getBandIds: function () {\n return this.options.bandIds;\n },\n\n setNoData: function (noData, noDataInterpretation) {\n if (Util.isArray(noData)) {\n this.options.noData = noData.join(',');\n } else {\n this.options.noData = noData.toString();\n }\n if (noDataInterpretation) {\n this.options.noDataInterpretation = noDataInterpretation;\n }\n this._update();\n return this;\n },\n\n getNoData: function () {\n return this.options.noData;\n },\n\n getNoDataInterpretation: function () {\n return this.options.noDataInterpretation;\n },\n\n setRenderingRule: function (renderingRule) {\n this.options.renderingRule = renderingRule;\n this._update();\n },\n\n getRenderingRule: function () {\n return this.options.renderingRule;\n },\n\n setMosaicRule: function (mosaicRule) {\n this.options.mosaicRule = mosaicRule;\n this._update();\n },\n\n getMosaicRule: function () {\n return this.options.mosaicRule;\n },\n\n _getPopupData: function (e) {\n var callback = Util.bind(function (error, results, response) {\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\n setTimeout(Util.bind(function () {\n this._renderPopup(e.latlng, error, results, response);\n }, this), 300);\n }, this);\n\n var identifyRequest = this.identify().at(e.latlng);\n\n // set mosaic rule for identify task if it is set for layer\n if (this.options.mosaicRule) {\n identifyRequest.setMosaicRule(this.options.mosaicRule);\n // @TODO: force return catalog items too?\n }\n\n // @TODO: set rendering rule? Not sure,\n // sometimes you want raw pixel values\n // if (this.options.renderingRule) {\n // identifyRequest.setRenderingRule(this.options.renderingRule);\n // }\n\n identifyRequest.run(callback);\n\n // set the flags to show the popup\n this._shouldRenderPopup = true;\n this._lastClick = e.latlng;\n },\n\n _buildExportParams: function () {\n var sr = parseInt(this._map.options.crs.code.split(':')[1], 10);\n\n var params = {\n bbox: this._calculateBbox(),\n size: this._calculateImageSize(),\n format: this.options.format,\n transparent: this.options.transparent,\n bboxSR: sr,\n imageSR: sr\n };\n\n if (this.options.from && this.options.to) {\n params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\n }\n\n if (this.options.pixelType) {\n params.pixelType = this.options.pixelType;\n }\n\n if (this.options.interpolation) {\n params.interpolation = this.options.interpolation;\n }\n\n if (this.options.compressionQuality) {\n params.compressionQuality = this.options.compressionQuality;\n }\n\n if (this.options.bandIds) {\n params.bandIds = this.options.bandIds;\n }\n\n // 0 is falsy *and* a valid input parameter\n if (this.options.noData === 0 || this.options.noData) {\n params.noData = this.options.noData;\n }\n\n if (this.options.noDataInterpretation) {\n params.noDataInterpretation = this.options.noDataInterpretation;\n }\n\n if (this.service.options.token) {\n params.token = this.service.options.token;\n }\n\n if (this.options.renderingRule) {\n params.renderingRule = JSON.stringify(this.options.renderingRule);\n }\n\n if (this.options.mosaicRule) {\n params.mosaicRule = JSON.stringify(this.options.mosaicRule);\n }\n\n return params;\n },\n\n _requestExport: function (params, bounds) {\n if (this.options.f === 'json') {\n this.service.request('exportImage', params, function (error, response) {\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\n if (this.options.token) {\n response.href += ('?token=' + this.options.token);\n }\n this._renderImage(response.href, bounds);\n }, this);\n } else {\n params.f = 'image';\n this._renderImage(this.options.url + 'exportImage' + Util.getParamString(params), bounds);\n }\n }\n});\n\nexport function imageMapLayer (url, options) {\n return new ImageMapLayer(url, options);\n}\n\nexport default imageMapLayer;\n","import { Util } from 'leaflet';\nimport { RasterLayer } from './RasterLayer';\nimport { getUrlParams } from '../Util';\nimport mapService from '../Services/MapService';\n\nexport var DynamicMapLayer = RasterLayer.extend({\n\n options: {\n updateInterval: 150,\n layers: false,\n layerDefs: false,\n timeOptions: false,\n format: 'png24',\n transparent: true,\n f: 'json'\n },\n\n initialize: function (options) {\n options = getUrlParams(options);\n this.service = mapService(options);\n this.service.addEventParent(this);\n\n if ((options.proxy || options.token) && options.f !== 'json') {\n options.f = 'json';\n }\n\n Util.setOptions(this, options);\n },\n\n getDynamicLayers: function () {\n return this.options.dynamicLayers;\n },\n\n setDynamicLayers: function (dynamicLayers) {\n this.options.dynamicLayers = dynamicLayers;\n this._update();\n return this;\n },\n\n getLayers: function () {\n return this.options.layers;\n },\n\n setLayers: function (layers) {\n this.options.layers = layers;\n this._update();\n return this;\n },\n\n getLayerDefs: function () {\n return this.options.layerDefs;\n },\n\n setLayerDefs: function (layerDefs) {\n this.options.layerDefs = layerDefs;\n this._update();\n return this;\n },\n\n getTimeOptions: function () {\n return this.options.timeOptions;\n },\n\n setTimeOptions: function (timeOptions) {\n this.options.timeOptions = timeOptions;\n this._update();\n return this;\n },\n\n query: function () {\n return this.service.query();\n },\n\n identify: function () {\n return this.service.identify();\n },\n\n find: function () {\n return this.service.find();\n },\n\n _getPopupData: function (e) {\n var callback = Util.bind(function (error, featureCollection, response) {\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\n setTimeout(Util.bind(function () {\n this._renderPopup(e.latlng, error, featureCollection, response);\n }, this), 300);\n }, this);\n\n var identifyRequest;\n if (this.options.popup) {\n identifyRequest = this.options.popup.on(this._map).at(e.latlng);\n } else {\n identifyRequest = this.identify().on(this._map).at(e.latlng);\n }\n\n // remove extraneous vertices from response features if it has not already been done\n identifyRequest.params.maxAllowableOffset ? true : identifyRequest.simplify(this._map, 0.5);\n\n if (!(this.options.popup && this.options.popup.params && this.options.popup.params.layers)) {\n if (this.options.layers) {\n identifyRequest.layers('visible:' + this.options.layers.join(','));\n } else {\n identifyRequest.layers('visible');\n }\n }\n\n // if present, pass layer ids and sql filters through to the identify task\n if (this.options.layerDefs && typeof this.options.layerDefs !== 'string' && !identifyRequest.params.layerDefs) {\n for (var id in this.options.layerDefs) {\n if (this.options.layerDefs.hasOwnProperty(id)) {\n identifyRequest.layerDef(id, this.options.layerDefs[id]);\n }\n }\n }\n\n identifyRequest.run(callback);\n\n // set the flags to show the popup\n this._shouldRenderPopup = true;\n this._lastClick = e.latlng;\n },\n\n _buildExportParams: function () {\n var sr = parseInt(this._map.options.crs.code.split(':')[1], 10);\n\n var params = {\n bbox: this._calculateBbox(),\n size: this._calculateImageSize(),\n dpi: 96,\n format: this.options.format,\n transparent: this.options.transparent,\n bboxSR: sr,\n imageSR: sr\n };\n\n if (this.options.dynamicLayers) {\n params.dynamicLayers = this.options.dynamicLayers;\n }\n\n if (this.options.layers) {\n if (this.options.layers.length === 0) {\n return;\n } else {\n params.layers = 'show:' + this.options.layers.join(',');\n }\n }\n\n if (this.options.layerDefs) {\n params.layerDefs = typeof this.options.layerDefs === 'string' ? this.options.layerDefs : JSON.stringify(this.options.layerDefs);\n }\n\n if (this.options.timeOptions) {\n params.timeOptions = JSON.stringify(this.options.timeOptions);\n }\n\n if (this.options.from && this.options.to) {\n params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\n }\n\n if (this.service.options.token) {\n params.token = this.service.options.token;\n }\n\n if (this.options.proxy) {\n params.proxy = this.options.proxy;\n }\n\n // use a timestamp to bust server cache\n if (this.options.disableCache) {\n params._ts = Date.now();\n }\n\n return params;\n },\n\n _requestExport: function (params, bounds) {\n if (this.options.f === 'json') {\n this.service.request('export', params, function (error, response) {\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\n\n if (this.options.token) {\n response.href += ('?token=' + this.options.token);\n }\n if (this.options.proxy) {\n response.href = this.options.proxy + '?' + response.href;\n }\n if (response.href) {\n this._renderImage(response.href, bounds);\n } else {\n this._renderImage(response.imageData, bounds, response.contentType);\n }\n }, this);\n } else {\n params.f = 'image';\n this._renderImage(this.options.url + 'export' + Util.getParamString(params), bounds);\n }\n }\n});\n\nexport function dynamicMapLayer (url, options) {\n return new DynamicMapLayer(url, options);\n}\n\nexport default dynamicMapLayer;\n","import {\n bounds,\n latLngBounds,\n point,\n Layer,\n setOptions,\n Util\n} from 'leaflet';\n\nvar VirtualGrid = Layer.extend({\n\n options: {\n cellSize: 512,\n updateInterval: 150\n },\n\n initialize: function (options) {\n options = setOptions(this, options);\n this._zooming = false;\n },\n\n onAdd: function (map) {\n this._map = map;\n this._update = Util.throttle(this._update, this.options.updateInterval, this);\n this._reset();\n this._update();\n },\n\n onRemove: function () {\n this._map.removeEventListener(this.getEvents(), this);\n this._removeCells();\n },\n\n getEvents: function () {\n var events = {\n moveend: this._update,\n zoomstart: this._zoomstart,\n zoomend: this._reset\n };\n\n return events;\n },\n\n addTo: function (map) {\n map.addLayer(this);\n return this;\n },\n\n removeFrom: function (map) {\n map.removeLayer(this);\n return this;\n },\n\n _zoomstart: function () {\n this._zooming = true;\n },\n\n _reset: function () {\n this._removeCells();\n\n this._cells = {};\n this._activeCells = {};\n this._cellsToLoad = 0;\n this._cellsTotal = 0;\n this._cellNumBounds = this._getCellNumBounds();\n\n this._resetWrap();\n this._zooming = false;\n },\n\n _resetWrap: function () {\n var map = this._map;\n var crs = map.options.crs;\n\n if (crs.infinite) { return; }\n\n var cellSize = this._getCellSize();\n\n if (crs.wrapLng) {\n this._wrapLng = [\n Math.floor(map.project([0, crs.wrapLng[0]]).x / cellSize),\n Math.ceil(map.project([0, crs.wrapLng[1]]).x / cellSize)\n ];\n }\n\n if (crs.wrapLat) {\n this._wrapLat = [\n Math.floor(map.project([crs.wrapLat[0], 0]).y / cellSize),\n Math.ceil(map.project([crs.wrapLat[1], 0]).y / cellSize)\n ];\n }\n },\n\n _getCellSize: function () {\n return this.options.cellSize;\n },\n\n _update: function () {\n if (!this._map) {\n return;\n }\n\n var mapBounds = this._map.getPixelBounds();\n var cellSize = this._getCellSize();\n\n // cell coordinates range for the current view\n var cellBounds = bounds(\n mapBounds.min.divideBy(cellSize).floor(),\n mapBounds.max.divideBy(cellSize).floor());\n\n this._removeOtherCells(cellBounds);\n this._addCells(cellBounds);\n\n this.fire('cellsupdated');\n },\n\n _addCells: function (cellBounds) {\n var queue = [];\n var center = cellBounds.getCenter();\n var zoom = this._map.getZoom();\n\n var j, i, coords;\n // create a queue of coordinates to load cells from\n for (j = cellBounds.min.y; j <= cellBounds.max.y; j++) {\n for (i = cellBounds.min.x; i <= cellBounds.max.x; i++) {\n coords = point(i, j);\n coords.z = zoom;\n\n if (this._isValidCell(coords)) {\n queue.push(coords);\n }\n }\n }\n\n var cellsToLoad = queue.length;\n\n if (cellsToLoad === 0) { return; }\n\n this._cellsToLoad += cellsToLoad;\n this._cellsTotal += cellsToLoad;\n\n // sort cell queue to load cells in order of their distance to center\n queue.sort(function (a, b) {\n return a.distanceTo(center) - b.distanceTo(center);\n });\n\n for (i = 0; i < cellsToLoad; i++) {\n this._addCell(queue[i]);\n }\n },\n\n _isValidCell: function (coords) {\n var crs = this._map.options.crs;\n\n if (!crs.infinite) {\n // don't load cell if it's out of bounds and not wrapped\n var cellNumBounds = this._cellNumBounds;\n\n if (!cellNumBounds) return false;\n if (\n (!crs.wrapLng && (coords.x < cellNumBounds.min.x || coords.x > cellNumBounds.max.x)) ||\n (!crs.wrapLat && (coords.y < cellNumBounds.min.y || coords.y > cellNumBounds.max.y))\n ) {\n return false;\n }\n }\n\n if (!this.options.bounds) {\n return true;\n }\n\n // don't load cell if it doesn't intersect the bounds in options\n var cellBounds = this._cellCoordsToBounds(coords);\n return latLngBounds(this.options.bounds).intersects(cellBounds);\n },\n\n // converts cell coordinates to its geographical bounds\n _cellCoordsToBounds: function (coords) {\n var map = this._map;\n var cellSize = this.options.cellSize;\n var nwPoint = coords.multiplyBy(cellSize);\n var sePoint = nwPoint.add([cellSize, cellSize]);\n var nw = map.wrapLatLng(map.unproject(nwPoint, coords.z));\n var se = map.wrapLatLng(map.unproject(sePoint, coords.z));\n\n return latLngBounds(nw, se);\n },\n\n // converts cell coordinates to key for the cell cache\n _cellCoordsToKey: function (coords) {\n return coords.x + ':' + coords.y;\n },\n\n // converts cell cache key to coordiantes\n _keyToCellCoords: function (key) {\n var kArr = key.split(':');\n var x = parseInt(kArr[0], 10);\n var y = parseInt(kArr[1], 10);\n\n return point(x, y);\n },\n\n // remove any present cells that are off the specified bounds\n _removeOtherCells: function (bounds) {\n for (var key in this._cells) {\n if (!bounds.contains(this._keyToCellCoords(key))) {\n this._removeCell(key);\n }\n }\n },\n\n _removeCell: function (key) {\n var cell = this._activeCells[key];\n\n if (cell) {\n delete this._activeCells[key];\n\n if (this.cellLeave) {\n this.cellLeave(cell.bounds, cell.coords);\n }\n\n this.fire('cellleave', {\n bounds: cell.bounds,\n coords: cell.coords\n });\n }\n },\n\n _removeCells: function () {\n for (var key in this._cells) {\n var cellBounds = this._cells[key].bounds;\n var coords = this._cells[key].coords;\n\n if (this.cellLeave) {\n this.cellLeave(cellBounds, coords);\n }\n\n this.fire('cellleave', {\n bounds: cellBounds,\n coords: coords\n });\n }\n },\n\n _addCell: function (coords) {\n // wrap cell coords if necessary (depending on CRS)\n this._wrapCoords(coords);\n\n // generate the cell key\n var key = this._cellCoordsToKey(coords);\n\n // get the cell from the cache\n var cell = this._cells[key];\n // if this cell should be shown as isnt active yet (enter)\n\n if (cell && !this._activeCells[key]) {\n if (this.cellEnter) {\n this.cellEnter(cell.bounds, coords);\n }\n\n this.fire('cellenter', {\n bounds: cell.bounds,\n coords: coords\n });\n\n this._activeCells[key] = cell;\n }\n\n // if we dont have this cell in the cache yet (create)\n if (!cell) {\n cell = {\n coords: coords,\n bounds: this._cellCoordsToBounds(coords)\n };\n\n this._cells[key] = cell;\n this._activeCells[key] = cell;\n\n if (this.createCell) {\n this.createCell(cell.bounds, coords);\n }\n\n this.fire('cellcreate', {\n bounds: cell.bounds,\n coords: coords\n });\n }\n },\n\n _wrapCoords: function (coords) {\n coords.x = this._wrapLng ? Util.wrapNum(coords.x, this._wrapLng) : coords.x;\n coords.y = this._wrapLat ? Util.wrapNum(coords.y, this._wrapLat) : coords.y;\n },\n\n // get the global cell coordinates range for the current zoom\n _getCellNumBounds: function () {\n var worldBounds = this._map.getPixelWorldBounds();\n var size = this._getCellSize();\n\n return worldBounds ? bounds(\n worldBounds.min.divideBy(size).floor(),\n worldBounds.max.divideBy(size).ceil().subtract([1, 1])) : null;\n }\n});\n\nexport default VirtualGrid;\n","function BinarySearchIndex (values) {\n this.values = [].concat(values || []);\n}\n\nBinarySearchIndex.prototype.query = function (value) {\n var index = this.getIndex(value);\n return this.values[index];\n};\n\nBinarySearchIndex.prototype.getIndex = function getIndex (value) {\n if (this.dirty) {\n this.sort();\n }\n\n var minIndex = 0;\n var maxIndex = this.values.length - 1;\n var currentIndex;\n var currentElement;\n\n while (minIndex <= maxIndex) {\n currentIndex = (minIndex + maxIndex) / 2 | 0;\n currentElement = this.values[Math.round(currentIndex)];\n if (+currentElement.value < +value) {\n minIndex = currentIndex + 1;\n } else if (+currentElement.value > +value) {\n maxIndex = currentIndex - 1;\n } else {\n return currentIndex;\n }\n }\n\n return Math.abs(~maxIndex);\n};\n\nBinarySearchIndex.prototype.between = function between (start, end) {\n var startIndex = this.getIndex(start);\n var endIndex = this.getIndex(end);\n\n if (startIndex === 0 && endIndex === 0) {\n return [];\n }\n\n while (this.values[startIndex - 1] && this.values[startIndex - 1].value === start) {\n startIndex--;\n }\n\n while (this.values[endIndex + 1] && this.values[endIndex + 1].value === end) {\n endIndex++;\n }\n\n if (this.values[endIndex] && this.values[endIndex].value === end && this.values[endIndex + 1]) {\n endIndex++;\n }\n\n return this.values.slice(startIndex, endIndex);\n};\n\nBinarySearchIndex.prototype.insert = function insert (item) {\n this.values.splice(this.getIndex(item.value), 0, item);\n return this;\n};\n\nBinarySearchIndex.prototype.bulkAdd = function bulkAdd (items, sort) {\n this.values = this.values.concat([].concat(items || []));\n\n if (sort) {\n this.sort();\n } else {\n this.dirty = true;\n }\n\n return this;\n};\n\nBinarySearchIndex.prototype.sort = function sort () {\n this.values.sort(function (a, b) {\n return +b.value - +a.value;\n }).reverse();\n this.dirty = false;\n return this;\n};\n\nexport default BinarySearchIndex;\n","import { Util } from 'leaflet';\nimport featureLayerService from '../../Services/FeatureLayerService';\nimport { getUrlParams, warn, setEsriAttribution } from '../../Util';\nimport VirtualGrid from 'leaflet-virtual-grid';\nimport BinarySearchIndex from 'tiny-binary-search';\n\nexport var FeatureManager = VirtualGrid.extend({\n /**\n * Options\n */\n\n options: {\n attribution: null,\n where: '1=1',\n fields: ['*'],\n from: false,\n to: false,\n timeField: false,\n timeFilterMode: 'server',\n simplifyFactor: 0,\n precision: 6\n },\n\n /**\n * Constructor\n */\n\n initialize: function (options) {\n VirtualGrid.prototype.initialize.call(this, options);\n\n options = getUrlParams(options);\n options = Util.setOptions(this, options);\n\n this.service = featureLayerService(options);\n this.service.addEventParent(this);\n\n // use case insensitive regex to look for common fieldnames used for indexing\n if (this.options.fields[0] !== '*') {\n var oidCheck = false;\n for (var i = 0; i < this.options.fields.length; i++) {\n if (this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i)) {\n oidCheck = true;\n }\n }\n if (oidCheck === false) {\n warn('no known esriFieldTypeOID field detected in fields Array. Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.');\n }\n }\n\n if (this.options.timeField.start && this.options.timeField.end) {\n this._startTimeIndex = new BinarySearchIndex();\n this._endTimeIndex = new BinarySearchIndex();\n } else if (this.options.timeField) {\n this._timeIndex = new BinarySearchIndex();\n }\n\n this._cache = {};\n this._currentSnapshot = []; // cache of what layers should be active\n this._activeRequests = 0;\n },\n\n /**\n * Layer Interface\n */\n\n onAdd: function (map) {\n // include 'Powered by Esri' in map attribution\n setEsriAttribution(map);\n\n this.service.metadata(function (err, metadata) {\n if (!err) {\n var supportedFormats = metadata.supportedQueryFormats;\n\n // Check if someone has requested that we don't use geoJSON, even if it's available\n var forceJsonFormat = false;\n if (this.service.options.isModern === false) {\n forceJsonFormat = true;\n }\n\n // Unless we've been told otherwise, check to see whether service can emit GeoJSON natively\n if (!forceJsonFormat && supportedFormats && supportedFormats.indexOf('geoJSON') !== -1) {\n this.service.options.isModern = true;\n }\n\n if (metadata.objectIdField) {\n this.service.options.idAttribute = metadata.objectIdField;\n }\n\n // add copyright text listed in service metadata\n if (!this.options.attribution && map.attributionControl && metadata.copyrightText) {\n this.options.attribution = metadata.copyrightText;\n map.attributionControl.addAttribution(this.getAttribution());\n }\n }\n }, this);\n\n map.on('zoomend', this._handleZoomChange, this);\n\n return VirtualGrid.prototype.onAdd.call(this, map);\n },\n\n onRemove: function (map) {\n map.off('zoomend', this._handleZoomChange, this);\n\n return VirtualGrid.prototype.onRemove.call(this, map);\n },\n\n getAttribution: function () {\n return this.options.attribution;\n },\n\n /**\n * Feature Management\n */\n\n createCell: function (bounds, coords) {\n // dont fetch features outside the scale range defined for the layer\n if (this._visibleZoom()) {\n this._requestFeatures(bounds, coords);\n }\n },\n\n _requestFeatures: function (bounds, coords, callback) {\n this._activeRequests++;\n\n // our first active request fires loading\n if (this._activeRequests === 1) {\n this.fire('loading', {\n bounds: bounds\n }, true);\n }\n\n return this._buildQuery(bounds).run(function (error, featureCollection, response) {\n if (response && response.exceededTransferLimit) {\n this.fire('drawlimitexceeded');\n }\n\n // no error, features\n if (!error && featureCollection && featureCollection.features.length) {\n // schedule adding features until the next animation frame\n Util.requestAnimFrame(Util.bind(function () {\n this._addFeatures(featureCollection.features, coords);\n this._postProcessFeatures(bounds);\n }, this));\n }\n\n // no error, no features\n if (!error && featureCollection && !featureCollection.features.length) {\n this._postProcessFeatures(bounds);\n }\n\n if (error) {\n this._postProcessFeatures(bounds);\n }\n\n if (callback) {\n callback.call(this, error, featureCollection);\n }\n }, this);\n },\n\n _postProcessFeatures: function (bounds) {\n // deincrement the request counter now that we have processed features\n this._activeRequests--;\n\n // if there are no more active requests fire a load event for this view\n if (this._activeRequests <= 0) {\n this.fire('load', {\n bounds: bounds\n });\n }\n },\n\n _cacheKey: function (coords) {\n return coords.z + ':' + coords.x + ':' + coords.y;\n },\n\n _addFeatures: function (features, coords) {\n var key = this._cacheKey(coords);\n this._cache[key] = this._cache[key] || [];\n\n for (var i = features.length - 1; i >= 0; i--) {\n var id = features[i].id;\n\n if (this._currentSnapshot.indexOf(id) === -1) {\n this._currentSnapshot.push(id);\n }\n if (this._cache[key].indexOf(id) === -1) {\n this._cache[key].push(id);\n }\n }\n\n if (this.options.timeField) {\n this._buildTimeIndexes(features);\n }\n\n this.createLayers(features);\n },\n\n _buildQuery: function (bounds) {\n var query = this.service.query()\n .intersects(bounds)\n .where(this.options.where)\n .fields(this.options.fields)\n .precision(this.options.precision);\n\n if (this.options.requestParams) {\n Util.extend(query.params, this.options.requestParams);\n }\n\n if (this.options.simplifyFactor) {\n query.simplify(this._map, this.options.simplifyFactor);\n }\n\n if (this.options.timeFilterMode === 'server' && this.options.from && this.options.to) {\n query.between(this.options.from, this.options.to);\n }\n\n return query;\n },\n\n /**\n * Where Methods\n */\n\n setWhere: function (where, callback, context) {\n this.options.where = (where && where.length) ? where : '1=1';\n\n var oldSnapshot = [];\n var newSnapshot = [];\n var pendingRequests = 0;\n var requestError = null;\n var requestCallback = Util.bind(function (error, featureCollection) {\n if (error) {\n requestError = error;\n }\n\n if (featureCollection) {\n for (var i = featureCollection.features.length - 1; i >= 0; i--) {\n newSnapshot.push(featureCollection.features[i].id);\n }\n }\n\n pendingRequests--;\n\n if (pendingRequests <= 0 && this._visibleZoom()) {\n this._currentSnapshot = newSnapshot;\n // schedule adding features for the next animation frame\n Util.requestAnimFrame(Util.bind(function () {\n this.removeLayers(oldSnapshot);\n this.addLayers(newSnapshot);\n if (callback) {\n callback.call(context, requestError);\n }\n }, this));\n }\n }, this);\n\n for (var i = this._currentSnapshot.length - 1; i >= 0; i--) {\n oldSnapshot.push(this._currentSnapshot[i]);\n }\n\n for (var key in this._activeCells) {\n pendingRequests++;\n var coords = this._keyToCellCoords(key);\n var bounds = this._cellCoordsToBounds(coords);\n this._requestFeatures(bounds, key, requestCallback);\n }\n\n return this;\n },\n\n getWhere: function () {\n return this.options.where;\n },\n\n /**\n * Time Range Methods\n */\n\n getTimeRange: function () {\n return [this.options.from, this.options.to];\n },\n\n setTimeRange: function (from, to, callback, context) {\n var oldFrom = this.options.from;\n var oldTo = this.options.to;\n var pendingRequests = 0;\n var requestError = null;\n var requestCallback = Util.bind(function (error) {\n if (error) {\n requestError = error;\n }\n this._filterExistingFeatures(oldFrom, oldTo, from, to);\n\n pendingRequests--;\n\n if (callback && pendingRequests <= 0) {\n callback.call(context, requestError);\n }\n }, this);\n\n this.options.from = from;\n this.options.to = to;\n\n this._filterExistingFeatures(oldFrom, oldTo, from, to);\n\n if (this.options.timeFilterMode === 'server') {\n for (var key in this._activeCells) {\n pendingRequests++;\n var coords = this._keyToCellCoords(key);\n var bounds = this._cellCoordsToBounds(coords);\n this._requestFeatures(bounds, key, requestCallback);\n }\n }\n\n return this;\n },\n\n refresh: function () {\n for (var key in this._activeCells) {\n var coords = this._keyToCellCoords(key);\n var bounds = this._cellCoordsToBounds(coords);\n this._requestFeatures(bounds, key);\n }\n\n if (this.redraw) {\n this.once('load', function () {\n this.eachFeature(function (layer) {\n this._redraw(layer.feature.id);\n }, this);\n }, this);\n }\n },\n\n _filterExistingFeatures: function (oldFrom, oldTo, newFrom, newTo) {\n var layersToRemove = (oldFrom && oldTo) ? this._getFeaturesInTimeRange(oldFrom, oldTo) : this._currentSnapshot;\n var layersToAdd = this._getFeaturesInTimeRange(newFrom, newTo);\n\n if (layersToAdd.indexOf) {\n for (var i = 0; i < layersToAdd.length; i++) {\n var shouldRemoveLayer = layersToRemove.indexOf(layersToAdd[i]);\n if (shouldRemoveLayer >= 0) {\n layersToRemove.splice(shouldRemoveLayer, 1);\n }\n }\n }\n\n // schedule adding features until the next animation frame\n Util.requestAnimFrame(Util.bind(function () {\n this.removeLayers(layersToRemove);\n this.addLayers(layersToAdd);\n }, this));\n },\n\n _getFeaturesInTimeRange: function (start, end) {\n var ids = [];\n var search;\n\n if (this.options.timeField.start && this.options.timeField.end) {\n var startTimes = this._startTimeIndex.between(start, end);\n var endTimes = this._endTimeIndex.between(start, end);\n search = startTimes.concat(endTimes);\n } else {\n search = this._timeIndex.between(start, end);\n }\n\n for (var i = search.length - 1; i >= 0; i--) {\n ids.push(search[i].id);\n }\n\n return ids;\n },\n\n _buildTimeIndexes: function (geojson) {\n var i;\n var feature;\n if (this.options.timeField.start && this.options.timeField.end) {\n var startTimeEntries = [];\n var endTimeEntries = [];\n for (i = geojson.length - 1; i >= 0; i--) {\n feature = geojson[i];\n startTimeEntries.push({\n id: feature.id,\n value: new Date(feature.properties[this.options.timeField.start])\n });\n endTimeEntries.push({\n id: feature.id,\n value: new Date(feature.properties[this.options.timeField.end])\n });\n }\n this._startTimeIndex.bulkAdd(startTimeEntries);\n this._endTimeIndex.bulkAdd(endTimeEntries);\n } else {\n var timeEntries = [];\n for (i = geojson.length - 1; i >= 0; i--) {\n feature = geojson[i];\n timeEntries.push({\n id: feature.id,\n value: new Date(feature.properties[this.options.timeField])\n });\n }\n\n this._timeIndex.bulkAdd(timeEntries);\n }\n },\n\n _featureWithinTimeRange: function (feature) {\n if (!this.options.from || !this.options.to) {\n return true;\n }\n\n var from = +this.options.from.valueOf();\n var to = +this.options.to.valueOf();\n\n if (typeof this.options.timeField === 'string') {\n var date = +feature.properties[this.options.timeField];\n return (date >= from) && (date <= to);\n }\n\n if (this.options.timeField.start && this.options.timeField.end) {\n var startDate = +feature.properties[this.options.timeField.start];\n var endDate = +feature.properties[this.options.timeField.end];\n return ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to));\n }\n },\n\n _visibleZoom: function () {\n // check to see whether the current zoom level of the map is within the optional limit defined for the FeatureLayer\n if (!this._map) {\n return false;\n }\n var zoom = this._map.getZoom();\n if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\n return false;\n } else { return true; }\n },\n\n _handleZoomChange: function () {\n if (!this._visibleZoom()) {\n this.removeLayers(this._currentSnapshot);\n this._currentSnapshot = [];\n } else {\n /*\n for every cell in this._activeCells\n 1. Get the cache key for the coords of the cell\n 2. If this._cache[key] exists it will be an array of feature IDs.\n 3. Call this.addLayers(this._cache[key]) to instruct the feature layer to add the layers back.\n */\n for (var i in this._activeCells) {\n var coords = this._activeCells[i].coords;\n var key = this._cacheKey(coords);\n if (this._cache[key]) {\n this.addLayers(this._cache[key]);\n }\n }\n }\n },\n\n /**\n * Service Methods\n */\n\n authenticate: function (token) {\n this.service.authenticate(token);\n return this;\n },\n\n metadata: function (callback, context) {\n this.service.metadata(callback, context);\n return this;\n },\n\n query: function () {\n return this.service.query();\n },\n\n _getMetadata: function (callback) {\n if (this._metadata) {\n var error;\n callback(error, this._metadata);\n } else {\n this.metadata(Util.bind(function (error, response) {\n this._metadata = response;\n callback(error, this._metadata);\n }, this));\n }\n },\n\n addFeature: function (feature, callback, context) {\n this.addFeatures(feature, callback, context);\n },\n\n addFeatures: function (features, callback, context) {\n this._getMetadata(Util.bind(function (error, metadata) {\n if (error) {\n if (callback) { callback.call(this, error, null); }\n return;\n }\n // GeoJSON featureCollection or simple feature\n var featuresArray = features.features ? features.features : [features];\n\n this.service.addFeatures(features, Util.bind(function (error, response) {\n if (!error) {\n for (var i = featuresArray.length - 1; i >= 0; i--) {\n // assign ID from result to appropriate objectid field from service metadata\n featuresArray[i].properties[metadata.objectIdField] = featuresArray.length > 1 ? response[i].objectId : response.objectId;\n // we also need to update the geojson id for createLayers() to function\n featuresArray[i].id = featuresArray.length > 1 ? response[i].objectId : response.objectId;\n }\n this.createLayers(featuresArray);\n }\n\n if (callback) {\n callback.call(context, error, response);\n }\n }, this));\n }, this));\n },\n\n updateFeature: function (feature, callback, context) {\n this.updateFeatures(feature, callback, context);\n },\n\n updateFeatures: function (features, callback, context) {\n // GeoJSON featureCollection or simple feature\n var featuresArray = features.features ? features.features : [features];\n this.service.updateFeatures(features, function (error, response) {\n if (!error) {\n for (var i = featuresArray.length - 1; i >= 0; i--) {\n this.removeLayers([featuresArray[i].id], true);\n }\n this.createLayers(featuresArray);\n }\n\n if (callback) {\n callback.call(context, error, response);\n }\n }, this);\n },\n\n deleteFeature: function (id, callback, context) {\n this.deleteFeatures(id, callback, context);\n },\n\n deleteFeatures: function (ids, callback, context) {\n return this.service.deleteFeatures(ids, function (error, response) {\n var responseArray = response.length ? response : [response];\n if (!error && responseArray.length > 0) {\n for (var i = responseArray.length - 1; i >= 0; i--) {\n this.removeLayers([responseArray[i].objectId], true);\n }\n }\n if (callback) {\n callback.call(context, error, response);\n }\n }, this);\n }\n});\n","import { Path, Util, GeoJSON, latLng } from 'leaflet';\nimport { FeatureManager } from './FeatureManager';\nimport { warn } from '../../Util';\n\nexport var FeatureLayer = FeatureManager.extend({\n\n options: {\n cacheLayers: true\n },\n\n /**\n * Constructor\n */\n initialize: function (options) {\n FeatureManager.prototype.initialize.call(this, options);\n this._originalStyle = this.options.style;\n this._layers = {};\n },\n\n /**\n * Layer Interface\n */\n\n onRemove: function (map) {\n for (var i in this._layers) {\n map.removeLayer(this._layers[i]);\n // trigger the event when the entire featureLayer is removed from the map\n this.fire('removefeature', {\n feature: this._layers[i].feature,\n permanent: false\n }, true);\n }\n\n return FeatureManager.prototype.onRemove.call(this, map);\n },\n\n createNewLayer: function (geojson) {\n var layer = GeoJSON.geometryToLayer(geojson, this.options);\n // trap for GeoJSON without geometry\n if (layer) {\n layer.defaultOptions = layer.options;\n }\n return layer;\n },\n\n _updateLayer: function (layer, geojson) {\n // convert the geojson coordinates into a Leaflet LatLng array/nested arrays\n // pass it to setLatLngs to update layer geometries\n var latlngs = [];\n var coordsToLatLng = this.options.coordsToLatLng || GeoJSON.coordsToLatLng;\n\n // copy new attributes, if present\n if (geojson.properties) {\n layer.feature.properties = geojson.properties;\n }\n\n switch (geojson.geometry.type) {\n case 'Point':\n latlngs = GeoJSON.coordsToLatLng(geojson.geometry.coordinates);\n layer.setLatLng(latlngs);\n break;\n case 'LineString':\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 0, coordsToLatLng);\n layer.setLatLngs(latlngs);\n break;\n case 'MultiLineString':\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng);\n layer.setLatLngs(latlngs);\n break;\n case 'Polygon':\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng);\n layer.setLatLngs(latlngs);\n break;\n case 'MultiPolygon':\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 2, coordsToLatLng);\n layer.setLatLngs(latlngs);\n break;\n }\n },\n\n /**\n * Feature Management Methods\n */\n\n createLayers: function (features) {\n for (var i = features.length - 1; i >= 0; i--) {\n var geojson = features[i];\n\n var layer = this._layers[geojson.id];\n var newLayer;\n\n if (this._visibleZoom() && layer && !this._map.hasLayer(layer)) {\n this._map.addLayer(layer);\n this.fire('addfeature', {\n feature: layer.feature\n }, true);\n }\n\n // update geometry if necessary\n if (layer && this.options.simplifyFactor > 0 && (layer.setLatLngs || layer.setLatLng)) {\n this._updateLayer(layer, geojson);\n }\n\n if (!layer) {\n newLayer = this.createNewLayer(geojson);\n\n if (!newLayer) {\n warn('invalid GeoJSON encountered');\n } else {\n newLayer.feature = geojson;\n\n // bubble events from individual layers to the feature layer\n newLayer.addEventParent(this);\n\n if (this.options.onEachFeature) {\n this.options.onEachFeature(newLayer.feature, newLayer);\n }\n\n // cache the layer\n this._layers[newLayer.feature.id] = newLayer;\n\n // style the layer\n this.setFeatureStyle(newLayer.feature.id, this.options.style);\n\n this.fire('createfeature', {\n feature: newLayer.feature\n }, true);\n\n // add the layer if the current zoom level is inside the range defined for the layer, it is within the current time bounds or our layer is not time enabled\n if (this._visibleZoom() && (!this.options.timeField || (this.options.timeField && this._featureWithinTimeRange(geojson)))) {\n this._map.addLayer(newLayer);\n }\n }\n }\n }\n },\n\n addLayers: function (ids) {\n for (var i = ids.length - 1; i >= 0; i--) {\n var layer = this._layers[ids[i]];\n if (layer) {\n this._map.addLayer(layer);\n }\n }\n },\n\n removeLayers: function (ids, permanent) {\n for (var i = ids.length - 1; i >= 0; i--) {\n var id = ids[i];\n var layer = this._layers[id];\n if (layer) {\n this.fire('removefeature', {\n feature: layer.feature,\n permanent: permanent\n }, true);\n this._map.removeLayer(layer);\n }\n if (layer && permanent) {\n delete this._layers[id];\n }\n }\n },\n\n cellEnter: function (bounds, coords) {\n if (this._visibleZoom() && !this._zooming && this._map) {\n Util.requestAnimFrame(Util.bind(function () {\n var cacheKey = this._cacheKey(coords);\n var cellKey = this._cellCoordsToKey(coords);\n var layers = this._cache[cacheKey];\n if (this._activeCells[cellKey] && layers) {\n this.addLayers(layers);\n }\n }, this));\n }\n },\n\n cellLeave: function (bounds, coords) {\n if (!this._zooming) {\n Util.requestAnimFrame(Util.bind(function () {\n if (this._map) {\n var cacheKey = this._cacheKey(coords);\n var cellKey = this._cellCoordsToKey(coords);\n var layers = this._cache[cacheKey];\n var mapBounds = this._map.getBounds();\n if (!this._activeCells[cellKey] && layers) {\n var removable = true;\n\n for (var i = 0; i < layers.length; i++) {\n var layer = this._layers[layers[i]];\n if (layer && layer.getBounds && mapBounds.intersects(layer.getBounds())) {\n removable = false;\n }\n }\n\n if (removable) {\n this.removeLayers(layers, !this.options.cacheLayers);\n }\n\n if (!this.options.cacheLayers && removable) {\n delete this._cache[cacheKey];\n delete this._cells[cellKey];\n delete this._activeCells[cellKey];\n }\n }\n }\n }, this));\n }\n },\n\n /**\n * Styling Methods\n */\n\n resetStyle: function () {\n this.options.style = this._originalStyle;\n this.eachFeature(function (layer) {\n this.resetFeatureStyle(layer.feature.id);\n }, this);\n return this;\n },\n\n setStyle: function (style) {\n this.options.style = style;\n this.eachFeature(function (layer) {\n this.setFeatureStyle(layer.feature.id, style);\n }, this);\n return this;\n },\n\n resetFeatureStyle: function (id) {\n var layer = this._layers[id];\n var style = this._originalStyle || Path.prototype.options;\n if (layer) {\n Util.extend(layer.options, layer.defaultOptions);\n this.setFeatureStyle(id, style);\n }\n return this;\n },\n\n setFeatureStyle: function (id, style) {\n var layer = this._layers[id];\n if (typeof style === 'function') {\n style = style(layer.feature);\n }\n if (layer.setStyle) {\n layer.setStyle(style);\n }\n return this;\n },\n\n /**\n * Utility Methods\n */\n\n eachActiveFeature: function (fn, context) {\n // figure out (roughly) which layers are in view\n if (this._map) {\n var activeBounds = this._map.getBounds();\n for (var i in this._layers) {\n if (this._currentSnapshot.indexOf(this._layers[i].feature.id) !== -1) {\n // a simple point in poly test for point geometries\n if (typeof this._layers[i].getLatLng === 'function' && activeBounds.contains(this._layers[i].getLatLng())) {\n fn.call(context, this._layers[i]);\n } else if (typeof this._layers[i].getBounds === 'function' && activeBounds.intersects(this._layers[i].getBounds())) {\n // intersecting bounds check for polyline and polygon geometries\n fn.call(context, this._layers[i]);\n }\n }\n }\n }\n return this;\n },\n\n eachFeature: function (fn, context) {\n for (var i in this._layers) {\n fn.call(context, this._layers[i]);\n }\n return this;\n },\n\n getFeature: function (id) {\n return this._layers[id];\n },\n\n bringToBack: function () {\n this.eachFeature(function (layer) {\n if (layer.bringToBack) {\n layer.bringToBack();\n }\n });\n },\n\n bringToFront: function () {\n this.eachFeature(function (layer) {\n if (layer.bringToFront) {\n layer.bringToFront();\n }\n });\n },\n\n redraw: function (id) {\n if (id) {\n this._redraw(id);\n }\n return this;\n },\n\n _redraw: function (id) {\n var layer = this._layers[id];\n var geojson = layer.feature;\n\n // if this looks like a marker\n if (layer && layer.setIcon && this.options.pointToLayer) {\n // update custom symbology, if necessary\n if (this.options.pointToLayer) {\n var getIcon = this.options.pointToLayer(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));\n var updatedIcon = getIcon.options.icon;\n layer.setIcon(updatedIcon);\n }\n }\n\n // looks like a vector marker (circleMarker)\n if (layer && layer.setStyle && this.options.pointToLayer) {\n var getStyle = this.options.pointToLayer(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));\n var updatedStyle = getStyle.options;\n this.setFeatureStyle(geojson.id, updatedStyle);\n }\n\n // looks like a path (polygon/polyline)\n if (layer && layer.setStyle && this.options.style) {\n this.resetStyle(geojson.id);\n }\n }\n});\n\nexport function featureLayer (options) {\n return new FeatureLayer(options);\n}\n\nexport default featureLayer;\n"],"names":["cors","window","XMLHttpRequest","pointerEvents","document","documentElement","style","Support","options","attributionWidthOffset","callbacks","serialize","params","data","key","f","hasOwnProperty","value","param","type","Object","prototype","toString","call","length","JSON","stringify","join","valueOf","encodeURIComponent","createRequest","callback","context","httpRequest","onerror","e","onreadystatechange","Util","falseFn","error","code","message","response","readyState","parse","responseText","ontimeout","this","xmlHttpPost","url","open","timeout","setRequestHeader","send","xmlHttpGet","request","paramString","requestLength","jsonp","warn","_EsriLeafletCallbacks","callbackId","responseType","script","DomUtil","create","body","src","id","addClass","abort","_callback","get","CORS","JSONP","Request","post","closeRing","coordinates","a","b","i","pointsEqual","push","ringIsClockwise","ringToTest","pt2","total","rLength","pt1","vertexIntersectsVertex","a1","a2","b1","b2","uaT","ubT","uB","ua","ub","arrayIntersectsArray","j","coordinatesContainCoordinates","outer","inner","intersects","contains","point","l","coordinatesContainPoint","orientRings","poly","output","polygon","slice","outerRing","shift","reverse","hole","shallowClone","obj","target","arcgisToGeoJSON","arcgis","idAttribute","geojson","features","x","y","z","points","paths","rings","outerRings","holes","r","ring","uncontainedHoles","pop","contained","convertRingsToGeoJSON","xmin","ymin","xmax","ymax","geometry","attributes","properties","keys","Error","getId","err","spatialReference","wkid","console","geojsonToArcGIS","result","flattenMultiPolygonRings","geometries","idAttr","g2a","a2g","extentToBounds","extent","sw","latLng","ne","latLngBounds","boundsToExtent","bounds","getSouthWest","lng","lat","getNorthEast","knownFieldNames","_findIdAttributeFromResponse","objectIdFieldName","fields","name","match","_findIdAttributeFromFeature","feature","responseToFeatureCollection","objectIdField","results","count","featureCollection","cleanUrl","trim","getUrlParams","indexOf","requestParams","queryString","substring","split","decodeURI","replace","isArcgisOnline","test","geojsonTypeToArcGIS","geoJsonType","arcgisGeometryType","apply","arguments","calcAttributionWidth","map","getSize","setEsriAttribution","attributionControl","_esriAttributionAdded","setPrefix","hoverAttributionStyle","createElement","innerHTML","getElementsByTagName","appendChild","_container","attributionStyle","on","maxWidth","parentNode","removeChild","nodeList","querySelectorAll","item","_setGeometry","geometryType","LatLngBounds","getLatLng","LatLng","GeoJSON","getLayers","toGeoJSON","_getAttributionData","bind","attributions","_esriAttributions","c","contributors","contributor","coverageAreas","coverageArea","southWest","bbox","northEast","attribution","score","minZoom","zoomMin","maxZoom","zoomMax","sort","_updateMapAttribution","evt","oldAttributions","attributionElement","querySelector","newAttributions","getBounds","wrappedBounds","wrap","zoom","getZoom","text","substr","fire","EsriUtil","Task","Class","extend","proxy","useCors","generateSetter","initialize","endpoint","_service","setOptions","setters","setter","token","authenticate","format","boolean","returnUnformattedValues","path","_request","method","Query","offset","limit","precision","featureIds","returnGeometry","returnM","transform","where","outSr","outFields","within","_setGeometryParams","spatialRel","crosses","touches","overlaps","bboxIntersects","indexIntersects","nearby","latlng","radius","units","distance","inSr","string","between","start","end","time","simplify","factor","mapWidth","Math","abs","getWest","getEast","maxAllowableOffset","orderBy","fieldName","order","orderByFields","run","_cleanParams","isModern","_trapSQLerrors","returnCountOnly","ids","returnIdsOnly","objectIds","returnExtentOnly","distinct","returnDistinctValues","pixelSize","rawPoint","castPoint","layer","converted","query","Find","sr","layers","dynamicLayers","returnZ","gdbVersion","layerDefs","find","Identify","IdentifyFeatures","tolerance","size","imageDisplay","mapExtent","at","layerDef","undefined","layerId","identifyFeatures","IdentifyImage","setMosaicRule","setRenderingRule","setPixelSize","returnCatalogItems","getMosaicRule","mosaicRule","getRenderingRule","renderingRule","getPixelSize","_responseToGeoJSON","location","catalogItems","catalogItemVisibilities","geoJSON","pixel","crs","OBJECTID","objectId","Values","values","catalogItemVisibility","identifyImage","Service","Evented","_requestQueue","_authenticating","metadata","_runQueue","getTimeout","setTimeout","wrappedCallback","_createServiceCallback","MapService","identify","mapService","ImageService","imageService","FeatureLayerService","addFeature","addFeatures","featuresArray","addResults","updateFeature","updateFeatures","updateResults","deleteFeature","deleteFeatures","deleteResults","featureLayerService","tileProtocol","protocol","BasemapLayer","TileLayer","statics","TILES","Streets","urlTemplate","subdomains","attributionUrl","Topographic","Oceans","OceansLabels","pane","NationalGeographic","DarkGray","DarkGrayLabels","Gray","GrayLabels","Imagery","ImageryLabels","ImageryTransportation","ShadedRelief","ShadedReliefLabels","Terrain","TerrainLabels","USATopo","ImageryClarity","Physical","ImageryFirefly","config","tileOptions","onAdd","_initPane","onRemove","off","_map","getPane","createPane","zIndex","getAttribution","TiledMapLayer","zoomOffsetAllowance","errorTileUrl","MercatorZoomLevels","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","tileUrl","getParamString","service","addEventParent","RegExp","getTileUrl","tilePoint","_getZoomForUrl","template","s","_getSubdomain","_lodMap","createTile","coords","done","tile","DomEvent","_tileOnLoad","_tileOnError","crossOrigin","alt","once","latestWkid","copyrightText","addAttribution","CRS","EPSG3857","arcgisLODs","tileInfo","lods","correctResolutions","arcgisLOD","ci","correctRes","_withinPercentage","resolution","level","tokenQs","percentage","Overlay","ImageOverlay","_topLeft","getPixelBounds","min","_reset","setPosition","_image","subtract","getPixelOrigin","RasterLayer","Layer","opacity","position","interactive","_update","throttle","updateInterval","_currentImage","_bounds","equals","addLayer","removeLayer","_popup","_getPopupData","_resetPopupState","bindPopup","fn","popupOptions","_shouldRenderPopup","_lastClick","popup","_popupFunction","unbindPopup","closePopup","bringToFront","bringToBack","getOpacity","setOpacity","getTimeRange","from","to","setTimeRange","redraw","_renderImage","contentType","image","addTo","onOverlayLoad","newImage","oldImage","_animatingZoom","_panTransition","_inProgress","_buildExportParams","_requestExport","_renderPopup","content","setLatLng","setContent","openOn","_calculateBbox","pixelBounds","unproject","getBottomLeft","getTopRight","neProjected","project","swProjected","boundsProjected","_calculateImageSize","top","latLngToLayerPoint","bottom","ImageMapLayer","transparent","setPixelType","pixelType","getPixelType","setBandIds","bandIds","isArray","getBandIds","setNoData","noData","noDataInterpretation","getNoData","getNoDataInterpretation","identifyRequest","parseInt","bboxSR","imageSR","interpolation","compressionQuality","href","DynamicMapLayer","timeOptions","getDynamicLayers","setDynamicLayers","setLayers","getLayerDefs","setLayerDefs","getTimeOptions","setTimeOptions","dpi","disableCache","_ts","Date","now","imageData","VirtualGrid","cellSize","_zooming","removeEventListener","getEvents","_removeCells","moveend","zoomstart","_zoomstart","zoomend","removeFrom","_cells","_activeCells","_cellsToLoad","_cellsTotal","_cellNumBounds","_getCellNumBounds","_resetWrap","infinite","_getCellSize","wrapLng","_wrapLng","floor","ceil","wrapLat","_wrapLat","mapBounds","cellBounds","divideBy","max","_removeOtherCells","_addCells","queue","center","getCenter","_isValidCell","cellsToLoad","distanceTo","_addCell","cellNumBounds","_cellCoordsToBounds","nwPoint","multiplyBy","sePoint","add","nw","wrapLatLng","se","_cellCoordsToKey","_keyToCellCoords","kArr","_removeCell","cell","cellLeave","_wrapCoords","cellEnter","createCell","wrapNum","worldBounds","getPixelWorldBounds","BinarySearchIndex","concat","index","getIndex","dirty","currentIndex","currentElement","minIndex","maxIndex","round","startIndex","endIndex","insert","splice","bulkAdd","items","FeatureManager","timeField","timeFilterMode","simplifyFactor","oidCheck","_startTimeIndex","_endTimeIndex","_timeIndex","_cache","_currentSnapshot","_activeRequests","supportedFormats","supportedQueryFormats","forceJsonFormat","_handleZoomChange","_visibleZoom","_requestFeatures","_buildQuery","exceededTransferLimit","requestAnimFrame","_addFeatures","_postProcessFeatures","_cacheKey","_buildTimeIndexes","createLayers","setWhere","oldSnapshot","newSnapshot","pendingRequests","requestError","requestCallback","removeLayers","addLayers","getWhere","oldFrom","oldTo","_filterExistingFeatures","refresh","eachFeature","_redraw","newFrom","newTo","layersToRemove","_getFeaturesInTimeRange","layersToAdd","shouldRemoveLayer","search","startTimes","endTimes","startTimeEntries","endTimeEntries","timeEntries","_featureWithinTimeRange","date","startDate","endDate","_getMetadata","_metadata","responseArray","FeatureLayer","cacheLayers","_originalStyle","_layers","permanent","createNewLayer","geometryToLayer","defaultOptions","_updateLayer","latlngs","coordsToLatLng","coordsToLatLngs","setLatLngs","newLayer","hasLayer","onEachFeature","setFeatureStyle","cacheKey","cellKey","removable","resetStyle","resetFeatureStyle","setStyle","Path","eachActiveFeature","activeBounds","getFeature","setIcon","pointToLayer","updatedIcon","icon","updatedStyle"],"mappings":";;;8OAAWA,EAASC,OAAOC,gBAAkB,oBAAqB,IAAID,OAAOC,eAClEC,EAAiE,K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
+ {"version":3,"file":"esri-leaflet.js","sources":["../src/Support.js","../src/Options.js","../src/Request.js","../node_modules/@terraformer/arcgis/dist/t-arcgis.esm.js","../src/Util.js","../src/Tasks/Task.js","../src/Tasks/Query.js","../src/Tasks/Find.js","../src/Tasks/Identify.js","../src/Tasks/IdentifyFeatures.js","../src/Tasks/IdentifyImage.js","../src/Services/Service.js","../src/Services/MapService.js","../src/Services/ImageService.js","../src/Services/FeatureLayerService.js","../src/Layers/BasemapLayer.js","../src/Layers/TiledMapLayer.js","../src/Layers/RasterLayer.js","../src/Layers/ImageMapLayer.js","../src/Layers/DynamicMapLayer.js","../src/Layers/FeatureLayer/FeatureGrid.js","../node_modules/tiny-binary-search/index.js","../src/Layers/FeatureLayer/FeatureManager.js","../src/Layers/FeatureLayer/FeatureLayer.js","../src/EsriLeaflet.js"],"sourcesContent":["export var cors = ((window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()));\r\nexport var pointerEvents = document.documentElement.style.pointerEvents === '';\r\n\r\nexport var Support = {\r\n cors: cors,\r\n pointerEvents: pointerEvents\r\n};\r\n\r\nexport default Support;\r\n","export var options = {\r\n attributionWidthOffset: 55\r\n};\r\n\r\nexport default options;\r\n","import { Util, DomUtil } from 'leaflet';\r\nimport { Support } from './Support';\r\n\r\nvar callbacks = 0;\r\n\r\nfunction serialize (params) {\r\n var data = '';\r\n\r\n params.f = params.f || 'json';\r\n\r\n for (var key in params) {\r\n if (params.hasOwnProperty(key)) {\r\n var param = params[key];\r\n var type = Object.prototype.toString.call(param);\r\n var value;\r\n\r\n if (data.length) {\r\n data += '&';\r\n }\r\n\r\n if (type === '[object Array]') {\r\n value = (Object.prototype.toString.call(param[0]) === '[object Object]') ? JSON.stringify(param) : param.join(',');\r\n } else if (type === '[object Object]') {\r\n value = JSON.stringify(param);\r\n } else if (type === '[object Date]') {\r\n value = param.valueOf();\r\n } else {\r\n value = param;\r\n }\r\n\r\n data += encodeURIComponent(key) + '=' + encodeURIComponent(value);\r\n }\r\n }\r\n\r\n return data;\r\n}\r\n\r\nfunction createRequest (callback, context) {\r\n var httpRequest = new window.XMLHttpRequest();\r\n\r\n httpRequest.onerror = function (e) {\r\n httpRequest.onreadystatechange = Util.falseFn;\r\n\r\n callback.call(context, {\r\n error: {\r\n code: 500,\r\n message: 'XMLHttpRequest error'\r\n }\r\n }, null);\r\n };\r\n\r\n httpRequest.onreadystatechange = function () {\r\n var response;\r\n var error;\r\n\r\n if (httpRequest.readyState === 4) {\r\n try {\r\n response = JSON.parse(httpRequest.responseText);\r\n } catch (e) {\r\n response = null;\r\n error = {\r\n code: 500,\r\n message: 'Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error.'\r\n };\r\n }\r\n\r\n if (!error && response.error) {\r\n error = response.error;\r\n response = null;\r\n }\r\n\r\n httpRequest.onerror = Util.falseFn;\r\n\r\n callback.call(context, error, response);\r\n }\r\n };\r\n\r\n httpRequest.ontimeout = function () {\r\n this.onerror();\r\n };\r\n\r\n return httpRequest;\r\n}\r\n\r\nfunction xmlHttpPost (url, params, callback, context) {\r\n var httpRequest = createRequest(callback, context);\r\n httpRequest.open('POST', url);\r\n\r\n if (typeof context !== 'undefined' && context !== null) {\r\n if (typeof context.options !== 'undefined') {\r\n httpRequest.timeout = context.options.timeout;\r\n }\r\n }\r\n httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');\r\n httpRequest.send(serialize(params));\r\n\r\n return httpRequest;\r\n}\r\n\r\nfunction xmlHttpGet (url, params, callback, context) {\r\n var httpRequest = createRequest(callback, context);\r\n httpRequest.open('GET', url + '?' + serialize(params), true);\r\n\r\n if (typeof context !== 'undefined' && context !== null) {\r\n if (typeof context.options !== 'undefined') {\r\n httpRequest.timeout = context.options.timeout;\r\n if (context.options.withCredentials) {\r\n httpRequest.withCredentials = true;\r\n }\r\n }\r\n }\r\n httpRequest.send(null);\r\n\r\n return httpRequest;\r\n}\r\n\r\n// AJAX handlers for CORS (modern browsers) or JSONP (older browsers)\r\nexport function request (url, params, callback, context) {\r\n var paramString = serialize(params);\r\n var httpRequest = createRequest(callback, context);\r\n var requestLength = (url + '?' + paramString).length;\r\n\r\n // ie10/11 require the request be opened before a timeout is applied\r\n if (requestLength <= 2000 && Support.cors) {\r\n httpRequest.open('GET', url + '?' + paramString);\r\n } else if (requestLength > 2000 && Support.cors) {\r\n httpRequest.open('POST', url);\r\n httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');\r\n }\r\n\r\n if (typeof context !== 'undefined' && context !== null) {\r\n if (typeof context.options !== 'undefined') {\r\n httpRequest.timeout = context.options.timeout;\r\n if (context.options.withCredentials) {\r\n httpRequest.withCredentials = true;\r\n }\r\n }\r\n }\r\n\r\n // request is less than 2000 characters and the browser supports CORS, make GET request with XMLHttpRequest\r\n if (requestLength <= 2000 && Support.cors) {\r\n httpRequest.send(null);\r\n\r\n // request is more than 2000 characters and the browser supports CORS, make POST request with XMLHttpRequest\r\n } else if (requestLength > 2000 && Support.cors) {\r\n httpRequest.send(paramString);\r\n\r\n // request is less than 2000 characters and the browser does not support CORS, make a JSONP request\r\n } else if (requestLength <= 2000 && !Support.cors) {\r\n return jsonp(url, params, callback, context);\r\n\r\n // request is longer then 2000 characters and the browser does not support CORS, log a warning\r\n } else {\r\n warn('a request to ' + url + ' was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html');\r\n return;\r\n }\r\n\r\n return httpRequest;\r\n}\r\n\r\nexport function jsonp (url, params, callback, context) {\r\n window._EsriLeafletCallbacks = window._EsriLeafletCallbacks || {};\r\n var callbackId = 'c' + callbacks;\r\n params.callback = 'window._EsriLeafletCallbacks.' + callbackId;\r\n\r\n window._EsriLeafletCallbacks[callbackId] = function (response) {\r\n if (window._EsriLeafletCallbacks[callbackId] !== true) {\r\n var error;\r\n var responseType = Object.prototype.toString.call(response);\r\n\r\n if (!(responseType === '[object Object]' || responseType === '[object Array]')) {\r\n error = {\r\n error: {\r\n code: 500,\r\n message: 'Expected array or object as JSONP response'\r\n }\r\n };\r\n response = null;\r\n }\r\n\r\n if (!error && response.error) {\r\n error = response;\r\n response = null;\r\n }\r\n\r\n callback.call(context, error, response);\r\n window._EsriLeafletCallbacks[callbackId] = true;\r\n }\r\n };\r\n\r\n var script = DomUtil.create('script', null, document.body);\r\n script.type = 'text/javascript';\r\n script.src = url + '?' + serialize(params);\r\n script.id = callbackId;\r\n script.onerror = function (error) {\r\n if (error && window._EsriLeafletCallbacks[callbackId] !== true) {\r\n // Can't get true error code: it can be 404, or 401, or 500\r\n var err = {\r\n error: {\r\n code: 500,\r\n message: 'An unknown error occurred'\r\n }\r\n };\r\n\r\n callback.call(context, err);\r\n window._EsriLeafletCallbacks[callbackId] = true;\r\n }\r\n };\r\n DomUtil.addClass(script, 'esri-leaflet-jsonp');\r\n\r\n callbacks++;\r\n\r\n return {\r\n id: callbackId,\r\n url: script.src,\r\n abort: function () {\r\n window._EsriLeafletCallbacks._callback[callbackId]({\r\n code: 0,\r\n message: 'Request aborted.'\r\n });\r\n }\r\n };\r\n}\r\n\r\nvar get = ((Support.cors) ? xmlHttpGet : jsonp);\r\nget.CORS = xmlHttpGet;\r\nget.JSONP = jsonp;\r\n\r\nexport function warn () {\r\n if (console && console.warn) {\r\n console.warn.apply(console, arguments);\r\n }\r\n}\r\n\r\n// choose the correct AJAX handler depending on CORS support\r\nexport { get };\r\n\r\n// always use XMLHttpRequest for posts\r\nexport { xmlHttpPost as post };\r\n\r\n// export the Request object to call the different handlers for debugging\r\nexport var Request = {\r\n request: request,\r\n get: get,\r\n post: xmlHttpPost\r\n};\r\n\r\nexport default Request;\r\n","/* @preserve\n* @terraformer/arcgis - v2.0.6 - MIT\n* Copyright (c) 2012-2020 Environmental Systems Research Institute, Inc.\n* Mon May 18 2020 14:30:35 GMT-0700 (Pacific Daylight Time)\n*/\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nvar edgeIntersectsEdge = function edgeIntersectsEdge(a1, a2, b1, b2) {\n var uaT = (b2[0] - b1[0]) * (a1[1] - b1[1]) - (b2[1] - b1[1]) * (a1[0] - b1[0]);\n var ubT = (a2[0] - a1[0]) * (a1[1] - b1[1]) - (a2[1] - a1[1]) * (a1[0] - b1[0]);\n var uB = (b2[1] - b1[1]) * (a2[0] - a1[0]) - (b2[0] - b1[0]) * (a2[1] - a1[1]);\n\n if (uB !== 0) {\n var ua = uaT / uB;\n var ub = ubT / uB;\n\n if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {\n return true;\n }\n }\n\n return false;\n};\nvar coordinatesContainPoint = function coordinatesContainPoint(coordinates, point) {\n var contains = false;\n\n for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) {\n if ((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1] || coordinates[j][1] <= point[1] && point[1] < coordinates[i][1]) && point[0] < (coordinates[j][0] - coordinates[i][0]) * (point[1] - coordinates[i][1]) / (coordinates[j][1] - coordinates[i][1]) + coordinates[i][0]) {\n contains = !contains;\n }\n }\n\n return contains;\n};\nvar pointsEqual = function pointsEqual(a, b) {\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n\n return true;\n};\nvar arrayIntersectsArray = function arrayIntersectsArray(a, b) {\n for (var i = 0; i < a.length - 1; i++) {\n for (var j = 0; j < b.length - 1; j++) {\n if (edgeIntersectsEdge(a[i], a[i + 1], b[j], b[j + 1])) {\n return true;\n }\n }\n }\n\n return false;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nvar closeRing = function closeRing(coordinates) {\n if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) {\n coordinates.push(coordinates[0]);\n }\n\n return coordinates;\n}; // determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring\n// or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-\n// points-are-in-clockwise-order\n\nvar ringIsClockwise = function ringIsClockwise(ringToTest) {\n var total = 0;\n var i = 0;\n var rLength = ringToTest.length;\n var pt1 = ringToTest[i];\n var pt2;\n\n for (i; i < rLength - 1; i++) {\n pt2 = ringToTest[i + 1];\n total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);\n pt1 = pt2;\n }\n\n return total >= 0;\n}; // This function ensures that rings are oriented in the right directions\n// from http://jsperf.com/cloning-an-object/2\n\nvar shallowClone = function shallowClone(obj) {\n var target = {};\n\n for (var i in obj) {\n // both arcgis attributes and geojson props are just hardcoded keys\n if (obj.hasOwnProperty(i)) {\n // eslint-disable-line no-prototype-builtins\n target[i] = obj[i];\n }\n }\n\n return target;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nvar coordinatesContainCoordinates = function coordinatesContainCoordinates(outer, inner) {\n var intersects = arrayIntersectsArray(outer, inner);\n var contains = coordinatesContainPoint(outer, inner[0]);\n\n if (!intersects && contains) {\n return true;\n }\n\n return false;\n}; // do any polygons in this array contain any other polygons in this array?\n// used for checking for holes in arcgis rings\n\n\nvar convertRingsToGeoJSON = function convertRingsToGeoJSON(rings) {\n var outerRings = [];\n var holes = [];\n var x; // iterator\n\n var outerRing; // current outer ring being evaluated\n\n var hole; // current hole being evaluated\n // for each ring\n\n for (var r = 0; r < rings.length; r++) {\n var ring = closeRing(rings[r].slice(0));\n\n if (ring.length < 4) {\n continue;\n } // is this ring an outer ring? is it clockwise?\n\n\n if (ringIsClockwise(ring)) {\n var polygon = [ring.slice().reverse()]; // wind outer rings counterclockwise for RFC 7946 compliance\n\n outerRings.push(polygon); // push to outer rings\n } else {\n holes.push(ring.slice().reverse()); // wind inner rings clockwise for RFC 7946 compliance\n }\n }\n\n var uncontainedHoles = []; // while there are holes left...\n\n while (holes.length) {\n // pop a hole off out stack\n hole = holes.pop(); // loop over all outer rings and see if they contain our hole.\n\n var contained = false;\n\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n\n if (coordinatesContainCoordinates(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n contained = true;\n break;\n }\n } // ring is not contained in any outer ring\n // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320\n\n\n if (!contained) {\n uncontainedHoles.push(hole);\n }\n } // if we couldn't match any holes using contains we can try intersects...\n\n\n while (uncontainedHoles.length) {\n // pop a hole off out stack\n hole = uncontainedHoles.pop(); // loop over all outer rings and see if any intersect our hole.\n\n var intersects = false;\n\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n\n if (arrayIntersectsArray(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n intersects = true;\n break;\n }\n }\n\n if (!intersects) {\n outerRings.push([hole.reverse()]);\n }\n }\n\n if (outerRings.length === 1) {\n return {\n type: 'Polygon',\n coordinates: outerRings[0]\n };\n } else {\n return {\n type: 'MultiPolygon',\n coordinates: outerRings\n };\n }\n};\n\nvar getId = function getId(attributes, idAttribute) {\n var keys = idAttribute ? [idAttribute, 'OBJECTID', 'FID'] : ['OBJECTID', 'FID'];\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key in attributes && (typeof attributes[key] === 'string' || typeof attributes[key] === 'number')) {\n return attributes[key];\n }\n }\n\n throw Error('No valid id attribute found');\n};\n\nvar arcgisToGeoJSON = function arcgisToGeoJSON(arcgis, idAttribute) {\n var geojson = {};\n\n if (arcgis.features) {\n geojson.type = 'FeatureCollection';\n geojson.features = [];\n\n for (var i = 0; i < arcgis.features.length; i++) {\n geojson.features.push(arcgisToGeoJSON(arcgis.features[i], idAttribute));\n }\n }\n\n if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') {\n geojson.type = 'Point';\n geojson.coordinates = [arcgis.x, arcgis.y];\n\n if (typeof arcgis.z === 'number') {\n geojson.coordinates.push(arcgis.z);\n }\n }\n\n if (arcgis.points) {\n geojson.type = 'MultiPoint';\n geojson.coordinates = arcgis.points.slice(0);\n }\n\n if (arcgis.paths) {\n if (arcgis.paths.length === 1) {\n geojson.type = 'LineString';\n geojson.coordinates = arcgis.paths[0].slice(0);\n } else {\n geojson.type = 'MultiLineString';\n geojson.coordinates = arcgis.paths.slice(0);\n }\n }\n\n if (arcgis.rings) {\n geojson = convertRingsToGeoJSON(arcgis.rings.slice(0));\n }\n\n if (typeof arcgis.xmin === 'number' && typeof arcgis.ymin === 'number' && typeof arcgis.xmax === 'number' && typeof arcgis.ymax === 'number') {\n geojson.type = 'Polygon';\n geojson.coordinates = [[[arcgis.xmax, arcgis.ymax], [arcgis.xmin, arcgis.ymax], [arcgis.xmin, arcgis.ymin], [arcgis.xmax, arcgis.ymin], [arcgis.xmax, arcgis.ymax]]];\n }\n\n if (arcgis.geometry || arcgis.attributes) {\n geojson.type = 'Feature';\n geojson.geometry = arcgis.geometry ? arcgisToGeoJSON(arcgis.geometry) : null;\n geojson.properties = arcgis.attributes ? shallowClone(arcgis.attributes) : null;\n\n if (arcgis.attributes) {\n try {\n geojson.id = getId(arcgis.attributes, idAttribute);\n } catch (err) {// don't set an id\n }\n }\n } // if no valid geometry was encountered\n\n\n if (JSON.stringify(geojson.geometry) === JSON.stringify({})) {\n geojson.geometry = null;\n }\n\n if (arcgis.spatialReference && arcgis.spatialReference.wkid && arcgis.spatialReference.wkid !== 4326) {\n console.warn('Object converted in non-standard crs - ' + JSON.stringify(arcgis.spatialReference));\n }\n\n return geojson;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n// outer rings are clockwise, holes are counterclockwise\n// used for converting GeoJSON Polygons to ArcGIS Polygons\n\nvar orientRings = function orientRings(poly) {\n var output = [];\n var polygon = poly.slice(0);\n var outerRing = closeRing(polygon.shift().slice(0));\n\n if (outerRing.length >= 4) {\n if (!ringIsClockwise(outerRing)) {\n outerRing.reverse();\n }\n\n output.push(outerRing);\n\n for (var i = 0; i < polygon.length; i++) {\n var hole = closeRing(polygon[i].slice(0));\n\n if (hole.length >= 4) {\n if (ringIsClockwise(hole)) {\n hole.reverse();\n }\n\n output.push(hole);\n }\n }\n }\n\n return output;\n}; // This function flattens holes in multipolygons to one array of polygons\n// used for converting GeoJSON Polygons to ArcGIS Polygons\n\n\nvar flattenMultiPolygonRings = function flattenMultiPolygonRings(rings) {\n var output = [];\n\n for (var i = 0; i < rings.length; i++) {\n var polygon = orientRings(rings[i]);\n\n for (var x = polygon.length - 1; x >= 0; x--) {\n var ring = polygon[x].slice(0);\n output.push(ring);\n }\n }\n\n return output;\n};\n\nvar geojsonToArcGIS = function geojsonToArcGIS(geojson, idAttribute) {\n idAttribute = idAttribute || 'OBJECTID';\n var spatialReference = {\n wkid: 4326\n };\n var result = {};\n var i;\n\n switch (geojson.type) {\n case 'Point':\n result.x = geojson.coordinates[0];\n result.y = geojson.coordinates[1];\n result.spatialReference = spatialReference;\n break;\n\n case 'MultiPoint':\n result.points = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n\n case 'LineString':\n result.paths = [geojson.coordinates.slice(0)];\n result.spatialReference = spatialReference;\n break;\n\n case 'MultiLineString':\n result.paths = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n\n case 'Polygon':\n result.rings = orientRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n\n case 'MultiPolygon':\n result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n\n case 'Feature':\n if (geojson.geometry) {\n result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);\n }\n\n result.attributes = geojson.properties ? shallowClone(geojson.properties) : {};\n\n if (geojson.id) {\n result.attributes[idAttribute] = geojson.id;\n }\n\n break;\n\n case 'FeatureCollection':\n result = [];\n\n for (i = 0; i < geojson.features.length; i++) {\n result.push(geojsonToArcGIS(geojson.features[i], idAttribute));\n }\n\n break;\n\n case 'GeometryCollection':\n result = [];\n\n for (i = 0; i < geojson.geometries.length; i++) {\n result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute));\n }\n\n break;\n }\n\n return result;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nexport { arcgisToGeoJSON, geojsonToArcGIS };\n","import { latLng, latLngBounds, LatLng, LatLngBounds, Util, DomUtil, GeoJSON } from 'leaflet';\r\nimport { request, warn } from './Request';\r\nimport { options } from './Options';\r\nimport { Support } from './Support';\r\n\r\nimport {\r\n geojsonToArcGIS as g2a,\r\n arcgisToGeoJSON as a2g\r\n} from '@terraformer/arcgis';\r\n\r\nvar BASE_LEAFLET_ATTRIBUTION_STRING = '<a href=\"http://leafletjs.com\" title=\"A JS library for interactive maps\">Leaflet</a>';\r\nvar POWERED_BY_ESRI_ATTRIBUTION_STRING = 'Powered by <a href=\"https://www.esri.com\">Esri</a>';\r\n\r\nexport function geojsonToArcGIS (geojson, idAttr) {\r\n return g2a(geojson, idAttr);\r\n}\r\n\r\nexport function arcgisToGeoJSON (arcgis, idAttr) {\r\n return a2g(arcgis, idAttr);\r\n}\r\n\r\n// convert an extent (ArcGIS) to LatLngBounds (Leaflet)\r\nexport function extentToBounds (extent) {\r\n // \"NaN\" coordinates from ArcGIS Server indicate a null geometry\r\n if (extent.xmin !== 'NaN' && extent.ymin !== 'NaN' && extent.xmax !== 'NaN' && extent.ymax !== 'NaN') {\r\n var sw = latLng(extent.ymin, extent.xmin);\r\n var ne = latLng(extent.ymax, extent.xmax);\r\n return latLngBounds(sw, ne);\r\n } else {\r\n return null;\r\n }\r\n}\r\n\r\n// convert an LatLngBounds (Leaflet) to extent (ArcGIS)\r\nexport function boundsToExtent (bounds) {\r\n bounds = latLngBounds(bounds);\r\n return {\r\n 'xmin': bounds.getSouthWest().lng,\r\n 'ymin': bounds.getSouthWest().lat,\r\n 'xmax': bounds.getNorthEast().lng,\r\n 'ymax': bounds.getNorthEast().lat,\r\n 'spatialReference': {\r\n 'wkid': 4326\r\n }\r\n };\r\n}\r\n\r\nvar knownFieldNames = /^(OBJECTID|FID|OID|ID)$/i;\r\n\r\n// Attempts to find the ID Field from response\r\nexport function _findIdAttributeFromResponse (response) {\r\n var result;\r\n\r\n if (response.objectIdFieldName) {\r\n // Find Id Field directly\r\n result = response.objectIdFieldName;\r\n } else if (response.fields) {\r\n // Find ID Field based on field type\r\n for (var j = 0; j <= response.fields.length - 1; j++) {\r\n if (response.fields[j].type === 'esriFieldTypeOID') {\r\n result = response.fields[j].name;\r\n break;\r\n }\r\n }\r\n if (!result) {\r\n // If no field was marked as being the esriFieldTypeOID try well known field names\r\n for (j = 0; j <= response.fields.length - 1; j++) {\r\n if (response.fields[j].name.match(knownFieldNames)) {\r\n result = response.fields[j].name;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n}\r\n\r\n// This is the 'last' resort, find the Id field from the specified feature\r\nexport function _findIdAttributeFromFeature (feature) {\r\n for (var key in feature.attributes) {\r\n if (key.match(knownFieldNames)) {\r\n return key;\r\n }\r\n }\r\n}\r\n\r\nexport function responseToFeatureCollection (response, idAttribute) {\r\n var objectIdField;\r\n var features = response.features || response.results;\r\n var count = features && features.length;\r\n\r\n if (idAttribute) {\r\n objectIdField = idAttribute;\r\n } else {\r\n objectIdField = _findIdAttributeFromResponse(response);\r\n }\r\n\r\n var featureCollection = {\r\n type: 'FeatureCollection',\r\n features: []\r\n };\r\n\r\n if (count) {\r\n for (var i = features.length - 1; i >= 0; i--) {\r\n var feature = arcgisToGeoJSON(features[i], objectIdField || _findIdAttributeFromFeature(features[i]));\r\n featureCollection.features.push(feature);\r\n }\r\n }\r\n\r\n return featureCollection;\r\n}\r\n\r\n // trim url whitespace and add a trailing slash if needed\r\nexport function cleanUrl (url) {\r\n // trim leading and trailing spaces, but not spaces inside the url\r\n url = Util.trim(url);\r\n\r\n // add a trailing slash to the url if the user omitted it\r\n if (url[url.length - 1] !== '/') {\r\n url += '/';\r\n }\r\n\r\n return url;\r\n}\r\n\r\n/* Extract url params if any and store them in requestParams attribute.\r\n Return the options params updated */\r\nexport function getUrlParams (options) {\r\n if (options.url.indexOf('?') !== -1) {\r\n options.requestParams = options.requestParams || {};\r\n var queryString = options.url.substring(options.url.indexOf('?') + 1);\r\n options.url = options.url.split('?')[0];\r\n options.requestParams = JSON.parse('{\"' + decodeURI(queryString).replace(/\"/g, '\\\\\"').replace(/&/g, '\",\"').replace(/=/g, '\":\"') + '\"}');\r\n }\r\n options.url = cleanUrl(options.url.split('?')[0]);\r\n return options;\r\n}\r\n\r\nexport function isArcgisOnline (url) {\r\n /* hosted feature services support geojson as an output format\r\n utility.arcgis.com services are proxied from a variety of ArcGIS Server vintages, and may not */\r\n return (/^(?!.*utility\\.arcgis\\.com).*\\.arcgis\\.com.*FeatureServer/i).test(url);\r\n}\r\n\r\nexport function geojsonTypeToArcGIS (geoJsonType) {\r\n var arcgisGeometryType;\r\n switch (geoJsonType) {\r\n case 'Point':\r\n arcgisGeometryType = 'esriGeometryPoint';\r\n break;\r\n case 'MultiPoint':\r\n arcgisGeometryType = 'esriGeometryMultipoint';\r\n break;\r\n case 'LineString':\r\n arcgisGeometryType = 'esriGeometryPolyline';\r\n break;\r\n case 'MultiLineString':\r\n arcgisGeometryType = 'esriGeometryPolyline';\r\n break;\r\n case 'Polygon':\r\n arcgisGeometryType = 'esriGeometryPolygon';\r\n break;\r\n case 'MultiPolygon':\r\n arcgisGeometryType = 'esriGeometryPolygon';\r\n break;\r\n }\r\n\r\n return arcgisGeometryType;\r\n}\r\n\r\nexport function calcAttributionWidth (map) {\r\n // either crop at 55px or user defined buffer\r\n return (map.getSize().x - options.attributionWidthOffset) + 'px';\r\n}\r\n\r\nexport function setEsriAttribution (map) {\r\n if (!map.attributionControl) {\r\n return;\r\n }\r\n\r\n if (!map.attributionControl._esriAttributionLayerCount) {\r\n map.attributionControl._esriAttributionLayerCount = 0;\r\n }\r\n\r\n if (map.attributionControl._esriAttributionLayerCount === 0) {\r\n // Dynamically creating the CSS rules, only run this once per page load:\r\n if (!map.attributionControl._esriAttributionAddedOnce) {\r\n var hoverAttributionStyle = document.createElement('style');\r\n hoverAttributionStyle.type = 'text/css';\r\n hoverAttributionStyle.innerHTML = '.esri-truncated-attribution:hover {' +\r\n 'white-space: normal;' +\r\n '}';\r\n document.getElementsByTagName('head')[0].appendChild(hoverAttributionStyle);\r\n\r\n // define a new css class in JS to trim attribution into a single line\r\n var attributionStyle = document.createElement('style');\r\n attributionStyle.type = 'text/css';\r\n attributionStyle.innerHTML = '.esri-truncated-attribution {' +\r\n 'vertical-align: -3px;' +\r\n 'white-space: nowrap;' +\r\n 'overflow: hidden;' +\r\n 'text-overflow: ellipsis;' +\r\n 'display: inline-block;' +\r\n 'transition: 0s white-space;' +\r\n 'transition-delay: 1s;' +\r\n 'max-width: ' + calcAttributionWidth(map) + ';' +\r\n '}';\r\n document.getElementsByTagName('head')[0].appendChild(attributionStyle);\r\n\r\n // update the width used to truncate when the map itself is resized\r\n map.on('resize', function (e) {\r\n if (map.attributionControl) {\r\n map.attributionControl._container.style.maxWidth = calcAttributionWidth(e.target);\r\n }\r\n });\r\n\r\n map.attributionControl._esriAttributionAddedOnce = true;\r\n }\r\n\r\n map.attributionControl.setPrefix(BASE_LEAFLET_ATTRIBUTION_STRING + ' | ' + POWERED_BY_ESRI_ATTRIBUTION_STRING);\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution:hover');\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution');\r\n }\r\n\r\n // Track the number of esri-leaflet layers that are on the map so we can know when we can remove the attribution (below in removeEsriAttribution)\r\n map.attributionControl._esriAttributionLayerCount = map.attributionControl._esriAttributionLayerCount + 1;\r\n}\r\n\r\nexport function removeEsriAttribution (map) {\r\n if (!map.attributionControl) {\r\n return;\r\n }\r\n\r\n // Only remove the attribution if we're about to remove the LAST esri-leaflet layer (_esriAttributionLayerCount)\r\n if (map.attributionControl._esriAttributionLayerCount && map.attributionControl._esriAttributionLayerCount === 1) {\r\n map.attributionControl.setPrefix(BASE_LEAFLET_ATTRIBUTION_STRING);\r\n DomUtil.removeClass(map.attributionControl._container, 'esri-truncated-attribution:hover');\r\n DomUtil.removeClass(map.attributionControl._container, 'esri-truncated-attribution');\r\n }\r\n map.attributionControl._esriAttributionLayerCount = map.attributionControl._esriAttributionLayerCount - 1;\r\n}\r\n\r\nexport function _setGeometry (geometry) {\r\n var params = {\r\n geometry: null,\r\n geometryType: null\r\n };\r\n\r\n // convert bounds to extent and finish\r\n if (geometry instanceof LatLngBounds) {\r\n // set geometry + geometryType\r\n params.geometry = boundsToExtent(geometry);\r\n params.geometryType = 'esriGeometryEnvelope';\r\n return params;\r\n }\r\n\r\n // convert L.Marker > L.LatLng\r\n if (geometry.getLatLng) {\r\n geometry = geometry.getLatLng();\r\n }\r\n\r\n // convert L.LatLng to a geojson point and continue;\r\n if (geometry instanceof LatLng) {\r\n geometry = {\r\n type: 'Point',\r\n coordinates: [geometry.lng, geometry.lat]\r\n };\r\n }\r\n\r\n // handle L.GeoJSON, pull out the first geometry\r\n if (geometry instanceof GeoJSON) {\r\n // reassign geometry to the GeoJSON value (we are assuming that only one feature is present)\r\n geometry = geometry.getLayers()[0].feature.geometry;\r\n params.geometry = geojsonToArcGIS(geometry);\r\n params.geometryType = geojsonTypeToArcGIS(geometry.type);\r\n }\r\n\r\n // Handle L.Polyline and L.Polygon\r\n if (geometry.toGeoJSON) {\r\n geometry = geometry.toGeoJSON();\r\n }\r\n\r\n // handle GeoJSON feature by pulling out the geometry\r\n if (geometry.type === 'Feature') {\r\n // get the geometry of the geojson feature\r\n geometry = geometry.geometry;\r\n }\r\n\r\n // confirm that our GeoJSON is a point, line or polygon\r\n if (geometry.type === 'Point' || geometry.type === 'LineString' || geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {\r\n params.geometry = geojsonToArcGIS(geometry);\r\n params.geometryType = geojsonTypeToArcGIS(geometry.type);\r\n return params;\r\n }\r\n\r\n // warn the user if we havn't found an appropriate object\r\n warn('invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object');\r\n\r\n return;\r\n}\r\n\r\nexport function _getAttributionData (url, map) {\r\n if (Support.cors) {\r\n request(url, {}, Util.bind(function (error, attributions) {\r\n if (error) { return; }\r\n map._esriAttributions = [];\r\n for (var c = 0; c < attributions.contributors.length; c++) {\r\n var contributor = attributions.contributors[c];\r\n\r\n for (var i = 0; i < contributor.coverageAreas.length; i++) {\r\n var coverageArea = contributor.coverageAreas[i];\r\n var southWest = latLng(coverageArea.bbox[0], coverageArea.bbox[1]);\r\n var northEast = latLng(coverageArea.bbox[2], coverageArea.bbox[3]);\r\n map._esriAttributions.push({\r\n attribution: contributor.attribution,\r\n score: coverageArea.score,\r\n bounds: latLngBounds(southWest, northEast),\r\n minZoom: coverageArea.zoomMin,\r\n maxZoom: coverageArea.zoomMax\r\n });\r\n }\r\n }\r\n\r\n map._esriAttributions.sort(function (a, b) {\r\n return b.score - a.score;\r\n });\r\n\r\n // pass the same argument as the map's 'moveend' event\r\n var obj = { target: map };\r\n _updateMapAttribution(obj);\r\n }, this));\r\n }\r\n}\r\n\r\nexport function _updateMapAttribution (evt) {\r\n var map = evt.target;\r\n var oldAttributions = map._esriAttributions;\r\n\r\n if (!map || !map.attributionControl) return;\r\n\r\n var attributionElement = map.attributionControl._container.querySelector('.esri-dynamic-attribution');\r\n\r\n if (attributionElement && oldAttributions) {\r\n var newAttributions = '';\r\n var bounds = map.getBounds();\r\n var wrappedBounds = latLngBounds(\r\n bounds.getSouthWest().wrap(),\r\n bounds.getNorthEast().wrap()\r\n );\r\n var zoom = map.getZoom();\r\n\r\n for (var i = 0; i < oldAttributions.length; i++) {\r\n var attribution = oldAttributions[i];\r\n var text = attribution.attribution;\r\n\r\n if (!newAttributions.match(text) && attribution.bounds.intersects(wrappedBounds) && zoom >= attribution.minZoom && zoom <= attribution.maxZoom) {\r\n newAttributions += (', ' + text);\r\n }\r\n }\r\n\r\n newAttributions = newAttributions.substr(2);\r\n attributionElement.innerHTML = newAttributions;\r\n attributionElement.style.maxWidth = calcAttributionWidth(map);\r\n\r\n map.fire('attributionupdated', {\r\n attribution: newAttributions\r\n });\r\n }\r\n}\r\n\r\n// for backwards compatibility\r\nexport { warn };\r\n\r\nexport var EsriUtil = {\r\n warn: warn,\r\n cleanUrl: cleanUrl,\r\n getUrlParams: getUrlParams,\r\n isArcgisOnline: isArcgisOnline,\r\n geojsonTypeToArcGIS: geojsonTypeToArcGIS,\r\n responseToFeatureCollection: responseToFeatureCollection,\r\n geojsonToArcGIS: geojsonToArcGIS,\r\n arcgisToGeoJSON: arcgisToGeoJSON,\r\n boundsToExtent: boundsToExtent,\r\n extentToBounds: extentToBounds,\r\n calcAttributionWidth: calcAttributionWidth,\r\n setEsriAttribution: setEsriAttribution,\r\n _setGeometry: _setGeometry,\r\n _getAttributionData: _getAttributionData,\r\n _updateMapAttribution: _updateMapAttribution,\r\n _findIdAttributeFromFeature: _findIdAttributeFromFeature,\r\n _findIdAttributeFromResponse: _findIdAttributeFromResponse\r\n};\r\n\r\nexport default EsriUtil;\r\n","import { Class, Util } from 'leaflet';\r\nimport {cors} from '../Support';\r\nimport { cleanUrl, getUrlParams } from '../Util';\r\nimport Request from '../Request';\r\n\r\nexport var Task = Class.extend({\r\n\r\n options: {\r\n proxy: false,\r\n useCors: cors\r\n },\r\n\r\n // Generate a method for each methodName:paramName in the setters for this task.\r\n generateSetter: function (param, context) {\r\n return Util.bind(function (value) {\r\n this.params[param] = value;\r\n return this;\r\n }, context);\r\n },\r\n\r\n initialize: function (endpoint) {\r\n // endpoint can be either a url (and options) for an ArcGIS Rest Service or an instance of EsriLeaflet.Service\r\n if (endpoint.request && endpoint.options) {\r\n this._service = endpoint;\r\n Util.setOptions(this, endpoint.options);\r\n } else {\r\n Util.setOptions(this, endpoint);\r\n this.options.url = cleanUrl(endpoint.url);\r\n }\r\n\r\n // clone default params into this object\r\n this.params = Util.extend({}, this.params || {});\r\n\r\n // generate setter methods based on the setters object implimented a child class\r\n if (this.setters) {\r\n for (var setter in this.setters) {\r\n var param = this.setters[setter];\r\n this[setter] = this.generateSetter(param, this);\r\n }\r\n }\r\n },\r\n\r\n token: function (token) {\r\n if (this._service) {\r\n this._service.authenticate(token);\r\n } else {\r\n this.params.token = token;\r\n }\r\n return this;\r\n },\r\n\r\n apikey: function (apikey) {\r\n return this.token(apikey);\r\n },\r\n\r\n // ArcGIS Server Find/Identify 10.5+\r\n format: function (boolean) {\r\n // use double negative to expose a more intuitive positive method name\r\n this.params.returnUnformattedValues = !boolean;\r\n return this;\r\n },\r\n\r\n request: function (callback, context) {\r\n if (this.options.requestParams) {\r\n Util.extend(this.params, this.options.requestParams);\r\n }\r\n if (this._service) {\r\n return this._service.request(this.path, this.params, callback, context);\r\n }\r\n\r\n return this._request('request', this.path, this.params, callback, context);\r\n },\r\n\r\n _request: function (method, path, params, callback, context) {\r\n var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\r\n\r\n if ((method === 'get' || method === 'request') && !this.options.useCors) {\r\n return Request.get.JSONP(url, params, callback, context);\r\n }\r\n\r\n return Request[method](url, params, callback, context);\r\n }\r\n});\r\n\r\nexport function task (options) {\r\n options = getUrlParams(options);\r\n return new Task(options);\r\n}\r\n\r\nexport default task;\r\n","import { point, latLng } from 'leaflet';\r\nimport { Task } from './Task';\r\nimport {\r\n warn,\r\n responseToFeatureCollection,\r\n isArcgisOnline,\r\n extentToBounds,\r\n _setGeometry\r\n} from '../Util';\r\n\r\nexport var Query = Task.extend({\r\n setters: {\r\n 'offset': 'resultOffset',\r\n 'limit': 'resultRecordCount',\r\n 'fields': 'outFields',\r\n 'precision': 'geometryPrecision',\r\n 'featureIds': 'objectIds',\r\n 'returnGeometry': 'returnGeometry',\r\n 'returnM': 'returnM',\r\n 'transform': 'datumTransformation',\r\n 'token': 'token'\r\n },\r\n\r\n path: 'query',\r\n\r\n params: {\r\n returnGeometry: true,\r\n where: '1=1',\r\n outSR: 4326,\r\n outFields: '*'\r\n },\r\n\r\n // Returns a feature if its shape is wholly contained within the search geometry. Valid for all shape type combinations.\r\n within: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelContains'; // to the REST api this reads geometry **contains** layer\r\n return this;\r\n },\r\n\r\n // Returns a feature if any spatial relationship is found. Applies to all shape type combinations.\r\n intersects: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelIntersects';\r\n return this;\r\n },\r\n\r\n // Returns a feature if its shape wholly contains the search geometry. Valid for all shape type combinations.\r\n contains: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelWithin'; // to the REST api this reads geometry **within** layer\r\n return this;\r\n },\r\n\r\n // Returns a feature if the intersection of the interiors of the two shapes is not empty and has a lower dimension than the maximum dimension of the two shapes. Two lines that share an endpoint in common do not cross. Valid for Line/Line, Line/Area, Multi-point/Area, and Multi-point/Line shape type combinations.\r\n crosses: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelCrosses';\r\n return this;\r\n },\r\n\r\n // Returns a feature if the two shapes share a common boundary. However, the intersection of the interiors of the two shapes must be empty. In the Point/Line case, the point may touch an endpoint only of the line. Applies to all combinations except Point/Point.\r\n touches: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelTouches';\r\n return this;\r\n },\r\n\r\n // Returns a feature if the intersection of the two shapes results in an object of the same dimension, but different from both of the shapes. Applies to Area/Area, Line/Line, and Multi-point/Multi-point shape type combinations.\r\n overlaps: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelOverlaps';\r\n return this;\r\n },\r\n\r\n // Returns a feature if the envelope of the two shapes intersects.\r\n bboxIntersects: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelEnvelopeIntersects';\r\n return this;\r\n },\r\n\r\n // if someone can help decipher the ArcObjects explanation and translate to plain speak, we should mention this method in the doc\r\n indexIntersects: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelIndexIntersects'; // Returns a feature if the envelope of the query geometry intersects the index entry for the target geometry\r\n return this;\r\n },\r\n\r\n // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online\r\n nearby: function (latlng, radius) {\r\n latlng = latLng(latlng);\r\n this.params.geometry = [latlng.lng, latlng.lat];\r\n this.params.geometryType = 'esriGeometryPoint';\r\n this.params.spatialRel = 'esriSpatialRelIntersects';\r\n this.params.units = 'esriSRUnit_Meter';\r\n this.params.distance = radius;\r\n this.params.inSR = 4326;\r\n return this;\r\n },\r\n\r\n where: function (string) {\r\n // instead of converting double-quotes to single quotes, pass as is, and provide a more informative message if a 400 is encountered\r\n this.params.where = string;\r\n return this;\r\n },\r\n\r\n between: function (start, end) {\r\n this.params.time = [start.valueOf(), end.valueOf()];\r\n return this;\r\n },\r\n\r\n simplify: function (map, factor) {\r\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\r\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\r\n return this;\r\n },\r\n\r\n orderBy: function (fieldName, order) {\r\n order = order || 'ASC';\r\n this.params.orderByFields = (this.params.orderByFields) ? this.params.orderByFields + ',' : '';\r\n this.params.orderByFields += ([fieldName, order]).join(' ');\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n this._cleanParams();\r\n\r\n // services hosted on ArcGIS Online and ArcGIS Server 10.3.1+ support requesting geojson directly\r\n if (this.options.isModern || (isArcgisOnline(this.options.url) && this.options.isModern === undefined)) {\r\n this.params.f = 'geojson';\r\n\r\n return this.request(function (error, response) {\r\n this._trapSQLerrors(error);\r\n callback.call(context, error, response, response);\r\n }, this);\r\n\r\n // otherwise convert it in the callback then pass it on\r\n } else {\r\n return this.request(function (error, response) {\r\n this._trapSQLerrors(error);\r\n callback.call(context, error, (response && responseToFeatureCollection(response)), response);\r\n }, this);\r\n }\r\n },\r\n\r\n count: function (callback, context) {\r\n this._cleanParams();\r\n this.params.returnCountOnly = true;\r\n return this.request(function (error, response) {\r\n callback.call(this, error, (response && response.count), response);\r\n }, context);\r\n },\r\n\r\n ids: function (callback, context) {\r\n this._cleanParams();\r\n this.params.returnIdsOnly = true;\r\n return this.request(function (error, response) {\r\n callback.call(this, error, (response && response.objectIds), response);\r\n }, context);\r\n },\r\n\r\n // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online\r\n bounds: function (callback, context) {\r\n this._cleanParams();\r\n this.params.returnExtentOnly = true;\r\n return this.request(function (error, response) {\r\n if (response && response.extent && extentToBounds(response.extent)) {\r\n callback.call(context, error, extentToBounds(response.extent), response);\r\n } else {\r\n error = {\r\n message: 'Invalid Bounds'\r\n };\r\n callback.call(context, error, null, response);\r\n }\r\n }, context);\r\n },\r\n\r\n distinct: function () {\r\n // geometry must be omitted for queries requesting distinct values\r\n this.params.returnGeometry = false;\r\n this.params.returnDistinctValues = true;\r\n return this;\r\n },\r\n\r\n // only valid for image services\r\n pixelSize: function (rawPoint) {\r\n var castPoint = point(rawPoint);\r\n this.params.pixelSize = [castPoint.x, castPoint.y];\r\n return this;\r\n },\r\n\r\n // only valid for map services\r\n layer: function (layer) {\r\n this.path = layer + '/query';\r\n return this;\r\n },\r\n\r\n _trapSQLerrors: function (error) {\r\n if (error) {\r\n if (error.code === '400') {\r\n warn('one common syntax error in query requests is encasing string values in double quotes instead of single quotes');\r\n }\r\n }\r\n },\r\n\r\n _cleanParams: function () {\r\n delete this.params.returnIdsOnly;\r\n delete this.params.returnExtentOnly;\r\n delete this.params.returnCountOnly;\r\n },\r\n\r\n _setGeometryParams: function (geometry) {\r\n this.params.inSR = 4326;\r\n var converted = _setGeometry(geometry);\r\n this.params.geometry = converted.geometry;\r\n this.params.geometryType = converted.geometryType;\r\n }\r\n\r\n});\r\n\r\nexport function query (options) {\r\n return new Query(options);\r\n}\r\n\r\nexport default query;\r\n","import { Task } from './Task';\r\nimport { responseToFeatureCollection } from '../Util';\r\n\r\nexport var Find = Task.extend({\r\n setters: {\r\n // method name > param name\r\n 'contains': 'contains',\r\n 'text': 'searchText',\r\n 'fields': 'searchFields', // denote an array or single string\r\n 'spatialReference': 'sr',\r\n 'sr': 'sr',\r\n 'layers': 'layers',\r\n 'returnGeometry': 'returnGeometry',\r\n 'maxAllowableOffset': 'maxAllowableOffset',\r\n 'precision': 'geometryPrecision',\r\n 'dynamicLayers': 'dynamicLayers',\r\n 'returnZ': 'returnZ',\r\n 'returnM': 'returnM',\r\n 'gdbVersion': 'gdbVersion',\r\n // skipped implementing this (for now) because the REST service implementation isnt consistent between operations\r\n // 'transform': 'datumTransformations',\r\n 'token': 'token'\r\n },\r\n\r\n path: 'find',\r\n\r\n params: {\r\n sr: 4326,\r\n contains: true,\r\n returnGeometry: true,\r\n returnZ: true,\r\n returnM: false\r\n },\r\n\r\n layerDefs: function (id, where) {\r\n this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\r\n this.params.layerDefs += ([id, where]).join(':');\r\n return this;\r\n },\r\n\r\n simplify: function (map, factor) {\r\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\r\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n return this.request(function (error, response) {\r\n callback.call(context, error, (response && responseToFeatureCollection(response)), response);\r\n }, context);\r\n }\r\n});\r\n\r\nexport function find (options) {\r\n return new Find(options);\r\n}\r\n\r\nexport default find;\r\n","import { Task } from './Task';\r\n\r\nexport var Identify = Task.extend({\r\n path: 'identify',\r\n\r\n between: function (start, end) {\r\n this.params.time = [start.valueOf(), end.valueOf()];\r\n return this;\r\n }\r\n});\r\n\r\nexport function identify (options) {\r\n return new Identify(options);\r\n}\r\n\r\nexport default identify;\r\n","import { latLng } from 'leaflet';\r\nimport { Identify } from './Identify';\r\nimport { responseToFeatureCollection,\r\n boundsToExtent,\r\n _setGeometry\r\n} from '../Util';\r\n\r\nexport var IdentifyFeatures = Identify.extend({\r\n setters: {\r\n 'layers': 'layers',\r\n 'precision': 'geometryPrecision',\r\n 'tolerance': 'tolerance',\r\n // skipped implementing this (for now) because the REST service implementation isnt consistent between operations.\r\n // 'transform': 'datumTransformations'\r\n 'returnGeometry': 'returnGeometry'\r\n },\r\n\r\n params: {\r\n sr: 4326,\r\n layers: 'all',\r\n tolerance: 3,\r\n returnGeometry: true\r\n },\r\n\r\n on: function (map) {\r\n var extent = boundsToExtent(map.getBounds());\r\n var size = map.getSize();\r\n this.params.imageDisplay = [size.x, size.y, 96];\r\n this.params.mapExtent = [extent.xmin, extent.ymin, extent.xmax, extent.ymax];\r\n return this;\r\n },\r\n\r\n at: function (geometry) {\r\n // cast lat, long pairs in raw array form manually\r\n if (geometry.length === 2) {\r\n geometry = latLng(geometry);\r\n }\r\n this._setGeometryParams(geometry);\r\n return this;\r\n },\r\n\r\n layerDef: function (id, where) {\r\n this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\r\n this.params.layerDefs += ([id, where]).join(':');\r\n return this;\r\n },\r\n\r\n simplify: function (map, factor) {\r\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\r\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n return this.request(function (error, response) {\r\n // immediately invoke with an error\r\n if (error) {\r\n callback.call(context, error, undefined, response);\r\n return;\r\n\r\n // ok no error lets just assume we have features...\r\n } else {\r\n var featureCollection = responseToFeatureCollection(response);\r\n response.results = response.results.reverse();\r\n for (var i = 0; i < featureCollection.features.length; i++) {\r\n var feature = featureCollection.features[i];\r\n feature.layerId = response.results[i].layerId;\r\n }\r\n callback.call(context, undefined, featureCollection, response);\r\n }\r\n });\r\n },\r\n\r\n _setGeometryParams: function (geometry) {\r\n var converted = _setGeometry(geometry);\r\n this.params.geometry = converted.geometry;\r\n this.params.geometryType = converted.geometryType;\r\n }\r\n});\r\n\r\nexport function identifyFeatures (options) {\r\n return new IdentifyFeatures(options);\r\n}\r\n\r\nexport default identifyFeatures;\r\n","import { latLng } from 'leaflet';\r\nimport { Identify } from './Identify';\r\nimport { responseToFeatureCollection } from '../Util';\r\n\r\nexport var IdentifyImage = Identify.extend({\r\n setters: {\r\n 'setMosaicRule': 'mosaicRule',\r\n 'setRenderingRule': 'renderingRule',\r\n 'setPixelSize': 'pixelSize',\r\n 'returnCatalogItems': 'returnCatalogItems',\r\n 'returnGeometry': 'returnGeometry'\r\n },\r\n\r\n params: {\r\n returnGeometry: false\r\n },\r\n\r\n at: function (latlng) {\r\n latlng = latLng(latlng);\r\n this.params.geometry = JSON.stringify({\r\n x: latlng.lng,\r\n y: latlng.lat,\r\n spatialReference: {\r\n wkid: 4326\r\n }\r\n });\r\n this.params.geometryType = 'esriGeometryPoint';\r\n return this;\r\n },\r\n\r\n getMosaicRule: function () {\r\n return this.params.mosaicRule;\r\n },\r\n\r\n getRenderingRule: function () {\r\n return this.params.renderingRule;\r\n },\r\n\r\n getPixelSize: function () {\r\n return this.params.pixelSize;\r\n },\r\n\r\n run: function (callback, context) {\r\n return this.request(function (error, response) {\r\n callback.call(context, error, (response && this._responseToGeoJSON(response)), response);\r\n }, this);\r\n },\r\n\r\n // get pixel data and return as geoJSON point\r\n // populate catalog items (if any)\r\n // merging in any catalogItemVisibilities as a propery of each feature\r\n _responseToGeoJSON: function (response) {\r\n var location = response.location;\r\n var catalogItems = response.catalogItems;\r\n var catalogItemVisibilities = response.catalogItemVisibilities;\r\n var geoJSON = {\r\n 'pixel': {\r\n 'type': 'Feature',\r\n 'geometry': {\r\n 'type': 'Point',\r\n 'coordinates': [location.x, location.y]\r\n },\r\n 'crs': {\r\n 'type': 'EPSG',\r\n 'properties': {\r\n 'code': location.spatialReference.wkid\r\n }\r\n },\r\n 'properties': {\r\n 'OBJECTID': response.objectId,\r\n 'name': response.name,\r\n 'value': response.value\r\n },\r\n 'id': response.objectId\r\n }\r\n };\r\n\r\n if (response.properties && response.properties.Values) {\r\n geoJSON.pixel.properties.values = response.properties.Values;\r\n }\r\n\r\n if (catalogItems && catalogItems.features) {\r\n geoJSON.catalogItems = responseToFeatureCollection(catalogItems);\r\n if (catalogItemVisibilities && catalogItemVisibilities.length === geoJSON.catalogItems.features.length) {\r\n for (var i = catalogItemVisibilities.length - 1; i >= 0; i--) {\r\n geoJSON.catalogItems.features[i].properties.catalogItemVisibility = catalogItemVisibilities[i];\r\n }\r\n }\r\n }\r\n return geoJSON;\r\n }\r\n\r\n});\r\n\r\nexport function identifyImage (params) {\r\n return new IdentifyImage(params);\r\n}\r\n\r\nexport default identifyImage;\r\n","import { Util, Evented } from 'leaflet';\r\nimport {cors} from '../Support';\r\nimport {cleanUrl, getUrlParams} from '../Util';\r\nimport Request from '../Request';\r\n\r\nexport var Service = Evented.extend({\r\n\r\n options: {\r\n proxy: false,\r\n useCors: cors,\r\n timeout: 0\r\n },\r\n\r\n initialize: function (options) {\r\n options = options || {};\r\n this._requestQueue = [];\r\n this._authenticating = false;\r\n Util.setOptions(this, options);\r\n this.options.url = cleanUrl(this.options.url);\r\n },\r\n\r\n get: function (path, params, callback, context) {\r\n return this._request('get', path, params, callback, context);\r\n },\r\n\r\n post: function (path, params, callback, context) {\r\n return this._request('post', path, params, callback, context);\r\n },\r\n\r\n request: function (path, params, callback, context) {\r\n return this._request('request', path, params, callback, context);\r\n },\r\n\r\n metadata: function (callback, context) {\r\n return this._request('get', '', {}, callback, context);\r\n },\r\n\r\n authenticate: function (token) {\r\n this._authenticating = false;\r\n this.options.token = token;\r\n this._runQueue();\r\n return this;\r\n },\r\n\r\n getTimeout: function () {\r\n return this.options.timeout;\r\n },\r\n\r\n setTimeout: function (timeout) {\r\n this.options.timeout = timeout;\r\n },\r\n\r\n _request: function (method, path, params, callback, context) {\r\n this.fire('requeststart', {\r\n url: this.options.url + path,\r\n params: params,\r\n method: method\r\n }, true);\r\n\r\n var wrappedCallback = this._createServiceCallback(method, path, params, callback, context);\r\n\r\n if (this.options.token) {\r\n params.token = this.options.token;\r\n }\r\n if (this.options.requestParams) {\r\n Util.extend(params, this.options.requestParams);\r\n }\r\n if (this._authenticating) {\r\n this._requestQueue.push([method, path, params, callback, context]);\r\n return;\r\n } else {\r\n var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\r\n\r\n if ((method === 'get' || method === 'request') && !this.options.useCors) {\r\n return Request.get.JSONP(url, params, wrappedCallback, context);\r\n } else {\r\n return Request[method](url, params, wrappedCallback, context);\r\n }\r\n }\r\n },\r\n\r\n _createServiceCallback: function (method, path, params, callback, context) {\r\n return Util.bind(function (error, response) {\r\n if (error && (error.code === 499 || error.code === 498)) {\r\n this._authenticating = true;\r\n\r\n this._requestQueue.push([method, path, params, callback, context]);\r\n\r\n // fire an event for users to handle and re-authenticate\r\n this.fire('authenticationrequired', {\r\n authenticate: Util.bind(this.authenticate, this)\r\n }, true);\r\n\r\n // if the user has access to a callback they can handle the auth error\r\n error.authenticate = Util.bind(this.authenticate, this);\r\n }\r\n\r\n callback.call(context, error, response);\r\n\r\n if (error) {\r\n this.fire('requesterror', {\r\n url: this.options.url + path,\r\n params: params,\r\n message: error.message,\r\n code: error.code,\r\n method: method\r\n }, true);\r\n } else {\r\n this.fire('requestsuccess', {\r\n url: this.options.url + path,\r\n params: params,\r\n response: response,\r\n method: method\r\n }, true);\r\n }\r\n\r\n this.fire('requestend', {\r\n url: this.options.url + path,\r\n params: params,\r\n method: method\r\n }, true);\r\n }, this);\r\n },\r\n\r\n _runQueue: function () {\r\n for (var i = this._requestQueue.length - 1; i >= 0; i--) {\r\n var request = this._requestQueue[i];\r\n var method = request.shift();\r\n this[method].apply(this, request);\r\n }\r\n this._requestQueue = [];\r\n }\r\n});\r\n\r\nexport function service (options) {\r\n options = getUrlParams(options);\r\n return new Service(options);\r\n}\r\n\r\nexport default service;\r\n","import { Service } from './Service';\r\nimport identifyFeatures from '../Tasks/IdentifyFeatures';\r\nimport query from '../Tasks/Query';\r\nimport find from '../Tasks/Find';\r\n\r\nexport var MapService = Service.extend({\r\n\r\n identify: function () {\r\n return identifyFeatures(this);\r\n },\r\n\r\n find: function () {\r\n return find(this);\r\n },\r\n\r\n query: function () {\r\n return query(this);\r\n }\r\n\r\n});\r\n\r\nexport function mapService (options) {\r\n return new MapService(options);\r\n}\r\n\r\nexport default mapService;\r\n","import { Service } from './Service';\r\nimport identifyImage from '../Tasks/IdentifyImage';\r\nimport query from '../Tasks/Query';\r\n\r\nexport var ImageService = Service.extend({\r\n\r\n query: function () {\r\n return query(this);\r\n },\r\n\r\n identify: function () {\r\n return identifyImage(this);\r\n }\r\n});\r\n\r\nexport function imageService (options) {\r\n return new ImageService(options);\r\n}\r\n\r\nexport default imageService;\r\n","import { Service } from './Service';\r\nimport query from '../Tasks/Query';\r\nimport { geojsonToArcGIS } from '../Util';\r\n\r\nexport var FeatureLayerService = Service.extend({\r\n\r\n options: {\r\n idAttribute: 'OBJECTID'\r\n },\r\n\r\n query: function () {\r\n return query(this);\r\n },\r\n\r\n addFeature: function (feature, callback, context) {\r\n this.addFeatures(feature, callback, context);\r\n },\r\n\r\n addFeatures: function (features, callback, context) {\r\n var featuresArray = features.features ? features.features : [features];\r\n for (var i = featuresArray.length - 1; i >= 0; i--) {\r\n delete featuresArray[i].id;\r\n }\r\n features = geojsonToArcGIS(features);\r\n features = featuresArray.length > 1 ? features : [features];\r\n return this.post('addFeatures', {\r\n features: features\r\n }, function (error, response) {\r\n // For compatibility reason with former addFeature function,\r\n // we return the object in the array and not the array itself\r\n var result = (response && response.addResults) ? response.addResults.length > 1 ? response.addResults : response.addResults[0] : undefined;\r\n if (callback) {\r\n callback.call(context, error || response.addResults[0].error, result);\r\n }\r\n }, context);\r\n },\r\n\r\n updateFeature: function (feature, callback, context) {\r\n this.updateFeatures(feature, callback, context);\r\n },\r\n\r\n updateFeatures: function (features, callback, context) {\r\n var featuresArray = features.features ? features.features : [features];\r\n features = geojsonToArcGIS(features, this.options.idAttribute);\r\n features = featuresArray.length > 1 ? features : [features];\r\n\r\n return this.post('updateFeatures', {\r\n features: features\r\n }, function (error, response) {\r\n // For compatibility reason with former updateFeature function,\r\n // we return the object in the array and not the array itself\r\n var result = (response && response.updateResults) ? response.updateResults.length > 1 ? response.updateResults : response.updateResults[0] : undefined;\r\n if (callback) {\r\n callback.call(context, error || response.updateResults[0].error, result);\r\n }\r\n }, context);\r\n },\r\n\r\n deleteFeature: function (id, callback, context) {\r\n this.deleteFeatures(id, callback, context);\r\n },\r\n\r\n deleteFeatures: function (ids, callback, context) {\r\n return this.post('deleteFeatures', {\r\n objectIds: ids\r\n }, function (error, response) {\r\n // For compatibility reason with former deleteFeature function,\r\n // we return the object in the array and not the array itself\r\n var result = (response && response.deleteResults) ? response.deleteResults.length > 1 ? response.deleteResults : response.deleteResults[0] : undefined;\r\n if (callback) {\r\n callback.call(context, error || response.deleteResults[0].error, result);\r\n }\r\n }, context);\r\n }\r\n});\r\n\r\nexport function featureLayerService (options) {\r\n return new FeatureLayerService(options);\r\n}\r\n\r\nexport default featureLayerService;\r\n","import { TileLayer, Util } from 'leaflet';\r\nimport { pointerEvents } from '../Support';\r\nimport {\r\n setEsriAttribution,\r\n removeEsriAttribution,\r\n _getAttributionData,\r\n _updateMapAttribution\r\n} from '../Util';\r\n\r\nvar tileProtocol = (window.location.protocol !== 'https:') ? 'http:' : 'https:';\r\n\r\nexport var BasemapLayer = TileLayer.extend({\r\n statics: {\r\n TILES: {\r\n Streets: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Street_Map'\r\n }\r\n },\r\n Topographic: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Topo_Map'\r\n }\r\n },\r\n Oceans: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA',\r\n attributionUrl: 'https://static.arcgis.com/attribution/Ocean_Basemap'\r\n }\r\n },\r\n OceansLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n NationalGeographic: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'National Geographic, DeLorme, HERE, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, increment P Corp.'\r\n }\r\n },\r\n DarkGray: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors'\r\n }\r\n },\r\n DarkGrayLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n\r\n }\r\n },\r\n Gray: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors'\r\n }\r\n },\r\n GrayLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n Imagery: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n attribution: 'DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery'\r\n }\r\n },\r\n ImageryLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n ImageryTransportation: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n ShadedRelief: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 13,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS'\r\n }\r\n },\r\n ShadedReliefLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 12,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n Terrain: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 13,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA'\r\n }\r\n },\r\n TerrainLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 13,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n USATopo: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 15,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, National Geographic Society, i-cubed'\r\n }\r\n },\r\n ImageryClarity: {\r\n urlTemplate: tileProtocol + '//clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community'\r\n }\r\n },\r\n Physical: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 8,\r\n subdomains: ['server', 'services'],\r\n attribution: 'U.S. National Park Service'\r\n }\r\n },\r\n ImageryFirefly: {\r\n urlTemplate: tileProtocol + '//fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery'\r\n }\r\n }\r\n }\r\n },\r\n\r\n initialize: function (key, options) {\r\n var config;\r\n\r\n // set the config variable with the appropriate config object\r\n if (typeof key === 'object' && key.urlTemplate && key.options) {\r\n config = key;\r\n } else if (typeof key === 'string' && BasemapLayer.TILES[key]) {\r\n config = BasemapLayer.TILES[key];\r\n } else {\r\n throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of \"Streets\", \"Topographic\", \"Oceans\", \"OceansLabels\", \"NationalGeographic\", \"Physical\", \"Gray\", \"GrayLabels\", \"DarkGray\", \"DarkGrayLabels\", \"Imagery\", \"ImageryLabels\", \"ImageryTransportation\", \"ImageryClarity\", \"ImageryFirefly\", ShadedRelief\", \"ShadedReliefLabels\", \"Terrain\", \"TerrainLabels\" or \"USATopo\"');\r\n }\r\n\r\n // merge passed options into the config options\r\n var tileOptions = Util.extend(config.options, options);\r\n\r\n Util.setOptions(this, tileOptions);\r\n\r\n // Deprecation notice:\r\n if (!this.options.ignoreDeprecationWarning) {\r\n console.warn('WARNING: L.esri.BasemapLayer uses data services that are in mature support and are not being updated. Please use L.esri.Vector.vectorBasemapLayer instead. More info: https://esriurl.com/esri-leaflet-basemap');\r\n }\r\n\r\n if (this.options.token && config.urlTemplate.indexOf('token=') === -1) {\r\n config.urlTemplate += ('?token=' + this.options.token);\r\n }\r\n if (this.options.proxy) {\r\n config.urlTemplate = this.options.proxy + '?' + config.urlTemplate;\r\n }\r\n\r\n // call the initialize method on L.TileLayer to set everything up\r\n TileLayer.prototype.initialize.call(this, config.urlTemplate, tileOptions);\r\n },\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n if (this.options.pane === 'esri-labels') {\r\n this._initPane();\r\n }\r\n // some basemaps can supply dynamic attribution\r\n if (this.options.attributionUrl) {\r\n _getAttributionData((this.options.proxy ? this.options.proxy + '?' : '') + this.options.attributionUrl, map);\r\n }\r\n\r\n map.on('moveend', _updateMapAttribution);\r\n\r\n TileLayer.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n\r\n map.off('moveend', _updateMapAttribution);\r\n\r\n TileLayer.prototype.onRemove.call(this, map);\r\n },\r\n\r\n _initPane: function () {\r\n if (!this._map.getPane(this.options.pane)) {\r\n var pane = this._map.createPane(this.options.pane);\r\n pane.style.pointerEvents = 'none';\r\n pane.style.zIndex = 500;\r\n }\r\n },\r\n\r\n getAttribution: function () {\r\n if (this.options.attribution) {\r\n var attribution = '<span class=\"esri-dynamic-attribution\">' + this.options.attribution + '</span>';\r\n }\r\n return attribution;\r\n }\r\n});\r\n\r\nexport function basemapLayer (key, options) {\r\n return new BasemapLayer(key, options);\r\n}\r\n\r\nexport default basemapLayer;\r\n","import { CRS, DomEvent, TileLayer, Util } from 'leaflet';\r\nimport { warn, getUrlParams, setEsriAttribution, removeEsriAttribution } from '../Util';\r\nimport mapService from '../Services/MapService';\r\n\r\nexport var TiledMapLayer = TileLayer.extend({\r\n options: {\r\n zoomOffsetAllowance: 0.1,\r\n errorTileUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEABAMAAACuXLVVAAAAA1BMVEUzNDVszlHHAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAAAAAAAAAB6mUWpAAAADZJREFUeJztwQEBAAAAgiD/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7waBAAABw08RwAAAAABJRU5ErkJggg=='\r\n },\r\n\r\n statics: {\r\n MercatorZoomLevels: {\r\n '0': 156543.03392799999,\r\n '1': 78271.516963999893,\r\n '2': 39135.758482000099,\r\n '3': 19567.879240999901,\r\n '4': 9783.9396204999593,\r\n '5': 4891.9698102499797,\r\n '6': 2445.9849051249898,\r\n '7': 1222.9924525624899,\r\n '8': 611.49622628138002,\r\n '9': 305.74811314055802,\r\n '10': 152.874056570411,\r\n '11': 76.437028285073197,\r\n '12': 38.218514142536598,\r\n '13': 19.109257071268299,\r\n '14': 9.5546285356341496,\r\n '15': 4.7773142679493699,\r\n '16': 2.38865713397468,\r\n '17': 1.1943285668550501,\r\n '18': 0.59716428355981699,\r\n '19': 0.29858214164761698,\r\n '20': 0.14929107082381,\r\n '21': 0.07464553541191,\r\n '22': 0.0373227677059525,\r\n '23': 0.0186613838529763\r\n }\r\n },\r\n\r\n initialize: function (options) {\r\n options = Util.setOptions(this, options);\r\n\r\n // set the urls\r\n options = getUrlParams(options);\r\n this.tileUrl = (options.proxy ? options.proxy + '?' : '') + options.url + 'tile/{z}/{y}/{x}' + (options.requestParams && Object.keys(options.requestParams).length > 0 ? Util.getParamString(options.requestParams) : '');\r\n // Remove subdomain in url\r\n // https://github.com/Esri/esri-leaflet/issues/991\r\n if (options.url.indexOf('{s}') !== -1 && options.subdomains) {\r\n options.url = options.url.replace('{s}', options.subdomains[0]);\r\n }\r\n this.service = mapService(options);\r\n this.service.addEventParent(this);\r\n\r\n var arcgisonline = new RegExp(/tiles.arcgis(online)?\\.com/g);\r\n if (arcgisonline.test(options.url)) {\r\n this.tileUrl = this.tileUrl.replace('://tiles', '://tiles{s}');\r\n options.subdomains = ['1', '2', '3', '4'];\r\n }\r\n\r\n if (this.options.token) {\r\n this.tileUrl += ('?token=' + this.options.token);\r\n }\r\n\r\n // init layer by calling TileLayers initialize method\r\n TileLayer.prototype.initialize.call(this, this.tileUrl, options);\r\n },\r\n\r\n getTileUrl: function (tilePoint) {\r\n var zoom = this._getZoomForUrl();\r\n\r\n return Util.template(this.tileUrl, Util.extend({\r\n s: this._getSubdomain(tilePoint),\r\n x: tilePoint.x,\r\n y: tilePoint.y,\r\n // try lod map first, then just default to zoom level\r\n z: (this._lodMap && this._lodMap[zoom]) ? this._lodMap[zoom] : zoom\r\n }, this.options));\r\n },\r\n\r\n createTile: function (coords, done) {\r\n var tile = document.createElement('img');\r\n\r\n DomEvent.on(tile, 'load', Util.bind(this._tileOnLoad, this, done, tile));\r\n DomEvent.on(tile, 'error', Util.bind(this._tileOnError, this, done, tile));\r\n\r\n if (this.options.crossOrigin) {\r\n tile.crossOrigin = '';\r\n }\r\n\r\n /*\r\n Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons\r\n http://www.w3.org/TR/WCAG20-TECHS/H67\r\n */\r\n tile.alt = '';\r\n\r\n // if there is no lod map or an lod map with a proper zoom load the tile\r\n // otherwise wait for the lod map to become available\r\n if (!this._lodMap || (this._lodMap && this._lodMap[this._getZoomForUrl()])) {\r\n tile.src = this.getTileUrl(coords);\r\n } else {\r\n this.once('lodmap', function () {\r\n tile.src = this.getTileUrl(coords);\r\n }, this);\r\n }\r\n\r\n return tile;\r\n },\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n if (!this._lodMap) {\r\n this.metadata(function (error, metadata) {\r\n if (!error && metadata.spatialReference) {\r\n var sr = metadata.spatialReference.latestWkid || metadata.spatialReference.wkid;\r\n // display the copyright text from the service using leaflet's attribution control\r\n if (!this.options.attribution && map.attributionControl && metadata.copyrightText) {\r\n this.options.attribution = metadata.copyrightText;\r\n map.attributionControl.addAttribution(this.getAttribution());\r\n }\r\n\r\n // if the service tiles were published in web mercator using conventional LODs but missing levels, we can try and remap them\r\n if (map.options.crs === CRS.EPSG3857 && (sr === 102100 || sr === 3857)) {\r\n this._lodMap = {};\r\n // create the zoom level data\r\n var arcgisLODs = metadata.tileInfo.lods;\r\n var correctResolutions = TiledMapLayer.MercatorZoomLevels;\r\n\r\n for (var i = 0; i < arcgisLODs.length; i++) {\r\n var arcgisLOD = arcgisLODs[i];\r\n for (var ci in correctResolutions) {\r\n var correctRes = correctResolutions[ci];\r\n\r\n if (this._withinPercentage(arcgisLOD.resolution, correctRes, this.options.zoomOffsetAllowance)) {\r\n this._lodMap[ci] = arcgisLOD.level;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.fire('lodmap');\r\n } else if (map.options.crs && map.options.crs.code && (map.options.crs.code.indexOf(sr) > -1)) {\r\n // if the projection is WGS84, or the developer is using Proj4 to define a custom CRS, no action is required\r\n } else {\r\n // if the service was cached in a custom projection and an appropriate LOD hasn't been defined in the map, guide the developer to our Proj4 sample\r\n warn('L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html');\r\n }\r\n }\r\n }, this);\r\n }\r\n\r\n TileLayer.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n\r\n TileLayer.prototype.onRemove.call(this, map);\r\n },\r\n\r\n metadata: function (callback, context) {\r\n this.service.metadata(callback, context);\r\n return this;\r\n },\r\n\r\n identify: function () {\r\n return this.service.identify();\r\n },\r\n\r\n find: function () {\r\n return this.service.find();\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n authenticate: function (token) {\r\n var tokenQs = '?token=' + token;\r\n this.tileUrl = (this.options.token) ? this.tileUrl.replace(/\\?token=(.+)/g, tokenQs) : this.tileUrl + tokenQs;\r\n this.options.token = token;\r\n this.service.authenticate(token);\r\n return this;\r\n },\r\n\r\n _withinPercentage: function (a, b, percentage) {\r\n var diff = Math.abs((a / b) - 1);\r\n return diff < percentage;\r\n }\r\n});\r\n\r\nexport function tiledMapLayer (url, options) {\r\n return new TiledMapLayer(url, options);\r\n}\r\n\r\nexport default tiledMapLayer;\r\n","import { ImageOverlay, CRS, DomUtil, Util, Layer, popup, latLng, bounds } from 'leaflet';\r\nimport { cors } from '../Support';\r\nimport { setEsriAttribution, removeEsriAttribution } from '../Util';\r\n\r\nvar Overlay = ImageOverlay.extend({\r\n onAdd: function (map) {\r\n this._topLeft = map.getPixelBounds().min;\r\n ImageOverlay.prototype.onAdd.call(this, map);\r\n },\r\n _reset: function () {\r\n if (this._map.options.crs === CRS.EPSG3857) {\r\n ImageOverlay.prototype._reset.call(this);\r\n } else {\r\n DomUtil.setPosition(this._image, this._topLeft.subtract(this._map.getPixelOrigin()));\r\n }\r\n }\r\n});\r\n\r\nexport var RasterLayer = Layer.extend({\r\n options: {\r\n opacity: 1,\r\n position: 'front',\r\n f: 'image',\r\n useCors: cors,\r\n attribution: null,\r\n interactive: false,\r\n alt: ''\r\n },\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n if (this.options.zIndex) {\r\n this.options.position = null;\r\n }\r\n\r\n this._update = Util.throttle(this._update, this.options.updateInterval, this);\r\n\r\n map.on('moveend', this._update, this);\r\n\r\n // if we had an image loaded and it matches the\r\n // current bounds show the image otherwise remove it\r\n if (this._currentImage && this._currentImage._bounds.equals(this._map.getBounds())) {\r\n map.addLayer(this._currentImage);\r\n } else if (this._currentImage) {\r\n this._map.removeLayer(this._currentImage);\r\n this._currentImage = null;\r\n }\r\n\r\n this._update();\r\n\r\n if (this._popup) {\r\n this._map.on('click', this._getPopupData, this);\r\n this._map.on('dblclick', this._resetPopupState, this);\r\n }\r\n\r\n // add copyright text listed in service metadata\r\n this.metadata(function (err, metadata) {\r\n if (!err && !this.options.attribution && map.attributionControl && metadata.copyrightText) {\r\n this.options.attribution = metadata.copyrightText;\r\n map.attributionControl.addAttribution(this.getAttribution());\r\n }\r\n }, this);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n\r\n if (this._currentImage) {\r\n this._map.removeLayer(this._currentImage);\r\n }\r\n\r\n if (this._popup) {\r\n this._map.off('click', this._getPopupData, this);\r\n this._map.off('dblclick', this._resetPopupState, this);\r\n }\r\n\r\n this._map.off('moveend', this._update, this);\r\n },\r\n\r\n bindPopup: function (fn, popupOptions) {\r\n this._shouldRenderPopup = false;\r\n this._lastClick = false;\r\n this._popup = popup(popupOptions);\r\n this._popupFunction = fn;\r\n if (this._map) {\r\n this._map.on('click', this._getPopupData, this);\r\n this._map.on('dblclick', this._resetPopupState, this);\r\n }\r\n return this;\r\n },\r\n\r\n unbindPopup: function () {\r\n if (this._map) {\r\n this._map.closePopup(this._popup);\r\n this._map.off('click', this._getPopupData, this);\r\n this._map.off('dblclick', this._resetPopupState, this);\r\n }\r\n this._popup = false;\r\n return this;\r\n },\r\n\r\n bringToFront: function () {\r\n this.options.position = 'front';\r\n if (this._currentImage) {\r\n this._currentImage.bringToFront();\r\n this._setAutoZIndex(Math.max);\r\n }\r\n return this;\r\n },\r\n\r\n bringToBack: function () {\r\n this.options.position = 'back';\r\n if (this._currentImage) {\r\n this._currentImage.bringToBack();\r\n this._setAutoZIndex(Math.min);\r\n }\r\n return this;\r\n },\r\n\r\n setZIndex: function (value) {\r\n this.options.zIndex = value;\r\n if (this._currentImage) {\r\n this._currentImage.setZIndex(value);\r\n }\r\n return this;\r\n },\r\n\r\n _setAutoZIndex: function (compare) {\r\n // go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back)\r\n if (!this._currentImage) {\r\n return;\r\n }\r\n var layers = this._currentImage.getPane().children;\r\n var edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min\r\n for (var i = 0, len = layers.length, zIndex; i < len; i++) {\r\n zIndex = layers[i].style.zIndex;\r\n if (layers[i] !== this._currentImage._image && zIndex) {\r\n edgeZIndex = compare(edgeZIndex, +zIndex);\r\n }\r\n }\r\n\r\n if (isFinite(edgeZIndex)) {\r\n this.options.zIndex = edgeZIndex + compare(-1, 1);\r\n this.setZIndex(this.options.zIndex);\r\n }\r\n },\r\n\r\n getAttribution: function () {\r\n return this.options.attribution;\r\n },\r\n\r\n getOpacity: function () {\r\n return this.options.opacity;\r\n },\r\n\r\n setOpacity: function (opacity) {\r\n this.options.opacity = opacity;\r\n if (this._currentImage) {\r\n this._currentImage.setOpacity(opacity);\r\n }\r\n return this;\r\n },\r\n\r\n getTimeRange: function () {\r\n return [this.options.from, this.options.to];\r\n },\r\n\r\n setTimeRange: function (from, to) {\r\n this.options.from = from;\r\n this.options.to = to;\r\n this._update();\r\n return this;\r\n },\r\n\r\n metadata: function (callback, context) {\r\n this.service.metadata(callback, context);\r\n return this;\r\n },\r\n\r\n authenticate: function (token) {\r\n this.service.authenticate(token);\r\n return this;\r\n },\r\n\r\n redraw: function () {\r\n this._update();\r\n },\r\n\r\n _renderImage: function (url, bounds, contentType) {\r\n if (this._map) {\r\n // if no output directory has been specified for a service, MIME data will be returned\r\n if (contentType) {\r\n url = 'data:' + contentType + ';base64,' + url;\r\n }\r\n\r\n // if server returns an inappropriate response, abort.\r\n if (!url) return;\r\n\r\n // create a new image overlay and add it to the map\r\n // to start loading the image\r\n // opacity is 0 while the image is loading\r\n var image = new Overlay(url, bounds, {\r\n opacity: 0,\r\n crossOrigin: this.options.withCredentials ? 'use-credentials' : this.options.useCors,\r\n alt: this.options.alt,\r\n pane: this.options.pane || this.getPane(),\r\n interactive: this.options.interactive\r\n }).addTo(this._map);\r\n\r\n var onOverlayError = function () {\r\n this._map.removeLayer(image);\r\n this.fire('error');\r\n image.off('load', onOverlayLoad, this);\r\n };\r\n\r\n var onOverlayLoad = function (e) {\r\n image.off('error', onOverlayLoad, this);\r\n if (this._map) {\r\n var newImage = e.target;\r\n var oldImage = this._currentImage;\r\n\r\n // if the bounds of this image matches the bounds that\r\n // _renderImage was called with and we have a map with the same bounds\r\n // hide the old image if there is one and set the opacity\r\n // of the new image otherwise remove the new image\r\n if (newImage._bounds.equals(bounds) && newImage._bounds.equals(this._map.getBounds())) {\r\n this._currentImage = newImage;\r\n\r\n if (this.options.position === 'front') {\r\n this.bringToFront();\r\n } else if (this.options.position === 'back') {\r\n this.bringToBack();\r\n }\r\n\r\n if (this.options.zIndex) {\r\n this.setZIndex(this.options.zIndex);\r\n }\r\n\r\n if (this._map && this._currentImage._map) {\r\n this._currentImage.setOpacity(this.options.opacity);\r\n } else {\r\n this._currentImage._map.removeLayer(this._currentImage);\r\n }\r\n\r\n if (oldImage && this._map) {\r\n this._map.removeLayer(oldImage);\r\n }\r\n\r\n if (oldImage && oldImage._map) {\r\n oldImage._map.removeLayer(oldImage);\r\n }\r\n } else {\r\n this._map.removeLayer(newImage);\r\n }\r\n }\r\n\r\n this.fire('load', {\r\n bounds: bounds\r\n });\r\n };\r\n\r\n // If loading the image fails\r\n image.once('error', onOverlayError, this);\r\n\r\n // once the image loads\r\n image.once('load', onOverlayLoad, this);\r\n }\r\n },\r\n\r\n _update: function () {\r\n if (!this._map) {\r\n return;\r\n }\r\n\r\n var zoom = this._map.getZoom();\r\n var bounds = this._map.getBounds();\r\n\r\n if (this._animatingZoom) {\r\n return;\r\n }\r\n\r\n if (this._map._panTransition && this._map._panTransition._inProgress) {\r\n return;\r\n }\r\n\r\n if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\r\n if (this._currentImage) {\r\n this._currentImage._map.removeLayer(this._currentImage);\r\n this._currentImage = null;\r\n }\r\n return;\r\n }\r\n\r\n var params = this._buildExportParams();\r\n Util.extend(params, this.options.requestParams);\r\n\r\n if (params) {\r\n this._requestExport(params, bounds);\r\n\r\n this.fire('loading', {\r\n bounds: bounds\r\n });\r\n } else if (this._currentImage) {\r\n this._currentImage._map.removeLayer(this._currentImage);\r\n this._currentImage = null;\r\n }\r\n },\r\n\r\n _renderPopup: function (latlng, error, results, response) {\r\n latlng = latLng(latlng);\r\n if (this._shouldRenderPopup && this._lastClick.equals(latlng)) {\r\n // add the popup to the map where the mouse was clicked at\r\n var content = this._popupFunction(error, results, response);\r\n if (content) {\r\n this._popup.setLatLng(latlng).setContent(content).openOn(this._map);\r\n }\r\n }\r\n },\r\n\r\n _resetPopupState: function (e) {\r\n this._shouldRenderPopup = false;\r\n this._lastClick = e.latlng;\r\n },\r\n\r\n _calculateBbox: function () {\r\n var pixelBounds = this._map.getPixelBounds();\r\n\r\n var sw = this._map.unproject(pixelBounds.getBottomLeft());\r\n var ne = this._map.unproject(pixelBounds.getTopRight());\r\n\r\n var neProjected = this._map.options.crs.project(ne);\r\n var swProjected = this._map.options.crs.project(sw);\r\n\r\n // this ensures ne/sw are switched in polar maps where north/top bottom/south is inverted\r\n var boundsProjected = bounds(neProjected, swProjected);\r\n\r\n return [boundsProjected.getBottomLeft().x, boundsProjected.getBottomLeft().y, boundsProjected.getTopRight().x, boundsProjected.getTopRight().y].join(',');\r\n },\r\n\r\n _calculateImageSize: function () {\r\n // ensure that we don't ask ArcGIS Server for a taller image than we have actual map displaying within the div\r\n var bounds = this._map.getPixelBounds();\r\n var size = this._map.getSize();\r\n\r\n var sw = this._map.unproject(bounds.getBottomLeft());\r\n var ne = this._map.unproject(bounds.getTopRight());\r\n\r\n var top = this._map.latLngToLayerPoint(ne).y;\r\n var bottom = this._map.latLngToLayerPoint(sw).y;\r\n\r\n if (top > 0 || bottom < size.y) {\r\n size.y = bottom - top;\r\n }\r\n\r\n return size.x + ',' + size.y;\r\n }\r\n});\r\n","import { Util } from 'leaflet';\r\nimport { RasterLayer } from './RasterLayer';\r\nimport { getUrlParams } from '../Util';\r\nimport imageService from '../Services/ImageService';\r\n\r\nexport var ImageMapLayer = RasterLayer.extend({\r\n\r\n options: {\r\n updateInterval: 150,\r\n format: 'jpgpng',\r\n transparent: true,\r\n f: 'image'\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n identify: function () {\r\n return this.service.identify();\r\n },\r\n\r\n initialize: function (options) {\r\n options = getUrlParams(options);\r\n this.service = imageService(options);\r\n this.service.addEventParent(this);\r\n\r\n Util.setOptions(this, options);\r\n },\r\n\r\n setPixelType: function (pixelType) {\r\n this.options.pixelType = pixelType;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getPixelType: function () {\r\n return this.options.pixelType;\r\n },\r\n\r\n setBandIds: function (bandIds) {\r\n if (Util.isArray(bandIds)) {\r\n this.options.bandIds = bandIds.join(',');\r\n } else {\r\n this.options.bandIds = bandIds.toString();\r\n }\r\n this._update();\r\n return this;\r\n },\r\n\r\n getBandIds: function () {\r\n return this.options.bandIds;\r\n },\r\n\r\n setNoData: function (noData, noDataInterpretation) {\r\n if (Util.isArray(noData)) {\r\n this.options.noData = noData.join(',');\r\n } else {\r\n this.options.noData = noData.toString();\r\n }\r\n if (noDataInterpretation) {\r\n this.options.noDataInterpretation = noDataInterpretation;\r\n }\r\n this._update();\r\n return this;\r\n },\r\n\r\n getNoData: function () {\r\n return this.options.noData;\r\n },\r\n\r\n getNoDataInterpretation: function () {\r\n return this.options.noDataInterpretation;\r\n },\r\n\r\n setRenderingRule: function (renderingRule) {\r\n this.options.renderingRule = renderingRule;\r\n this._update();\r\n },\r\n\r\n getRenderingRule: function () {\r\n return this.options.renderingRule;\r\n },\r\n\r\n setMosaicRule: function (mosaicRule) {\r\n this.options.mosaicRule = mosaicRule;\r\n this._update();\r\n },\r\n\r\n getMosaicRule: function () {\r\n return this.options.mosaicRule;\r\n },\r\n\r\n _getPopupData: function (e) {\r\n var callback = Util.bind(function (error, results, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n setTimeout(Util.bind(function () {\r\n this._renderPopup(e.latlng, error, results, response);\r\n }, this), 300);\r\n }, this);\r\n\r\n var identifyRequest = this.identify().at(e.latlng);\r\n\r\n // set mosaic rule for identify task if it is set for layer\r\n if (this.options.mosaicRule) {\r\n identifyRequest.setMosaicRule(this.options.mosaicRule);\r\n // @TODO: force return catalog items too?\r\n }\r\n\r\n // @TODO: set rendering rule? Not sure,\r\n // sometimes you want raw pixel values\r\n // if (this.options.renderingRule) {\r\n // identifyRequest.setRenderingRule(this.options.renderingRule);\r\n // }\r\n\r\n identifyRequest.run(callback);\r\n\r\n // set the flags to show the popup\r\n this._shouldRenderPopup = true;\r\n this._lastClick = e.latlng;\r\n },\r\n\r\n _buildExportParams: function () {\r\n var sr = parseInt(this._map.options.crs.code.split(':')[1], 10);\r\n\r\n var params = {\r\n bbox: this._calculateBbox(),\r\n size: this._calculateImageSize(),\r\n format: this.options.format,\r\n transparent: this.options.transparent,\r\n bboxSR: sr,\r\n imageSR: sr\r\n };\r\n\r\n if (this.options.from && this.options.to) {\r\n params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\r\n }\r\n\r\n if (this.options.pixelType) {\r\n params.pixelType = this.options.pixelType;\r\n }\r\n\r\n if (this.options.interpolation) {\r\n params.interpolation = this.options.interpolation;\r\n }\r\n\r\n if (this.options.compressionQuality) {\r\n params.compressionQuality = this.options.compressionQuality;\r\n }\r\n\r\n if (this.options.bandIds) {\r\n params.bandIds = this.options.bandIds;\r\n }\r\n\r\n // 0 is falsy *and* a valid input parameter\r\n if (this.options.noData === 0 || this.options.noData) {\r\n params.noData = this.options.noData;\r\n }\r\n\r\n if (this.options.noDataInterpretation) {\r\n params.noDataInterpretation = this.options.noDataInterpretation;\r\n }\r\n\r\n if (this.service.options.token) {\r\n params.token = this.service.options.token;\r\n }\r\n\r\n if (this.options.renderingRule) {\r\n params.renderingRule = JSON.stringify(this.options.renderingRule);\r\n }\r\n\r\n if (this.options.mosaicRule) {\r\n params.mosaicRule = JSON.stringify(this.options.mosaicRule);\r\n }\r\n\r\n return params;\r\n },\r\n\r\n _requestExport: function (params, bounds) {\r\n if (this.options.f === 'json') {\r\n this.service.request('exportImage', params, function (error, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n if (this.options.token) {\r\n response.href += ('?token=' + this.options.token);\r\n }\r\n if (this.options.proxy) {\r\n response.href = this.options.proxy + '?' + response.href;\r\n }\r\n this._renderImage(response.href, bounds);\r\n }, this);\r\n } else {\r\n params.f = 'image';\r\n var fullUrl = this.options.url + 'exportImage' + Util.getParamString(params);\r\n if (this.options.proxy) {\r\n fullUrl = this.options.proxy + '?' + fullUrl;\r\n }\r\n this._renderImage(fullUrl, bounds);\r\n }\r\n }\r\n});\r\n\r\nexport function imageMapLayer (url, options) {\r\n return new ImageMapLayer(url, options);\r\n}\r\n\r\nexport default imageMapLayer;\r\n","import { Util } from 'leaflet';\r\nimport { RasterLayer } from './RasterLayer';\r\nimport { getUrlParams } from '../Util';\r\nimport mapService from '../Services/MapService';\r\n\r\nexport var DynamicMapLayer = RasterLayer.extend({\r\n\r\n options: {\r\n updateInterval: 150,\r\n layers: false,\r\n layerDefs: false,\r\n timeOptions: false,\r\n format: 'png32',\r\n transparent: true,\r\n f: 'json'\r\n },\r\n\r\n initialize: function (options) {\r\n options = getUrlParams(options);\r\n this.service = mapService(options);\r\n this.service.addEventParent(this);\r\n\r\n Util.setOptions(this, options);\r\n },\r\n\r\n getDynamicLayers: function () {\r\n return this.options.dynamicLayers;\r\n },\r\n\r\n setDynamicLayers: function (dynamicLayers) {\r\n this.options.dynamicLayers = dynamicLayers;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getLayers: function () {\r\n return this.options.layers;\r\n },\r\n\r\n setLayers: function (layers) {\r\n this.options.layers = layers;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getLayerDefs: function () {\r\n return this.options.layerDefs;\r\n },\r\n\r\n setLayerDefs: function (layerDefs) {\r\n this.options.layerDefs = layerDefs;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getTimeOptions: function () {\r\n return this.options.timeOptions;\r\n },\r\n\r\n setTimeOptions: function (timeOptions) {\r\n this.options.timeOptions = timeOptions;\r\n this._update();\r\n return this;\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n identify: function () {\r\n return this.service.identify();\r\n },\r\n\r\n find: function () {\r\n return this.service.find();\r\n },\r\n\r\n _getPopupData: function (e) {\r\n var callback = Util.bind(function (error, featureCollection, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n setTimeout(Util.bind(function () {\r\n this._renderPopup(e.latlng, error, featureCollection, response);\r\n }, this), 300);\r\n }, this);\r\n\r\n var identifyRequest;\r\n if (this.options.popup) {\r\n identifyRequest = this.options.popup.on(this._map).at(e.latlng);\r\n } else {\r\n identifyRequest = this.identify().on(this._map).at(e.latlng);\r\n }\r\n\r\n // remove extraneous vertices from response features if it has not already been done\r\n identifyRequest.params.maxAllowableOffset ? true : identifyRequest.simplify(this._map, 0.5);\r\n\r\n if (!(this.options.popup && this.options.popup.params && this.options.popup.params.layers)) {\r\n if (this.options.layers) {\r\n identifyRequest.layers('visible:' + this.options.layers.join(','));\r\n } else {\r\n identifyRequest.layers('visible');\r\n }\r\n }\r\n\r\n // if present, pass layer ids and sql filters through to the identify task\r\n if (this.options.layerDefs && typeof this.options.layerDefs !== 'string' && !identifyRequest.params.layerDefs) {\r\n for (var id in this.options.layerDefs) {\r\n if (this.options.layerDefs.hasOwnProperty(id)) {\r\n identifyRequest.layerDef(id, this.options.layerDefs[id]);\r\n }\r\n }\r\n }\r\n\r\n identifyRequest.run(callback);\r\n\r\n // set the flags to show the popup\r\n this._shouldRenderPopup = true;\r\n this._lastClick = e.latlng;\r\n },\r\n\r\n _buildExportParams: function () {\r\n var sr = parseInt(this._map.options.crs.code.split(':')[1], 10);\r\n\r\n var params = {\r\n bbox: this._calculateBbox(),\r\n size: this._calculateImageSize(),\r\n dpi: 96,\r\n format: this.options.format,\r\n transparent: this.options.transparent,\r\n bboxSR: sr,\r\n imageSR: sr\r\n };\r\n\r\n if (this.options.dynamicLayers) {\r\n params.dynamicLayers = this.options.dynamicLayers;\r\n }\r\n\r\n if (this.options.layers) {\r\n if (this.options.layers.length === 0) {\r\n return;\r\n } else {\r\n params.layers = 'show:' + this.options.layers.join(',');\r\n }\r\n }\r\n\r\n if (this.options.layerDefs) {\r\n params.layerDefs = typeof this.options.layerDefs === 'string' ? this.options.layerDefs : JSON.stringify(this.options.layerDefs);\r\n }\r\n\r\n if (this.options.timeOptions) {\r\n params.timeOptions = JSON.stringify(this.options.timeOptions);\r\n }\r\n\r\n if (this.options.from && this.options.to) {\r\n params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\r\n }\r\n\r\n if (this.service.options.token) {\r\n params.token = this.service.options.token;\r\n }\r\n\r\n if (this.options.proxy) {\r\n params.proxy = this.options.proxy;\r\n }\r\n\r\n // use a timestamp to bust server cache\r\n if (this.options.disableCache) {\r\n params._ts = Date.now();\r\n }\r\n\r\n return params;\r\n },\r\n\r\n _requestExport: function (params, bounds) {\r\n if (this.options.f === 'json') {\r\n this.service.request('export', params, function (error, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n\r\n if (this.options.token && response.href) {\r\n response.href += ('?token=' + this.options.token);\r\n }\r\n if (this.options.proxy && response.href) {\r\n response.href = this.options.proxy + '?' + response.href;\r\n }\r\n if (response.href) {\r\n this._renderImage(response.href, bounds);\r\n } else {\r\n this._renderImage(response.imageData, bounds, response.contentType);\r\n }\r\n }, this);\r\n } else {\r\n params.f = 'image';\r\n var fullUrl = this.options.url + 'export' + Util.getParamString(params);\r\n if (this.options.proxy) {\r\n fullUrl = this.options.proxy + '?' + fullUrl;\r\n }\r\n this._renderImage(fullUrl, bounds);\r\n }\r\n }\r\n});\r\n\r\nexport function dynamicMapLayer (url, options) {\r\n return new DynamicMapLayer(url, options);\r\n}\r\n\r\nexport default dynamicMapLayer;\r\n","import {\r\n LatLngBounds,\r\n toLatLngBounds as latLngBounds,\r\n Layer,\r\n Browser,\r\n Util,\r\n Point,\r\n Bounds\r\n} from 'leaflet';\r\n\r\nexport var FeatureGrid = Layer.extend({\r\n // @section\r\n // @aka GridLayer options\r\n options: {\r\n // @option cellSize: Number|Point = 256\r\n // Width and height of cells in the grid. Use a number if width and height are equal, or `L.point(width, height)` otherwise.\r\n cellSize: 512,\r\n\r\n // @option updateWhenIdle: Boolean = (depends)\r\n // Load new cells only when panning ends.\r\n // `true` by default on mobile browsers, in order to avoid too many requests and keep smooth navigation.\r\n // `false` otherwise in order to display new cells _during_ panning, since it is easy to pan outside the\r\n // [`keepBuffer`](#gridlayer-keepbuffer) option in desktop browsers.\r\n updateWhenIdle: Browser.mobile,\r\n\r\n // @option updateInterval: Number = 150\r\n // Cells will not update more than once every `updateInterval` milliseconds when panning.\r\n updateInterval: 150,\r\n\r\n // @option noWrap: Boolean = false\r\n // Whether the layer is wrapped around the antimeridian. If `true`, the\r\n // GridLayer will only be displayed once at low zoom levels. Has no\r\n // effect when the [map CRS](#map-crs) doesn't wrap around. Can be used\r\n // in combination with [`bounds`](#gridlayer-bounds) to prevent requesting\r\n // cells outside the CRS limits.\r\n noWrap: false,\r\n\r\n // @option keepBuffer: Number = 1.5\r\n // When panning the map, keep this many rows and columns of cells before unloading them.\r\n keepBuffer: 1.5\r\n },\r\n\r\n initialize: function (options) {\r\n Util.setOptions(this, options);\r\n },\r\n\r\n onAdd: function (map) {\r\n this._cells = {};\r\n this._activeCells = {};\r\n this._resetView();\r\n this._update();\r\n },\r\n\r\n onRemove: function (map) {\r\n this._removeAllCells();\r\n this._cellZoom = undefined;\r\n },\r\n\r\n // @method isLoading: Boolean\r\n // Returns `true` if any cell in the grid layer has not finished loading.\r\n isLoading: function () {\r\n return this._loading;\r\n },\r\n\r\n // @method redraw: this\r\n // Causes the layer to clear all the cells and request them again.\r\n redraw: function () {\r\n if (this._map) {\r\n this._removeAllCells();\r\n this._update();\r\n }\r\n return this;\r\n },\r\n\r\n getEvents: function () {\r\n var events = {\r\n viewprereset: this._invalidateAll,\r\n viewreset: this._resetView,\r\n zoom: this._resetView,\r\n moveend: this._onMoveEnd\r\n };\r\n\r\n if (!this.options.updateWhenIdle) {\r\n // update cells on move, but not more often than once per given interval\r\n if (!this._onMove) {\r\n this._onMove = Util.throttle(\r\n this._onMoveEnd,\r\n this.options.updateInterval,\r\n this\r\n );\r\n }\r\n\r\n events.move = this._onMove;\r\n }\r\n\r\n return events;\r\n },\r\n\r\n // @section Extension methods\r\n // Layers extending `GridLayer` shall reimplement the following method.\r\n // @method createCell(coords: Object, done?: Function): HTMLElement\r\n // Called only internally, must be overridden by classes extending `GridLayer`.\r\n // Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback\r\n // is specified, it must be called when the cell has finished loading and drawing.\r\n createCell: function () {\r\n return document.createElement('div');\r\n },\r\n\r\n removeCell: function () {\r\n return;\r\n },\r\n\r\n reuseCell: function () {\r\n return;\r\n },\r\n\r\n cellLeave: function () {\r\n return;\r\n },\r\n\r\n cellEnter: function () {\r\n return;\r\n },\r\n // @section\r\n // @method getCellSize: Point\r\n // Normalizes the [cellSize option](#gridlayer-cellsize) into a point. Used by the `createCell()` method.\r\n getCellSize: function () {\r\n var s = this.options.cellSize;\r\n return s instanceof Point ? s : new Point(s, s);\r\n },\r\n\r\n _pruneCells: function () {\r\n if (!this._map) {\r\n return;\r\n }\r\n\r\n var key, cell;\r\n\r\n for (key in this._cells) {\r\n cell = this._cells[key];\r\n cell.retain = cell.current;\r\n }\r\n\r\n for (key in this._cells) {\r\n cell = this._cells[key];\r\n if (cell.current && !cell.active) {\r\n var coords = cell.coords;\r\n if (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) {\r\n this._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);\r\n }\r\n }\r\n }\r\n\r\n for (key in this._cells) {\r\n if (!this._cells[key].retain) {\r\n this._removeCell(key);\r\n }\r\n }\r\n },\r\n\r\n _removeAllCells: function () {\r\n for (var key in this._cells) {\r\n this._removeCell(key);\r\n }\r\n },\r\n\r\n _invalidateAll: function () {\r\n this._removeAllCells();\r\n\r\n this._cellZoom = undefined;\r\n },\r\n\r\n _retainParent: function (x, y, z, minZoom) {\r\n var x2 = Math.floor(x / 2);\r\n var y2 = Math.floor(y / 2);\r\n var z2 = z - 1;\r\n var coords2 = new Point(+x2, +y2);\r\n coords2.z = +z2;\r\n\r\n var key = this._cellCoordsToKey(coords2);\r\n var cell = this._cells[key];\r\n\r\n if (cell && cell.active) {\r\n cell.retain = true;\r\n return true;\r\n } else if (cell && cell.loaded) {\r\n cell.retain = true;\r\n }\r\n\r\n if (z2 > minZoom) {\r\n return this._retainParent(x2, y2, z2, minZoom);\r\n }\r\n\r\n return false;\r\n },\r\n\r\n _retainChildren: function (x, y, z, maxZoom) {\r\n for (var i = 2 * x; i < 2 * x + 2; i++) {\r\n for (var j = 2 * y; j < 2 * y + 2; j++) {\r\n var coords = new Point(i, j);\r\n coords.z = z + 1;\r\n\r\n var key = this._cellCoordsToKey(coords);\r\n var cell = this._cells[key];\r\n\r\n if (cell && cell.active) {\r\n cell.retain = true;\r\n continue;\r\n } else if (cell && cell.loaded) {\r\n cell.retain = true;\r\n }\r\n\r\n if (z + 1 < maxZoom) {\r\n this._retainChildren(i, j, z + 1, maxZoom);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _resetView: function (e) {\r\n var animating = e && (e.pinch || e.flyTo);\r\n\r\n if (animating) {\r\n return;\r\n }\r\n\r\n this._setView(\r\n this._map.getCenter(),\r\n this._map.getZoom(),\r\n animating,\r\n animating\r\n );\r\n },\r\n\r\n _setView: function (center, zoom, noPrune, noUpdate) {\r\n var cellZoom = Math.round(zoom);\r\n\r\n if (!noUpdate) {\r\n this._cellZoom = cellZoom;\r\n\r\n if (this._abortLoading) {\r\n this._abortLoading();\r\n }\r\n\r\n this._resetGrid();\r\n\r\n if (cellZoom !== undefined) {\r\n this._update(center);\r\n }\r\n\r\n if (!noPrune) {\r\n this._pruneCells();\r\n }\r\n\r\n // Flag to prevent _updateOpacity from pruning cells during\r\n // a zoom anim or a pinch gesture\r\n this._noPrune = !!noPrune;\r\n }\r\n },\r\n\r\n _resetGrid: function () {\r\n var map = this._map;\r\n var crs = map.options.crs;\r\n var cellSize = (this._cellSize = this.getCellSize());\r\n var cellZoom = this._cellZoom;\r\n\r\n var bounds = this._map.getPixelWorldBounds(this._cellZoom);\r\n if (bounds) {\r\n this._globalCellRange = this._pxBoundsToCellRange(bounds);\r\n }\r\n\r\n this._wrapX = crs.wrapLng &&\r\n !this.options.noWrap && [\r\n Math.floor(map.project([0, crs.wrapLng[0]], cellZoom).x / cellSize.x),\r\n Math.ceil(map.project([0, crs.wrapLng[1]], cellZoom).x / cellSize.y)\r\n ];\r\n this._wrapY = crs.wrapLat &&\r\n !this.options.noWrap && [\r\n Math.floor(map.project([crs.wrapLat[0], 0], cellZoom).y / cellSize.x),\r\n Math.ceil(map.project([crs.wrapLat[1], 0], cellZoom).y / cellSize.y)\r\n ];\r\n },\r\n\r\n _onMoveEnd: function (e) {\r\n var animating = e && (e.pinch || e.flyTo);\r\n\r\n if (animating || !this._map || this._map._animatingZoom) {\r\n return;\r\n }\r\n\r\n this._update();\r\n },\r\n\r\n _getCelldPixelBounds: function (center) {\r\n var map = this._map;\r\n var mapZoom = map._animatingZoom\r\n ? Math.max(map._animateToZoom, map.getZoom())\r\n : map.getZoom();\r\n var scale = map.getZoomScale(mapZoom, this._cellZoom);\r\n var pixelCenter = map.project(center, this._cellZoom).floor();\r\n var halfSize = map.getSize().divideBy(scale * 2);\r\n\r\n return new Bounds(\r\n pixelCenter.subtract(halfSize),\r\n pixelCenter.add(halfSize)\r\n );\r\n },\r\n\r\n // Private method to load cells in the grid's active zoom level according to map bounds\r\n _update: function (center) {\r\n var map = this._map;\r\n if (!map) {\r\n return;\r\n }\r\n var zoom = Math.round(map.getZoom());\r\n\r\n if (center === undefined) {\r\n center = map.getCenter();\r\n }\r\n\r\n var pixelBounds = this._getCelldPixelBounds(center);\r\n var cellRange = this._pxBoundsToCellRange(pixelBounds);\r\n var cellCenter = cellRange.getCenter();\r\n var queue = [];\r\n var margin = this.options.keepBuffer;\r\n var noPruneRange = new Bounds(\r\n cellRange.getBottomLeft().subtract([margin, -margin]),\r\n cellRange.getTopRight().add([margin, -margin])\r\n );\r\n\r\n // Sanity check: panic if the cell range contains Infinity somewhere.\r\n if (\r\n !(\r\n isFinite(cellRange.min.x) &&\r\n isFinite(cellRange.min.y) &&\r\n isFinite(cellRange.max.x) &&\r\n isFinite(cellRange.max.y)\r\n )\r\n ) {\r\n throw new Error('Attempted to load an infinite number of cells');\r\n }\r\n\r\n for (var key in this._cells) {\r\n var c = this._cells[key].coords;\r\n if (\r\n c.z !== this._cellZoom ||\r\n !noPruneRange.contains(new Point(c.x, c.y))\r\n ) {\r\n this._cells[key].current = false;\r\n }\r\n }\r\n\r\n // _update just loads more cells. If the cell zoom level differs too much\r\n // from the map's, let _setView reset levels and prune old cells.\r\n if (Math.abs(zoom - this._cellZoom) > 1) {\r\n this._setView(center, zoom);\r\n return;\r\n }\r\n\r\n // create a queue of coordinates to load cells from\r\n for (var j = cellRange.min.y; j <= cellRange.max.y; j++) {\r\n for (var i = cellRange.min.x; i <= cellRange.max.x; i++) {\r\n var coords = new Point(i, j);\r\n coords.z = this._cellZoom;\r\n\r\n if (!this._isValidCell(coords)) {\r\n continue;\r\n }\r\n\r\n var cell = this._cells[this._cellCoordsToKey(coords)];\r\n if (cell) {\r\n cell.current = true;\r\n } else {\r\n queue.push(coords);\r\n }\r\n }\r\n }\r\n\r\n // sort cell queue to load cells in order of their distance to center\r\n queue.sort(function (a, b) {\r\n return a.distanceTo(cellCenter) - b.distanceTo(cellCenter);\r\n });\r\n\r\n if (queue.length !== 0) {\r\n // if it's the first batch of cells to load\r\n if (!this._loading) {\r\n this._loading = true;\r\n }\r\n\r\n for (i = 0; i < queue.length; i++) {\r\n var _key = this._cellCoordsToKey(queue[i]);\r\n var _coords = this._keyToCellCoords(_key);\r\n if (this._activeCells[_coords]) {\r\n this._reuseCell(queue[i]);\r\n } else {\r\n this._createCell(queue[i]);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _isValidCell: function (coords) {\r\n var crs = this._map.options.crs;\r\n\r\n if (!crs.infinite) {\r\n // don't load cell if it's out of bounds and not wrapped\r\n var bounds = this._globalCellRange;\r\n if (\r\n (!crs.wrapLng &&\r\n (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\r\n (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))\r\n ) {\r\n return false;\r\n }\r\n }\r\n\r\n if (!this.options.bounds) {\r\n return true;\r\n }\r\n\r\n // don't load cell if it doesn't intersect the bounds in options\r\n var cellBounds = this._cellCoordsToBounds(coords);\r\n return latLngBounds(this.options.bounds).overlaps(cellBounds);\r\n },\r\n\r\n _keyToBounds: function (key) {\r\n return this._cellCoordsToBounds(this._keyToCellCoords(key));\r\n },\r\n\r\n _cellCoordsToNwSe: function (coords) {\r\n var map = this._map;\r\n var cellSize = this.getCellSize();\r\n var nwPoint = coords.scaleBy(cellSize);\r\n var sePoint = nwPoint.add(cellSize);\r\n var nw = map.unproject(nwPoint, coords.z);\r\n var se = map.unproject(sePoint, coords.z);\r\n\r\n return [nw, se];\r\n },\r\n\r\n // converts cell coordinates to its geographical bounds\r\n _cellCoordsToBounds: function (coords) {\r\n var bp = this._cellCoordsToNwSe(coords);\r\n var bounds = new LatLngBounds(bp[0], bp[1]);\r\n\r\n if (!this.options.noWrap) {\r\n bounds = this._map.wrapLatLngBounds(bounds);\r\n }\r\n return bounds;\r\n },\r\n // converts cell coordinates to key for the cell cache\r\n _cellCoordsToKey: function (coords) {\r\n return coords.x + ':' + coords.y + ':' + coords.z;\r\n },\r\n\r\n // converts cell cache key to coordinates\r\n _keyToCellCoords: function (key) {\r\n var k = key.split(':');\r\n var coords = new Point(+k[0], +k[1]);\r\n\r\n coords.z = +k[2];\r\n return coords;\r\n },\r\n\r\n _removeCell: function (key) {\r\n var cell = this._cells[key];\r\n\r\n if (!cell) {\r\n return;\r\n }\r\n\r\n var coords = this._keyToCellCoords(key);\r\n var wrappedCoords = this._wrapCoords(coords);\r\n var cellBounds = this._cellCoordsToBounds(this._wrapCoords(coords));\r\n\r\n cell.current = false;\r\n\r\n delete this._cells[key];\r\n this._activeCells[key] = cell;\r\n\r\n this.cellLeave(cellBounds, wrappedCoords, key);\r\n\r\n this.fire('cellleave', {\r\n key: key,\r\n coords: wrappedCoords,\r\n bounds: cellBounds\r\n });\r\n },\r\n\r\n _reuseCell: function (coords) {\r\n var key = this._cellCoordsToKey(coords);\r\n\r\n // save cell in cache\r\n this._cells[key] = this._activeCells[key];\r\n this._cells[key].current = true;\r\n\r\n var wrappedCoords = this._wrapCoords(coords);\r\n var cellBounds = this._cellCoordsToBounds(this._wrapCoords(coords));\r\n\r\n this.cellEnter(cellBounds, wrappedCoords, key);\r\n\r\n this.fire('cellenter', {\r\n key: key,\r\n coords: wrappedCoords,\r\n bounds: cellBounds\r\n });\r\n },\r\n\r\n _createCell: function (coords) {\r\n var key = this._cellCoordsToKey(coords);\r\n\r\n var wrappedCoords = this._wrapCoords(coords);\r\n var cellBounds = this._cellCoordsToBounds(this._wrapCoords(coords));\r\n\r\n this.createCell(cellBounds, wrappedCoords, key);\r\n\r\n this.fire('cellcreate', {\r\n key: key,\r\n coords: wrappedCoords,\r\n bounds: cellBounds\r\n });\r\n\r\n // save cell in cache\r\n this._cells[key] = {\r\n coords: coords,\r\n current: true\r\n };\r\n\r\n Util.requestAnimFrame(this._pruneCells, this);\r\n },\r\n\r\n _cellReady: function (coords, err, cell) {\r\n var key = this._cellCoordsToKey(coords);\r\n\r\n cell = this._cells[key];\r\n\r\n if (!cell) {\r\n return;\r\n }\r\n\r\n cell.loaded = +new Date();\r\n\r\n cell.active = true;\r\n },\r\n\r\n _getCellPos: function (coords) {\r\n return coords.scaleBy(this.getCellSize());\r\n },\r\n\r\n _wrapCoords: function (coords) {\r\n var newCoords = new Point(\r\n this._wrapX ? Util.wrapNum(coords.x, this._wrapX) : coords.x,\r\n this._wrapY ? Util.wrapNum(coords.y, this._wrapY) : coords.y\r\n );\r\n newCoords.z = coords.z;\r\n return newCoords;\r\n },\r\n\r\n _pxBoundsToCellRange: function (bounds) {\r\n var cellSize = this.getCellSize();\r\n return new Bounds(\r\n bounds.min.unscaleBy(cellSize).floor(),\r\n bounds.max.unscaleBy(cellSize).ceil().subtract([1, 1])\r\n );\r\n }\r\n});\r\n","function BinarySearchIndex (values) {\n this.values = [].concat(values || []);\n}\n\nBinarySearchIndex.prototype.query = function (value) {\n var index = this.getIndex(value);\n return this.values[index];\n};\n\nBinarySearchIndex.prototype.getIndex = function getIndex (value) {\n if (this.dirty) {\n this.sort();\n }\n\n var minIndex = 0;\n var maxIndex = this.values.length - 1;\n var currentIndex;\n var currentElement;\n\n while (minIndex <= maxIndex) {\n currentIndex = (minIndex + maxIndex) / 2 | 0;\n currentElement = this.values[Math.round(currentIndex)];\n if (+currentElement.value < +value) {\n minIndex = currentIndex + 1;\n } else if (+currentElement.value > +value) {\n maxIndex = currentIndex - 1;\n } else {\n return currentIndex;\n }\n }\n\n return Math.abs(~maxIndex);\n};\n\nBinarySearchIndex.prototype.between = function between (start, end) {\n var startIndex = this.getIndex(start);\n var endIndex = this.getIndex(end);\n\n if (startIndex === 0 && endIndex === 0) {\n return [];\n }\n\n while (this.values[startIndex - 1] && this.values[startIndex - 1].value === start) {\n startIndex--;\n }\n\n while (this.values[endIndex + 1] && this.values[endIndex + 1].value === end) {\n endIndex++;\n }\n\n if (this.values[endIndex] && this.values[endIndex].value === end && this.values[endIndex + 1]) {\n endIndex++;\n }\n\n return this.values.slice(startIndex, endIndex);\n};\n\nBinarySearchIndex.prototype.insert = function insert (item) {\n this.values.splice(this.getIndex(item.value), 0, item);\n return this;\n};\n\nBinarySearchIndex.prototype.bulkAdd = function bulkAdd (items, sort) {\n this.values = this.values.concat([].concat(items || []));\n\n if (sort) {\n this.sort();\n } else {\n this.dirty = true;\n }\n\n return this;\n};\n\nBinarySearchIndex.prototype.sort = function sort () {\n this.values.sort(function (a, b) {\n return +b.value - +a.value;\n }).reverse();\n this.dirty = false;\n return this;\n};\n\nexport default BinarySearchIndex;\n","import { Util } from 'leaflet';\r\nimport featureLayerService from '../../Services/FeatureLayerService';\r\nimport {\r\n getUrlParams,\r\n warn,\r\n setEsriAttribution,\r\n removeEsriAttribution\r\n} from '../../Util';\r\nimport { FeatureGrid } from './FeatureGrid';\r\nimport BinarySearchIndex from 'tiny-binary-search';\r\n\r\nexport var FeatureManager = FeatureGrid.extend({\r\n /**\r\n * Options\r\n */\r\n\r\n options: {\r\n attribution: null,\r\n where: '1=1',\r\n fields: ['*'],\r\n from: false,\r\n to: false,\r\n timeField: false,\r\n timeFilterMode: 'server',\r\n simplifyFactor: 0,\r\n precision: 6,\r\n fetchAllFeatures: false\r\n },\r\n\r\n /**\r\n * Constructor\r\n */\r\n\r\n initialize: function (options) {\r\n FeatureGrid.prototype.initialize.call(this, options);\r\n\r\n options = getUrlParams(options);\r\n options = Util.setOptions(this, options);\r\n\r\n this.service = featureLayerService(options);\r\n this.service.addEventParent(this);\r\n\r\n // use case insensitive regex to look for common fieldnames used for indexing\r\n if (this.options.fields[0] !== '*') {\r\n var oidCheck = false;\r\n for (var i = 0; i < this.options.fields.length; i++) {\r\n if (this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i)) {\r\n oidCheck = true;\r\n }\r\n }\r\n if (oidCheck === false) {\r\n warn(\r\n 'no known esriFieldTypeOID field detected in fields Array. Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.'\r\n );\r\n }\r\n }\r\n\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n this._startTimeIndex = new BinarySearchIndex();\r\n this._endTimeIndex = new BinarySearchIndex();\r\n } else if (this.options.timeField) {\r\n this._timeIndex = new BinarySearchIndex();\r\n }\r\n\r\n this._cache = {};\r\n this._currentSnapshot = []; // cache of what layers should be active\r\n this._activeRequests = 0;\r\n },\r\n\r\n /**\r\n * Layer Interface\r\n */\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n this.service.metadata(function (err, metadata) {\r\n if (!err) {\r\n var supportedFormats = metadata.supportedQueryFormats;\r\n\r\n // Check if someone has requested that we don't use geoJSON, even if it's available\r\n var forceJsonFormat = false;\r\n if (\r\n this.service.options.isModern === false ||\r\n this.options.fetchAllFeatures\r\n ) {\r\n forceJsonFormat = true;\r\n }\r\n\r\n // Unless we've been told otherwise, check to see whether service can emit GeoJSON natively\r\n if (\r\n !forceJsonFormat &&\r\n supportedFormats &&\r\n supportedFormats.indexOf('geoJSON') !== -1\r\n ) {\r\n this.service.options.isModern = true;\r\n }\r\n\r\n if (metadata.objectIdField) {\r\n this.service.options.idAttribute = metadata.objectIdField;\r\n }\r\n\r\n // add copyright text listed in service metadata\r\n if (\r\n !this.options.attribution &&\r\n map.attributionControl &&\r\n metadata.copyrightText\r\n ) {\r\n this.options.attribution = metadata.copyrightText;\r\n map.attributionControl.addAttribution(this.getAttribution());\r\n }\r\n }\r\n }, this);\r\n\r\n map.on('zoomend', this._handleZoomChange, this);\r\n\r\n return FeatureGrid.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n map.off('zoomend', this._handleZoomChange, this);\r\n\r\n return FeatureGrid.prototype.onRemove.call(this, map);\r\n },\r\n\r\n getAttribution: function () {\r\n return this.options.attribution;\r\n },\r\n\r\n /**\r\n * Feature Management\r\n */\r\n\r\n createCell: function (bounds, coords) {\r\n // dont fetch features outside the scale range defined for the layer\r\n if (this._visibleZoom()) {\r\n this._requestFeatures(bounds, coords);\r\n }\r\n },\r\n\r\n _requestFeatures: function (bounds, coords, callback, offset) {\r\n this._activeRequests++;\r\n\r\n // default param\r\n offset = offset || 0;\r\n\r\n var originalWhere = this.options.where;\r\n\r\n // our first active request fires loading\r\n if (this._activeRequests === 1) {\r\n this.fire(\r\n 'loading',\r\n {\r\n bounds: bounds\r\n },\r\n true\r\n );\r\n }\r\n\r\n return this._buildQuery(bounds, offset).run(function (\r\n error,\r\n featureCollection,\r\n response\r\n ) {\r\n if (response && response.exceededTransferLimit) {\r\n this.fire('drawlimitexceeded');\r\n }\r\n\r\n // the where changed while this request was being run so don't it.\r\n if (this.options.where !== originalWhere) {\r\n return;\r\n }\r\n\r\n // no error, features\r\n if (!error && featureCollection && featureCollection.features.length) {\r\n // schedule adding features until the next animation frame\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n this._addFeatures(featureCollection.features, coords);\r\n this._postProcessFeatures(bounds);\r\n }, this)\r\n );\r\n }\r\n\r\n // no error, no features\r\n if (!error && featureCollection && !featureCollection.features.length) {\r\n this._postProcessFeatures(bounds);\r\n }\r\n\r\n if (error) {\r\n this._postProcessFeatures(bounds);\r\n }\r\n\r\n if (callback) {\r\n callback.call(this, error, featureCollection);\r\n }\r\n if (\r\n response &&\r\n (response.exceededTransferLimit ||\r\n (response.properties && response.properties.exceededTransferLimit)) &&\r\n this.options.fetchAllFeatures\r\n ) {\r\n this._requestFeatures(\r\n bounds,\r\n coords,\r\n callback,\r\n offset + featureCollection.features.length\r\n );\r\n }\r\n },\r\n this);\r\n },\r\n\r\n _postProcessFeatures: function (bounds) {\r\n // deincrement the request counter now that we have processed features\r\n this._activeRequests--;\r\n\r\n // if there are no more active requests fire a load event for this view\r\n if (this._activeRequests <= 0) {\r\n this.fire('load', {\r\n bounds: bounds\r\n });\r\n }\r\n },\r\n\r\n _cacheKey: function (coords) {\r\n return coords.z + ':' + coords.x + ':' + coords.y;\r\n },\r\n\r\n _addFeatures: function (features, coords) {\r\n // coords is optional - will be false if coming from addFeatures() function\r\n if (coords) {\r\n var key = this._cacheKey(coords);\r\n this._cache[key] = this._cache[key] || [];\r\n }\r\n\r\n for (var i = features.length - 1; i >= 0; i--) {\r\n var id = features[i].id;\r\n\r\n if (this._currentSnapshot.indexOf(id) === -1) {\r\n this._currentSnapshot.push(id);\r\n }\r\n if (typeof key !== 'undefined' && this._cache[key].indexOf(id) === -1) {\r\n this._cache[key].push(id);\r\n }\r\n }\r\n\r\n if (this.options.timeField) {\r\n this._buildTimeIndexes(features);\r\n }\r\n\r\n this.createLayers(features);\r\n },\r\n\r\n _buildQuery: function (bounds, offset) {\r\n var query = this.service\r\n .query()\r\n .intersects(bounds)\r\n .where(this.options.where)\r\n .fields(this.options.fields)\r\n .precision(this.options.precision);\r\n\r\n if (this.options.fetchAllFeatures && !isNaN(parseInt(offset))) {\r\n query = query.offset(offset);\r\n }\r\n\r\n query.params['resultType'] = 'tile';\r\n\r\n if (this.options.requestParams) {\r\n Util.extend(query.params, this.options.requestParams);\r\n }\r\n\r\n if (this.options.simplifyFactor) {\r\n query.simplify(this._map, this.options.simplifyFactor);\r\n }\r\n\r\n if (\r\n this.options.timeFilterMode === 'server' &&\r\n this.options.from &&\r\n this.options.to\r\n ) {\r\n query.between(this.options.from, this.options.to);\r\n }\r\n\r\n return query;\r\n },\r\n\r\n /**\r\n * Where Methods\r\n */\r\n\r\n setWhere: function (where, callback, context) {\r\n this.options.where = where && where.length ? where : '1=1';\r\n\r\n var oldSnapshot = [];\r\n var newSnapshot = [];\r\n var pendingRequests = 0;\r\n var requestError = null;\r\n var requestCallback = Util.bind(function (error, featureCollection) {\r\n if (error) {\r\n requestError = error;\r\n }\r\n\r\n if (featureCollection) {\r\n for (var i = featureCollection.features.length - 1; i >= 0; i--) {\r\n newSnapshot.push(featureCollection.features[i].id);\r\n }\r\n }\r\n\r\n pendingRequests--;\r\n\r\n if (\r\n pendingRequests <= 0 &&\r\n this._visibleZoom() &&\r\n where === this.options.where // the where is still the same so use this one\r\n ) {\r\n this._currentSnapshot = newSnapshot;\r\n // schedule adding features for the next animation frame\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n this.removeLayers(oldSnapshot);\r\n this.addLayers(newSnapshot);\r\n if (callback) {\r\n callback.call(context, requestError);\r\n }\r\n }, this)\r\n );\r\n }\r\n }, this);\r\n\r\n for (var i = this._currentSnapshot.length - 1; i >= 0; i--) {\r\n oldSnapshot.push(this._currentSnapshot[i]);\r\n }\r\n\r\n this._cache = {};\r\n\r\n for (var key in this._cells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, coords, requestCallback);\r\n }\r\n\r\n return this;\r\n },\r\n\r\n getWhere: function () {\r\n return this.options.where;\r\n },\r\n\r\n /**\r\n * Time Range Methods\r\n */\r\n\r\n getTimeRange: function () {\r\n return [this.options.from, this.options.to];\r\n },\r\n\r\n setTimeRange: function (from, to, callback, context) {\r\n var oldFrom = this.options.from;\r\n var oldTo = this.options.to;\r\n var pendingRequests = 0;\r\n var requestError = null;\r\n var requestCallback = Util.bind(function (error) {\r\n if (error) {\r\n requestError = error;\r\n }\r\n this._filterExistingFeatures(oldFrom, oldTo, from, to);\r\n\r\n pendingRequests--;\r\n\r\n if (callback && pendingRequests <= 0) {\r\n callback.call(context, requestError);\r\n }\r\n }, this);\r\n\r\n this.options.from = from;\r\n this.options.to = to;\r\n\r\n this._filterExistingFeatures(oldFrom, oldTo, from, to);\r\n\r\n if (this.options.timeFilterMode === 'server') {\r\n for (var key in this._cells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, coords, requestCallback);\r\n }\r\n }\r\n\r\n return this;\r\n },\r\n\r\n refresh: function () {\r\n this.setWhere(this.options.where);\r\n },\r\n\r\n _filterExistingFeatures: function (oldFrom, oldTo, newFrom, newTo) {\r\n var layersToRemove =\r\n oldFrom && oldTo\r\n ? this._getFeaturesInTimeRange(oldFrom, oldTo)\r\n : this._currentSnapshot;\r\n var layersToAdd = this._getFeaturesInTimeRange(newFrom, newTo);\r\n\r\n if (layersToAdd.indexOf) {\r\n for (var i = 0; i < layersToAdd.length; i++) {\r\n var shouldRemoveLayer = layersToRemove.indexOf(layersToAdd[i]);\r\n if (shouldRemoveLayer >= 0) {\r\n layersToRemove.splice(shouldRemoveLayer, 1);\r\n }\r\n }\r\n }\r\n\r\n // schedule adding features until the next animation frame\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n this.removeLayers(layersToRemove);\r\n this.addLayers(layersToAdd);\r\n }, this)\r\n );\r\n },\r\n\r\n _getFeaturesInTimeRange: function (start, end) {\r\n var ids = [];\r\n var search;\r\n\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n var startTimes = this._startTimeIndex.between(start, end);\r\n var endTimes = this._endTimeIndex.between(start, end);\r\n search = startTimes.concat(endTimes);\r\n } else if (this._timeIndex) {\r\n search = this._timeIndex.between(start, end);\r\n } else {\r\n warn(\r\n 'You must set timeField in the layer constructor in order to manipulate the start and end time filter.'\r\n );\r\n return [];\r\n }\r\n\r\n for (var i = search.length - 1; i >= 0; i--) {\r\n ids.push(search[i].id);\r\n }\r\n\r\n return ids;\r\n },\r\n\r\n _buildTimeIndexes: function (geojson) {\r\n var i;\r\n var feature;\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n var startTimeEntries = [];\r\n var endTimeEntries = [];\r\n for (i = geojson.length - 1; i >= 0; i--) {\r\n feature = geojson[i];\r\n startTimeEntries.push({\r\n id: feature.id,\r\n value: new Date(feature.properties[this.options.timeField.start])\r\n });\r\n endTimeEntries.push({\r\n id: feature.id,\r\n value: new Date(feature.properties[this.options.timeField.end])\r\n });\r\n }\r\n this._startTimeIndex.bulkAdd(startTimeEntries);\r\n this._endTimeIndex.bulkAdd(endTimeEntries);\r\n } else {\r\n var timeEntries = [];\r\n for (i = geojson.length - 1; i >= 0; i--) {\r\n feature = geojson[i];\r\n timeEntries.push({\r\n id: feature.id,\r\n value: new Date(feature.properties[this.options.timeField])\r\n });\r\n }\r\n\r\n this._timeIndex.bulkAdd(timeEntries);\r\n }\r\n },\r\n\r\n _featureWithinTimeRange: function (feature) {\r\n if (!this.options.from || !this.options.to) {\r\n return true;\r\n }\r\n\r\n var from = +this.options.from.valueOf();\r\n var to = +this.options.to.valueOf();\r\n\r\n if (typeof this.options.timeField === 'string') {\r\n var date = +feature.properties[this.options.timeField];\r\n return date >= from && date <= to;\r\n }\r\n\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n var startDate = +feature.properties[this.options.timeField.start];\r\n var endDate = +feature.properties[this.options.timeField.end];\r\n return (\r\n (startDate >= from && startDate <= to) ||\r\n (endDate >= from && endDate <= to) ||\r\n (startDate <= from && endDate >= to)\r\n );\r\n }\r\n },\r\n\r\n _visibleZoom: function () {\r\n // check to see whether the current zoom level of the map is within the optional limit defined for the FeatureLayer\r\n if (!this._map) {\r\n return false;\r\n }\r\n var zoom = this._map.getZoom();\r\n if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n },\r\n\r\n _handleZoomChange: function () {\r\n if (!this._visibleZoom()) {\r\n // if we have moved outside the visible zoom range clear the current snapshot, no layers should be active\r\n this.removeLayers(this._currentSnapshot);\r\n this._currentSnapshot = [];\r\n } else {\r\n /*\r\n for every cell in this._cells\r\n 1. Get the cache key for the coords of the cell\r\n 2. If this._cache[key] exists it will be an array of feature IDs.\r\n 3. Call this.addLayers(this._cache[key]) to instruct the feature layer to add the layers back.\r\n */\r\n for (var i in this._cells) {\r\n var coords = this._cells[i].coords;\r\n var key = this._cacheKey(coords);\r\n if (this._cache[key]) {\r\n this.addLayers(this._cache[key]);\r\n }\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Service Methods\r\n */\r\n\r\n authenticate: function (token) {\r\n this.service.authenticate(token);\r\n return this;\r\n },\r\n\r\n metadata: function (callback, context) {\r\n this.service.metadata(callback, context);\r\n return this;\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n _getMetadata: function (callback) {\r\n if (this._metadata) {\r\n var error;\r\n callback(error, this._metadata);\r\n } else {\r\n this.metadata(\r\n Util.bind(function (error, response) {\r\n this._metadata = response;\r\n callback(error, this._metadata);\r\n }, this)\r\n );\r\n }\r\n },\r\n\r\n addFeature: function (feature, callback, context) {\r\n this.addFeatures(feature, callback, context);\r\n },\r\n\r\n addFeatures: function (features, callback, context) {\r\n this._getMetadata(\r\n Util.bind(function (error, metadata) {\r\n if (error) {\r\n if (callback) {\r\n callback.call(this, error, null);\r\n }\r\n return;\r\n }\r\n // GeoJSON featureCollection or simple feature\r\n var featuresArray = features.features ? features.features : [features];\r\n\r\n this.service.addFeatures(\r\n features,\r\n Util.bind(function (error, response) {\r\n if (!error) {\r\n for (var i = featuresArray.length - 1; i >= 0; i--) {\r\n // assign ID from result to appropriate objectid field from service metadata\r\n featuresArray[i].properties[metadata.objectIdField] =\r\n featuresArray.length > 1\r\n ? response[i].objectId\r\n : response.objectId;\r\n // we also need to update the geojson id for createLayers() to function\r\n featuresArray[i].id =\r\n featuresArray.length > 1\r\n ? response[i].objectId\r\n : response.objectId;\r\n }\r\n this._addFeatures(featuresArray);\r\n }\r\n\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n }, this)\r\n );\r\n }, this)\r\n );\r\n },\r\n\r\n updateFeature: function (feature, callback, context) {\r\n this.updateFeatures(feature, callback, context);\r\n },\r\n\r\n updateFeatures: function (features, callback, context) {\r\n // GeoJSON featureCollection or simple feature\r\n var featuresArray = features.features ? features.features : [features];\r\n this.service.updateFeatures(\r\n features,\r\n function (error, response) {\r\n if (!error) {\r\n for (var i = featuresArray.length - 1; i >= 0; i--) {\r\n this.removeLayers([featuresArray[i].id], true);\r\n }\r\n this._addFeatures(featuresArray);\r\n }\r\n\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n },\r\n this\r\n );\r\n },\r\n\r\n deleteFeature: function (id, callback, context) {\r\n this.deleteFeatures(id, callback, context);\r\n },\r\n\r\n deleteFeatures: function (ids, callback, context) {\r\n return this.service.deleteFeatures(\r\n ids,\r\n function (error, response) {\r\n var responseArray = response.length ? response : [response];\r\n if (!error && responseArray.length > 0) {\r\n for (var i = responseArray.length - 1; i >= 0; i--) {\r\n this.removeLayers([responseArray[i].objectId], true);\r\n }\r\n }\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n },\r\n this\r\n );\r\n }\r\n});\r\n","import { Path, Util, GeoJSON, latLng } from 'leaflet';\r\nimport { FeatureManager } from './FeatureManager';\r\nimport { warn } from '../../Util';\r\n\r\nexport var FeatureLayer = FeatureManager.extend({\r\n options: {\r\n cacheLayers: true\r\n },\r\n\r\n /**\r\n * Constructor\r\n */\r\n initialize: function (options) {\r\n if (options.apikey) {\r\n options.token = options.apikey;\r\n }\r\n FeatureManager.prototype.initialize.call(this, options);\r\n this._originalStyle = this.options.style;\r\n this._layers = {};\r\n },\r\n\r\n /**\r\n * Layer Interface\r\n */\r\n\r\n onRemove: function (map) {\r\n for (var i in this._layers) {\r\n map.removeLayer(this._layers[i]);\r\n // trigger the event when the entire featureLayer is removed from the map\r\n this.fire(\r\n 'removefeature',\r\n {\r\n feature: this._layers[i].feature,\r\n permanent: false\r\n },\r\n true\r\n );\r\n }\r\n\r\n return FeatureManager.prototype.onRemove.call(this, map);\r\n },\r\n\r\n createNewLayer: function (geojson) {\r\n var layer = GeoJSON.geometryToLayer(geojson, this.options);\r\n // trap for GeoJSON without geometry\r\n if (layer) {\r\n layer.defaultOptions = layer.options;\r\n }\r\n return layer;\r\n },\r\n\r\n _updateLayer: function (layer, geojson) {\r\n // convert the geojson coordinates into a Leaflet LatLng array/nested arrays\r\n // pass it to setLatLngs to update layer geometries\r\n var latlngs = [];\r\n var coordsToLatLng = this.options.coordsToLatLng || GeoJSON.coordsToLatLng;\r\n\r\n // copy new attributes, if present\r\n if (geojson.properties) {\r\n layer.feature.properties = geojson.properties;\r\n }\r\n\r\n switch (geojson.geometry.type) {\r\n case 'Point':\r\n latlngs = GeoJSON.coordsToLatLng(geojson.geometry.coordinates);\r\n layer.setLatLng(latlngs);\r\n break;\r\n case 'LineString':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 0,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiLineString':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 1,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'Polygon':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 1,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiPolygon':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 2,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n }\r\n },\r\n\r\n /**\r\n * Feature Management Methods\r\n */\r\n\r\n createLayers: function (features) {\r\n for (var i = features.length - 1; i >= 0; i--) {\r\n var geojson = features[i];\r\n\r\n var layer = this._layers[geojson.id];\r\n var newLayer;\r\n\r\n if (\r\n this._visibleZoom() &&\r\n layer &&\r\n !this._map.hasLayer(layer) &&\r\n (!this.options.timeField || this._featureWithinTimeRange(geojson))\r\n ) {\r\n this._map.addLayer(layer);\r\n this.fire(\r\n 'addfeature',\r\n {\r\n feature: layer.feature\r\n },\r\n true\r\n );\r\n }\r\n\r\n // update geometry if necessary\r\n if (\r\n layer &&\r\n this.options.simplifyFactor > 0 &&\r\n (layer.setLatLngs || layer.setLatLng)\r\n ) {\r\n this._updateLayer(layer, geojson);\r\n }\r\n\r\n if (!layer) {\r\n newLayer = this.createNewLayer(geojson);\r\n\r\n if (!newLayer) {\r\n warn('invalid GeoJSON encountered');\r\n } else {\r\n newLayer.feature = geojson;\r\n\r\n // bubble events from individual layers to the feature layer\r\n newLayer.addEventParent(this);\r\n\r\n if (this.options.onEachFeature) {\r\n this.options.onEachFeature(newLayer.feature, newLayer);\r\n }\r\n\r\n // cache the layer\r\n this._layers[newLayer.feature.id] = newLayer;\r\n\r\n // style the layer\r\n this.setFeatureStyle(newLayer.feature.id, this.options.style);\r\n\r\n this.fire(\r\n 'createfeature',\r\n {\r\n feature: newLayer.feature\r\n },\r\n true\r\n );\r\n\r\n // add the layer if the current zoom level is inside the range defined for the layer, it is within the current time bounds or our layer is not time enabled\r\n if (\r\n this._visibleZoom() &&\r\n (!this.options.timeField ||\r\n (this.options.timeField && this._featureWithinTimeRange(geojson)))\r\n ) {\r\n this._map.addLayer(newLayer);\r\n }\r\n }\r\n }\r\n }\r\n },\r\n\r\n addLayers: function (ids) {\r\n for (var i = ids.length - 1; i >= 0; i--) {\r\n var layer = this._layers[ids[i]];\r\n if (\r\n layer &&\r\n (!this.options.timeField || this._featureWithinTimeRange(layer.feature))\r\n ) {\r\n this._map.addLayer(layer);\r\n this.fire(\r\n 'addfeature',\r\n {\r\n feature: layer.feature\r\n },\r\n true\r\n );\r\n }\r\n }\r\n },\r\n\r\n removeLayers: function (ids, permanent) {\r\n for (var i = ids.length - 1; i >= 0; i--) {\r\n var id = ids[i];\r\n var layer = this._layers[id];\r\n if (layer) {\r\n this.fire(\r\n 'removefeature',\r\n {\r\n feature: layer.feature,\r\n permanent: permanent\r\n },\r\n true\r\n );\r\n this._map.removeLayer(layer);\r\n }\r\n if (layer && permanent) {\r\n delete this._layers[id];\r\n }\r\n }\r\n },\r\n\r\n cellEnter: function (bounds, coords) {\r\n if (this._visibleZoom() && !this._zooming && this._map) {\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n var cacheKey = this._cacheKey(coords);\r\n var cellKey = this._cellCoordsToKey(coords);\r\n var layers = this._cache[cacheKey];\r\n if (this._activeCells[cellKey] && layers) {\r\n this.addLayers(layers);\r\n }\r\n }, this)\r\n );\r\n }\r\n },\r\n\r\n cellLeave: function (bounds, coords) {\r\n if (!this._zooming) {\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n if (this._map) {\r\n var cacheKey = this._cacheKey(coords);\r\n var cellKey = this._cellCoordsToKey(coords);\r\n var layers = this._cache[cacheKey];\r\n var mapBounds = this._map.getBounds();\r\n if (!this._activeCells[cellKey] && layers) {\r\n var removable = true;\r\n\r\n for (var i = 0; i < layers.length; i++) {\r\n var layer = this._layers[layers[i]];\r\n if (\r\n layer &&\r\n layer.getBounds &&\r\n mapBounds.intersects(layer.getBounds())\r\n ) {\r\n removable = false;\r\n }\r\n }\r\n\r\n if (removable) {\r\n this.removeLayers(layers, !this.options.cacheLayers);\r\n }\r\n\r\n if (!this.options.cacheLayers && removable) {\r\n delete this._cache[cacheKey];\r\n delete this._cells[cellKey];\r\n delete this._activeCells[cellKey];\r\n }\r\n }\r\n }\r\n }, this)\r\n );\r\n }\r\n },\r\n\r\n /**\r\n * Styling Methods\r\n */\r\n\r\n resetStyle: function () {\r\n this.options.style = this._originalStyle;\r\n this.eachFeature(function (layer) {\r\n this.resetFeatureStyle(layer.feature.id);\r\n }, this);\r\n return this;\r\n },\r\n\r\n setStyle: function (style) {\r\n this.options.style = style;\r\n this.eachFeature(function (layer) {\r\n this.setFeatureStyle(layer.feature.id, style);\r\n }, this);\r\n return this;\r\n },\r\n\r\n resetFeatureStyle: function (id) {\r\n var layer = this._layers[id];\r\n var style = this._originalStyle || Path.prototype.options;\r\n if (layer) {\r\n Util.extend(layer.options, layer.defaultOptions);\r\n this.setFeatureStyle(id, style);\r\n }\r\n return this;\r\n },\r\n\r\n setFeatureStyle: function (id, style) {\r\n var layer = this._layers[id];\r\n if (typeof style === 'function') {\r\n style = style(layer.feature);\r\n }\r\n if (layer.setStyle) {\r\n layer.setStyle(style);\r\n }\r\n return this;\r\n },\r\n\r\n /**\r\n * Utility Methods\r\n */\r\n\r\n eachActiveFeature: function (fn, context) {\r\n // figure out (roughly) which layers are in view\r\n if (this._map) {\r\n var activeBounds = this._map.getBounds();\r\n for (var i in this._layers) {\r\n if (this._currentSnapshot.indexOf(this._layers[i].feature.id) !== -1) {\r\n // a simple point in poly test for point geometries\r\n if (\r\n typeof this._layers[i].getLatLng === 'function' &&\r\n activeBounds.contains(this._layers[i].getLatLng())\r\n ) {\r\n fn.call(context, this._layers[i]);\r\n } else if (\r\n typeof this._layers[i].getBounds === 'function' &&\r\n activeBounds.intersects(this._layers[i].getBounds())\r\n ) {\r\n // intersecting bounds check for polyline and polygon geometries\r\n fn.call(context, this._layers[i]);\r\n }\r\n }\r\n }\r\n }\r\n return this;\r\n },\r\n\r\n eachFeature: function (fn, context) {\r\n for (var i in this._layers) {\r\n fn.call(context, this._layers[i]);\r\n }\r\n return this;\r\n },\r\n\r\n getFeature: function (id) {\r\n return this._layers[id];\r\n },\r\n\r\n bringToBack: function () {\r\n this.eachFeature(function (layer) {\r\n if (layer.bringToBack) {\r\n layer.bringToBack();\r\n }\r\n });\r\n },\r\n\r\n bringToFront: function () {\r\n this.eachFeature(function (layer) {\r\n if (layer.bringToFront) {\r\n layer.bringToFront();\r\n }\r\n });\r\n },\r\n\r\n redraw: function (id) {\r\n if (id) {\r\n this._redraw(id);\r\n }\r\n return this;\r\n },\r\n\r\n _redraw: function (id) {\r\n var layer = this._layers[id];\r\n var geojson = layer.feature;\r\n\r\n // if this looks like a marker\r\n if (layer && layer.setIcon && this.options.pointToLayer) {\r\n // update custom symbology, if necessary\r\n if (this.options.pointToLayer) {\r\n var getIcon = this.options.pointToLayer(\r\n geojson,\r\n latLng(\r\n geojson.geometry.coordinates[1],\r\n geojson.geometry.coordinates[0]\r\n )\r\n );\r\n var updatedIcon = getIcon.options.icon;\r\n layer.setIcon(updatedIcon);\r\n }\r\n }\r\n\r\n // looks like a vector marker (circleMarker)\r\n if (layer && layer.setStyle && this.options.pointToLayer) {\r\n var getStyle = this.options.pointToLayer(\r\n geojson,\r\n latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0])\r\n );\r\n var updatedStyle = getStyle.options;\r\n this.setFeatureStyle(geojson.id, updatedStyle);\r\n }\r\n\r\n // looks like a path (polygon/polyline)\r\n if (layer && layer.setStyle && this.options.style) {\r\n this.resetStyle(geojson.id);\r\n }\r\n }\r\n});\r\n\r\nexport function featureLayer (options) {\r\n return new FeatureLayer(options);\r\n}\r\n\r\nexport default featureLayer;\r\n","// export version\r\nimport packageInfo from '../package.json';\r\nvar version = packageInfo.version;\r\nexport { version as VERSION };\r\n\r\n// import base\r\nexport { Support } from './Support';\r\nexport { options } from './Options';\r\nexport { EsriUtil as Util } from './Util';\r\nexport { get, post, request } from './Request';\r\n\r\n// export tasks\r\nexport { Task, task } from './Tasks/Task';\r\nexport { Query, query } from './Tasks/Query';\r\nexport { Find, find } from './Tasks/Find';\r\nexport { Identify, identify } from './Tasks/Identify';\r\nexport { IdentifyFeatures, identifyFeatures } from './Tasks/IdentifyFeatures';\r\nexport { IdentifyImage, identifyImage } from './Tasks/IdentifyImage';\r\n\r\n// export services\r\nexport { Service, service } from './Services/Service';\r\nexport { MapService, mapService } from './Services/MapService';\r\nexport { ImageService, imageService } from './Services/ImageService';\r\nexport { FeatureLayerService, featureLayerService } from './Services/FeatureLayerService';\r\n\r\n// export layers\r\nexport { BasemapLayer, basemapLayer } from './Layers/BasemapLayer';\r\nexport { TiledMapLayer, tiledMapLayer } from './Layers/TiledMapLayer';\r\nexport { RasterLayer } from './Layers/RasterLayer';\r\nexport { ImageMapLayer, imageMapLayer } from './Layers/ImageMapLayer';\r\nexport { DynamicMapLayer, dynamicMapLayer } from './Layers/DynamicMapLayer';\r\nexport { FeatureManager } from './Layers/FeatureLayer/FeatureManager';\r\nexport { FeatureLayer, featureLayer } from './Layers/FeatureLayer/FeatureLayer';\r\n"],"names":["cors","window","XMLHttpRequest","pointerEvents","document","documentElement","style","Support","options","attributionWidthOffset","callbacks","serialize","params","param","type","value","data","key","f","hasOwnProperty","Object","prototype","toString","call","length","JSON","stringify","join","valueOf","encodeURIComponent","createRequest","callback","context","httpRequest","onerror","e","onreadystatechange","Util","falseFn","error","code","message","response","readyState","parse","responseText","ontimeout","this","xmlHttpPost","url","open","timeout","setRequestHeader","send","xmlHttpGet","withCredentials","request","paramString","requestLength","jsonp","warn","_EsriLeafletCallbacks","callbackId","responseType","script","DomUtil","create","body","src","id","addClass","abort","_callback","get","console","apply","arguments","CORS","JSONP","arrayIntersectsArray","a","b","i","j","a1","a2","b1","b2","uaT","ubT","uB","ua","ub","edgeIntersectsEdge","closeRing","coordinates","pointsEqual","push","ringIsClockwise","ringToTest","pt2","total","rLength","pt1","shallowClone","obj","target","convertRingsToGeoJSON","rings","outerRing","hole","outerRings","holes","r","polygon","ring","slice","reverse","outer","inner","intersects","contains","uncontainedHoles","pop","contained","x","point","l","coordinatesContainPoint","orientRings","poly","output","shift","Request","post","arcgisToGeoJSON","arcgis","idAttribute","geojson","features","y","z","points","paths","xmin","ymin","xmax","ymax","geometry","attributes","properties","keys","Error","getId","err","spatialReference","wkid","geojsonToArcGIS","result","flattenMultiPolygonRings","geometries","BASE_LEAFLET_ATTRIBUTION_STRING","idAttr","g2a","a2g","extentToBounds","extent","sw","latLng","ne","latLngBounds","boundsToExtent","bounds","getSouthWest","lng","lat","getNorthEast","knownFieldNames","_findIdAttributeFromResponse","objectIdFieldName","fields","name","match","_findIdAttributeFromFeature","feature","responseToFeatureCollection","results","count","objectIdField","featureCollection","cleanUrl","trim","getUrlParams","queryString","indexOf","requestParams","substring","split","decodeURI","replace","isArcgisOnline","test","geojsonTypeToArcGIS","geoJsonType","arcgisGeometryType","calcAttributionWidth","map","getSize","setEsriAttribution","hoverAttributionStyle","attributionStyle","attributionControl","_esriAttributionLayerCount","_esriAttributionAddedOnce","createElement","innerHTML","getElementsByTagName","appendChild","on","_container","maxWidth","setPrefix","removeEsriAttribution","removeClass","_setGeometry","geometryType","LatLngBounds","getLatLng","LatLng","GeoJSON","getLayers","toGeoJSON","_getAttributionData","bind","attributions","_esriAttributions","c","contributors","contributor","coverageAreas","coverageArea","southWest","bbox","northEast","attribution","score","minZoom","zoomMin","maxZoom","zoomMax","sort","_updateMapAttribution","evt","oldAttributions","attributionElement","querySelector","newAttributions","getBounds","wrappedBounds","wrap","zoom","getZoom","text","substr","fire","EsriUtil","Task","Class","extend","proxy","useCors","generateSetter","initialize","endpoint","_service","setOptions","setters","setter","token","authenticate","apikey","format","boolean","returnUnformattedValues","path","_request","method","Query","offset","limit","precision","featureIds","returnGeometry","returnM","transform","where","outSR","outFields","within","_setGeometryParams","spatialRel","crosses","touches","overlaps","bboxIntersects","indexIntersects","nearby","latlng","radius","units","distance","inSR","string","between","start","end","time","simplify","factor","mapWidth","Math","abs","getWest","getEast","maxAllowableOffset","orderBy","fieldName","order","orderByFields","run","_cleanParams","isModern","undefined","_trapSQLerrors","returnCountOnly","ids","returnIdsOnly","objectIds","returnExtentOnly","distinct","returnDistinctValues","pixelSize","rawPoint","castPoint","layer","converted","query","Find","sr","layers","dynamicLayers","returnZ","gdbVersion","layerDefs","find","Identify","IdentifyFeatures","tolerance","size","imageDisplay","mapExtent","at","layerDef","layerId","identifyFeatures","IdentifyImage","setMosaicRule","setRenderingRule","setPixelSize","returnCatalogItems","getMosaicRule","mosaicRule","getRenderingRule","renderingRule","getPixelSize","_responseToGeoJSON","location","catalogItems","catalogItemVisibilities","geoJSON","pixel","crs","OBJECTID","objectId","Values","values","catalogItemVisibility","identifyImage","Service","Evented","_requestQueue","_authenticating","metadata","_runQueue","getTimeout","setTimeout","wrappedCallback","_createServiceCallback","MapService","identify","mapService","ImageService","imageService","FeatureLayerService","addFeature","addFeatures","featuresArray","addResults","updateFeature","updateFeatures","updateResults","deleteFeature","deleteFeatures","deleteResults","featureLayerService","tileProtocol","protocol","BasemapLayer","TileLayer","statics","TILES","Streets","urlTemplate","subdomains","attributionUrl","Topographic","Oceans","OceansLabels","pane","NationalGeographic","DarkGray","DarkGrayLabels","Gray","GrayLabels","Imagery","ImageryLabels","ImageryTransportation","ShadedRelief","ShadedReliefLabels","Terrain","TerrainLabels","USATopo","ImageryClarity","Physical","ImageryFirefly","config","tileOptions","ignoreDeprecationWarning","onAdd","_initPane","onRemove","off","_map","getPane","createPane","zIndex","getAttribution","TiledMapLayer","zoomOffsetAllowance","errorTileUrl","MercatorZoomLevels","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","tileUrl","getParamString","service","addEventParent","RegExp","getTileUrl","tilePoint","_getZoomForUrl","template","s","_getSubdomain","_lodMap","createTile","coords","done","tile","DomEvent","_tileOnLoad","_tileOnError","crossOrigin","alt","once","latestWkid","copyrightText","addAttribution","CRS","EPSG3857","arcgisLODs","tileInfo","lods","correctResolutions","arcgisLOD","ci","correctRes","_withinPercentage","resolution","level","tokenQs","percentage","Overlay","ImageOverlay","_topLeft","getPixelBounds","min","_reset","setPosition","_image","subtract","getPixelOrigin","RasterLayer","Layer","opacity","position","interactive","_update","throttle","updateInterval","_currentImage","_bounds","equals","addLayer","removeLayer","_popup","_getPopupData","_resetPopupState","bindPopup","fn","popupOptions","_shouldRenderPopup","_lastClick","popup","_popupFunction","unbindPopup","closePopup","bringToFront","_setAutoZIndex","max","bringToBack","setZIndex","compare","children","edgeZIndex","Infinity","len","isFinite","getOpacity","setOpacity","getTimeRange","from","to","setTimeRange","redraw","_renderImage","contentType","image","addTo","onOverlayLoad","newImage","oldImage","_animatingZoom","_panTransition","_inProgress","_buildExportParams","_requestExport","_renderPopup","content","setLatLng","setContent","openOn","_calculateBbox","pixelBounds","unproject","getBottomLeft","getTopRight","neProjected","project","swProjected","boundsProjected","_calculateImageSize","top","latLngToLayerPoint","bottom","ImageMapLayer","transparent","setPixelType","pixelType","getPixelType","setBandIds","bandIds","isArray","getBandIds","setNoData","noData","noDataInterpretation","getNoData","getNoDataInterpretation","identifyRequest","parseInt","bboxSR","imageSR","interpolation","compressionQuality","fullUrl","href","DynamicMapLayer","timeOptions","getDynamicLayers","setDynamicLayers","setLayers","getLayerDefs","setLayerDefs","getTimeOptions","setTimeOptions","dpi","disableCache","_ts","Date","now","imageData","FeatureGrid","cellSize","updateWhenIdle","Browser","mobile","noWrap","keepBuffer","_cells","_activeCells","_resetView","_removeAllCells","_cellZoom","isLoading","_loading","getEvents","events","viewprereset","_invalidateAll","viewreset","moveend","_onMoveEnd","_onMove","move","createCell","removeCell","reuseCell","cellLeave","cellEnter","getCellSize","Point","_pruneCells","cell","retain","current","active","_retainParent","_retainChildren","_removeCell","x2","floor","y2","z2","coords2","_cellCoordsToKey","loaded","animating","pinch","flyTo","_setView","getCenter","center","noPrune","noUpdate","cellZoom","round","_abortLoading","_resetGrid","_noPrune","_cellSize","getPixelWorldBounds","_globalCellRange","_pxBoundsToCellRange","_wrapX","wrapLng","ceil","_wrapY","wrapLat","_getCelldPixelBounds","mapZoom","_animateToZoom","scale","getZoomScale","pixelCenter","halfSize","divideBy","Bounds","add","cellRange","cellCenter","queue","margin","noPruneRange","_isValidCell","distanceTo","_key","_coords","_keyToCellCoords","_reuseCell","_createCell","infinite","cellBounds","_cellCoordsToBounds","_keyToBounds","_cellCoordsToNwSe","nwPoint","scaleBy","sePoint","bp","wrapLatLngBounds","k","wrappedCoords","_wrapCoords","requestAnimFrame","_cellReady","_getCellPos","newCoords","wrapNum","unscaleBy","BinarySearchIndex","concat","index","getIndex","dirty","currentIndex","currentElement","minIndex","maxIndex","startIndex","endIndex","insert","item","splice","bulkAdd","items","FeatureManager","timeField","timeFilterMode","simplifyFactor","fetchAllFeatures","oidCheck","_startTimeIndex","_endTimeIndex","_timeIndex","_cache","_currentSnapshot","_activeRequests","supportedFormats","forceJsonFormat","supportedQueryFormats","_handleZoomChange","_visibleZoom","_requestFeatures","originalWhere","_buildQuery","exceededTransferLimit","_addFeatures","_postProcessFeatures","_cacheKey","_buildTimeIndexes","createLayers","isNaN","setWhere","oldSnapshot","newSnapshot","pendingRequests","requestError","requestCallback","removeLayers","addLayers","getWhere","oldFrom","oldTo","_filterExistingFeatures","refresh","newFrom","newTo","layersToRemove","_getFeaturesInTimeRange","layersToAdd","shouldRemoveLayer","startTimes","endTimes","search","startTimeEntries","endTimeEntries","timeEntries","_featureWithinTimeRange","date","startDate","endDate","_getMetadata","_metadata","responseArray","FeatureLayer","cacheLayers","_originalStyle","_layers","permanent","createNewLayer","geometryToLayer","defaultOptions","_updateLayer","latlngs","coordsToLatLng","coordsToLatLngs","setLatLngs","newLayer","hasLayer","onEachFeature","setFeatureStyle","_zooming","cacheKey","cellKey","mapBounds","removable","resetStyle","eachFeature","resetFeatureStyle","setStyle","Path","eachActiveFeature","activeBounds","getFeature","_redraw","updatedIcon","updatedStyle","setIcon","pointToLayer","icon","version","packageInfo"],"mappings":";;;4SAAWA,EAASC,OAAOC,gBAAkB,oBAAqB,IAAID,OAAOC,eAClEC,EAAiE,KAAjDC,SAASC,gBAAgBC,MAAMH,cAE/CI,EAAU,CACnBP,KAAMA,EACNG,cAAeA,GCLNK,EAAU,CACnBC,uBAAwB,ICEtBC,EAAY,EAEhB,SAASC,EAAWC,GAClB,IAMQC,EACAC,EACAC,EARJC,EAAO,GAIX,IAAK,IAAIC,KAFTL,EAAOM,EAAIN,EAAOM,GAAK,OAEPN,EAAQ,CAClBA,EAAOO,eAAeF,KACpBJ,EAAQD,EAAOK,GACfH,EAAOM,OAAOC,UAAUC,SAASC,KAAKV,GAGtCG,EAAKQ,SACPR,GAAQ,KAIRD,EADW,mBAATD,EACoD,oBAA7CM,OAAOC,UAAUC,SAASC,KAAKV,EAAM,IAA6BY,KAAKC,UAAUb,GAASA,EAAMc,KAAK,KAC5F,oBAATb,EACDW,KAAKC,UAAUb,GACL,kBAATC,EACDD,EAAMe,UAENf,EAGVG,GAAQa,mBAAmBZ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