{"version":3,"file":"esri-leaflet.js","sources":["../package.json","../src/Support.js","../src/Options.js","../src/Request.js","../node_modules/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":["{\n \"name\": \"esri-leaflet\",\n \"description\": \"Leaflet plugins for consuming ArcGIS Online and ArcGIS Server services.\",\n \"version\": \"2.1.0\",\n \"author\": \"Patrick Arlt (http://patrickarlt.com)\",\n \"browser\": \"dist/esri-leaflet-debug.js\",\n \"bugs\": {\n \"url\": \"https://github.com/esri/esri-leaflet/issues\"\n },\n \"contributors\": [\n \"Patrick Arlt (http://patrickarlt.com)\",\n \"John Gravois (http://johngravois.com)\"\n ],\n \"dependencies\": {\n \"arcgis-to-geojson-utils\": \"^1.0.1\",\n \"leaflet\": \"~1.0.0\",\n \"leaflet-virtual-grid\": \"^1.0.3\",\n \"tiny-binary-search\": \"^1.0.2\"\n },\n \"devDependencies\": {\n \"chai\": \"3.5.0\",\n \"gh-release\": \"^2.0.0\",\n \"highlight.js\": \"^8.0.0\",\n \"http-server\": \"^0.8.5\",\n \"husky\": \"^0.12.0\",\n \"isparta\": \"^4.0.0\",\n \"istanbul\": \"^0.4.2\",\n \"karma\": \"^1.7.0\",\n \"karma-chai-sinon\": \"^0.1.3\",\n \"karma-coverage\": \"^1.1.1\",\n \"karma-mocha\": \"^1.3.0\",\n \"karma-mocha-reporter\": \"^2.2.1\",\n \"karma-phantomjs-launcher\": \"^0.2.0\",\n \"karma-sourcemap-loader\": \"^0.3.5\",\n \"mkdirp\": \"^0.5.1\",\n \"mocha\": \"^3.4.2\",\n \"parallelshell\": \"^2.0.0\",\n \"phantomjs\": \"^1.9.8\",\n \"rollup\": \"^0.25.4\",\n \"rollup-plugin-json\": \"^2.3.0\",\n \"rollup-plugin-node-resolve\": \"^1.4.0\",\n \"rollup-plugin-uglify\": \"^0.3.1\",\n \"semistandard\": \"^9.0.0\",\n \"sinon\": \"^1.11.1\",\n \"sinon-chai\": \"2.8.0\",\n \"snazzy\": \"^5.0.0\",\n \"uglify-js\": \"^2.8.29\",\n \"watch\": \"^0.17.1\"\n },\n \"homepage\": \"http://esri.github.io/esri-leaflet\",\n \"module\": \"src/EsriLeaflet.js\",\n \"jsnext:main\": \"src/EsriLeaflet.js\",\n \"jspm\": {\n \"registry\": \"npm\",\n \"format\": \"es6\",\n \"main\": \"src/EsriLeaflet.js\"\n },\n \"keywords\": [\n \"arcgis\",\n \"esri\",\n \"esri leaflet\",\n \"gis\",\n \"leaflet plugin\",\n \"mapping\"\n ],\n \"license\": \"Apache-2.0\",\n \"main\": \"dist/esri-leaflet-debug.js\",\n \"readmeFilename\": \"README.md\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git@github.com:Esri/esri-leaflet.git\"\n },\n \"scripts\": {\n \"build\": \"rollup -c profiles/debug.js & rollup -c profiles/production.js\",\n \"lint\": \"semistandard | snazzy\",\n \"prebuild\": \"mkdirp dist\",\n \"prepublish\": \"npm run build\",\n \"pretest\": \"npm run build\",\n \"precommit\": \"npm run lint\",\n \"release\": \"./scripts/release.sh\",\n \"start-watch\": \"watch \\\"npm run build\\\" src\",\n \"start\": \"parallelshell \\\"npm run start-watch\\\" \\\"http-server -p 5000 -c-1 -o\\\"\",\n \"test\": \"npm run lint && karma start\"\n },\n \"semistandard\": {\n \"globals\": [\n \"expect\",\n \"L\",\n \"XMLHttpRequest\",\n \"sinon\",\n \"xhr\",\n \"proj4\"\n ]\n }\n}\n","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');\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');\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\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 2015 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 Liscense.\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 ];\n outerRings.push(polygon); // push to outer rings\n } else {\n holes.push(ring); // counterclockwise push to holes\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\nexport function arcgisToGeoJSON (arcgis, idAttribute) {\n var geojson = {};\n\n if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') {\n geojson.type = 'Point';\n geojson.coordinates = [arcgis.x, arcgis.y];\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 (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 geojson.id = arcgis.attributes[idAttribute] || arcgis.attributes.OBJECTID || arcgis.attributes.FID;\n }\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","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 '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// shallow object clone for feature properties and attributes\n// from http://jsperf.com/cloning-an-object/2\nexport function 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\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\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 if (response.objectIdFieldName) {\n objectIdField = response.objectIdFieldName;\n } else if (response.fields) {\n for (var j = 0; j <= response.fields.length - 1; j++) {\n if (response.fields[j].type === 'esriFieldTypeOID') {\n objectIdField = response.fields[j].name;\n break;\n }\n }\n } else if (count) {\n /* as a last resort, check for common ID fieldnames in the first feature returned\n not foolproof. identifyFeatures can returned a mixed array of features. */\n for (var key in features[0].attributes) {\n if (key.match(/^(OBJECTID|FID|OID|ID)$/i)) {\n objectIdField = key;\n break;\n }\n }\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);\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\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('Leaflet | Powered by Esri');\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 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\n if (map && map.attributionControl && 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 var attributionElement = map.attributionControl._container.querySelector('.esri-dynamic-attribution');\n\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 shallowClone: shallowClone,\n warn: warn,\n cleanUrl: cleanUrl,\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};\n\nexport default EsriUtil;\n","import { Class, Util } from 'leaflet';\nimport {cors} from '../Support';\nimport {cleanUrl} 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._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 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 '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 // 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} 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\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 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 delete feature.id;\n\n feature = geojsonToArcGIS(feature);\n\n return this.post('addFeatures', {\n features: [feature]\n }, function (error, response) {\n var result = (response && 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 feature = geojsonToArcGIS(feature, this.options.idAttribute);\n\n return this.post('updateFeatures', {\n features: [feature]\n }, function (error, response) {\n var result = (response && 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 return this.post('deleteFeatures', {\n objectIds: id\n }, function (error, response) {\n var result = (response && 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 deleteFeatures: function (ids, callback, context) {\n return this.post('deleteFeatures', {\n objectIds: ids\n }, function (error, response) {\n // pass back the entire array\n var result = (response && response.deleteResults) ? response.deleteResults : 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 }\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, © 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, © 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 }\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 }\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 }\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\", \"Gray\", \"GrayLabels\", \"DarkGray\", \"DarkGrayLabels\", \"Imagery\", \"ImageryLabels\", \"ImageryTransportation\", \"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) {\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 = '' + this.options.attribution + '';\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 { TileLayer, Util } from 'leaflet';\nimport { warn, cleanUrl, 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.url = cleanUrl(options.url);\n options = Util.setOptions(this, options);\n\n // set the urls\n this.tileUrl = options.url + 'tile/{z}/{y}/{x}';\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 L.DomEvent.on(tile, 'load', L.bind(this._tileOnLoad, this, done, tile));\n L.DomEvent.on(tile, 'error', L.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 if (!this.options.attribution && map.attributionControl && metadata.copyrightText) {\n this.options.attribution = metadata.copyrightText;\n map.attributionControl.addAttribution(this.getAttribution());\n }\n if (map.options.crs === L.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 {\n if (!proj4) {\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 }\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 // 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\n this._requestExport(params, bounds);\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 { cleanUrl } 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: 'json'\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.url = cleanUrl(options.url);\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 { cleanUrl } 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.url = cleanUrl(options.url);\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 = this.identify().on(this._map).at(e.latlng);\n\n // remove extraneous vertices from response features\n identifyRequest.simplify(this._map, 0.5);\n\n if (this.options.layers) {\n identifyRequest.layers('visible:' + this.options.layers.join(','));\n } else {\n identifyRequest.layers('visible');\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') {\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 params.layers = 'show:' + this.options.layers.join(',');\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 L from 'leaflet';\n\nvar VirtualGrid = L.Layer.extend({\n\n options: {\n cellSize: 512,\n updateInterval: 150\n },\n\n initialize: function (options) {\n options = L.setOptions(this, options);\n this._zooming = false;\n },\n\n onAdd: function (map) {\n this._map = map;\n this._update = L.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 bounds = this._map.getPixelBounds();\n var cellSize = this._getCellSize();\n\n // cell coordinates range for the current view\n var cellBounds = L.bounds(\n bounds.min.divideBy(cellSize).floor(),\n bounds.max.divideBy(cellSize).floor());\n\n this._removeOtherCells(cellBounds);\n this._addCells(cellBounds);\n\n this.fire('cellsupdated');\n },\n\n _addCells: function (bounds) {\n var queue = [];\n var center = bounds.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 = bounds.min.y; j <= bounds.max.y; j++) {\n for (i = bounds.min.x; i <= bounds.max.x; i++) {\n coords = L.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 bounds = this._cellNumBounds;\n if (\n (!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\n (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.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 L.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 L.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 L.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 bounds = this._cells[key].bounds;\n var coords = this._cells[key].coords;\n\n if (this.cellLeave) {\n this.cellLeave(bounds, coords);\n }\n\n this.fire('cellleave', {\n bounds: bounds,\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 ? L.Util.wrapNum(coords.x, this._wrapLng) : coords.x;\n coords.y = this._wrapLat ? L.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 bounds = this._map.getPixelWorldBounds();\n var size = this._getCellSize();\n\n return bounds ? L.bounds(\n bounds.min.divideBy(size).floor(),\n bounds.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 { cleanUrl, 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.url = cleanUrl(options.url);\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 // 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.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._getMetadata(Util.bind(function (error, metadata) {\n if (error) {\n if (callback) { callback.call(this, error, null); }\n return;\n }\n\n this.service.addFeature(feature, Util.bind(function (error, response) {\n if (!error) {\n // assign ID from result to appropriate objectid field from service metadata\n feature.properties[metadata.objectIdField] = response.objectId;\n\n // we also need to update the geojson id for createLayers() to function\n feature.id = response.objectId;\n this.createLayers([feature]);\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.service.updateFeature(feature, function (error, response) {\n if (!error) {\n this.removeLayers([feature.id], true);\n this.createLayers([feature]);\n }\n\n if (callback) {\n callback.call(context, error, response);\n }\n }, this);\n },\n\n deleteFeature: function (id, callback, context) {\n this.service.deleteFeature(id, function (error, response) {\n if (!error && response.objectId) {\n this.removeLayers([response.objectId], true);\n }\n if (callback) {\n callback.call(context, error, response);\n }\n }, this);\n },\n\n deleteFeatures: function (ids, callback, context) {\n return this.service.deleteFeatures(ids, function (error, response) {\n if (!error && response.length > 0) {\n for (var i = 0; i < response.length; i++) {\n this.removeLayers([response[i].objectId], true);\n }\n }\n if (callback) {\n callback.call(context, error, response);\n }\n }, this);\n }\n});\n","import { Util, GeoJSON, latLng } from 'leaflet';\nimport { FeatureManager } from './FeatureManager';\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 layer.defaultOptions = layer.options;\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 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 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 || L.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":["serialize","params","data","f","key","hasOwnProperty","value","param","type","Object","prototype","toString","call","length","JSON","stringify","join","valueOf","encodeURIComponent","createRequest","callback","context","httpRequest","window","XMLHttpRequest","onerror","e","onreadystatechange","Util","falseFn","error","code","message","response","readyState","parse","responseText","ontimeout","this","xmlHttpPost","url","open","options","timeout","setRequestHeader","send","xmlHttpGet","request","paramString","requestLength","Support","cors","jsonp","warn","_EsriLeafletCallbacks","callbackId","callbacks","responseType","script","DomUtil","create","document","body","src","id","abort","_callback","pointsEqual","a","b","i","closeRing","coordinates","push","ringIsClockwise","ringToTest","pt2","total","rLength","pt1","vertexIntersectsVertex","a1","a2","b1","b2","uaT","ubT","uB","ua","ub","arrayIntersectsArray","j","coordinatesContainPoint","point","contains","l","coordinatesContainCoordinates","outer","inner","intersects","convertRingsToGeoJSON","rings","x","outerRing","hole","outerRings","holes","r","ring","slice","polygon","uncontainedHoles","pop","contained","reverse","orientRings","poly","output","shift","flattenMultiPolygonRings","shallowClone","obj","target","arcgisToGeoJSON","arcgis","idAttribute","geojson","y","points","paths","geometry","attributes","properties","OBJECTID","FID","geojsonToArcGIS","spatialReference","wkid","result","features","geometries","idAttr","g2a","a2g","extentToBounds","extent","xmin","ymin","xmax","ymax","sw","latLng","ne","latLngBounds","boundsToExtent","bounds","getSouthWest","lng","lat","getNorthEast","responseToFeatureCollection","objectIdField","results","count","objectIdFieldName","fields","name","match","featureCollection","feature","cleanUrl","trim","isArcgisOnline","test","geojsonTypeToArcGIS","geoJsonType","arcgisGeometryType","console","apply","arguments","calcAttributionWidth","map","getSize","attributionWidthOffset","setEsriAttribution","attributionControl","_esriAttributionAdded","setPrefix","hoverAttributionStyle","createElement","innerHTML","getElementsByTagName","appendChild","addClass","_container","attributionStyle","on","style","maxWidth","_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","newAttributions","getBounds","wrappedBounds","wrap","zoom","getZoom","text","substr","attributionElement","querySelector","fire","task","Task","query","Query","find","Find","identify","Identify","identifyFeatures","IdentifyFeatures","identifyImage","IdentifyImage","service","Service","mapService","MapService","imageService","ImageService","featureLayerService","FeatureLayerService","basemapLayer","BasemapLayer","tiledMapLayer","TiledMapLayer","imageMapLayer","ImageMapLayer","dynamicMapLayer","DynamicMapLayer","BinarySearchIndex","values","concat","featureLayer","FeatureLayer","pointerEvents","documentElement","get","CORS","JSONP","Request","post","EsriUtil","Class","extend","proxy","useCors","generateSetter","initialize","endpoint","_service","setOptions","setters","setter","token","authenticate","format","boolean","returnUnformattedValues","path","_request","method","offset","limit","precision","featureIds","returnGeometry","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","pixelSize","rawPoint","castPoint","layer","converted","sr","layers","dynamicLayers","returnZ","returnM","gdbVersion","layerDefs","tolerance","size","imageDisplay","mapExtent","at","layerDef","undefined","layerId","setMosaicRule","setRenderingRule","setPixelSize","returnCatalogItems","getMosaicRule","mosaicRule","getRenderingRule","renderingRule","getPixelSize","_responseToGeoJSON","location","catalogItems","catalogItemVisibilities","geoJSON","pixel","crs","objectId","Values","catalogItemVisibility","Evented","_requestQueue","_authenticating","metadata","_runQueue","getTimeout","setTimeout","wrappedCallback","_createServiceCallback","addFeature","addResults","updateFeature","updateResults","deleteFeature","deleteResults","deleteFeatures","tileProtocol","protocol","TileLayer","statics","TILES","Streets","urlTemplate","subdomains","attributionUrl","Topographic","Oceans","OceansLabels","pane","NationalGeographic","DarkGray","DarkGrayLabels","Gray","GrayLabels","Imagery","ImageryLabels","ImageryTransportation","ShadedRelief","ShadedReliefLabels","Terrain","TerrainLabels","USATopo","config","Error","tileOptions","onAdd","_initPane","onRemove","off","_map","getPane","createPane","zIndex","getAttribution","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","addEventParent","RegExp","replace","getTileUrl","tilePoint","_getZoomForUrl","template","s","_getSubdomain","z","_lodMap","createTile","coords","done","tile","L","DomEvent","_tileOnLoad","_tileOnError","crossOrigin","alt","once","latestWkid","copyrightText","addAttribution","CRS","EPSG3857","arcgisLODs","tileInfo","lods","correctResolutions","arcgisLOD","ci","correctRes","_withinPercentage","resolution","level","proj4","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","err","bindPopup","fn","popupOptions","_shouldRenderPopup","_lastClick","popup","_popupFunction","unbindPopup","closePopup","bringToFront","bringToBack","getOpacity","setOpacity","getTimeRange","from","to","setTimeRange","redraw","_renderImage","contentType","image","addTo","onOverlayError","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","transparent","setPixelType","pixelType","getPixelType","setBandIds","bandIds","isArray","getBandIds","setNoData","noData","noDataInterpretation","getNoData","getNoDataInterpretation","identifyRequest","parseInt","split","bboxSR","imageSR","interpolation","compressionQuality","href","getParamString","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","cellBounds","divideBy","max","_removeOtherCells","_addCells","queue","center","getCenter","_isValidCell","cellsToLoad","distanceTo","_addCell","_cellCoordsToBounds","nwPoint","multiplyBy","sePoint","add","nw","wrapLatLng","se","_cellCoordsToKey","_keyToCellCoords","kArr","_removeCell","cell","cellLeave","_wrapCoords","cellEnter","createCell","wrapNum","getPixelWorldBounds","index","getIndex","dirty","currentIndex","currentElement","minIndex","maxIndex","round","startIndex","endIndex","insert","item","splice","bulkAdd","items","FeatureManager","timeField","timeFilterMode","simplifyFactor","oidCheck","_startTimeIndex","_endTimeIndex","_timeIndex","_cache","_currentSnapshot","_activeRequests","supportedFormats","supportedQueryFormats","forceJsonFormat","indexOf","_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","cacheLayers","_originalStyle","_layers","permanent","createNewLayer","geometryToLayer","defaultOptions","_updateLayer","latlngs","coordsToLatLng","coordsToLatLngs","setLatLngs","newLayer","hasLayer","onEachFeature","setFeatureStyle","cacheKey","cellKey","mapBounds","removable","resetStyle","resetFeatureStyle","setStyle","Path","eachActiveFeature","activeBounds","getFeature","setIcon","pointToLayer","getIcon","updatedIcon","icon","getStyle","updatedStyle"],"mappings":";;;mPGMA,SAASA,GAAWC,GAClB,GAAIC,GAAO,EAEXD,GAAOE,EAAIF,EAAOE,GAAK,MAEvB,KAAK,GAAIC,KAAOH,GACd,GAAIA,EAAOI,eAAeD,GAAM,CAC9B,GAEIE,GAFAC,EAAQN,EAAOG,GACfI,EAAOC,OAAOC,UAAUC,SAASC,KAAKL,EAGtCL,GAAKW,SACPX,GAAQ,KAIRI,EADW,mBAATE,EACoD,oBAA7CC,OAAOC,UAAUC,SAASC,KAAKL,EAAM,IAA6BO,KAAKC,UAAUR,GAASA,EAAMS,KAAK,KAC5F,oBAATR,EACDM,KAAKC,UAAUR,GACL,kBAATC,EACDD,EAAMU,UAENV,EAGVL,GAAQgB,mBAAmBd,GAAO,IAAMc,mBAAmBZ,GAI/D,MAAOJ,GAGT,QAASiB,GAAeC,EAAUC,GAChC,GAAIC,GAAc,GAAIC,QAAOC,cA2C7B,OAzCAF,GAAYG,QAAU,SAAUC,GAC9BJ,EAAYK,mBAAqBC,OAAKC,QAEtCT,EAASR,KAAKS,GACZS,OACEC,KAAM,IACNC,QAAS,yBAEV,OAGLV,EAAYK,mBAAqB,WAC/B,GAAIM,GACAH,CAEJ,IAA+B,IAA3BR,EAAYY,WAAkB,CAChC,IACED,EAAWnB,KAAKqB,MAAMb,EAAYc,cAClC,MAAOV,GACPO,EAAW,KACXH,GACEC,KAAM,IACNC,QAAS,mGAIRF,GAASG,EAASH,QACrBA,EAAQG,EAASH,MACjBG,EAAW,MAGbX,EAAYG,QAAUG,OAAKC,QAE3BT,EAASR,KAAKS,EAASS,EAAOG,KAIlCX,EAAYe,UAAY,WACtBC,KAAKb,WAGAH,EAGT,QAASiB,GAAaC,EAAKvC,EAAQmB,EAAUC,GAC3C,GAAIC,GAAcH,EAAcC,E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