{"version":3,"file":"esri-leaflet.js","sources":["../src/Support.js","../src/Options.js","../src/Request.js","../node_modules/@terraformer/arcgis/dist/t-arcgis.esm.js","../src/Util.js","../src/Tasks/Task.js","../src/Tasks/Query.js","../src/Tasks/Find.js","../src/Tasks/Identify.js","../src/Tasks/IdentifyFeatures.js","../src/Tasks/IdentifyImage.js","../src/Services/Service.js","../src/Services/MapService.js","../src/Services/ImageService.js","../src/Services/FeatureLayerService.js","../src/Layers/BasemapLayer.js","../src/Layers/TiledMapLayer.js","../src/Layers/RasterLayer.js","../src/Layers/ImageMapLayer.js","../src/Layers/DynamicMapLayer.js","../src/Layers/FeatureLayer/FeatureGrid.js","../node_modules/tiny-binary-search/index.js","../src/Layers/FeatureLayer/FeatureManager.js","../src/Layers/FeatureLayer/FeatureLayer.js","../src/EsriLeaflet.js"],"sourcesContent":["export var cors = ((window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest()));\r\nexport var pointerEvents = document.documentElement.style.pointerEvents === '';\r\n\r\nexport var Support = {\r\n cors: cors,\r\n pointerEvents: pointerEvents\r\n};\r\n\r\nexport default Support;\r\n","export var options = {\r\n attributionWidthOffset: 55\r\n};\r\n\r\nexport default options;\r\n","import { Util, DomUtil } from 'leaflet';\r\nimport { Support } from './Support';\r\n\r\nvar callbacks = 0;\r\n\r\nfunction serialize (params) {\r\n var data = '';\r\n\r\n params.f = params.f || 'json';\r\n\r\n for (var key in params) {\r\n if (params.hasOwnProperty(key)) {\r\n var param = params[key];\r\n var type = Object.prototype.toString.call(param);\r\n var value;\r\n\r\n if (data.length) {\r\n data += '&';\r\n }\r\n\r\n if (type === '[object Array]') {\r\n value = (Object.prototype.toString.call(param[0]) === '[object Object]') ? JSON.stringify(param) : param.join(',');\r\n } else if (type === '[object Object]') {\r\n value = JSON.stringify(param);\r\n } else if (type === '[object Date]') {\r\n value = param.valueOf();\r\n } else {\r\n value = param;\r\n }\r\n\r\n data += encodeURIComponent(key) + '=' + encodeURIComponent(value);\r\n }\r\n }\r\n\r\n return data;\r\n}\r\n\r\nfunction createRequest (callback, context) {\r\n var httpRequest = new window.XMLHttpRequest();\r\n\r\n httpRequest.onerror = function (e) {\r\n httpRequest.onreadystatechange = Util.falseFn;\r\n\r\n callback.call(context, {\r\n error: {\r\n code: 500,\r\n message: 'XMLHttpRequest error'\r\n }\r\n }, null);\r\n };\r\n\r\n httpRequest.onreadystatechange = function () {\r\n var response;\r\n var error;\r\n\r\n if (httpRequest.readyState === 4) {\r\n try {\r\n response = JSON.parse(httpRequest.responseText);\r\n } catch (e) {\r\n response = null;\r\n error = {\r\n code: 500,\r\n message: 'Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error.'\r\n };\r\n }\r\n\r\n if (!error && response.error) {\r\n error = response.error;\r\n response = null;\r\n }\r\n\r\n httpRequest.onerror = Util.falseFn;\r\n\r\n callback.call(context, error, response);\r\n }\r\n };\r\n\r\n httpRequest.ontimeout = function () {\r\n this.onerror();\r\n };\r\n\r\n return httpRequest;\r\n}\r\n\r\nfunction xmlHttpPost (url, params, callback, context) {\r\n var httpRequest = createRequest(callback, context);\r\n httpRequest.open('POST', url);\r\n\r\n if (typeof context !== 'undefined' && context !== null) {\r\n if (typeof context.options !== 'undefined') {\r\n httpRequest.timeout = context.options.timeout;\r\n }\r\n }\r\n httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');\r\n httpRequest.send(serialize(params));\r\n\r\n return httpRequest;\r\n}\r\n\r\nfunction xmlHttpGet (url, params, callback, context) {\r\n var httpRequest = createRequest(callback, context);\r\n httpRequest.open('GET', url + '?' + serialize(params), true);\r\n\r\n if (typeof context !== 'undefined' && context !== null) {\r\n if (typeof context.options !== 'undefined') {\r\n httpRequest.timeout = context.options.timeout;\r\n if (context.options.withCredentials) {\r\n httpRequest.withCredentials = true;\r\n }\r\n }\r\n }\r\n httpRequest.send(null);\r\n\r\n return httpRequest;\r\n}\r\n\r\n// AJAX handlers for CORS (modern browsers) or JSONP (older browsers)\r\nexport function request (url, params, callback, context) {\r\n var paramString = serialize(params);\r\n var httpRequest = createRequest(callback, context);\r\n var requestLength = (url + '?' + paramString).length;\r\n\r\n // ie10/11 require the request be opened before a timeout is applied\r\n if (requestLength <= 2000 && Support.cors) {\r\n httpRequest.open('GET', url + '?' + paramString);\r\n } else if (requestLength > 2000 && Support.cors) {\r\n httpRequest.open('POST', url);\r\n httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');\r\n }\r\n\r\n if (typeof context !== 'undefined' && context !== null) {\r\n if (typeof context.options !== 'undefined') {\r\n httpRequest.timeout = context.options.timeout;\r\n if (context.options.withCredentials) {\r\n httpRequest.withCredentials = true;\r\n }\r\n }\r\n }\r\n\r\n // request is less than 2000 characters and the browser supports CORS, make GET request with XMLHttpRequest\r\n if (requestLength <= 2000 && Support.cors) {\r\n httpRequest.send(null);\r\n\r\n // request is more than 2000 characters and the browser supports CORS, make POST request with XMLHttpRequest\r\n } else if (requestLength > 2000 && Support.cors) {\r\n httpRequest.send(paramString);\r\n\r\n // request is less than 2000 characters and the browser does not support CORS, make a JSONP request\r\n } else if (requestLength <= 2000 && !Support.cors) {\r\n return jsonp(url, params, callback, context);\r\n\r\n // request is longer then 2000 characters and the browser does not support CORS, log a warning\r\n } else {\r\n warn('a request to ' + url + ' was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html');\r\n return;\r\n }\r\n\r\n return httpRequest;\r\n}\r\n\r\nexport function jsonp (url, params, callback, context) {\r\n window._EsriLeafletCallbacks = window._EsriLeafletCallbacks || {};\r\n var callbackId = 'c' + callbacks;\r\n params.callback = 'window._EsriLeafletCallbacks.' + callbackId;\r\n\r\n window._EsriLeafletCallbacks[callbackId] = function (response) {\r\n if (window._EsriLeafletCallbacks[callbackId] !== true) {\r\n var error;\r\n var responseType = Object.prototype.toString.call(response);\r\n\r\n if (!(responseType === '[object Object]' || responseType === '[object Array]')) {\r\n error = {\r\n error: {\r\n code: 500,\r\n message: 'Expected array or object as JSONP response'\r\n }\r\n };\r\n response = null;\r\n }\r\n\r\n if (!error && response.error) {\r\n error = response;\r\n response = null;\r\n }\r\n\r\n callback.call(context, error, response);\r\n window._EsriLeafletCallbacks[callbackId] = true;\r\n }\r\n };\r\n\r\n var script = DomUtil.create('script', null, document.body);\r\n script.type = 'text/javascript';\r\n script.src = url + '?' + serialize(params);\r\n script.id = callbackId;\r\n script.onerror = function (error) {\r\n if (error && window._EsriLeafletCallbacks[callbackId] !== true) {\r\n // Can't get true error code: it can be 404, or 401, or 500\r\n var err = {\r\n error: {\r\n code: 500,\r\n message: 'An unknown error occurred'\r\n }\r\n };\r\n\r\n callback.call(context, err);\r\n window._EsriLeafletCallbacks[callbackId] = true;\r\n }\r\n };\r\n DomUtil.addClass(script, 'esri-leaflet-jsonp');\r\n\r\n callbacks++;\r\n\r\n return {\r\n id: callbackId,\r\n url: script.src,\r\n abort: function () {\r\n window._EsriLeafletCallbacks._callback[callbackId]({\r\n code: 0,\r\n message: 'Request aborted.'\r\n });\r\n }\r\n };\r\n}\r\n\r\nvar get = ((Support.cors) ? xmlHttpGet : jsonp);\r\nget.CORS = xmlHttpGet;\r\nget.JSONP = jsonp;\r\n\r\nexport function warn () {\r\n if (console && console.warn) {\r\n console.warn.apply(console, arguments);\r\n }\r\n}\r\n\r\n// choose the correct AJAX handler depending on CORS support\r\nexport { get };\r\n\r\n// always use XMLHttpRequest for posts\r\nexport { xmlHttpPost as post };\r\n\r\n// export the Request object to call the different handlers for debugging\r\nexport var Request = {\r\n request: request,\r\n get: get,\r\n post: xmlHttpPost\r\n};\r\n\r\nexport default Request;\r\n","/* @preserve\n* @terraformer/arcgis - v2.0.6 - MIT\n* Copyright (c) 2012-2020 Environmental Systems Research Institute, Inc.\n* Mon May 18 2020 14:30:35 GMT-0700 (Pacific Daylight Time)\n*/\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nvar edgeIntersectsEdge = function edgeIntersectsEdge(a1, a2, b1, b2) {\n var uaT = (b2[0] - b1[0]) * (a1[1] - b1[1]) - (b2[1] - b1[1]) * (a1[0] - b1[0]);\n var ubT = (a2[0] - a1[0]) * (a1[1] - b1[1]) - (a2[1] - a1[1]) * (a1[0] - b1[0]);\n var uB = (b2[1] - b1[1]) * (a2[0] - a1[0]) - (b2[0] - b1[0]) * (a2[1] - a1[1]);\n\n if (uB !== 0) {\n var ua = uaT / uB;\n var ub = ubT / uB;\n\n if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {\n return true;\n }\n }\n\n return false;\n};\nvar coordinatesContainPoint = function coordinatesContainPoint(coordinates, point) {\n var contains = false;\n\n for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) {\n if ((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1] || coordinates[j][1] <= point[1] && point[1] < coordinates[i][1]) && point[0] < (coordinates[j][0] - coordinates[i][0]) * (point[1] - coordinates[i][1]) / (coordinates[j][1] - coordinates[i][1]) + coordinates[i][0]) {\n contains = !contains;\n }\n }\n\n return contains;\n};\nvar pointsEqual = function pointsEqual(a, b) {\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n\n return true;\n};\nvar arrayIntersectsArray = function arrayIntersectsArray(a, b) {\n for (var i = 0; i < a.length - 1; i++) {\n for (var j = 0; j < b.length - 1; j++) {\n if (edgeIntersectsEdge(a[i], a[i + 1], b[j], b[j + 1])) {\n return true;\n }\n }\n }\n\n return false;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nvar closeRing = function closeRing(coordinates) {\n if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) {\n coordinates.push(coordinates[0]);\n }\n\n return coordinates;\n}; // determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring\n// or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-\n// points-are-in-clockwise-order\n\nvar ringIsClockwise = function ringIsClockwise(ringToTest) {\n var total = 0;\n var i = 0;\n var rLength = ringToTest.length;\n var pt1 = ringToTest[i];\n var pt2;\n\n for (i; i < rLength - 1; i++) {\n pt2 = ringToTest[i + 1];\n total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);\n pt1 = pt2;\n }\n\n return total >= 0;\n}; // This function ensures that rings are oriented in the right directions\n// from http://jsperf.com/cloning-an-object/2\n\nvar shallowClone = function shallowClone(obj) {\n var target = {};\n\n for (var i in obj) {\n // both arcgis attributes and geojson props are just hardcoded keys\n if (obj.hasOwnProperty(i)) {\n // eslint-disable-line no-prototype-builtins\n target[i] = obj[i];\n }\n }\n\n return target;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nvar coordinatesContainCoordinates = function coordinatesContainCoordinates(outer, inner) {\n var intersects = arrayIntersectsArray(outer, inner);\n var contains = coordinatesContainPoint(outer, inner[0]);\n\n if (!intersects && contains) {\n return true;\n }\n\n return false;\n}; // do any polygons in this array contain any other polygons in this array?\n// used for checking for holes in arcgis rings\n\n\nvar convertRingsToGeoJSON = function convertRingsToGeoJSON(rings) {\n var outerRings = [];\n var holes = [];\n var x; // iterator\n\n var outerRing; // current outer ring being evaluated\n\n var hole; // current hole being evaluated\n // for each ring\n\n for (var r = 0; r < rings.length; r++) {\n var ring = closeRing(rings[r].slice(0));\n\n if (ring.length < 4) {\n continue;\n } // is this ring an outer ring? is it clockwise?\n\n\n if (ringIsClockwise(ring)) {\n var polygon = [ring.slice().reverse()]; // wind outer rings counterclockwise for RFC 7946 compliance\n\n outerRings.push(polygon); // push to outer rings\n } else {\n holes.push(ring.slice().reverse()); // wind inner rings clockwise for RFC 7946 compliance\n }\n }\n\n var uncontainedHoles = []; // while there are holes left...\n\n while (holes.length) {\n // pop a hole off out stack\n hole = holes.pop(); // loop over all outer rings and see if they contain our hole.\n\n var contained = false;\n\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n\n if (coordinatesContainCoordinates(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n contained = true;\n break;\n }\n } // ring is not contained in any outer ring\n // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320\n\n\n if (!contained) {\n uncontainedHoles.push(hole);\n }\n } // if we couldn't match any holes using contains we can try intersects...\n\n\n while (uncontainedHoles.length) {\n // pop a hole off out stack\n hole = uncontainedHoles.pop(); // loop over all outer rings and see if any intersect our hole.\n\n var intersects = false;\n\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n\n if (arrayIntersectsArray(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n intersects = true;\n break;\n }\n }\n\n if (!intersects) {\n outerRings.push([hole.reverse()]);\n }\n }\n\n if (outerRings.length === 1) {\n return {\n type: 'Polygon',\n coordinates: outerRings[0]\n };\n } else {\n return {\n type: 'MultiPolygon',\n coordinates: outerRings\n };\n }\n};\n\nvar getId = function getId(attributes, idAttribute) {\n var keys = idAttribute ? [idAttribute, 'OBJECTID', 'FID'] : ['OBJECTID', 'FID'];\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key in attributes && (typeof attributes[key] === 'string' || typeof attributes[key] === 'number')) {\n return attributes[key];\n }\n }\n\n throw Error('No valid id attribute found');\n};\n\nvar arcgisToGeoJSON = function arcgisToGeoJSON(arcgis, idAttribute) {\n var geojson = {};\n\n if (arcgis.features) {\n geojson.type = 'FeatureCollection';\n geojson.features = [];\n\n for (var i = 0; i < arcgis.features.length; i++) {\n geojson.features.push(arcgisToGeoJSON(arcgis.features[i], idAttribute));\n }\n }\n\n if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') {\n geojson.type = 'Point';\n geojson.coordinates = [arcgis.x, arcgis.y];\n\n if (typeof arcgis.z === 'number') {\n geojson.coordinates.push(arcgis.z);\n }\n }\n\n if (arcgis.points) {\n geojson.type = 'MultiPoint';\n geojson.coordinates = arcgis.points.slice(0);\n }\n\n if (arcgis.paths) {\n if (arcgis.paths.length === 1) {\n geojson.type = 'LineString';\n geojson.coordinates = arcgis.paths[0].slice(0);\n } else {\n geojson.type = 'MultiLineString';\n geojson.coordinates = arcgis.paths.slice(0);\n }\n }\n\n if (arcgis.rings) {\n geojson = convertRingsToGeoJSON(arcgis.rings.slice(0));\n }\n\n if (typeof arcgis.xmin === 'number' && typeof arcgis.ymin === 'number' && typeof arcgis.xmax === 'number' && typeof arcgis.ymax === 'number') {\n geojson.type = 'Polygon';\n geojson.coordinates = [[[arcgis.xmax, arcgis.ymax], [arcgis.xmin, arcgis.ymax], [arcgis.xmin, arcgis.ymin], [arcgis.xmax, arcgis.ymin], [arcgis.xmax, arcgis.ymax]]];\n }\n\n if (arcgis.geometry || arcgis.attributes) {\n geojson.type = 'Feature';\n geojson.geometry = arcgis.geometry ? arcgisToGeoJSON(arcgis.geometry) : null;\n geojson.properties = arcgis.attributes ? shallowClone(arcgis.attributes) : null;\n\n if (arcgis.attributes) {\n try {\n geojson.id = getId(arcgis.attributes, idAttribute);\n } catch (err) {// don't set an id\n }\n }\n } // if no valid geometry was encountered\n\n\n if (JSON.stringify(geojson.geometry) === JSON.stringify({})) {\n geojson.geometry = null;\n }\n\n if (arcgis.spatialReference && arcgis.spatialReference.wkid && arcgis.spatialReference.wkid !== 4326) {\n console.warn('Object converted in non-standard crs - ' + JSON.stringify(arcgis.spatialReference));\n }\n\n return geojson;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n// outer rings are clockwise, holes are counterclockwise\n// used for converting GeoJSON Polygons to ArcGIS Polygons\n\nvar orientRings = function orientRings(poly) {\n var output = [];\n var polygon = poly.slice(0);\n var outerRing = closeRing(polygon.shift().slice(0));\n\n if (outerRing.length >= 4) {\n if (!ringIsClockwise(outerRing)) {\n outerRing.reverse();\n }\n\n output.push(outerRing);\n\n for (var i = 0; i < polygon.length; i++) {\n var hole = closeRing(polygon[i].slice(0));\n\n if (hole.length >= 4) {\n if (ringIsClockwise(hole)) {\n hole.reverse();\n }\n\n output.push(hole);\n }\n }\n }\n\n return output;\n}; // This function flattens holes in multipolygons to one array of polygons\n// used for converting GeoJSON Polygons to ArcGIS Polygons\n\n\nvar flattenMultiPolygonRings = function flattenMultiPolygonRings(rings) {\n var output = [];\n\n for (var i = 0; i < rings.length; i++) {\n var polygon = orientRings(rings[i]);\n\n for (var x = polygon.length - 1; x >= 0; x--) {\n var ring = polygon[x].slice(0);\n output.push(ring);\n }\n }\n\n return output;\n};\n\nvar geojsonToArcGIS = function geojsonToArcGIS(geojson, idAttribute) {\n idAttribute = idAttribute || 'OBJECTID';\n var spatialReference = {\n wkid: 4326\n };\n var result = {};\n var i;\n\n switch (geojson.type) {\n case 'Point':\n result.x = geojson.coordinates[0];\n result.y = geojson.coordinates[1];\n result.spatialReference = spatialReference;\n break;\n\n case 'MultiPoint':\n result.points = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n\n case 'LineString':\n result.paths = [geojson.coordinates.slice(0)];\n result.spatialReference = spatialReference;\n break;\n\n case 'MultiLineString':\n result.paths = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n\n case 'Polygon':\n result.rings = orientRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n\n case 'MultiPolygon':\n result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n\n case 'Feature':\n if (geojson.geometry) {\n result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);\n }\n\n result.attributes = geojson.properties ? shallowClone(geojson.properties) : {};\n\n if (geojson.id) {\n result.attributes[idAttribute] = geojson.id;\n }\n\n break;\n\n case 'FeatureCollection':\n result = [];\n\n for (i = 0; i < geojson.features.length; i++) {\n result.push(geojsonToArcGIS(geojson.features[i], idAttribute));\n }\n\n break;\n\n case 'GeometryCollection':\n result = [];\n\n for (i = 0; i < geojson.geometries.length; i++) {\n result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute));\n }\n\n break;\n }\n\n return result;\n};\n\n/* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nexport { arcgisToGeoJSON, geojsonToArcGIS };\n","import { latLng, latLngBounds, LatLng, LatLngBounds, Util, DomUtil, GeoJSON } from 'leaflet';\r\nimport { request, warn } from './Request';\r\nimport { options } from './Options';\r\nimport { Support } from './Support';\r\n\r\nimport {\r\n geojsonToArcGIS as g2a,\r\n arcgisToGeoJSON as a2g\r\n} from '@terraformer/arcgis';\r\n\r\nvar BASE_LEAFLET_ATTRIBUTION_STRING = 'Leaflet';\r\nvar POWERED_BY_ESRI_ATTRIBUTION_STRING = 'Powered by Esri';\r\n\r\nexport function geojsonToArcGIS (geojson, idAttr) {\r\n return g2a(geojson, idAttr);\r\n}\r\n\r\nexport function arcgisToGeoJSON (arcgis, idAttr) {\r\n return a2g(arcgis, idAttr);\r\n}\r\n\r\n// convert an extent (ArcGIS) to LatLngBounds (Leaflet)\r\nexport function extentToBounds (extent) {\r\n // \"NaN\" coordinates from ArcGIS Server indicate a null geometry\r\n if (extent.xmin !== 'NaN' && extent.ymin !== 'NaN' && extent.xmax !== 'NaN' && extent.ymax !== 'NaN') {\r\n var sw = latLng(extent.ymin, extent.xmin);\r\n var ne = latLng(extent.ymax, extent.xmax);\r\n return latLngBounds(sw, ne);\r\n } else {\r\n return null;\r\n }\r\n}\r\n\r\n// convert an LatLngBounds (Leaflet) to extent (ArcGIS)\r\nexport function boundsToExtent (bounds) {\r\n bounds = latLngBounds(bounds);\r\n return {\r\n 'xmin': bounds.getSouthWest().lng,\r\n 'ymin': bounds.getSouthWest().lat,\r\n 'xmax': bounds.getNorthEast().lng,\r\n 'ymax': bounds.getNorthEast().lat,\r\n 'spatialReference': {\r\n 'wkid': 4326\r\n }\r\n };\r\n}\r\n\r\nvar knownFieldNames = /^(OBJECTID|FID|OID|ID)$/i;\r\n\r\n// Attempts to find the ID Field from response\r\nexport function _findIdAttributeFromResponse (response) {\r\n var result;\r\n\r\n if (response.objectIdFieldName) {\r\n // Find Id Field directly\r\n result = response.objectIdFieldName;\r\n } else if (response.fields) {\r\n // Find ID Field based on field type\r\n for (var j = 0; j <= response.fields.length - 1; j++) {\r\n if (response.fields[j].type === 'esriFieldTypeOID') {\r\n result = response.fields[j].name;\r\n break;\r\n }\r\n }\r\n if (!result) {\r\n // If no field was marked as being the esriFieldTypeOID try well known field names\r\n for (j = 0; j <= response.fields.length - 1; j++) {\r\n if (response.fields[j].name.match(knownFieldNames)) {\r\n result = response.fields[j].name;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n}\r\n\r\n// This is the 'last' resort, find the Id field from the specified feature\r\nexport function _findIdAttributeFromFeature (feature) {\r\n for (var key in feature.attributes) {\r\n if (key.match(knownFieldNames)) {\r\n return key;\r\n }\r\n }\r\n}\r\n\r\nexport function responseToFeatureCollection (response, idAttribute) {\r\n var objectIdField;\r\n var features = response.features || response.results;\r\n var count = features && features.length;\r\n\r\n if (idAttribute) {\r\n objectIdField = idAttribute;\r\n } else {\r\n objectIdField = _findIdAttributeFromResponse(response);\r\n }\r\n\r\n var featureCollection = {\r\n type: 'FeatureCollection',\r\n features: []\r\n };\r\n\r\n if (count) {\r\n for (var i = features.length - 1; i >= 0; i--) {\r\n var feature = arcgisToGeoJSON(features[i], objectIdField || _findIdAttributeFromFeature(features[i]));\r\n featureCollection.features.push(feature);\r\n }\r\n }\r\n\r\n return featureCollection;\r\n}\r\n\r\n // trim url whitespace and add a trailing slash if needed\r\nexport function cleanUrl (url) {\r\n // trim leading and trailing spaces, but not spaces inside the url\r\n url = Util.trim(url);\r\n\r\n // add a trailing slash to the url if the user omitted it\r\n if (url[url.length - 1] !== '/') {\r\n url += '/';\r\n }\r\n\r\n return url;\r\n}\r\n\r\n/* Extract url params if any and store them in requestParams attribute.\r\n Return the options params updated */\r\nexport function getUrlParams (options) {\r\n if (options.url.indexOf('?') !== -1) {\r\n options.requestParams = options.requestParams || {};\r\n var queryString = options.url.substring(options.url.indexOf('?') + 1);\r\n options.url = options.url.split('?')[0];\r\n options.requestParams = JSON.parse('{\"' + decodeURI(queryString).replace(/\"/g, '\\\\\"').replace(/&/g, '\",\"').replace(/=/g, '\":\"') + '\"}');\r\n }\r\n options.url = cleanUrl(options.url.split('?')[0]);\r\n return options;\r\n}\r\n\r\nexport function isArcgisOnline (url) {\r\n /* hosted feature services support geojson as an output format\r\n utility.arcgis.com services are proxied from a variety of ArcGIS Server vintages, and may not */\r\n return (/^(?!.*utility\\.arcgis\\.com).*\\.arcgis\\.com.*FeatureServer/i).test(url);\r\n}\r\n\r\nexport function geojsonTypeToArcGIS (geoJsonType) {\r\n var arcgisGeometryType;\r\n switch (geoJsonType) {\r\n case 'Point':\r\n arcgisGeometryType = 'esriGeometryPoint';\r\n break;\r\n case 'MultiPoint':\r\n arcgisGeometryType = 'esriGeometryMultipoint';\r\n break;\r\n case 'LineString':\r\n arcgisGeometryType = 'esriGeometryPolyline';\r\n break;\r\n case 'MultiLineString':\r\n arcgisGeometryType = 'esriGeometryPolyline';\r\n break;\r\n case 'Polygon':\r\n arcgisGeometryType = 'esriGeometryPolygon';\r\n break;\r\n case 'MultiPolygon':\r\n arcgisGeometryType = 'esriGeometryPolygon';\r\n break;\r\n }\r\n\r\n return arcgisGeometryType;\r\n}\r\n\r\nexport function calcAttributionWidth (map) {\r\n // either crop at 55px or user defined buffer\r\n return (map.getSize().x - options.attributionWidthOffset) + 'px';\r\n}\r\n\r\nexport function setEsriAttribution (map) {\r\n if (!map.attributionControl) {\r\n return;\r\n }\r\n\r\n if (!map.attributionControl._esriAttributionLayerCount) {\r\n map.attributionControl._esriAttributionLayerCount = 0;\r\n }\r\n\r\n if (map.attributionControl._esriAttributionLayerCount === 0) {\r\n // Dynamically creating the CSS rules, only run this once per page load:\r\n if (!map.attributionControl._esriAttributionAddedOnce) {\r\n var hoverAttributionStyle = document.createElement('style');\r\n hoverAttributionStyle.type = 'text/css';\r\n hoverAttributionStyle.innerHTML = '.esri-truncated-attribution:hover {' +\r\n 'white-space: normal;' +\r\n '}';\r\n document.getElementsByTagName('head')[0].appendChild(hoverAttributionStyle);\r\n\r\n // define a new css class in JS to trim attribution into a single line\r\n var attributionStyle = document.createElement('style');\r\n attributionStyle.type = 'text/css';\r\n attributionStyle.innerHTML = '.esri-truncated-attribution {' +\r\n 'vertical-align: -3px;' +\r\n 'white-space: nowrap;' +\r\n 'overflow: hidden;' +\r\n 'text-overflow: ellipsis;' +\r\n 'display: inline-block;' +\r\n 'transition: 0s white-space;' +\r\n 'transition-delay: 1s;' +\r\n 'max-width: ' + calcAttributionWidth(map) + ';' +\r\n '}';\r\n document.getElementsByTagName('head')[0].appendChild(attributionStyle);\r\n\r\n // update the width used to truncate when the map itself is resized\r\n map.on('resize', function (e) {\r\n if (map.attributionControl) {\r\n map.attributionControl._container.style.maxWidth = calcAttributionWidth(e.target);\r\n }\r\n });\r\n\r\n map.attributionControl._esriAttributionAddedOnce = true;\r\n }\r\n\r\n map.attributionControl.setPrefix(BASE_LEAFLET_ATTRIBUTION_STRING + ' | ' + POWERED_BY_ESRI_ATTRIBUTION_STRING);\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution:hover');\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution');\r\n }\r\n\r\n // Track the number of esri-leaflet layers that are on the map so we can know when we can remove the attribution (below in removeEsriAttribution)\r\n map.attributionControl._esriAttributionLayerCount = map.attributionControl._esriAttributionLayerCount + 1;\r\n}\r\n\r\nexport function removeEsriAttribution (map) {\r\n if (!map.attributionControl) {\r\n return;\r\n }\r\n\r\n // Only remove the attribution if we're about to remove the LAST esri-leaflet layer (_esriAttributionLayerCount)\r\n if (map.attributionControl._esriAttributionLayerCount && map.attributionControl._esriAttributionLayerCount === 1) {\r\n map.attributionControl.setPrefix(BASE_LEAFLET_ATTRIBUTION_STRING);\r\n DomUtil.removeClass(map.attributionControl._container, 'esri-truncated-attribution:hover');\r\n DomUtil.removeClass(map.attributionControl._container, 'esri-truncated-attribution');\r\n }\r\n map.attributionControl._esriAttributionLayerCount = map.attributionControl._esriAttributionLayerCount - 1;\r\n}\r\n\r\nexport function _setGeometry (geometry) {\r\n var params = {\r\n geometry: null,\r\n geometryType: null\r\n };\r\n\r\n // convert bounds to extent and finish\r\n if (geometry instanceof LatLngBounds) {\r\n // set geometry + geometryType\r\n params.geometry = boundsToExtent(geometry);\r\n params.geometryType = 'esriGeometryEnvelope';\r\n return params;\r\n }\r\n\r\n // convert L.Marker > L.LatLng\r\n if (geometry.getLatLng) {\r\n geometry = geometry.getLatLng();\r\n }\r\n\r\n // convert L.LatLng to a geojson point and continue;\r\n if (geometry instanceof LatLng) {\r\n geometry = {\r\n type: 'Point',\r\n coordinates: [geometry.lng, geometry.lat]\r\n };\r\n }\r\n\r\n // handle L.GeoJSON, pull out the first geometry\r\n if (geometry instanceof GeoJSON) {\r\n // reassign geometry to the GeoJSON value (we are assuming that only one feature is present)\r\n geometry = geometry.getLayers()[0].feature.geometry;\r\n params.geometry = geojsonToArcGIS(geometry);\r\n params.geometryType = geojsonTypeToArcGIS(geometry.type);\r\n }\r\n\r\n // Handle L.Polyline and L.Polygon\r\n if (geometry.toGeoJSON) {\r\n geometry = geometry.toGeoJSON();\r\n }\r\n\r\n // handle GeoJSON feature by pulling out the geometry\r\n if (geometry.type === 'Feature') {\r\n // get the geometry of the geojson feature\r\n geometry = geometry.geometry;\r\n }\r\n\r\n // confirm that our GeoJSON is a point, line or polygon\r\n if (geometry.type === 'Point' || geometry.type === 'LineString' || geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {\r\n params.geometry = geojsonToArcGIS(geometry);\r\n params.geometryType = geojsonTypeToArcGIS(geometry.type);\r\n return params;\r\n }\r\n\r\n // warn the user if we havn't found an appropriate object\r\n warn('invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object');\r\n\r\n return;\r\n}\r\n\r\nexport function _getAttributionData (url, map) {\r\n if (Support.cors) {\r\n request(url, {}, Util.bind(function (error, attributions) {\r\n if (error) { return; }\r\n map._esriAttributions = [];\r\n for (var c = 0; c < attributions.contributors.length; c++) {\r\n var contributor = attributions.contributors[c];\r\n\r\n for (var i = 0; i < contributor.coverageAreas.length; i++) {\r\n var coverageArea = contributor.coverageAreas[i];\r\n var southWest = latLng(coverageArea.bbox[0], coverageArea.bbox[1]);\r\n var northEast = latLng(coverageArea.bbox[2], coverageArea.bbox[3]);\r\n map._esriAttributions.push({\r\n attribution: contributor.attribution,\r\n score: coverageArea.score,\r\n bounds: latLngBounds(southWest, northEast),\r\n minZoom: coverageArea.zoomMin,\r\n maxZoom: coverageArea.zoomMax\r\n });\r\n }\r\n }\r\n\r\n map._esriAttributions.sort(function (a, b) {\r\n return b.score - a.score;\r\n });\r\n\r\n // pass the same argument as the map's 'moveend' event\r\n var obj = { target: map };\r\n _updateMapAttribution(obj);\r\n }, this));\r\n }\r\n}\r\n\r\nexport function _updateMapAttribution (evt) {\r\n var map = evt.target;\r\n var oldAttributions = map._esriAttributions;\r\n\r\n if (!map || !map.attributionControl) return;\r\n\r\n var attributionElement = map.attributionControl._container.querySelector('.esri-dynamic-attribution');\r\n\r\n if (attributionElement && oldAttributions) {\r\n var newAttributions = '';\r\n var bounds = map.getBounds();\r\n var wrappedBounds = latLngBounds(\r\n bounds.getSouthWest().wrap(),\r\n bounds.getNorthEast().wrap()\r\n );\r\n var zoom = map.getZoom();\r\n\r\n for (var i = 0; i < oldAttributions.length; i++) {\r\n var attribution = oldAttributions[i];\r\n var text = attribution.attribution;\r\n\r\n if (!newAttributions.match(text) && attribution.bounds.intersects(wrappedBounds) && zoom >= attribution.minZoom && zoom <= attribution.maxZoom) {\r\n newAttributions += (', ' + text);\r\n }\r\n }\r\n\r\n newAttributions = newAttributions.substr(2);\r\n attributionElement.innerHTML = newAttributions;\r\n attributionElement.style.maxWidth = calcAttributionWidth(map);\r\n\r\n map.fire('attributionupdated', {\r\n attribution: newAttributions\r\n });\r\n }\r\n}\r\n\r\n// for backwards compatibility\r\nexport { warn };\r\n\r\nexport var EsriUtil = {\r\n warn: warn,\r\n cleanUrl: cleanUrl,\r\n getUrlParams: getUrlParams,\r\n isArcgisOnline: isArcgisOnline,\r\n geojsonTypeToArcGIS: geojsonTypeToArcGIS,\r\n responseToFeatureCollection: responseToFeatureCollection,\r\n geojsonToArcGIS: geojsonToArcGIS,\r\n arcgisToGeoJSON: arcgisToGeoJSON,\r\n boundsToExtent: boundsToExtent,\r\n extentToBounds: extentToBounds,\r\n calcAttributionWidth: calcAttributionWidth,\r\n setEsriAttribution: setEsriAttribution,\r\n _setGeometry: _setGeometry,\r\n _getAttributionData: _getAttributionData,\r\n _updateMapAttribution: _updateMapAttribution,\r\n _findIdAttributeFromFeature: _findIdAttributeFromFeature,\r\n _findIdAttributeFromResponse: _findIdAttributeFromResponse\r\n};\r\n\r\nexport default EsriUtil;\r\n","import { Class, Util } from 'leaflet';\r\nimport {cors} from '../Support';\r\nimport { cleanUrl, getUrlParams } from '../Util';\r\nimport Request from '../Request';\r\n\r\nexport var Task = Class.extend({\r\n\r\n options: {\r\n proxy: false,\r\n useCors: cors\r\n },\r\n\r\n // Generate a method for each methodName:paramName in the setters for this task.\r\n generateSetter: function (param, context) {\r\n return Util.bind(function (value) {\r\n this.params[param] = value;\r\n return this;\r\n }, context);\r\n },\r\n\r\n initialize: function (endpoint) {\r\n // endpoint can be either a url (and options) for an ArcGIS Rest Service or an instance of EsriLeaflet.Service\r\n if (endpoint.request && endpoint.options) {\r\n this._service = endpoint;\r\n Util.setOptions(this, endpoint.options);\r\n } else {\r\n Util.setOptions(this, endpoint);\r\n this.options.url = cleanUrl(endpoint.url);\r\n }\r\n\r\n // clone default params into this object\r\n this.params = Util.extend({}, this.params || {});\r\n\r\n // generate setter methods based on the setters object implimented a child class\r\n if (this.setters) {\r\n for (var setter in this.setters) {\r\n var param = this.setters[setter];\r\n this[setter] = this.generateSetter(param, this);\r\n }\r\n }\r\n },\r\n\r\n token: function (token) {\r\n if (this._service) {\r\n this._service.authenticate(token);\r\n } else {\r\n this.params.token = token;\r\n }\r\n return this;\r\n },\r\n\r\n apikey: function (apikey) {\r\n return this.token(apikey);\r\n },\r\n\r\n // ArcGIS Server Find/Identify 10.5+\r\n format: function (boolean) {\r\n // use double negative to expose a more intuitive positive method name\r\n this.params.returnUnformattedValues = !boolean;\r\n return this;\r\n },\r\n\r\n request: function (callback, context) {\r\n if (this.options.requestParams) {\r\n Util.extend(this.params, this.options.requestParams);\r\n }\r\n if (this._service) {\r\n return this._service.request(this.path, this.params, callback, context);\r\n }\r\n\r\n return this._request('request', this.path, this.params, callback, context);\r\n },\r\n\r\n _request: function (method, path, params, callback, context) {\r\n var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\r\n\r\n if ((method === 'get' || method === 'request') && !this.options.useCors) {\r\n return Request.get.JSONP(url, params, callback, context);\r\n }\r\n\r\n return Request[method](url, params, callback, context);\r\n }\r\n});\r\n\r\nexport function task (options) {\r\n options = getUrlParams(options);\r\n return new Task(options);\r\n}\r\n\r\nexport default task;\r\n","import { point, latLng } from 'leaflet';\r\nimport { Task } from './Task';\r\nimport {\r\n warn,\r\n responseToFeatureCollection,\r\n isArcgisOnline,\r\n extentToBounds,\r\n _setGeometry\r\n} from '../Util';\r\n\r\nexport var Query = Task.extend({\r\n setters: {\r\n 'offset': 'resultOffset',\r\n 'limit': 'resultRecordCount',\r\n 'fields': 'outFields',\r\n 'precision': 'geometryPrecision',\r\n 'featureIds': 'objectIds',\r\n 'returnGeometry': 'returnGeometry',\r\n 'returnM': 'returnM',\r\n 'transform': 'datumTransformation',\r\n 'token': 'token'\r\n },\r\n\r\n path: 'query',\r\n\r\n params: {\r\n returnGeometry: true,\r\n where: '1=1',\r\n outSR: 4326,\r\n outFields: '*'\r\n },\r\n\r\n // Returns a feature if its shape is wholly contained within the search geometry. Valid for all shape type combinations.\r\n within: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelContains'; // to the REST api this reads geometry **contains** layer\r\n return this;\r\n },\r\n\r\n // Returns a feature if any spatial relationship is found. Applies to all shape type combinations.\r\n intersects: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelIntersects';\r\n return this;\r\n },\r\n\r\n // Returns a feature if its shape wholly contains the search geometry. Valid for all shape type combinations.\r\n contains: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelWithin'; // to the REST api this reads geometry **within** layer\r\n return this;\r\n },\r\n\r\n // Returns a feature if the intersection of the interiors of the two shapes is not empty and has a lower dimension than the maximum dimension of the two shapes. Two lines that share an endpoint in common do not cross. Valid for Line/Line, Line/Area, Multi-point/Area, and Multi-point/Line shape type combinations.\r\n crosses: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelCrosses';\r\n return this;\r\n },\r\n\r\n // Returns a feature if the two shapes share a common boundary. However, the intersection of the interiors of the two shapes must be empty. In the Point/Line case, the point may touch an endpoint only of the line. Applies to all combinations except Point/Point.\r\n touches: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelTouches';\r\n return this;\r\n },\r\n\r\n // Returns a feature if the intersection of the two shapes results in an object of the same dimension, but different from both of the shapes. Applies to Area/Area, Line/Line, and Multi-point/Multi-point shape type combinations.\r\n overlaps: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelOverlaps';\r\n return this;\r\n },\r\n\r\n // Returns a feature if the envelope of the two shapes intersects.\r\n bboxIntersects: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelEnvelopeIntersects';\r\n return this;\r\n },\r\n\r\n // if someone can help decipher the ArcObjects explanation and translate to plain speak, we should mention this method in the doc\r\n indexIntersects: function (geometry) {\r\n this._setGeometryParams(geometry);\r\n this.params.spatialRel = 'esriSpatialRelIndexIntersects'; // Returns a feature if the envelope of the query geometry intersects the index entry for the target geometry\r\n return this;\r\n },\r\n\r\n // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online\r\n nearby: function (latlng, radius) {\r\n latlng = latLng(latlng);\r\n this.params.geometry = [latlng.lng, latlng.lat];\r\n this.params.geometryType = 'esriGeometryPoint';\r\n this.params.spatialRel = 'esriSpatialRelIntersects';\r\n this.params.units = 'esriSRUnit_Meter';\r\n this.params.distance = radius;\r\n this.params.inSR = 4326;\r\n return this;\r\n },\r\n\r\n where: function (string) {\r\n // instead of converting double-quotes to single quotes, pass as is, and provide a more informative message if a 400 is encountered\r\n this.params.where = string;\r\n return this;\r\n },\r\n\r\n between: function (start, end) {\r\n this.params.time = [start.valueOf(), end.valueOf()];\r\n return this;\r\n },\r\n\r\n simplify: function (map, factor) {\r\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\r\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\r\n return this;\r\n },\r\n\r\n orderBy: function (fieldName, order) {\r\n order = order || 'ASC';\r\n this.params.orderByFields = (this.params.orderByFields) ? this.params.orderByFields + ',' : '';\r\n this.params.orderByFields += ([fieldName, order]).join(' ');\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n this._cleanParams();\r\n\r\n // services hosted on ArcGIS Online and ArcGIS Server 10.3.1+ support requesting geojson directly\r\n if (this.options.isModern || (isArcgisOnline(this.options.url) && this.options.isModern === undefined)) {\r\n this.params.f = 'geojson';\r\n\r\n return this.request(function (error, response) {\r\n this._trapSQLerrors(error);\r\n callback.call(context, error, response, response);\r\n }, this);\r\n\r\n // otherwise convert it in the callback then pass it on\r\n } else {\r\n return this.request(function (error, response) {\r\n this._trapSQLerrors(error);\r\n callback.call(context, error, (response && responseToFeatureCollection(response)), response);\r\n }, this);\r\n }\r\n },\r\n\r\n count: function (callback, context) {\r\n this._cleanParams();\r\n this.params.returnCountOnly = true;\r\n return this.request(function (error, response) {\r\n callback.call(this, error, (response && response.count), response);\r\n }, context);\r\n },\r\n\r\n ids: function (callback, context) {\r\n this._cleanParams();\r\n this.params.returnIdsOnly = true;\r\n return this.request(function (error, response) {\r\n callback.call(this, error, (response && response.objectIds), response);\r\n }, context);\r\n },\r\n\r\n // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online\r\n bounds: function (callback, context) {\r\n this._cleanParams();\r\n this.params.returnExtentOnly = true;\r\n return this.request(function (error, response) {\r\n if (response && response.extent && extentToBounds(response.extent)) {\r\n callback.call(context, error, extentToBounds(response.extent), response);\r\n } else {\r\n error = {\r\n message: 'Invalid Bounds'\r\n };\r\n callback.call(context, error, null, response);\r\n }\r\n }, context);\r\n },\r\n\r\n distinct: function () {\r\n // geometry must be omitted for queries requesting distinct values\r\n this.params.returnGeometry = false;\r\n this.params.returnDistinctValues = true;\r\n return this;\r\n },\r\n\r\n // only valid for image services\r\n pixelSize: function (rawPoint) {\r\n var castPoint = point(rawPoint);\r\n this.params.pixelSize = [castPoint.x, castPoint.y];\r\n return this;\r\n },\r\n\r\n // only valid for map services\r\n layer: function (layer) {\r\n this.path = layer + '/query';\r\n return this;\r\n },\r\n\r\n _trapSQLerrors: function (error) {\r\n if (error) {\r\n if (error.code === '400') {\r\n warn('one common syntax error in query requests is encasing string values in double quotes instead of single quotes');\r\n }\r\n }\r\n },\r\n\r\n _cleanParams: function () {\r\n delete this.params.returnIdsOnly;\r\n delete this.params.returnExtentOnly;\r\n delete this.params.returnCountOnly;\r\n },\r\n\r\n _setGeometryParams: function (geometry) {\r\n this.params.inSR = 4326;\r\n var converted = _setGeometry(geometry);\r\n this.params.geometry = converted.geometry;\r\n this.params.geometryType = converted.geometryType;\r\n }\r\n\r\n});\r\n\r\nexport function query (options) {\r\n return new Query(options);\r\n}\r\n\r\nexport default query;\r\n","import { Task } from './Task';\r\nimport { responseToFeatureCollection } from '../Util';\r\n\r\nexport var Find = Task.extend({\r\n setters: {\r\n // method name > param name\r\n 'contains': 'contains',\r\n 'text': 'searchText',\r\n 'fields': 'searchFields', // denote an array or single string\r\n 'spatialReference': 'sr',\r\n 'sr': 'sr',\r\n 'layers': 'layers',\r\n 'returnGeometry': 'returnGeometry',\r\n 'maxAllowableOffset': 'maxAllowableOffset',\r\n 'precision': 'geometryPrecision',\r\n 'dynamicLayers': 'dynamicLayers',\r\n 'returnZ': 'returnZ',\r\n 'returnM': 'returnM',\r\n 'gdbVersion': 'gdbVersion',\r\n // skipped implementing this (for now) because the REST service implementation isnt consistent between operations\r\n // 'transform': 'datumTransformations',\r\n 'token': 'token'\r\n },\r\n\r\n path: 'find',\r\n\r\n params: {\r\n sr: 4326,\r\n contains: true,\r\n returnGeometry: true,\r\n returnZ: true,\r\n returnM: false\r\n },\r\n\r\n layerDefs: function (id, where) {\r\n this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\r\n this.params.layerDefs += ([id, where]).join(':');\r\n return this;\r\n },\r\n\r\n simplify: function (map, factor) {\r\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\r\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n return this.request(function (error, response) {\r\n callback.call(context, error, (response && responseToFeatureCollection(response)), response);\r\n }, context);\r\n }\r\n});\r\n\r\nexport function find (options) {\r\n return new Find(options);\r\n}\r\n\r\nexport default find;\r\n","import { Task } from './Task';\r\n\r\nexport var Identify = Task.extend({\r\n path: 'identify',\r\n\r\n between: function (start, end) {\r\n this.params.time = [start.valueOf(), end.valueOf()];\r\n return this;\r\n }\r\n});\r\n\r\nexport function identify (options) {\r\n return new Identify(options);\r\n}\r\n\r\nexport default identify;\r\n","import { latLng } from 'leaflet';\r\nimport { Identify } from './Identify';\r\nimport { responseToFeatureCollection,\r\n boundsToExtent,\r\n _setGeometry\r\n} from '../Util';\r\n\r\nexport var IdentifyFeatures = Identify.extend({\r\n setters: {\r\n 'layers': 'layers',\r\n 'precision': 'geometryPrecision',\r\n 'tolerance': 'tolerance',\r\n // skipped implementing this (for now) because the REST service implementation isnt consistent between operations.\r\n // 'transform': 'datumTransformations'\r\n 'returnGeometry': 'returnGeometry'\r\n },\r\n\r\n params: {\r\n sr: 4326,\r\n layers: 'all',\r\n tolerance: 3,\r\n returnGeometry: true\r\n },\r\n\r\n on: function (map) {\r\n var extent = boundsToExtent(map.getBounds());\r\n var size = map.getSize();\r\n this.params.imageDisplay = [size.x, size.y, 96];\r\n this.params.mapExtent = [extent.xmin, extent.ymin, extent.xmax, extent.ymax];\r\n return this;\r\n },\r\n\r\n at: function (geometry) {\r\n // cast lat, long pairs in raw array form manually\r\n if (geometry.length === 2) {\r\n geometry = latLng(geometry);\r\n }\r\n this._setGeometryParams(geometry);\r\n return this;\r\n },\r\n\r\n layerDef: function (id, where) {\r\n this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\r\n this.params.layerDefs += ([id, where]).join(':');\r\n return this;\r\n },\r\n\r\n simplify: function (map, factor) {\r\n var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\r\n this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\r\n return this;\r\n },\r\n\r\n run: function (callback, context) {\r\n return this.request(function (error, response) {\r\n // immediately invoke with an error\r\n if (error) {\r\n callback.call(context, error, undefined, response);\r\n return;\r\n\r\n // ok no error lets just assume we have features...\r\n } else {\r\n var featureCollection = responseToFeatureCollection(response);\r\n response.results = response.results.reverse();\r\n for (var i = 0; i < featureCollection.features.length; i++) {\r\n var feature = featureCollection.features[i];\r\n feature.layerId = response.results[i].layerId;\r\n }\r\n callback.call(context, undefined, featureCollection, response);\r\n }\r\n });\r\n },\r\n\r\n _setGeometryParams: function (geometry) {\r\n var converted = _setGeometry(geometry);\r\n this.params.geometry = converted.geometry;\r\n this.params.geometryType = converted.geometryType;\r\n }\r\n});\r\n\r\nexport function identifyFeatures (options) {\r\n return new IdentifyFeatures(options);\r\n}\r\n\r\nexport default identifyFeatures;\r\n","import { latLng } from 'leaflet';\r\nimport { Identify } from './Identify';\r\nimport { responseToFeatureCollection } from '../Util';\r\n\r\nexport var IdentifyImage = Identify.extend({\r\n setters: {\r\n 'setMosaicRule': 'mosaicRule',\r\n 'setRenderingRule': 'renderingRule',\r\n 'setPixelSize': 'pixelSize',\r\n 'returnCatalogItems': 'returnCatalogItems',\r\n 'returnGeometry': 'returnGeometry'\r\n },\r\n\r\n params: {\r\n returnGeometry: false\r\n },\r\n\r\n at: function (latlng) {\r\n latlng = latLng(latlng);\r\n this.params.geometry = JSON.stringify({\r\n x: latlng.lng,\r\n y: latlng.lat,\r\n spatialReference: {\r\n wkid: 4326\r\n }\r\n });\r\n this.params.geometryType = 'esriGeometryPoint';\r\n return this;\r\n },\r\n\r\n getMosaicRule: function () {\r\n return this.params.mosaicRule;\r\n },\r\n\r\n getRenderingRule: function () {\r\n return this.params.renderingRule;\r\n },\r\n\r\n getPixelSize: function () {\r\n return this.params.pixelSize;\r\n },\r\n\r\n run: function (callback, context) {\r\n return this.request(function (error, response) {\r\n callback.call(context, error, (response && this._responseToGeoJSON(response)), response);\r\n }, this);\r\n },\r\n\r\n // get pixel data and return as geoJSON point\r\n // populate catalog items (if any)\r\n // merging in any catalogItemVisibilities as a propery of each feature\r\n _responseToGeoJSON: function (response) {\r\n var location = response.location;\r\n var catalogItems = response.catalogItems;\r\n var catalogItemVisibilities = response.catalogItemVisibilities;\r\n var geoJSON = {\r\n 'pixel': {\r\n 'type': 'Feature',\r\n 'geometry': {\r\n 'type': 'Point',\r\n 'coordinates': [location.x, location.y]\r\n },\r\n 'crs': {\r\n 'type': 'EPSG',\r\n 'properties': {\r\n 'code': location.spatialReference.wkid\r\n }\r\n },\r\n 'properties': {\r\n 'OBJECTID': response.objectId,\r\n 'name': response.name,\r\n 'value': response.value\r\n },\r\n 'id': response.objectId\r\n }\r\n };\r\n\r\n if (response.properties && response.properties.Values) {\r\n geoJSON.pixel.properties.values = response.properties.Values;\r\n }\r\n\r\n if (catalogItems && catalogItems.features) {\r\n geoJSON.catalogItems = responseToFeatureCollection(catalogItems);\r\n if (catalogItemVisibilities && catalogItemVisibilities.length === geoJSON.catalogItems.features.length) {\r\n for (var i = catalogItemVisibilities.length - 1; i >= 0; i--) {\r\n geoJSON.catalogItems.features[i].properties.catalogItemVisibility = catalogItemVisibilities[i];\r\n }\r\n }\r\n }\r\n return geoJSON;\r\n }\r\n\r\n});\r\n\r\nexport function identifyImage (params) {\r\n return new IdentifyImage(params);\r\n}\r\n\r\nexport default identifyImage;\r\n","import { Util, Evented } from 'leaflet';\r\nimport {cors} from '../Support';\r\nimport {cleanUrl, getUrlParams} from '../Util';\r\nimport Request from '../Request';\r\n\r\nexport var Service = Evented.extend({\r\n\r\n options: {\r\n proxy: false,\r\n useCors: cors,\r\n timeout: 0\r\n },\r\n\r\n initialize: function (options) {\r\n options = options || {};\r\n this._requestQueue = [];\r\n this._authenticating = false;\r\n Util.setOptions(this, options);\r\n this.options.url = cleanUrl(this.options.url);\r\n },\r\n\r\n get: function (path, params, callback, context) {\r\n return this._request('get', path, params, callback, context);\r\n },\r\n\r\n post: function (path, params, callback, context) {\r\n return this._request('post', path, params, callback, context);\r\n },\r\n\r\n request: function (path, params, callback, context) {\r\n return this._request('request', path, params, callback, context);\r\n },\r\n\r\n metadata: function (callback, context) {\r\n return this._request('get', '', {}, callback, context);\r\n },\r\n\r\n authenticate: function (token) {\r\n this._authenticating = false;\r\n this.options.token = token;\r\n this._runQueue();\r\n return this;\r\n },\r\n\r\n getTimeout: function () {\r\n return this.options.timeout;\r\n },\r\n\r\n setTimeout: function (timeout) {\r\n this.options.timeout = timeout;\r\n },\r\n\r\n _request: function (method, path, params, callback, context) {\r\n this.fire('requeststart', {\r\n url: this.options.url + path,\r\n params: params,\r\n method: method\r\n }, true);\r\n\r\n var wrappedCallback = this._createServiceCallback(method, path, params, callback, context);\r\n\r\n if (this.options.token) {\r\n params.token = this.options.token;\r\n }\r\n if (this.options.requestParams) {\r\n Util.extend(params, this.options.requestParams);\r\n }\r\n if (this._authenticating) {\r\n this._requestQueue.push([method, path, params, callback, context]);\r\n return;\r\n } else {\r\n var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\r\n\r\n if ((method === 'get' || method === 'request') && !this.options.useCors) {\r\n return Request.get.JSONP(url, params, wrappedCallback, context);\r\n } else {\r\n return Request[method](url, params, wrappedCallback, context);\r\n }\r\n }\r\n },\r\n\r\n _createServiceCallback: function (method, path, params, callback, context) {\r\n return Util.bind(function (error, response) {\r\n if (error && (error.code === 499 || error.code === 498)) {\r\n this._authenticating = true;\r\n\r\n this._requestQueue.push([method, path, params, callback, context]);\r\n\r\n // fire an event for users to handle and re-authenticate\r\n this.fire('authenticationrequired', {\r\n authenticate: Util.bind(this.authenticate, this)\r\n }, true);\r\n\r\n // if the user has access to a callback they can handle the auth error\r\n error.authenticate = Util.bind(this.authenticate, this);\r\n }\r\n\r\n callback.call(context, error, response);\r\n\r\n if (error) {\r\n this.fire('requesterror', {\r\n url: this.options.url + path,\r\n params: params,\r\n message: error.message,\r\n code: error.code,\r\n method: method\r\n }, true);\r\n } else {\r\n this.fire('requestsuccess', {\r\n url: this.options.url + path,\r\n params: params,\r\n response: response,\r\n method: method\r\n }, true);\r\n }\r\n\r\n this.fire('requestend', {\r\n url: this.options.url + path,\r\n params: params,\r\n method: method\r\n }, true);\r\n }, this);\r\n },\r\n\r\n _runQueue: function () {\r\n for (var i = this._requestQueue.length - 1; i >= 0; i--) {\r\n var request = this._requestQueue[i];\r\n var method = request.shift();\r\n this[method].apply(this, request);\r\n }\r\n this._requestQueue = [];\r\n }\r\n});\r\n\r\nexport function service (options) {\r\n options = getUrlParams(options);\r\n return new Service(options);\r\n}\r\n\r\nexport default service;\r\n","import { Service } from './Service';\r\nimport identifyFeatures from '../Tasks/IdentifyFeatures';\r\nimport query from '../Tasks/Query';\r\nimport find from '../Tasks/Find';\r\n\r\nexport var MapService = Service.extend({\r\n\r\n identify: function () {\r\n return identifyFeatures(this);\r\n },\r\n\r\n find: function () {\r\n return find(this);\r\n },\r\n\r\n query: function () {\r\n return query(this);\r\n }\r\n\r\n});\r\n\r\nexport function mapService (options) {\r\n return new MapService(options);\r\n}\r\n\r\nexport default mapService;\r\n","import { Service } from './Service';\r\nimport identifyImage from '../Tasks/IdentifyImage';\r\nimport query from '../Tasks/Query';\r\n\r\nexport var ImageService = Service.extend({\r\n\r\n query: function () {\r\n return query(this);\r\n },\r\n\r\n identify: function () {\r\n return identifyImage(this);\r\n }\r\n});\r\n\r\nexport function imageService (options) {\r\n return new ImageService(options);\r\n}\r\n\r\nexport default imageService;\r\n","import { Service } from './Service';\r\nimport query from '../Tasks/Query';\r\nimport { geojsonToArcGIS } from '../Util';\r\n\r\nexport var FeatureLayerService = Service.extend({\r\n\r\n options: {\r\n idAttribute: 'OBJECTID'\r\n },\r\n\r\n query: function () {\r\n return query(this);\r\n },\r\n\r\n addFeature: function (feature, callback, context) {\r\n this.addFeatures(feature, callback, context);\r\n },\r\n\r\n addFeatures: function (features, callback, context) {\r\n var featuresArray = features.features ? features.features : [features];\r\n for (var i = featuresArray.length - 1; i >= 0; i--) {\r\n delete featuresArray[i].id;\r\n }\r\n features = geojsonToArcGIS(features);\r\n features = featuresArray.length > 1 ? features : [features];\r\n return this.post('addFeatures', {\r\n features: features\r\n }, function (error, response) {\r\n // For compatibility reason with former addFeature function,\r\n // we return the object in the array and not the array itself\r\n var result = (response && response.addResults) ? response.addResults.length > 1 ? response.addResults : response.addResults[0] : undefined;\r\n if (callback) {\r\n callback.call(context, error || response.addResults[0].error, result);\r\n }\r\n }, context);\r\n },\r\n\r\n updateFeature: function (feature, callback, context) {\r\n this.updateFeatures(feature, callback, context);\r\n },\r\n\r\n updateFeatures: function (features, callback, context) {\r\n var featuresArray = features.features ? features.features : [features];\r\n features = geojsonToArcGIS(features, this.options.idAttribute);\r\n features = featuresArray.length > 1 ? features : [features];\r\n\r\n return this.post('updateFeatures', {\r\n features: features\r\n }, function (error, response) {\r\n // For compatibility reason with former updateFeature function,\r\n // we return the object in the array and not the array itself\r\n var result = (response && response.updateResults) ? response.updateResults.length > 1 ? response.updateResults : response.updateResults[0] : undefined;\r\n if (callback) {\r\n callback.call(context, error || response.updateResults[0].error, result);\r\n }\r\n }, context);\r\n },\r\n\r\n deleteFeature: function (id, callback, context) {\r\n this.deleteFeatures(id, callback, context);\r\n },\r\n\r\n deleteFeatures: function (ids, callback, context) {\r\n return this.post('deleteFeatures', {\r\n objectIds: ids\r\n }, function (error, response) {\r\n // For compatibility reason with former deleteFeature function,\r\n // we return the object in the array and not the array itself\r\n var result = (response && response.deleteResults) ? response.deleteResults.length > 1 ? response.deleteResults : response.deleteResults[0] : undefined;\r\n if (callback) {\r\n callback.call(context, error || response.deleteResults[0].error, result);\r\n }\r\n }, context);\r\n }\r\n});\r\n\r\nexport function featureLayerService (options) {\r\n return new FeatureLayerService(options);\r\n}\r\n\r\nexport default featureLayerService;\r\n","import { TileLayer, Util } from 'leaflet';\r\nimport { pointerEvents } from '../Support';\r\nimport {\r\n setEsriAttribution,\r\n removeEsriAttribution,\r\n _getAttributionData,\r\n _updateMapAttribution\r\n} from '../Util';\r\n\r\nvar tileProtocol = (window.location.protocol !== 'https:') ? 'http:' : 'https:';\r\n\r\nexport var BasemapLayer = TileLayer.extend({\r\n statics: {\r\n TILES: {\r\n Streets: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Street_Map'\r\n }\r\n },\r\n Topographic: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Topo_Map'\r\n }\r\n },\r\n Oceans: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA',\r\n attributionUrl: 'https://static.arcgis.com/attribution/Ocean_Basemap'\r\n }\r\n },\r\n OceansLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n NationalGeographic: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'National Geographic, DeLorme, HERE, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, increment P Corp.'\r\n }\r\n },\r\n DarkGray: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'HERE, DeLorme, MapmyIndia, © OpenStreetMap contributors'\r\n }\r\n },\r\n DarkGrayLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n\r\n }\r\n },\r\n Gray: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n attribution: 'HERE, DeLorme, MapmyIndia, © OpenStreetMap contributors'\r\n }\r\n },\r\n GrayLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 16,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n Imagery: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n attribution: 'DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery'\r\n }\r\n },\r\n ImageryLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n ImageryTransportation: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n ShadedRelief: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 13,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS'\r\n }\r\n },\r\n ShadedReliefLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 12,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n Terrain: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 13,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, NOAA'\r\n }\r\n },\r\n TerrainLabels: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 13,\r\n subdomains: ['server', 'services'],\r\n pane: (pointerEvents) ? 'esri-labels' : 'tilePane',\r\n attribution: ''\r\n }\r\n },\r\n USATopo: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 15,\r\n subdomains: ['server', 'services'],\r\n attribution: 'USGS, National Geographic Society, i-cubed'\r\n }\r\n },\r\n ImageryClarity: {\r\n urlTemplate: tileProtocol + '//clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community'\r\n }\r\n },\r\n Physical: {\r\n urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 8,\r\n subdomains: ['server', 'services'],\r\n attribution: 'U.S. National Park Service'\r\n }\r\n },\r\n ImageryFirefly: {\r\n urlTemplate: tileProtocol + '//fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{z}/{y}/{x}',\r\n options: {\r\n minZoom: 1,\r\n maxZoom: 19,\r\n attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community',\r\n attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery'\r\n }\r\n }\r\n }\r\n },\r\n\r\n initialize: function (key, options) {\r\n var config;\r\n\r\n // set the config variable with the appropriate config object\r\n if (typeof key === 'object' && key.urlTemplate && key.options) {\r\n config = key;\r\n } else if (typeof key === 'string' && BasemapLayer.TILES[key]) {\r\n config = BasemapLayer.TILES[key];\r\n } else {\r\n throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of \"Streets\", \"Topographic\", \"Oceans\", \"OceansLabels\", \"NationalGeographic\", \"Physical\", \"Gray\", \"GrayLabels\", \"DarkGray\", \"DarkGrayLabels\", \"Imagery\", \"ImageryLabels\", \"ImageryTransportation\", \"ImageryClarity\", \"ImageryFirefly\", ShadedRelief\", \"ShadedReliefLabels\", \"Terrain\", \"TerrainLabels\" or \"USATopo\"');\r\n }\r\n\r\n // merge passed options into the config options\r\n var tileOptions = Util.extend(config.options, options);\r\n\r\n Util.setOptions(this, tileOptions);\r\n\r\n // Deprecation notice:\r\n if (!this.options.ignoreDeprecationWarning) {\r\n console.warn('WARNING: L.esri.BasemapLayer uses data services that are in mature support and are not being updated. Please use L.esri.Vector.vectorBasemapLayer instead. More info: https://esriurl.com/esri-leaflet-basemap');\r\n }\r\n\r\n if (this.options.token && config.urlTemplate.indexOf('token=') === -1) {\r\n config.urlTemplate += ('?token=' + this.options.token);\r\n }\r\n if (this.options.proxy) {\r\n config.urlTemplate = this.options.proxy + '?' + config.urlTemplate;\r\n }\r\n\r\n // call the initialize method on L.TileLayer to set everything up\r\n TileLayer.prototype.initialize.call(this, config.urlTemplate, tileOptions);\r\n },\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n if (this.options.pane === 'esri-labels') {\r\n this._initPane();\r\n }\r\n // some basemaps can supply dynamic attribution\r\n if (this.options.attributionUrl) {\r\n _getAttributionData((this.options.proxy ? this.options.proxy + '?' : '') + this.options.attributionUrl, map);\r\n }\r\n\r\n map.on('moveend', _updateMapAttribution);\r\n\r\n TileLayer.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n\r\n map.off('moveend', _updateMapAttribution);\r\n\r\n TileLayer.prototype.onRemove.call(this, map);\r\n },\r\n\r\n _initPane: function () {\r\n if (!this._map.getPane(this.options.pane)) {\r\n var pane = this._map.createPane(this.options.pane);\r\n pane.style.pointerEvents = 'none';\r\n pane.style.zIndex = 500;\r\n }\r\n },\r\n\r\n getAttribution: function () {\r\n if (this.options.attribution) {\r\n var attribution = '' + this.options.attribution + '';\r\n }\r\n return attribution;\r\n }\r\n});\r\n\r\nexport function basemapLayer (key, options) {\r\n return new BasemapLayer(key, options);\r\n}\r\n\r\nexport default basemapLayer;\r\n","import { CRS, DomEvent, TileLayer, Util } from 'leaflet';\r\nimport { warn, getUrlParams, setEsriAttribution, removeEsriAttribution } from '../Util';\r\nimport mapService from '../Services/MapService';\r\n\r\nexport var TiledMapLayer = TileLayer.extend({\r\n options: {\r\n zoomOffsetAllowance: 0.1,\r\n errorTileUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEABAMAAACuXLVVAAAAA1BMVEUzNDVszlHHAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAAAAAAAAAB6mUWpAAAADZJREFUeJztwQEBAAAAgiD/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7waBAAABw08RwAAAAABJRU5ErkJggg=='\r\n },\r\n\r\n statics: {\r\n MercatorZoomLevels: {\r\n '0': 156543.03392799999,\r\n '1': 78271.516963999893,\r\n '2': 39135.758482000099,\r\n '3': 19567.879240999901,\r\n '4': 9783.9396204999593,\r\n '5': 4891.9698102499797,\r\n '6': 2445.9849051249898,\r\n '7': 1222.9924525624899,\r\n '8': 611.49622628138002,\r\n '9': 305.74811314055802,\r\n '10': 152.874056570411,\r\n '11': 76.437028285073197,\r\n '12': 38.218514142536598,\r\n '13': 19.109257071268299,\r\n '14': 9.5546285356341496,\r\n '15': 4.7773142679493699,\r\n '16': 2.38865713397468,\r\n '17': 1.1943285668550501,\r\n '18': 0.59716428355981699,\r\n '19': 0.29858214164761698,\r\n '20': 0.14929107082381,\r\n '21': 0.07464553541191,\r\n '22': 0.0373227677059525,\r\n '23': 0.0186613838529763\r\n }\r\n },\r\n\r\n initialize: function (options) {\r\n options = Util.setOptions(this, options);\r\n\r\n // set the urls\r\n options = getUrlParams(options);\r\n this.tileUrl = (options.proxy ? options.proxy + '?' : '') + options.url + 'tile/{z}/{y}/{x}' + (options.requestParams && Object.keys(options.requestParams).length > 0 ? Util.getParamString(options.requestParams) : '');\r\n // Remove subdomain in url\r\n // https://github.com/Esri/esri-leaflet/issues/991\r\n if (options.url.indexOf('{s}') !== -1 && options.subdomains) {\r\n options.url = options.url.replace('{s}', options.subdomains[0]);\r\n }\r\n this.service = mapService(options);\r\n this.service.addEventParent(this);\r\n\r\n var arcgisonline = new RegExp(/tiles.arcgis(online)?\\.com/g);\r\n if (arcgisonline.test(options.url)) {\r\n this.tileUrl = this.tileUrl.replace('://tiles', '://tiles{s}');\r\n options.subdomains = ['1', '2', '3', '4'];\r\n }\r\n\r\n if (this.options.token) {\r\n this.tileUrl += ('?token=' + this.options.token);\r\n }\r\n\r\n // init layer by calling TileLayers initialize method\r\n TileLayer.prototype.initialize.call(this, this.tileUrl, options);\r\n },\r\n\r\n getTileUrl: function (tilePoint) {\r\n var zoom = this._getZoomForUrl();\r\n\r\n return Util.template(this.tileUrl, Util.extend({\r\n s: this._getSubdomain(tilePoint),\r\n x: tilePoint.x,\r\n y: tilePoint.y,\r\n // try lod map first, then just default to zoom level\r\n z: (this._lodMap && this._lodMap[zoom]) ? this._lodMap[zoom] : zoom\r\n }, this.options));\r\n },\r\n\r\n createTile: function (coords, done) {\r\n var tile = document.createElement('img');\r\n\r\n DomEvent.on(tile, 'load', Util.bind(this._tileOnLoad, this, done, tile));\r\n DomEvent.on(tile, 'error', Util.bind(this._tileOnError, this, done, tile));\r\n\r\n if (this.options.crossOrigin) {\r\n tile.crossOrigin = '';\r\n }\r\n\r\n /*\r\n Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons\r\n http://www.w3.org/TR/WCAG20-TECHS/H67\r\n */\r\n tile.alt = '';\r\n\r\n // if there is no lod map or an lod map with a proper zoom load the tile\r\n // otherwise wait for the lod map to become available\r\n if (!this._lodMap || (this._lodMap && this._lodMap[this._getZoomForUrl()])) {\r\n tile.src = this.getTileUrl(coords);\r\n } else {\r\n this.once('lodmap', function () {\r\n tile.src = this.getTileUrl(coords);\r\n }, this);\r\n }\r\n\r\n return tile;\r\n },\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n if (!this._lodMap) {\r\n this.metadata(function (error, metadata) {\r\n if (!error && metadata.spatialReference) {\r\n var sr = metadata.spatialReference.latestWkid || metadata.spatialReference.wkid;\r\n // display the copyright text from the service using leaflet's attribution control\r\n if (!this.options.attribution && map.attributionControl && metadata.copyrightText) {\r\n this.options.attribution = metadata.copyrightText;\r\n map.attributionControl.addAttribution(this.getAttribution());\r\n }\r\n\r\n // if the service tiles were published in web mercator using conventional LODs but missing levels, we can try and remap them\r\n if (map.options.crs === CRS.EPSG3857 && (sr === 102100 || sr === 3857)) {\r\n this._lodMap = {};\r\n // create the zoom level data\r\n var arcgisLODs = metadata.tileInfo.lods;\r\n var correctResolutions = TiledMapLayer.MercatorZoomLevels;\r\n\r\n for (var i = 0; i < arcgisLODs.length; i++) {\r\n var arcgisLOD = arcgisLODs[i];\r\n for (var ci in correctResolutions) {\r\n var correctRes = correctResolutions[ci];\r\n\r\n if (this._withinPercentage(arcgisLOD.resolution, correctRes, this.options.zoomOffsetAllowance)) {\r\n this._lodMap[ci] = arcgisLOD.level;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n this.fire('lodmap');\r\n } else if (map.options.crs && map.options.crs.code && (map.options.crs.code.indexOf(sr) > -1)) {\r\n // if the projection is WGS84, or the developer is using Proj4 to define a custom CRS, no action is required\r\n } else {\r\n // if the service was cached in a custom projection and an appropriate LOD hasn't been defined in the map, guide the developer to our Proj4 sample\r\n warn('L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html');\r\n }\r\n }\r\n }, this);\r\n }\r\n\r\n TileLayer.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n\r\n TileLayer.prototype.onRemove.call(this, map);\r\n },\r\n\r\n metadata: function (callback, context) {\r\n this.service.metadata(callback, context);\r\n return this;\r\n },\r\n\r\n identify: function () {\r\n return this.service.identify();\r\n },\r\n\r\n find: function () {\r\n return this.service.find();\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n authenticate: function (token) {\r\n var tokenQs = '?token=' + token;\r\n this.tileUrl = (this.options.token) ? this.tileUrl.replace(/\\?token=(.+)/g, tokenQs) : this.tileUrl + tokenQs;\r\n this.options.token = token;\r\n this.service.authenticate(token);\r\n return this;\r\n },\r\n\r\n _withinPercentage: function (a, b, percentage) {\r\n var diff = Math.abs((a / b) - 1);\r\n return diff < percentage;\r\n }\r\n});\r\n\r\nexport function tiledMapLayer (url, options) {\r\n return new TiledMapLayer(url, options);\r\n}\r\n\r\nexport default tiledMapLayer;\r\n","import { ImageOverlay, CRS, DomUtil, Util, Layer, popup, latLng, bounds } from 'leaflet';\r\nimport { cors } from '../Support';\r\nimport { setEsriAttribution, removeEsriAttribution } from '../Util';\r\n\r\nvar Overlay = ImageOverlay.extend({\r\n onAdd: function (map) {\r\n this._topLeft = map.getPixelBounds().min;\r\n ImageOverlay.prototype.onAdd.call(this, map);\r\n },\r\n _reset: function () {\r\n if (this._map.options.crs === CRS.EPSG3857) {\r\n ImageOverlay.prototype._reset.call(this);\r\n } else {\r\n DomUtil.setPosition(this._image, this._topLeft.subtract(this._map.getPixelOrigin()));\r\n }\r\n }\r\n});\r\n\r\nexport var RasterLayer = Layer.extend({\r\n options: {\r\n opacity: 1,\r\n position: 'front',\r\n f: 'image',\r\n useCors: cors,\r\n attribution: null,\r\n interactive: false,\r\n alt: ''\r\n },\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n if (this.options.zIndex) {\r\n this.options.position = null;\r\n }\r\n\r\n this._update = Util.throttle(this._update, this.options.updateInterval, this);\r\n\r\n map.on('moveend', this._update, this);\r\n\r\n // if we had an image loaded and it matches the\r\n // current bounds show the image otherwise remove it\r\n if (this._currentImage && this._currentImage._bounds.equals(this._map.getBounds())) {\r\n map.addLayer(this._currentImage);\r\n } else if (this._currentImage) {\r\n this._map.removeLayer(this._currentImage);\r\n this._currentImage = null;\r\n }\r\n\r\n this._update();\r\n\r\n if (this._popup) {\r\n this._map.on('click', this._getPopupData, this);\r\n this._map.on('dblclick', this._resetPopupState, this);\r\n }\r\n\r\n // add copyright text listed in service metadata\r\n this.metadata(function (err, metadata) {\r\n if (!err && !this.options.attribution && map.attributionControl && metadata.copyrightText) {\r\n this.options.attribution = metadata.copyrightText;\r\n map.attributionControl.addAttribution(this.getAttribution());\r\n }\r\n }, this);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n\r\n if (this._currentImage) {\r\n this._map.removeLayer(this._currentImage);\r\n }\r\n\r\n if (this._popup) {\r\n this._map.off('click', this._getPopupData, this);\r\n this._map.off('dblclick', this._resetPopupState, this);\r\n }\r\n\r\n this._map.off('moveend', this._update, this);\r\n },\r\n\r\n bindPopup: function (fn, popupOptions) {\r\n this._shouldRenderPopup = false;\r\n this._lastClick = false;\r\n this._popup = popup(popupOptions);\r\n this._popupFunction = fn;\r\n if (this._map) {\r\n this._map.on('click', this._getPopupData, this);\r\n this._map.on('dblclick', this._resetPopupState, this);\r\n }\r\n return this;\r\n },\r\n\r\n unbindPopup: function () {\r\n if (this._map) {\r\n this._map.closePopup(this._popup);\r\n this._map.off('click', this._getPopupData, this);\r\n this._map.off('dblclick', this._resetPopupState, this);\r\n }\r\n this._popup = false;\r\n return this;\r\n },\r\n\r\n bringToFront: function () {\r\n this.options.position = 'front';\r\n if (this._currentImage) {\r\n this._currentImage.bringToFront();\r\n this._setAutoZIndex(Math.max);\r\n }\r\n return this;\r\n },\r\n\r\n bringToBack: function () {\r\n this.options.position = 'back';\r\n if (this._currentImage) {\r\n this._currentImage.bringToBack();\r\n this._setAutoZIndex(Math.min);\r\n }\r\n return this;\r\n },\r\n\r\n setZIndex: function (value) {\r\n this.options.zIndex = value;\r\n if (this._currentImage) {\r\n this._currentImage.setZIndex(value);\r\n }\r\n return this;\r\n },\r\n\r\n _setAutoZIndex: function (compare) {\r\n // go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back)\r\n if (!this._currentImage) {\r\n return;\r\n }\r\n var layers = this._currentImage.getPane().children;\r\n var edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min\r\n for (var i = 0, len = layers.length, zIndex; i < len; i++) {\r\n zIndex = layers[i].style.zIndex;\r\n if (layers[i] !== this._currentImage._image && zIndex) {\r\n edgeZIndex = compare(edgeZIndex, +zIndex);\r\n }\r\n }\r\n\r\n if (isFinite(edgeZIndex)) {\r\n this.options.zIndex = edgeZIndex + compare(-1, 1);\r\n this.setZIndex(this.options.zIndex);\r\n }\r\n },\r\n\r\n getAttribution: function () {\r\n return this.options.attribution;\r\n },\r\n\r\n getOpacity: function () {\r\n return this.options.opacity;\r\n },\r\n\r\n setOpacity: function (opacity) {\r\n this.options.opacity = opacity;\r\n if (this._currentImage) {\r\n this._currentImage.setOpacity(opacity);\r\n }\r\n return this;\r\n },\r\n\r\n getTimeRange: function () {\r\n return [this.options.from, this.options.to];\r\n },\r\n\r\n setTimeRange: function (from, to) {\r\n this.options.from = from;\r\n this.options.to = to;\r\n this._update();\r\n return this;\r\n },\r\n\r\n metadata: function (callback, context) {\r\n this.service.metadata(callback, context);\r\n return this;\r\n },\r\n\r\n authenticate: function (token) {\r\n this.service.authenticate(token);\r\n return this;\r\n },\r\n\r\n redraw: function () {\r\n this._update();\r\n },\r\n\r\n _renderImage: function (url, bounds, contentType) {\r\n if (this._map) {\r\n // if no output directory has been specified for a service, MIME data will be returned\r\n if (contentType) {\r\n url = 'data:' + contentType + ';base64,' + url;\r\n }\r\n\r\n // if server returns an inappropriate response, abort.\r\n if (!url) return;\r\n\r\n // create a new image overlay and add it to the map\r\n // to start loading the image\r\n // opacity is 0 while the image is loading\r\n var image = new Overlay(url, bounds, {\r\n opacity: 0,\r\n crossOrigin: this.options.withCredentials ? 'use-credentials' : this.options.useCors,\r\n alt: this.options.alt,\r\n pane: this.options.pane || this.getPane(),\r\n interactive: this.options.interactive\r\n }).addTo(this._map);\r\n\r\n var onOverlayError = function () {\r\n this._map.removeLayer(image);\r\n this.fire('error');\r\n image.off('load', onOverlayLoad, this);\r\n };\r\n\r\n var onOverlayLoad = function (e) {\r\n image.off('error', onOverlayLoad, this);\r\n if (this._map) {\r\n var newImage = e.target;\r\n var oldImage = this._currentImage;\r\n\r\n // if the bounds of this image matches the bounds that\r\n // _renderImage was called with and we have a map with the same bounds\r\n // hide the old image if there is one and set the opacity\r\n // of the new image otherwise remove the new image\r\n if (newImage._bounds.equals(bounds) && newImage._bounds.equals(this._map.getBounds())) {\r\n this._currentImage = newImage;\r\n\r\n if (this.options.position === 'front') {\r\n this.bringToFront();\r\n } else if (this.options.position === 'back') {\r\n this.bringToBack();\r\n }\r\n\r\n if (this.options.zIndex) {\r\n this.setZIndex(this.options.zIndex);\r\n }\r\n\r\n if (this._map && this._currentImage._map) {\r\n this._currentImage.setOpacity(this.options.opacity);\r\n } else {\r\n this._currentImage._map.removeLayer(this._currentImage);\r\n }\r\n\r\n if (oldImage && this._map) {\r\n this._map.removeLayer(oldImage);\r\n }\r\n\r\n if (oldImage && oldImage._map) {\r\n oldImage._map.removeLayer(oldImage);\r\n }\r\n } else {\r\n this._map.removeLayer(newImage);\r\n }\r\n }\r\n\r\n this.fire('load', {\r\n bounds: bounds\r\n });\r\n };\r\n\r\n // If loading the image fails\r\n image.once('error', onOverlayError, this);\r\n\r\n // once the image loads\r\n image.once('load', onOverlayLoad, this);\r\n }\r\n },\r\n\r\n _update: function () {\r\n if (!this._map) {\r\n return;\r\n }\r\n\r\n var zoom = this._map.getZoom();\r\n var bounds = this._map.getBounds();\r\n\r\n if (this._animatingZoom) {\r\n return;\r\n }\r\n\r\n if (this._map._panTransition && this._map._panTransition._inProgress) {\r\n return;\r\n }\r\n\r\n if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\r\n if (this._currentImage) {\r\n this._currentImage._map.removeLayer(this._currentImage);\r\n this._currentImage = null;\r\n }\r\n return;\r\n }\r\n\r\n var params = this._buildExportParams();\r\n Util.extend(params, this.options.requestParams);\r\n\r\n if (params) {\r\n this._requestExport(params, bounds);\r\n\r\n this.fire('loading', {\r\n bounds: bounds\r\n });\r\n } else if (this._currentImage) {\r\n this._currentImage._map.removeLayer(this._currentImage);\r\n this._currentImage = null;\r\n }\r\n },\r\n\r\n _renderPopup: function (latlng, error, results, response) {\r\n latlng = latLng(latlng);\r\n if (this._shouldRenderPopup && this._lastClick.equals(latlng)) {\r\n // add the popup to the map where the mouse was clicked at\r\n var content = this._popupFunction(error, results, response);\r\n if (content) {\r\n this._popup.setLatLng(latlng).setContent(content).openOn(this._map);\r\n }\r\n }\r\n },\r\n\r\n _resetPopupState: function (e) {\r\n this._shouldRenderPopup = false;\r\n this._lastClick = e.latlng;\r\n },\r\n\r\n _calculateBbox: function () {\r\n var pixelBounds = this._map.getPixelBounds();\r\n\r\n var sw = this._map.unproject(pixelBounds.getBottomLeft());\r\n var ne = this._map.unproject(pixelBounds.getTopRight());\r\n\r\n var neProjected = this._map.options.crs.project(ne);\r\n var swProjected = this._map.options.crs.project(sw);\r\n\r\n // this ensures ne/sw are switched in polar maps where north/top bottom/south is inverted\r\n var boundsProjected = bounds(neProjected, swProjected);\r\n\r\n return [boundsProjected.getBottomLeft().x, boundsProjected.getBottomLeft().y, boundsProjected.getTopRight().x, boundsProjected.getTopRight().y].join(',');\r\n },\r\n\r\n _calculateImageSize: function () {\r\n // ensure that we don't ask ArcGIS Server for a taller image than we have actual map displaying within the div\r\n var bounds = this._map.getPixelBounds();\r\n var size = this._map.getSize();\r\n\r\n var sw = this._map.unproject(bounds.getBottomLeft());\r\n var ne = this._map.unproject(bounds.getTopRight());\r\n\r\n var top = this._map.latLngToLayerPoint(ne).y;\r\n var bottom = this._map.latLngToLayerPoint(sw).y;\r\n\r\n if (top > 0 || bottom < size.y) {\r\n size.y = bottom - top;\r\n }\r\n\r\n return size.x + ',' + size.y;\r\n }\r\n});\r\n","import { Util } from 'leaflet';\r\nimport { RasterLayer } from './RasterLayer';\r\nimport { getUrlParams } from '../Util';\r\nimport imageService from '../Services/ImageService';\r\n\r\nexport var ImageMapLayer = RasterLayer.extend({\r\n\r\n options: {\r\n updateInterval: 150,\r\n format: 'jpgpng',\r\n transparent: true,\r\n f: 'image'\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n identify: function () {\r\n return this.service.identify();\r\n },\r\n\r\n initialize: function (options) {\r\n options = getUrlParams(options);\r\n this.service = imageService(options);\r\n this.service.addEventParent(this);\r\n\r\n Util.setOptions(this, options);\r\n },\r\n\r\n setPixelType: function (pixelType) {\r\n this.options.pixelType = pixelType;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getPixelType: function () {\r\n return this.options.pixelType;\r\n },\r\n\r\n setBandIds: function (bandIds) {\r\n if (Util.isArray(bandIds)) {\r\n this.options.bandIds = bandIds.join(',');\r\n } else {\r\n this.options.bandIds = bandIds.toString();\r\n }\r\n this._update();\r\n return this;\r\n },\r\n\r\n getBandIds: function () {\r\n return this.options.bandIds;\r\n },\r\n\r\n setNoData: function (noData, noDataInterpretation) {\r\n if (Util.isArray(noData)) {\r\n this.options.noData = noData.join(',');\r\n } else {\r\n this.options.noData = noData.toString();\r\n }\r\n if (noDataInterpretation) {\r\n this.options.noDataInterpretation = noDataInterpretation;\r\n }\r\n this._update();\r\n return this;\r\n },\r\n\r\n getNoData: function () {\r\n return this.options.noData;\r\n },\r\n\r\n getNoDataInterpretation: function () {\r\n return this.options.noDataInterpretation;\r\n },\r\n\r\n setRenderingRule: function (renderingRule) {\r\n this.options.renderingRule = renderingRule;\r\n this._update();\r\n },\r\n\r\n getRenderingRule: function () {\r\n return this.options.renderingRule;\r\n },\r\n\r\n setMosaicRule: function (mosaicRule) {\r\n this.options.mosaicRule = mosaicRule;\r\n this._update();\r\n },\r\n\r\n getMosaicRule: function () {\r\n return this.options.mosaicRule;\r\n },\r\n\r\n _getPopupData: function (e) {\r\n var callback = Util.bind(function (error, results, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n setTimeout(Util.bind(function () {\r\n this._renderPopup(e.latlng, error, results, response);\r\n }, this), 300);\r\n }, this);\r\n\r\n var identifyRequest = this.identify().at(e.latlng);\r\n\r\n // set mosaic rule for identify task if it is set for layer\r\n if (this.options.mosaicRule) {\r\n identifyRequest.setMosaicRule(this.options.mosaicRule);\r\n // @TODO: force return catalog items too?\r\n }\r\n\r\n // @TODO: set rendering rule? Not sure,\r\n // sometimes you want raw pixel values\r\n // if (this.options.renderingRule) {\r\n // identifyRequest.setRenderingRule(this.options.renderingRule);\r\n // }\r\n\r\n identifyRequest.run(callback);\r\n\r\n // set the flags to show the popup\r\n this._shouldRenderPopup = true;\r\n this._lastClick = e.latlng;\r\n },\r\n\r\n _buildExportParams: function () {\r\n var sr = parseInt(this._map.options.crs.code.split(':')[1], 10);\r\n\r\n var params = {\r\n bbox: this._calculateBbox(),\r\n size: this._calculateImageSize(),\r\n format: this.options.format,\r\n transparent: this.options.transparent,\r\n bboxSR: sr,\r\n imageSR: sr\r\n };\r\n\r\n if (this.options.from && this.options.to) {\r\n params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\r\n }\r\n\r\n if (this.options.pixelType) {\r\n params.pixelType = this.options.pixelType;\r\n }\r\n\r\n if (this.options.interpolation) {\r\n params.interpolation = this.options.interpolation;\r\n }\r\n\r\n if (this.options.compressionQuality) {\r\n params.compressionQuality = this.options.compressionQuality;\r\n }\r\n\r\n if (this.options.bandIds) {\r\n params.bandIds = this.options.bandIds;\r\n }\r\n\r\n // 0 is falsy *and* a valid input parameter\r\n if (this.options.noData === 0 || this.options.noData) {\r\n params.noData = this.options.noData;\r\n }\r\n\r\n if (this.options.noDataInterpretation) {\r\n params.noDataInterpretation = this.options.noDataInterpretation;\r\n }\r\n\r\n if (this.service.options.token) {\r\n params.token = this.service.options.token;\r\n }\r\n\r\n if (this.options.renderingRule) {\r\n params.renderingRule = JSON.stringify(this.options.renderingRule);\r\n }\r\n\r\n if (this.options.mosaicRule) {\r\n params.mosaicRule = JSON.stringify(this.options.mosaicRule);\r\n }\r\n\r\n return params;\r\n },\r\n\r\n _requestExport: function (params, bounds) {\r\n if (this.options.f === 'json') {\r\n this.service.request('exportImage', params, function (error, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n if (this.options.token) {\r\n response.href += ('?token=' + this.options.token);\r\n }\r\n if (this.options.proxy) {\r\n response.href = this.options.proxy + '?' + response.href;\r\n }\r\n this._renderImage(response.href, bounds);\r\n }, this);\r\n } else {\r\n params.f = 'image';\r\n var fullUrl = this.options.url + 'exportImage' + Util.getParamString(params);\r\n if (this.options.proxy) {\r\n fullUrl = this.options.proxy + '?' + fullUrl;\r\n }\r\n this._renderImage(fullUrl, bounds);\r\n }\r\n }\r\n});\r\n\r\nexport function imageMapLayer (url, options) {\r\n return new ImageMapLayer(url, options);\r\n}\r\n\r\nexport default imageMapLayer;\r\n","import { Util } from 'leaflet';\r\nimport { RasterLayer } from './RasterLayer';\r\nimport { getUrlParams } from '../Util';\r\nimport mapService from '../Services/MapService';\r\n\r\nexport var DynamicMapLayer = RasterLayer.extend({\r\n\r\n options: {\r\n updateInterval: 150,\r\n layers: false,\r\n layerDefs: false,\r\n timeOptions: false,\r\n format: 'png32',\r\n transparent: true,\r\n f: 'json'\r\n },\r\n\r\n initialize: function (options) {\r\n options = getUrlParams(options);\r\n this.service = mapService(options);\r\n this.service.addEventParent(this);\r\n\r\n Util.setOptions(this, options);\r\n },\r\n\r\n getDynamicLayers: function () {\r\n return this.options.dynamicLayers;\r\n },\r\n\r\n setDynamicLayers: function (dynamicLayers) {\r\n this.options.dynamicLayers = dynamicLayers;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getLayers: function () {\r\n return this.options.layers;\r\n },\r\n\r\n setLayers: function (layers) {\r\n this.options.layers = layers;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getLayerDefs: function () {\r\n return this.options.layerDefs;\r\n },\r\n\r\n setLayerDefs: function (layerDefs) {\r\n this.options.layerDefs = layerDefs;\r\n this._update();\r\n return this;\r\n },\r\n\r\n getTimeOptions: function () {\r\n return this.options.timeOptions;\r\n },\r\n\r\n setTimeOptions: function (timeOptions) {\r\n this.options.timeOptions = timeOptions;\r\n this._update();\r\n return this;\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n identify: function () {\r\n return this.service.identify();\r\n },\r\n\r\n find: function () {\r\n return this.service.find();\r\n },\r\n\r\n _getPopupData: function (e) {\r\n var callback = Util.bind(function (error, featureCollection, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n setTimeout(Util.bind(function () {\r\n this._renderPopup(e.latlng, error, featureCollection, response);\r\n }, this), 300);\r\n }, this);\r\n\r\n var identifyRequest;\r\n if (this.options.popup) {\r\n identifyRequest = this.options.popup.on(this._map).at(e.latlng);\r\n } else {\r\n identifyRequest = this.identify().on(this._map).at(e.latlng);\r\n }\r\n\r\n // remove extraneous vertices from response features if it has not already been done\r\n identifyRequest.params.maxAllowableOffset ? true : identifyRequest.simplify(this._map, 0.5);\r\n\r\n if (!(this.options.popup && this.options.popup.params && this.options.popup.params.layers)) {\r\n if (this.options.layers) {\r\n identifyRequest.layers('visible:' + this.options.layers.join(','));\r\n } else {\r\n identifyRequest.layers('visible');\r\n }\r\n }\r\n\r\n // if present, pass layer ids and sql filters through to the identify task\r\n if (this.options.layerDefs && typeof this.options.layerDefs !== 'string' && !identifyRequest.params.layerDefs) {\r\n for (var id in this.options.layerDefs) {\r\n if (this.options.layerDefs.hasOwnProperty(id)) {\r\n identifyRequest.layerDef(id, this.options.layerDefs[id]);\r\n }\r\n }\r\n }\r\n\r\n identifyRequest.run(callback);\r\n\r\n // set the flags to show the popup\r\n this._shouldRenderPopup = true;\r\n this._lastClick = e.latlng;\r\n },\r\n\r\n _buildExportParams: function () {\r\n var sr = parseInt(this._map.options.crs.code.split(':')[1], 10);\r\n\r\n var params = {\r\n bbox: this._calculateBbox(),\r\n size: this._calculateImageSize(),\r\n dpi: 96,\r\n format: this.options.format,\r\n transparent: this.options.transparent,\r\n bboxSR: sr,\r\n imageSR: sr\r\n };\r\n\r\n if (this.options.dynamicLayers) {\r\n params.dynamicLayers = this.options.dynamicLayers;\r\n }\r\n\r\n if (this.options.layers) {\r\n if (this.options.layers.length === 0) {\r\n return;\r\n } else {\r\n params.layers = 'show:' + this.options.layers.join(',');\r\n }\r\n }\r\n\r\n if (this.options.layerDefs) {\r\n params.layerDefs = typeof this.options.layerDefs === 'string' ? this.options.layerDefs : JSON.stringify(this.options.layerDefs);\r\n }\r\n\r\n if (this.options.timeOptions) {\r\n params.timeOptions = JSON.stringify(this.options.timeOptions);\r\n }\r\n\r\n if (this.options.from && this.options.to) {\r\n params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\r\n }\r\n\r\n if (this.service.options.token) {\r\n params.token = this.service.options.token;\r\n }\r\n\r\n if (this.options.proxy) {\r\n params.proxy = this.options.proxy;\r\n }\r\n\r\n // use a timestamp to bust server cache\r\n if (this.options.disableCache) {\r\n params._ts = Date.now();\r\n }\r\n\r\n return params;\r\n },\r\n\r\n _requestExport: function (params, bounds) {\r\n if (this.options.f === 'json') {\r\n this.service.request('export', params, function (error, response) {\r\n if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire\r\n\r\n if (this.options.token && response.href) {\r\n response.href += ('?token=' + this.options.token);\r\n }\r\n if (this.options.proxy && response.href) {\r\n response.href = this.options.proxy + '?' + response.href;\r\n }\r\n if (response.href) {\r\n this._renderImage(response.href, bounds);\r\n } else {\r\n this._renderImage(response.imageData, bounds, response.contentType);\r\n }\r\n }, this);\r\n } else {\r\n params.f = 'image';\r\n var fullUrl = this.options.url + 'export' + Util.getParamString(params);\r\n if (this.options.proxy) {\r\n fullUrl = this.options.proxy + '?' + fullUrl;\r\n }\r\n this._renderImage(fullUrl, bounds);\r\n }\r\n }\r\n});\r\n\r\nexport function dynamicMapLayer (url, options) {\r\n return new DynamicMapLayer(url, options);\r\n}\r\n\r\nexport default dynamicMapLayer;\r\n","import {\r\n LatLngBounds,\r\n toLatLngBounds as latLngBounds,\r\n Layer,\r\n Browser,\r\n Util,\r\n Point,\r\n Bounds\r\n} from 'leaflet';\r\n\r\nexport var FeatureGrid = Layer.extend({\r\n // @section\r\n // @aka GridLayer options\r\n options: {\r\n // @option cellSize: Number|Point = 256\r\n // Width and height of cells in the grid. Use a number if width and height are equal, or `L.point(width, height)` otherwise.\r\n cellSize: 512,\r\n\r\n // @option updateWhenIdle: Boolean = (depends)\r\n // Load new cells only when panning ends.\r\n // `true` by default on mobile browsers, in order to avoid too many requests and keep smooth navigation.\r\n // `false` otherwise in order to display new cells _during_ panning, since it is easy to pan outside the\r\n // [`keepBuffer`](#gridlayer-keepbuffer) option in desktop browsers.\r\n updateWhenIdle: Browser.mobile,\r\n\r\n // @option updateInterval: Number = 150\r\n // Cells will not update more than once every `updateInterval` milliseconds when panning.\r\n updateInterval: 150,\r\n\r\n // @option noWrap: Boolean = false\r\n // Whether the layer is wrapped around the antimeridian. If `true`, the\r\n // GridLayer will only be displayed once at low zoom levels. Has no\r\n // effect when the [map CRS](#map-crs) doesn't wrap around. Can be used\r\n // in combination with [`bounds`](#gridlayer-bounds) to prevent requesting\r\n // cells outside the CRS limits.\r\n noWrap: false,\r\n\r\n // @option keepBuffer: Number = 1.5\r\n // When panning the map, keep this many rows and columns of cells before unloading them.\r\n keepBuffer: 1.5\r\n },\r\n\r\n initialize: function (options) {\r\n Util.setOptions(this, options);\r\n },\r\n\r\n onAdd: function (map) {\r\n this._cells = {};\r\n this._activeCells = {};\r\n this._resetView();\r\n this._update();\r\n },\r\n\r\n onRemove: function (map) {\r\n this._removeAllCells();\r\n this._cellZoom = undefined;\r\n },\r\n\r\n // @method isLoading: Boolean\r\n // Returns `true` if any cell in the grid layer has not finished loading.\r\n isLoading: function () {\r\n return this._loading;\r\n },\r\n\r\n // @method redraw: this\r\n // Causes the layer to clear all the cells and request them again.\r\n redraw: function () {\r\n if (this._map) {\r\n this._removeAllCells();\r\n this._update();\r\n }\r\n return this;\r\n },\r\n\r\n getEvents: function () {\r\n var events = {\r\n viewprereset: this._invalidateAll,\r\n viewreset: this._resetView,\r\n zoom: this._resetView,\r\n moveend: this._onMoveEnd\r\n };\r\n\r\n if (!this.options.updateWhenIdle) {\r\n // update cells on move, but not more often than once per given interval\r\n if (!this._onMove) {\r\n this._onMove = Util.throttle(\r\n this._onMoveEnd,\r\n this.options.updateInterval,\r\n this\r\n );\r\n }\r\n\r\n events.move = this._onMove;\r\n }\r\n\r\n return events;\r\n },\r\n\r\n // @section Extension methods\r\n // Layers extending `GridLayer` shall reimplement the following method.\r\n // @method createCell(coords: Object, done?: Function): HTMLElement\r\n // Called only internally, must be overridden by classes extending `GridLayer`.\r\n // Returns the `HTMLElement` corresponding to the given `coords`. If the `done` callback\r\n // is specified, it must be called when the cell has finished loading and drawing.\r\n createCell: function () {\r\n return document.createElement('div');\r\n },\r\n\r\n removeCell: function () {\r\n return;\r\n },\r\n\r\n reuseCell: function () {\r\n return;\r\n },\r\n\r\n cellLeave: function () {\r\n return;\r\n },\r\n\r\n cellEnter: function () {\r\n return;\r\n },\r\n // @section\r\n // @method getCellSize: Point\r\n // Normalizes the [cellSize option](#gridlayer-cellsize) into a point. Used by the `createCell()` method.\r\n getCellSize: function () {\r\n var s = this.options.cellSize;\r\n return s instanceof Point ? s : new Point(s, s);\r\n },\r\n\r\n _pruneCells: function () {\r\n if (!this._map) {\r\n return;\r\n }\r\n\r\n var key, cell;\r\n\r\n for (key in this._cells) {\r\n cell = this._cells[key];\r\n cell.retain = cell.current;\r\n }\r\n\r\n for (key in this._cells) {\r\n cell = this._cells[key];\r\n if (cell.current && !cell.active) {\r\n var coords = cell.coords;\r\n if (!this._retainParent(coords.x, coords.y, coords.z, coords.z - 5)) {\r\n this._retainChildren(coords.x, coords.y, coords.z, coords.z + 2);\r\n }\r\n }\r\n }\r\n\r\n for (key in this._cells) {\r\n if (!this._cells[key].retain) {\r\n this._removeCell(key);\r\n }\r\n }\r\n },\r\n\r\n _removeAllCells: function () {\r\n for (var key in this._cells) {\r\n this._removeCell(key);\r\n }\r\n },\r\n\r\n _invalidateAll: function () {\r\n this._removeAllCells();\r\n\r\n this._cellZoom = undefined;\r\n },\r\n\r\n _retainParent: function (x, y, z, minZoom) {\r\n var x2 = Math.floor(x / 2);\r\n var y2 = Math.floor(y / 2);\r\n var z2 = z - 1;\r\n var coords2 = new Point(+x2, +y2);\r\n coords2.z = +z2;\r\n\r\n var key = this._cellCoordsToKey(coords2);\r\n var cell = this._cells[key];\r\n\r\n if (cell && cell.active) {\r\n cell.retain = true;\r\n return true;\r\n } else if (cell && cell.loaded) {\r\n cell.retain = true;\r\n }\r\n\r\n if (z2 > minZoom) {\r\n return this._retainParent(x2, y2, z2, minZoom);\r\n }\r\n\r\n return false;\r\n },\r\n\r\n _retainChildren: function (x, y, z, maxZoom) {\r\n for (var i = 2 * x; i < 2 * x + 2; i++) {\r\n for (var j = 2 * y; j < 2 * y + 2; j++) {\r\n var coords = new Point(i, j);\r\n coords.z = z + 1;\r\n\r\n var key = this._cellCoordsToKey(coords);\r\n var cell = this._cells[key];\r\n\r\n if (cell && cell.active) {\r\n cell.retain = true;\r\n continue;\r\n } else if (cell && cell.loaded) {\r\n cell.retain = true;\r\n }\r\n\r\n if (z + 1 < maxZoom) {\r\n this._retainChildren(i, j, z + 1, maxZoom);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _resetView: function (e) {\r\n var animating = e && (e.pinch || e.flyTo);\r\n\r\n if (animating) {\r\n return;\r\n }\r\n\r\n this._setView(\r\n this._map.getCenter(),\r\n this._map.getZoom(),\r\n animating,\r\n animating\r\n );\r\n },\r\n\r\n _setView: function (center, zoom, noPrune, noUpdate) {\r\n var cellZoom = Math.round(zoom);\r\n\r\n if (!noUpdate) {\r\n this._cellZoom = cellZoom;\r\n\r\n if (this._abortLoading) {\r\n this._abortLoading();\r\n }\r\n\r\n this._resetGrid();\r\n\r\n if (cellZoom !== undefined) {\r\n this._update(center);\r\n }\r\n\r\n if (!noPrune) {\r\n this._pruneCells();\r\n }\r\n\r\n // Flag to prevent _updateOpacity from pruning cells during\r\n // a zoom anim or a pinch gesture\r\n this._noPrune = !!noPrune;\r\n }\r\n },\r\n\r\n _resetGrid: function () {\r\n var map = this._map;\r\n var crs = map.options.crs;\r\n var cellSize = (this._cellSize = this.getCellSize());\r\n var cellZoom = this._cellZoom;\r\n\r\n var bounds = this._map.getPixelWorldBounds(this._cellZoom);\r\n if (bounds) {\r\n this._globalCellRange = this._pxBoundsToCellRange(bounds);\r\n }\r\n\r\n this._wrapX = crs.wrapLng &&\r\n !this.options.noWrap && [\r\n Math.floor(map.project([0, crs.wrapLng[0]], cellZoom).x / cellSize.x),\r\n Math.ceil(map.project([0, crs.wrapLng[1]], cellZoom).x / cellSize.y)\r\n ];\r\n this._wrapY = crs.wrapLat &&\r\n !this.options.noWrap && [\r\n Math.floor(map.project([crs.wrapLat[0], 0], cellZoom).y / cellSize.x),\r\n Math.ceil(map.project([crs.wrapLat[1], 0], cellZoom).y / cellSize.y)\r\n ];\r\n },\r\n\r\n _onMoveEnd: function (e) {\r\n var animating = e && (e.pinch || e.flyTo);\r\n\r\n if (animating || !this._map || this._map._animatingZoom) {\r\n return;\r\n }\r\n\r\n this._update();\r\n },\r\n\r\n _getCelldPixelBounds: function (center) {\r\n var map = this._map;\r\n var mapZoom = map._animatingZoom\r\n ? Math.max(map._animateToZoom, map.getZoom())\r\n : map.getZoom();\r\n var scale = map.getZoomScale(mapZoom, this._cellZoom);\r\n var pixelCenter = map.project(center, this._cellZoom).floor();\r\n var halfSize = map.getSize().divideBy(scale * 2);\r\n\r\n return new Bounds(\r\n pixelCenter.subtract(halfSize),\r\n pixelCenter.add(halfSize)\r\n );\r\n },\r\n\r\n // Private method to load cells in the grid's active zoom level according to map bounds\r\n _update: function (center) {\r\n var map = this._map;\r\n if (!map) {\r\n return;\r\n }\r\n var zoom = Math.round(map.getZoom());\r\n\r\n if (center === undefined) {\r\n center = map.getCenter();\r\n }\r\n\r\n var pixelBounds = this._getCelldPixelBounds(center);\r\n var cellRange = this._pxBoundsToCellRange(pixelBounds);\r\n var cellCenter = cellRange.getCenter();\r\n var queue = [];\r\n var margin = this.options.keepBuffer;\r\n var noPruneRange = new Bounds(\r\n cellRange.getBottomLeft().subtract([margin, -margin]),\r\n cellRange.getTopRight().add([margin, -margin])\r\n );\r\n\r\n // Sanity check: panic if the cell range contains Infinity somewhere.\r\n if (\r\n !(\r\n isFinite(cellRange.min.x) &&\r\n isFinite(cellRange.min.y) &&\r\n isFinite(cellRange.max.x) &&\r\n isFinite(cellRange.max.y)\r\n )\r\n ) {\r\n throw new Error('Attempted to load an infinite number of cells');\r\n }\r\n\r\n for (var key in this._cells) {\r\n var c = this._cells[key].coords;\r\n if (\r\n c.z !== this._cellZoom ||\r\n !noPruneRange.contains(new Point(c.x, c.y))\r\n ) {\r\n this._cells[key].current = false;\r\n }\r\n }\r\n\r\n // _update just loads more cells. If the cell zoom level differs too much\r\n // from the map's, let _setView reset levels and prune old cells.\r\n if (Math.abs(zoom - this._cellZoom) > 1) {\r\n this._setView(center, zoom);\r\n return;\r\n }\r\n\r\n // create a queue of coordinates to load cells from\r\n for (var j = cellRange.min.y; j <= cellRange.max.y; j++) {\r\n for (var i = cellRange.min.x; i <= cellRange.max.x; i++) {\r\n var coords = new Point(i, j);\r\n coords.z = this._cellZoom;\r\n\r\n if (!this._isValidCell(coords)) {\r\n continue;\r\n }\r\n\r\n var cell = this._cells[this._cellCoordsToKey(coords)];\r\n if (cell) {\r\n cell.current = true;\r\n } else {\r\n queue.push(coords);\r\n }\r\n }\r\n }\r\n\r\n // sort cell queue to load cells in order of their distance to center\r\n queue.sort(function (a, b) {\r\n return a.distanceTo(cellCenter) - b.distanceTo(cellCenter);\r\n });\r\n\r\n if (queue.length !== 0) {\r\n // if it's the first batch of cells to load\r\n if (!this._loading) {\r\n this._loading = true;\r\n }\r\n\r\n for (i = 0; i < queue.length; i++) {\r\n var _key = this._cellCoordsToKey(queue[i]);\r\n var _coords = this._keyToCellCoords(_key);\r\n if (this._activeCells[_coords]) {\r\n this._reuseCell(queue[i]);\r\n } else {\r\n this._createCell(queue[i]);\r\n }\r\n }\r\n }\r\n },\r\n\r\n _isValidCell: function (coords) {\r\n var crs = this._map.options.crs;\r\n\r\n if (!crs.infinite) {\r\n // don't load cell if it's out of bounds and not wrapped\r\n var bounds = this._globalCellRange;\r\n if (\r\n (!crs.wrapLng &&\r\n (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\r\n (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))\r\n ) {\r\n return false;\r\n }\r\n }\r\n\r\n if (!this.options.bounds) {\r\n return true;\r\n }\r\n\r\n // don't load cell if it doesn't intersect the bounds in options\r\n var cellBounds = this._cellCoordsToBounds(coords);\r\n return latLngBounds(this.options.bounds).overlaps(cellBounds);\r\n },\r\n\r\n _keyToBounds: function (key) {\r\n return this._cellCoordsToBounds(this._keyToCellCoords(key));\r\n },\r\n\r\n _cellCoordsToNwSe: function (coords) {\r\n var map = this._map;\r\n var cellSize = this.getCellSize();\r\n var nwPoint = coords.scaleBy(cellSize);\r\n var sePoint = nwPoint.add(cellSize);\r\n var nw = map.unproject(nwPoint, coords.z);\r\n var se = map.unproject(sePoint, coords.z);\r\n\r\n return [nw, se];\r\n },\r\n\r\n // converts cell coordinates to its geographical bounds\r\n _cellCoordsToBounds: function (coords) {\r\n var bp = this._cellCoordsToNwSe(coords);\r\n var bounds = new LatLngBounds(bp[0], bp[1]);\r\n\r\n if (!this.options.noWrap) {\r\n bounds = this._map.wrapLatLngBounds(bounds);\r\n }\r\n return bounds;\r\n },\r\n // converts cell coordinates to key for the cell cache\r\n _cellCoordsToKey: function (coords) {\r\n return coords.x + ':' + coords.y + ':' + coords.z;\r\n },\r\n\r\n // converts cell cache key to coordinates\r\n _keyToCellCoords: function (key) {\r\n var k = key.split(':');\r\n var coords = new Point(+k[0], +k[1]);\r\n\r\n coords.z = +k[2];\r\n return coords;\r\n },\r\n\r\n _removeCell: function (key) {\r\n var cell = this._cells[key];\r\n\r\n if (!cell) {\r\n return;\r\n }\r\n\r\n var coords = this._keyToCellCoords(key);\r\n var wrappedCoords = this._wrapCoords(coords);\r\n var cellBounds = this._cellCoordsToBounds(this._wrapCoords(coords));\r\n\r\n cell.current = false;\r\n\r\n delete this._cells[key];\r\n this._activeCells[key] = cell;\r\n\r\n this.cellLeave(cellBounds, wrappedCoords, key);\r\n\r\n this.fire('cellleave', {\r\n key: key,\r\n coords: wrappedCoords,\r\n bounds: cellBounds\r\n });\r\n },\r\n\r\n _reuseCell: function (coords) {\r\n var key = this._cellCoordsToKey(coords);\r\n\r\n // save cell in cache\r\n this._cells[key] = this._activeCells[key];\r\n this._cells[key].current = true;\r\n\r\n var wrappedCoords = this._wrapCoords(coords);\r\n var cellBounds = this._cellCoordsToBounds(this._wrapCoords(coords));\r\n\r\n this.cellEnter(cellBounds, wrappedCoords, key);\r\n\r\n this.fire('cellenter', {\r\n key: key,\r\n coords: wrappedCoords,\r\n bounds: cellBounds\r\n });\r\n },\r\n\r\n _createCell: function (coords) {\r\n var key = this._cellCoordsToKey(coords);\r\n\r\n var wrappedCoords = this._wrapCoords(coords);\r\n var cellBounds = this._cellCoordsToBounds(this._wrapCoords(coords));\r\n\r\n this.createCell(cellBounds, wrappedCoords, key);\r\n\r\n this.fire('cellcreate', {\r\n key: key,\r\n coords: wrappedCoords,\r\n bounds: cellBounds\r\n });\r\n\r\n // save cell in cache\r\n this._cells[key] = {\r\n coords: coords,\r\n current: true\r\n };\r\n\r\n Util.requestAnimFrame(this._pruneCells, this);\r\n },\r\n\r\n _cellReady: function (coords, err, cell) {\r\n var key = this._cellCoordsToKey(coords);\r\n\r\n cell = this._cells[key];\r\n\r\n if (!cell) {\r\n return;\r\n }\r\n\r\n cell.loaded = +new Date();\r\n\r\n cell.active = true;\r\n },\r\n\r\n _getCellPos: function (coords) {\r\n return coords.scaleBy(this.getCellSize());\r\n },\r\n\r\n _wrapCoords: function (coords) {\r\n var newCoords = new Point(\r\n this._wrapX ? Util.wrapNum(coords.x, this._wrapX) : coords.x,\r\n this._wrapY ? Util.wrapNum(coords.y, this._wrapY) : coords.y\r\n );\r\n newCoords.z = coords.z;\r\n return newCoords;\r\n },\r\n\r\n _pxBoundsToCellRange: function (bounds) {\r\n var cellSize = this.getCellSize();\r\n return new Bounds(\r\n bounds.min.unscaleBy(cellSize).floor(),\r\n bounds.max.unscaleBy(cellSize).ceil().subtract([1, 1])\r\n );\r\n }\r\n});\r\n","function BinarySearchIndex (values) {\n this.values = [].concat(values || []);\n}\n\nBinarySearchIndex.prototype.query = function (value) {\n var index = this.getIndex(value);\n return this.values[index];\n};\n\nBinarySearchIndex.prototype.getIndex = function getIndex (value) {\n if (this.dirty) {\n this.sort();\n }\n\n var minIndex = 0;\n var maxIndex = this.values.length - 1;\n var currentIndex;\n var currentElement;\n\n while (minIndex <= maxIndex) {\n currentIndex = (minIndex + maxIndex) / 2 | 0;\n currentElement = this.values[Math.round(currentIndex)];\n if (+currentElement.value < +value) {\n minIndex = currentIndex + 1;\n } else if (+currentElement.value > +value) {\n maxIndex = currentIndex - 1;\n } else {\n return currentIndex;\n }\n }\n\n return Math.abs(~maxIndex);\n};\n\nBinarySearchIndex.prototype.between = function between (start, end) {\n var startIndex = this.getIndex(start);\n var endIndex = this.getIndex(end);\n\n if (startIndex === 0 && endIndex === 0) {\n return [];\n }\n\n while (this.values[startIndex - 1] && this.values[startIndex - 1].value === start) {\n startIndex--;\n }\n\n while (this.values[endIndex + 1] && this.values[endIndex + 1].value === end) {\n endIndex++;\n }\n\n if (this.values[endIndex] && this.values[endIndex].value === end && this.values[endIndex + 1]) {\n endIndex++;\n }\n\n return this.values.slice(startIndex, endIndex);\n};\n\nBinarySearchIndex.prototype.insert = function insert (item) {\n this.values.splice(this.getIndex(item.value), 0, item);\n return this;\n};\n\nBinarySearchIndex.prototype.bulkAdd = function bulkAdd (items, sort) {\n this.values = this.values.concat([].concat(items || []));\n\n if (sort) {\n this.sort();\n } else {\n this.dirty = true;\n }\n\n return this;\n};\n\nBinarySearchIndex.prototype.sort = function sort () {\n this.values.sort(function (a, b) {\n return +b.value - +a.value;\n }).reverse();\n this.dirty = false;\n return this;\n};\n\nexport default BinarySearchIndex;\n","import { Util } from 'leaflet';\r\nimport featureLayerService from '../../Services/FeatureLayerService';\r\nimport {\r\n getUrlParams,\r\n warn,\r\n setEsriAttribution,\r\n removeEsriAttribution\r\n} from '../../Util';\r\nimport { FeatureGrid } from './FeatureGrid';\r\nimport BinarySearchIndex from 'tiny-binary-search';\r\n\r\nexport var FeatureManager = FeatureGrid.extend({\r\n /**\r\n * Options\r\n */\r\n\r\n options: {\r\n attribution: null,\r\n where: '1=1',\r\n fields: ['*'],\r\n from: false,\r\n to: false,\r\n timeField: false,\r\n timeFilterMode: 'server',\r\n simplifyFactor: 0,\r\n precision: 6,\r\n fetchAllFeatures: false\r\n },\r\n\r\n /**\r\n * Constructor\r\n */\r\n\r\n initialize: function (options) {\r\n FeatureGrid.prototype.initialize.call(this, options);\r\n\r\n options = getUrlParams(options);\r\n options = Util.setOptions(this, options);\r\n\r\n this.service = featureLayerService(options);\r\n this.service.addEventParent(this);\r\n\r\n // use case insensitive regex to look for common fieldnames used for indexing\r\n if (this.options.fields[0] !== '*') {\r\n var oidCheck = false;\r\n for (var i = 0; i < this.options.fields.length; i++) {\r\n if (this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i)) {\r\n oidCheck = true;\r\n }\r\n }\r\n if (oidCheck === false) {\r\n warn(\r\n 'no known esriFieldTypeOID field detected in fields Array. Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.'\r\n );\r\n }\r\n }\r\n\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n this._startTimeIndex = new BinarySearchIndex();\r\n this._endTimeIndex = new BinarySearchIndex();\r\n } else if (this.options.timeField) {\r\n this._timeIndex = new BinarySearchIndex();\r\n }\r\n\r\n this._cache = {};\r\n this._currentSnapshot = []; // cache of what layers should be active\r\n this._activeRequests = 0;\r\n },\r\n\r\n /**\r\n * Layer Interface\r\n */\r\n\r\n onAdd: function (map) {\r\n // include 'Powered by Esri' in map attribution\r\n setEsriAttribution(map);\r\n\r\n this.service.metadata(function (err, metadata) {\r\n if (!err) {\r\n var supportedFormats = metadata.supportedQueryFormats;\r\n\r\n // Check if someone has requested that we don't use geoJSON, even if it's available\r\n var forceJsonFormat = false;\r\n if (\r\n this.service.options.isModern === false ||\r\n this.options.fetchAllFeatures\r\n ) {\r\n forceJsonFormat = true;\r\n }\r\n\r\n // Unless we've been told otherwise, check to see whether service can emit GeoJSON natively\r\n if (\r\n !forceJsonFormat &&\r\n supportedFormats &&\r\n supportedFormats.indexOf('geoJSON') !== -1\r\n ) {\r\n this.service.options.isModern = true;\r\n }\r\n\r\n if (metadata.objectIdField) {\r\n this.service.options.idAttribute = metadata.objectIdField;\r\n }\r\n\r\n // add copyright text listed in service metadata\r\n if (\r\n !this.options.attribution &&\r\n map.attributionControl &&\r\n metadata.copyrightText\r\n ) {\r\n this.options.attribution = metadata.copyrightText;\r\n map.attributionControl.addAttribution(this.getAttribution());\r\n }\r\n }\r\n }, this);\r\n\r\n map.on('zoomend', this._handleZoomChange, this);\r\n\r\n return FeatureGrid.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n removeEsriAttribution(map);\r\n map.off('zoomend', this._handleZoomChange, this);\r\n\r\n return FeatureGrid.prototype.onRemove.call(this, map);\r\n },\r\n\r\n getAttribution: function () {\r\n return this.options.attribution;\r\n },\r\n\r\n /**\r\n * Feature Management\r\n */\r\n\r\n createCell: function (bounds, coords) {\r\n // dont fetch features outside the scale range defined for the layer\r\n if (this._visibleZoom()) {\r\n this._requestFeatures(bounds, coords);\r\n }\r\n },\r\n\r\n _requestFeatures: function (bounds, coords, callback, offset) {\r\n this._activeRequests++;\r\n\r\n // default param\r\n offset = offset || 0;\r\n\r\n var originalWhere = this.options.where;\r\n\r\n // our first active request fires loading\r\n if (this._activeRequests === 1) {\r\n this.fire(\r\n 'loading',\r\n {\r\n bounds: bounds\r\n },\r\n true\r\n );\r\n }\r\n\r\n return this._buildQuery(bounds, offset).run(function (\r\n error,\r\n featureCollection,\r\n response\r\n ) {\r\n if (response && response.exceededTransferLimit) {\r\n this.fire('drawlimitexceeded');\r\n }\r\n\r\n // the where changed while this request was being run so don't it.\r\n if (this.options.where !== originalWhere) {\r\n return;\r\n }\r\n\r\n // no error, features\r\n if (!error && featureCollection && featureCollection.features.length) {\r\n // schedule adding features until the next animation frame\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n this._addFeatures(featureCollection.features, coords);\r\n this._postProcessFeatures(bounds);\r\n }, this)\r\n );\r\n }\r\n\r\n // no error, no features\r\n if (!error && featureCollection && !featureCollection.features.length) {\r\n this._postProcessFeatures(bounds);\r\n }\r\n\r\n if (error) {\r\n this._postProcessFeatures(bounds);\r\n }\r\n\r\n if (callback) {\r\n callback.call(this, error, featureCollection);\r\n }\r\n if (\r\n response &&\r\n (response.exceededTransferLimit ||\r\n (response.properties && response.properties.exceededTransferLimit)) &&\r\n this.options.fetchAllFeatures\r\n ) {\r\n this._requestFeatures(\r\n bounds,\r\n coords,\r\n callback,\r\n offset + featureCollection.features.length\r\n );\r\n }\r\n },\r\n this);\r\n },\r\n\r\n _postProcessFeatures: function (bounds) {\r\n // deincrement the request counter now that we have processed features\r\n this._activeRequests--;\r\n\r\n // if there are no more active requests fire a load event for this view\r\n if (this._activeRequests <= 0) {\r\n this.fire('load', {\r\n bounds: bounds\r\n });\r\n }\r\n },\r\n\r\n _cacheKey: function (coords) {\r\n return coords.z + ':' + coords.x + ':' + coords.y;\r\n },\r\n\r\n _addFeatures: function (features, coords) {\r\n // coords is optional - will be false if coming from addFeatures() function\r\n if (coords) {\r\n var key = this._cacheKey(coords);\r\n this._cache[key] = this._cache[key] || [];\r\n }\r\n\r\n for (var i = features.length - 1; i >= 0; i--) {\r\n var id = features[i].id;\r\n\r\n if (this._currentSnapshot.indexOf(id) === -1) {\r\n this._currentSnapshot.push(id);\r\n }\r\n if (typeof key !== 'undefined' && this._cache[key].indexOf(id) === -1) {\r\n this._cache[key].push(id);\r\n }\r\n }\r\n\r\n if (this.options.timeField) {\r\n this._buildTimeIndexes(features);\r\n }\r\n\r\n this.createLayers(features);\r\n },\r\n\r\n _buildQuery: function (bounds, offset) {\r\n var query = this.service\r\n .query()\r\n .intersects(bounds)\r\n .where(this.options.where)\r\n .fields(this.options.fields)\r\n .precision(this.options.precision);\r\n\r\n if (this.options.fetchAllFeatures && !isNaN(parseInt(offset))) {\r\n query = query.offset(offset);\r\n }\r\n\r\n query.params['resultType'] = 'tile';\r\n\r\n if (this.options.requestParams) {\r\n Util.extend(query.params, this.options.requestParams);\r\n }\r\n\r\n if (this.options.simplifyFactor) {\r\n query.simplify(this._map, this.options.simplifyFactor);\r\n }\r\n\r\n if (\r\n this.options.timeFilterMode === 'server' &&\r\n this.options.from &&\r\n this.options.to\r\n ) {\r\n query.between(this.options.from, this.options.to);\r\n }\r\n\r\n return query;\r\n },\r\n\r\n /**\r\n * Where Methods\r\n */\r\n\r\n setWhere: function (where, callback, context) {\r\n this.options.where = where && where.length ? where : '1=1';\r\n\r\n var oldSnapshot = [];\r\n var newSnapshot = [];\r\n var pendingRequests = 0;\r\n var requestError = null;\r\n var requestCallback = Util.bind(function (error, featureCollection) {\r\n if (error) {\r\n requestError = error;\r\n }\r\n\r\n if (featureCollection) {\r\n for (var i = featureCollection.features.length - 1; i >= 0; i--) {\r\n newSnapshot.push(featureCollection.features[i].id);\r\n }\r\n }\r\n\r\n pendingRequests--;\r\n\r\n if (\r\n pendingRequests <= 0 &&\r\n this._visibleZoom() &&\r\n where === this.options.where // the where is still the same so use this one\r\n ) {\r\n this._currentSnapshot = newSnapshot;\r\n // schedule adding features for the next animation frame\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n this.removeLayers(oldSnapshot);\r\n this.addLayers(newSnapshot);\r\n if (callback) {\r\n callback.call(context, requestError);\r\n }\r\n }, this)\r\n );\r\n }\r\n }, this);\r\n\r\n for (var i = this._currentSnapshot.length - 1; i >= 0; i--) {\r\n oldSnapshot.push(this._currentSnapshot[i]);\r\n }\r\n\r\n this._cache = {};\r\n\r\n for (var key in this._cells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, coords, requestCallback);\r\n }\r\n\r\n return this;\r\n },\r\n\r\n getWhere: function () {\r\n return this.options.where;\r\n },\r\n\r\n /**\r\n * Time Range Methods\r\n */\r\n\r\n getTimeRange: function () {\r\n return [this.options.from, this.options.to];\r\n },\r\n\r\n setTimeRange: function (from, to, callback, context) {\r\n var oldFrom = this.options.from;\r\n var oldTo = this.options.to;\r\n var pendingRequests = 0;\r\n var requestError = null;\r\n var requestCallback = Util.bind(function (error) {\r\n if (error) {\r\n requestError = error;\r\n }\r\n this._filterExistingFeatures(oldFrom, oldTo, from, to);\r\n\r\n pendingRequests--;\r\n\r\n if (callback && pendingRequests <= 0) {\r\n callback.call(context, requestError);\r\n }\r\n }, this);\r\n\r\n this.options.from = from;\r\n this.options.to = to;\r\n\r\n this._filterExistingFeatures(oldFrom, oldTo, from, to);\r\n\r\n if (this.options.timeFilterMode === 'server') {\r\n for (var key in this._cells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, coords, requestCallback);\r\n }\r\n }\r\n\r\n return this;\r\n },\r\n\r\n refresh: function () {\r\n this.setWhere(this.options.where);\r\n },\r\n\r\n _filterExistingFeatures: function (oldFrom, oldTo, newFrom, newTo) {\r\n var layersToRemove =\r\n oldFrom && oldTo\r\n ? this._getFeaturesInTimeRange(oldFrom, oldTo)\r\n : this._currentSnapshot;\r\n var layersToAdd = this._getFeaturesInTimeRange(newFrom, newTo);\r\n\r\n if (layersToAdd.indexOf) {\r\n for (var i = 0; i < layersToAdd.length; i++) {\r\n var shouldRemoveLayer = layersToRemove.indexOf(layersToAdd[i]);\r\n if (shouldRemoveLayer >= 0) {\r\n layersToRemove.splice(shouldRemoveLayer, 1);\r\n }\r\n }\r\n }\r\n\r\n // schedule adding features until the next animation frame\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n this.removeLayers(layersToRemove);\r\n this.addLayers(layersToAdd);\r\n }, this)\r\n );\r\n },\r\n\r\n _getFeaturesInTimeRange: function (start, end) {\r\n var ids = [];\r\n var search;\r\n\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n var startTimes = this._startTimeIndex.between(start, end);\r\n var endTimes = this._endTimeIndex.between(start, end);\r\n search = startTimes.concat(endTimes);\r\n } else if (this._timeIndex) {\r\n search = this._timeIndex.between(start, end);\r\n } else {\r\n warn(\r\n 'You must set timeField in the layer constructor in order to manipulate the start and end time filter.'\r\n );\r\n return [];\r\n }\r\n\r\n for (var i = search.length - 1; i >= 0; i--) {\r\n ids.push(search[i].id);\r\n }\r\n\r\n return ids;\r\n },\r\n\r\n _buildTimeIndexes: function (geojson) {\r\n var i;\r\n var feature;\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n var startTimeEntries = [];\r\n var endTimeEntries = [];\r\n for (i = geojson.length - 1; i >= 0; i--) {\r\n feature = geojson[i];\r\n startTimeEntries.push({\r\n id: feature.id,\r\n value: new Date(feature.properties[this.options.timeField.start])\r\n });\r\n endTimeEntries.push({\r\n id: feature.id,\r\n value: new Date(feature.properties[this.options.timeField.end])\r\n });\r\n }\r\n this._startTimeIndex.bulkAdd(startTimeEntries);\r\n this._endTimeIndex.bulkAdd(endTimeEntries);\r\n } else {\r\n var timeEntries = [];\r\n for (i = geojson.length - 1; i >= 0; i--) {\r\n feature = geojson[i];\r\n timeEntries.push({\r\n id: feature.id,\r\n value: new Date(feature.properties[this.options.timeField])\r\n });\r\n }\r\n\r\n this._timeIndex.bulkAdd(timeEntries);\r\n }\r\n },\r\n\r\n _featureWithinTimeRange: function (feature) {\r\n if (!this.options.from || !this.options.to) {\r\n return true;\r\n }\r\n\r\n var from = +this.options.from.valueOf();\r\n var to = +this.options.to.valueOf();\r\n\r\n if (typeof this.options.timeField === 'string') {\r\n var date = +feature.properties[this.options.timeField];\r\n return date >= from && date <= to;\r\n }\r\n\r\n if (this.options.timeField.start && this.options.timeField.end) {\r\n var startDate = +feature.properties[this.options.timeField.start];\r\n var endDate = +feature.properties[this.options.timeField.end];\r\n return (\r\n (startDate >= from && startDate <= to) ||\r\n (endDate >= from && endDate <= to) ||\r\n (startDate <= from && endDate >= to)\r\n );\r\n }\r\n },\r\n\r\n _visibleZoom: function () {\r\n // check to see whether the current zoom level of the map is within the optional limit defined for the FeatureLayer\r\n if (!this._map) {\r\n return false;\r\n }\r\n var zoom = this._map.getZoom();\r\n if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\r\n return false;\r\n } else {\r\n return true;\r\n }\r\n },\r\n\r\n _handleZoomChange: function () {\r\n if (!this._visibleZoom()) {\r\n // if we have moved outside the visible zoom range clear the current snapshot, no layers should be active\r\n this.removeLayers(this._currentSnapshot);\r\n this._currentSnapshot = [];\r\n } else {\r\n /*\r\n for every cell in this._cells\r\n 1. Get the cache key for the coords of the cell\r\n 2. If this._cache[key] exists it will be an array of feature IDs.\r\n 3. Call this.addLayers(this._cache[key]) to instruct the feature layer to add the layers back.\r\n */\r\n for (var i in this._cells) {\r\n var coords = this._cells[i].coords;\r\n var key = this._cacheKey(coords);\r\n if (this._cache[key]) {\r\n this.addLayers(this._cache[key]);\r\n }\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Service Methods\r\n */\r\n\r\n authenticate: function (token) {\r\n this.service.authenticate(token);\r\n return this;\r\n },\r\n\r\n metadata: function (callback, context) {\r\n this.service.metadata(callback, context);\r\n return this;\r\n },\r\n\r\n query: function () {\r\n return this.service.query();\r\n },\r\n\r\n _getMetadata: function (callback) {\r\n if (this._metadata) {\r\n var error;\r\n callback(error, this._metadata);\r\n } else {\r\n this.metadata(\r\n Util.bind(function (error, response) {\r\n this._metadata = response;\r\n callback(error, this._metadata);\r\n }, this)\r\n );\r\n }\r\n },\r\n\r\n addFeature: function (feature, callback, context) {\r\n this.addFeatures(feature, callback, context);\r\n },\r\n\r\n addFeatures: function (features, callback, context) {\r\n this._getMetadata(\r\n Util.bind(function (error, metadata) {\r\n if (error) {\r\n if (callback) {\r\n callback.call(this, error, null);\r\n }\r\n return;\r\n }\r\n // GeoJSON featureCollection or simple feature\r\n var featuresArray = features.features ? features.features : [features];\r\n\r\n this.service.addFeatures(\r\n features,\r\n Util.bind(function (error, response) {\r\n if (!error) {\r\n for (var i = featuresArray.length - 1; i >= 0; i--) {\r\n // assign ID from result to appropriate objectid field from service metadata\r\n featuresArray[i].properties[metadata.objectIdField] =\r\n featuresArray.length > 1\r\n ? response[i].objectId\r\n : response.objectId;\r\n // we also need to update the geojson id for createLayers() to function\r\n featuresArray[i].id =\r\n featuresArray.length > 1\r\n ? response[i].objectId\r\n : response.objectId;\r\n }\r\n this._addFeatures(featuresArray);\r\n }\r\n\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n }, this)\r\n );\r\n }, this)\r\n );\r\n },\r\n\r\n updateFeature: function (feature, callback, context) {\r\n this.updateFeatures(feature, callback, context);\r\n },\r\n\r\n updateFeatures: function (features, callback, context) {\r\n // GeoJSON featureCollection or simple feature\r\n var featuresArray = features.features ? features.features : [features];\r\n this.service.updateFeatures(\r\n features,\r\n function (error, response) {\r\n if (!error) {\r\n for (var i = featuresArray.length - 1; i >= 0; i--) {\r\n this.removeLayers([featuresArray[i].id], true);\r\n }\r\n this._addFeatures(featuresArray);\r\n }\r\n\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n },\r\n this\r\n );\r\n },\r\n\r\n deleteFeature: function (id, callback, context) {\r\n this.deleteFeatures(id, callback, context);\r\n },\r\n\r\n deleteFeatures: function (ids, callback, context) {\r\n return this.service.deleteFeatures(\r\n ids,\r\n function (error, response) {\r\n var responseArray = response.length ? response : [response];\r\n if (!error && responseArray.length > 0) {\r\n for (var i = responseArray.length - 1; i >= 0; i--) {\r\n this.removeLayers([responseArray[i].objectId], true);\r\n }\r\n }\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n },\r\n this\r\n );\r\n }\r\n});\r\n","import { Path, Util, GeoJSON, latLng } from 'leaflet';\r\nimport { FeatureManager } from './FeatureManager';\r\nimport { warn } from '../../Util';\r\n\r\nexport var FeatureLayer = FeatureManager.extend({\r\n options: {\r\n cacheLayers: true\r\n },\r\n\r\n /**\r\n * Constructor\r\n */\r\n initialize: function (options) {\r\n if (options.apikey) {\r\n options.token = options.apikey;\r\n }\r\n FeatureManager.prototype.initialize.call(this, options);\r\n this._originalStyle = this.options.style;\r\n this._layers = {};\r\n },\r\n\r\n /**\r\n * Layer Interface\r\n */\r\n\r\n onRemove: function (map) {\r\n for (var i in this._layers) {\r\n map.removeLayer(this._layers[i]);\r\n // trigger the event when the entire featureLayer is removed from the map\r\n this.fire(\r\n 'removefeature',\r\n {\r\n feature: this._layers[i].feature,\r\n permanent: false\r\n },\r\n true\r\n );\r\n }\r\n\r\n return FeatureManager.prototype.onRemove.call(this, map);\r\n },\r\n\r\n createNewLayer: function (geojson) {\r\n var layer = GeoJSON.geometryToLayer(geojson, this.options);\r\n // trap for GeoJSON without geometry\r\n if (layer) {\r\n layer.defaultOptions = layer.options;\r\n }\r\n return layer;\r\n },\r\n\r\n _updateLayer: function (layer, geojson) {\r\n // convert the geojson coordinates into a Leaflet LatLng array/nested arrays\r\n // pass it to setLatLngs to update layer geometries\r\n var latlngs = [];\r\n var coordsToLatLng = this.options.coordsToLatLng || GeoJSON.coordsToLatLng;\r\n\r\n // copy new attributes, if present\r\n if (geojson.properties) {\r\n layer.feature.properties = geojson.properties;\r\n }\r\n\r\n switch (geojson.geometry.type) {\r\n case 'Point':\r\n latlngs = GeoJSON.coordsToLatLng(geojson.geometry.coordinates);\r\n layer.setLatLng(latlngs);\r\n break;\r\n case 'LineString':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 0,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiLineString':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 1,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'Polygon':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 1,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiPolygon':\r\n latlngs = GeoJSON.coordsToLatLngs(\r\n geojson.geometry.coordinates,\r\n 2,\r\n coordsToLatLng\r\n );\r\n layer.setLatLngs(latlngs);\r\n break;\r\n }\r\n },\r\n\r\n /**\r\n * Feature Management Methods\r\n */\r\n\r\n createLayers: function (features) {\r\n for (var i = features.length - 1; i >= 0; i--) {\r\n var geojson = features[i];\r\n\r\n var layer = this._layers[geojson.id];\r\n var newLayer;\r\n\r\n if (\r\n this._visibleZoom() &&\r\n layer &&\r\n !this._map.hasLayer(layer) &&\r\n (!this.options.timeField || this._featureWithinTimeRange(geojson))\r\n ) {\r\n this._map.addLayer(layer);\r\n this.fire(\r\n 'addfeature',\r\n {\r\n feature: layer.feature\r\n },\r\n true\r\n );\r\n }\r\n\r\n // update geometry if necessary\r\n if (\r\n layer &&\r\n this.options.simplifyFactor > 0 &&\r\n (layer.setLatLngs || layer.setLatLng)\r\n ) {\r\n this._updateLayer(layer, geojson);\r\n }\r\n\r\n if (!layer) {\r\n newLayer = this.createNewLayer(geojson);\r\n\r\n if (!newLayer) {\r\n warn('invalid GeoJSON encountered');\r\n } else {\r\n newLayer.feature = geojson;\r\n\r\n // bubble events from individual layers to the feature layer\r\n newLayer.addEventParent(this);\r\n\r\n if (this.options.onEachFeature) {\r\n this.options.onEachFeature(newLayer.feature, newLayer);\r\n }\r\n\r\n // cache the layer\r\n this._layers[newLayer.feature.id] = newLayer;\r\n\r\n // style the layer\r\n this.setFeatureStyle(newLayer.feature.id, this.options.style);\r\n\r\n this.fire(\r\n 'createfeature',\r\n {\r\n feature: newLayer.feature\r\n },\r\n true\r\n );\r\n\r\n // add the layer if the current zoom level is inside the range defined for the layer, it is within the current time bounds or our layer is not time enabled\r\n if (\r\n this._visibleZoom() &&\r\n (!this.options.timeField ||\r\n (this.options.timeField && this._featureWithinTimeRange(geojson)))\r\n ) {\r\n this._map.addLayer(newLayer);\r\n }\r\n }\r\n }\r\n }\r\n },\r\n\r\n addLayers: function (ids) {\r\n for (var i = ids.length - 1; i >= 0; i--) {\r\n var layer = this._layers[ids[i]];\r\n if (\r\n layer &&\r\n (!this.options.timeField || this._featureWithinTimeRange(layer.feature))\r\n ) {\r\n this._map.addLayer(layer);\r\n this.fire(\r\n 'addfeature',\r\n {\r\n feature: layer.feature\r\n },\r\n true\r\n );\r\n }\r\n }\r\n },\r\n\r\n removeLayers: function (ids, permanent) {\r\n for (var i = ids.length - 1; i >= 0; i--) {\r\n var id = ids[i];\r\n var layer = this._layers[id];\r\n if (layer) {\r\n this.fire(\r\n 'removefeature',\r\n {\r\n feature: layer.feature,\r\n permanent: permanent\r\n },\r\n true\r\n );\r\n this._map.removeLayer(layer);\r\n }\r\n if (layer && permanent) {\r\n delete this._layers[id];\r\n }\r\n }\r\n },\r\n\r\n cellEnter: function (bounds, coords) {\r\n if (this._visibleZoom() && !this._zooming && this._map) {\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n var cacheKey = this._cacheKey(coords);\r\n var cellKey = this._cellCoordsToKey(coords);\r\n var layers = this._cache[cacheKey];\r\n if (this._activeCells[cellKey] && layers) {\r\n this.addLayers(layers);\r\n }\r\n }, this)\r\n );\r\n }\r\n },\r\n\r\n cellLeave: function (bounds, coords) {\r\n if (!this._zooming) {\r\n Util.requestAnimFrame(\r\n Util.bind(function () {\r\n if (this._map) {\r\n var cacheKey = this._cacheKey(coords);\r\n var cellKey = this._cellCoordsToKey(coords);\r\n var layers = this._cache[cacheKey];\r\n var mapBounds = this._map.getBounds();\r\n if (!this._activeCells[cellKey] && layers) {\r\n var removable = true;\r\n\r\n for (var i = 0; i < layers.length; i++) {\r\n var layer = this._layers[layers[i]];\r\n if (\r\n layer &&\r\n layer.getBounds &&\r\n mapBounds.intersects(layer.getBounds())\r\n ) {\r\n removable = false;\r\n }\r\n }\r\n\r\n if (removable) {\r\n this.removeLayers(layers, !this.options.cacheLayers);\r\n }\r\n\r\n if (!this.options.cacheLayers && removable) {\r\n delete this._cache[cacheKey];\r\n delete this._cells[cellKey];\r\n delete this._activeCells[cellKey];\r\n }\r\n }\r\n }\r\n }, this)\r\n );\r\n }\r\n },\r\n\r\n /**\r\n * Styling Methods\r\n */\r\n\r\n resetStyle: function () {\r\n this.options.style = this._originalStyle;\r\n this.eachFeature(function (layer) {\r\n this.resetFeatureStyle(layer.feature.id);\r\n }, this);\r\n return this;\r\n },\r\n\r\n setStyle: function (style) {\r\n this.options.style = style;\r\n this.eachFeature(function (layer) {\r\n this.setFeatureStyle(layer.feature.id, style);\r\n }, this);\r\n return this;\r\n },\r\n\r\n resetFeatureStyle: function (id) {\r\n var layer = this._layers[id];\r\n var style = this._originalStyle || Path.prototype.options;\r\n if (layer) {\r\n Util.extend(layer.options, layer.defaultOptions);\r\n this.setFeatureStyle(id, style);\r\n }\r\n return this;\r\n },\r\n\r\n setFeatureStyle: function (id, style) {\r\n var layer = this._layers[id];\r\n if (typeof style === 'function') {\r\n style = style(layer.feature);\r\n }\r\n if (layer.setStyle) {\r\n layer.setStyle(style);\r\n }\r\n return this;\r\n },\r\n\r\n /**\r\n * Utility Methods\r\n */\r\n\r\n eachActiveFeature: function (fn, context) {\r\n // figure out (roughly) which layers are in view\r\n if (this._map) {\r\n var activeBounds = this._map.getBounds();\r\n for (var i in this._layers) {\r\n if (this._currentSnapshot.indexOf(this._layers[i].feature.id) !== -1) {\r\n // a simple point in poly test for point geometries\r\n if (\r\n typeof this._layers[i].getLatLng === 'function' &&\r\n activeBounds.contains(this._layers[i].getLatLng())\r\n ) {\r\n fn.call(context, this._layers[i]);\r\n } else if (\r\n typeof this._layers[i].getBounds === 'function' &&\r\n activeBounds.intersects(this._layers[i].getBounds())\r\n ) {\r\n // intersecting bounds check for polyline and polygon geometries\r\n fn.call(context, this._layers[i]);\r\n }\r\n }\r\n }\r\n }\r\n return this;\r\n },\r\n\r\n eachFeature: function (fn, context) {\r\n for (var i in this._layers) {\r\n fn.call(context, this._layers[i]);\r\n }\r\n return this;\r\n },\r\n\r\n getFeature: function (id) {\r\n return this._layers[id];\r\n },\r\n\r\n bringToBack: function () {\r\n this.eachFeature(function (layer) {\r\n if (layer.bringToBack) {\r\n layer.bringToBack();\r\n }\r\n });\r\n },\r\n\r\n bringToFront: function () {\r\n this.eachFeature(function (layer) {\r\n if (layer.bringToFront) {\r\n layer.bringToFront();\r\n }\r\n });\r\n },\r\n\r\n redraw: function (id) {\r\n if (id) {\r\n this._redraw(id);\r\n }\r\n return this;\r\n },\r\n\r\n _redraw: function (id) {\r\n var layer = this._layers[id];\r\n var geojson = layer.feature;\r\n\r\n // if this looks like a marker\r\n if (layer && layer.setIcon && this.options.pointToLayer) {\r\n // update custom symbology, if necessary\r\n if (this.options.pointToLayer) {\r\n var getIcon = this.options.pointToLayer(\r\n geojson,\r\n latLng(\r\n geojson.geometry.coordinates[1],\r\n geojson.geometry.coordinates[0]\r\n )\r\n );\r\n var updatedIcon = getIcon.options.icon;\r\n layer.setIcon(updatedIcon);\r\n }\r\n }\r\n\r\n // looks like a vector marker (circleMarker)\r\n if (layer && layer.setStyle && this.options.pointToLayer) {\r\n var getStyle = this.options.pointToLayer(\r\n geojson,\r\n latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0])\r\n );\r\n var updatedStyle = getStyle.options;\r\n this.setFeatureStyle(geojson.id, updatedStyle);\r\n }\r\n\r\n // looks like a path (polygon/polyline)\r\n if (layer && layer.setStyle && this.options.style) {\r\n this.resetStyle(geojson.id);\r\n }\r\n }\r\n});\r\n\r\nexport function featureLayer (options) {\r\n return new FeatureLayer(options);\r\n}\r\n\r\nexport default featureLayer;\r\n","// export version\r\nimport packageInfo from '../package.json';\r\nvar version = packageInfo.version;\r\nexport { version as VERSION };\r\n\r\n// import base\r\nexport { Support } from './Support';\r\nexport { options } from './Options';\r\nexport { EsriUtil as Util } from './Util';\r\nexport { get, post, request } from './Request';\r\n\r\n// export tasks\r\nexport { Task, task } from './Tasks/Task';\r\nexport { Query, query } from './Tasks/Query';\r\nexport { Find, find } from './Tasks/Find';\r\nexport { Identify, identify } from './Tasks/Identify';\r\nexport { IdentifyFeatures, identifyFeatures } from './Tasks/IdentifyFeatures';\r\nexport { IdentifyImage, identifyImage } from './Tasks/IdentifyImage';\r\n\r\n// export services\r\nexport { Service, service } from './Services/Service';\r\nexport { MapService, mapService } from './Services/MapService';\r\nexport { ImageService, imageService } from './Services/ImageService';\r\nexport { FeatureLayerService, featureLayerService } from './Services/FeatureLayerService';\r\n\r\n// export layers\r\nexport { BasemapLayer, basemapLayer } from './Layers/BasemapLayer';\r\nexport { TiledMapLayer, tiledMapLayer } from './Layers/TiledMapLayer';\r\nexport { RasterLayer } from './Layers/RasterLayer';\r\nexport { ImageMapLayer, imageMapLayer } from './Layers/ImageMapLayer';\r\nexport { DynamicMapLayer, dynamicMapLayer } from './Layers/DynamicMapLayer';\r\nexport { FeatureManager } from './Layers/FeatureLayer/FeatureManager';\r\nexport { FeatureLayer, featureLayer } from './Layers/FeatureLayer/FeatureLayer';\r\n"],"names":["cors","window","XMLHttpRequest","pointerEvents","document","documentElement","style","Support","options","attributionWidthOffset","callbacks","serialize","params","param","type","value","data","key","f","hasOwnProperty","Object","prototype","toString","call","length","JSON","stringify","join","valueOf","encodeURIComponent","createRequest","callback","context","httpRequest","onerror","e","onreadystatechange","Util","falseFn","error","code","message","response","readyState","parse","responseText","ontimeout","this","xmlHttpPost","url","open","timeout","setRequestHeader","send","xmlHttpGet","withCredentials","request","paramString","requestLength","jsonp","warn","_EsriLeafletCallbacks","callbackId","responseType","script","DomUtil","create","body","src","id","addClass","abort","_callback","get","console","apply","arguments","CORS","JSONP","arrayIntersectsArray","a","b","i","j","a1","a2","b1","b2","uaT","ubT","uB","ua","ub","edgeIntersectsEdge","closeRing","coordinates","pointsEqual","push","ringIsClockwise","ringToTest","pt2","total","rLength","pt1","shallowClone","obj","target","convertRingsToGeoJSON","rings","outerRing","hole","outerRings","holes","r","polygon","ring","slice","reverse","outer","inner","intersects","contains","uncontainedHoles","pop","contained","x","point","l","coordinatesContainPoint","orientRings","poly","output","shift","Request","post","arcgisToGeoJSON","arcgis","idAttribute","geojson","features","y","z","points","paths","xmin","ymin","xmax","ymax","geometry","attributes","properties","keys","Error","getId","err","spatialReference","wkid","geojsonToArcGIS","result","flattenMultiPolygonRings","geometries","BASE_LEAFLET_ATTRIBUTION_STRING","idAttr","g2a","a2g","extentToBounds","extent","sw","latLng","ne","latLngBounds","boundsToExtent","bounds","getSouthWest","lng","lat","getNorthEast","knownFieldNames","_findIdAttributeFromResponse","objectIdFieldName","fields","name","match","_findIdAttributeFromFeature","feature","responseToFeatureCollection","results","count","objectIdField","featureCollection","cleanUrl","trim","getUrlParams","queryString","indexOf","requestParams","substring","split","decodeURI","replace","isArcgisOnline","test","geojsonTypeToArcGIS","geoJsonType","arcgisGeometryType","calcAttributionWidth","map","getSize","setEsriAttribution","hoverAttributionStyle","attributionStyle","attributionControl","_esriAttributionLayerCount","_esriAttributionAddedOnce","createElement","innerHTML","getElementsByTagName","appendChild","on","_container","maxWidth","setPrefix","removeEsriAttribution","removeClass","_setGeometry","geometryType","LatLngBounds","getLatLng","LatLng","GeoJSON","getLayers","toGeoJSON","_getAttributionData","bind","attributions","_esriAttributions","c","contributors","contributor","coverageAreas","coverageArea","southWest","bbox","northEast","attribution","score","minZoom","zoomMin","maxZoom","zoomMax","sort","_updateMapAttribution","evt","oldAttributions","attributionElement","querySelector","newAttributions","getBounds","wrappedBounds","wrap","zoom","getZoom","text","substr","fire","EsriUtil","Task","Class","extend","proxy","useCors","generateSetter","initialize","endpoint","_service","setOptions","setters","setter","token","authenticate","apikey","format","boolean","returnUnformattedValues","path","_request","method","Query","offset","limit","precision","featureIds","returnGeometry","returnM","transform","where","outSR","outFields","within","_setGeometryParams","spatialRel","crosses","touches","overlaps","bboxIntersects","indexIntersects","nearby","latlng","radius","units","distance","inSR","string","between","start","end","time","simplify","factor","mapWidth","Math","abs","getWest","getEast","maxAllowableOffset","orderBy","fieldName","order","orderByFields","run","_cleanParams","isModern","undefined","_trapSQLerrors","returnCountOnly","ids","returnIdsOnly","objectIds","returnExtentOnly","distinct","returnDistinctValues","pixelSize","rawPoint","castPoint","layer","converted","query","Find","sr","layers","dynamicLayers","returnZ","gdbVersion","layerDefs","find","Identify","IdentifyFeatures","tolerance","size","imageDisplay","mapExtent","at","layerDef","layerId","identifyFeatures","IdentifyImage","setMosaicRule","setRenderingRule","setPixelSize","returnCatalogItems","getMosaicRule","mosaicRule","getRenderingRule","renderingRule","getPixelSize","_responseToGeoJSON","location","catalogItems","catalogItemVisibilities","geoJSON","pixel","crs","OBJECTID","objectId","Values","values","catalogItemVisibility","identifyImage","Service","Evented","_requestQueue","_authenticating","metadata","_runQueue","getTimeout","setTimeout","wrappedCallback","_createServiceCallback","MapService","identify","mapService","ImageService","imageService","FeatureLayerService","addFeature","addFeatures","featuresArray","addResults","updateFeature","updateFeatures","updateResults","deleteFeature","deleteFeatures","deleteResults","featureLayerService","tileProtocol","protocol","BasemapLayer","TileLayer","statics","TILES","Streets","urlTemplate","subdomains","attributionUrl","Topographic","Oceans","OceansLabels","pane","NationalGeographic","DarkGray","DarkGrayLabels","Gray","GrayLabels","Imagery","ImageryLabels","ImageryTransportation","ShadedRelief","ShadedReliefLabels","Terrain","TerrainLabels","USATopo","ImageryClarity","Physical","ImageryFirefly","config","tileOptions","ignoreDeprecationWarning","onAdd","_initPane","onRemove","off","_map","getPane","createPane","zIndex","getAttribution","TiledMapLayer","zoomOffsetAllowance","errorTileUrl","MercatorZoomLevels","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","tileUrl","getParamString","service","addEventParent","RegExp","getTileUrl","tilePoint","_getZoomForUrl","template","s","_getSubdomain","_lodMap","createTile","coords","done","tile","DomEvent","_tileOnLoad","_tileOnError","crossOrigin","alt","once","latestWkid","copyrightText","addAttribution","CRS","EPSG3857","arcgisLODs","tileInfo","lods","correctResolutions","arcgisLOD","ci","correctRes","_withinPercentage","resolution","level","tokenQs","percentage","Overlay","ImageOverlay","_topLeft","getPixelBounds","min","_reset","setPosition","_image","subtract","getPixelOrigin","RasterLayer","Layer","opacity","position","interactive","_update","throttle","updateInterval","_currentImage","_bounds","equals","addLayer","removeLayer","_popup","_getPopupData","_resetPopupState","bindPopup","fn","popupOptions","_shouldRenderPopup","_lastClick","popup","_popupFunction","unbindPopup","closePopup","bringToFront","_setAutoZIndex","max","bringToBack","setZIndex","compare","children","edgeZIndex","Infinity","len","isFinite","getOpacity","setOpacity","getTimeRange","from","to","setTimeRange","redraw","_renderImage","contentType","image","addTo","onOverlayLoad","newImage","oldImage","_animatingZoom","_panTransition","_inProgress","_buildExportParams","_requestExport","_renderPopup","content","setLatLng","setContent","openOn","_calculateBbox","pixelBounds","unproject","getBottomLeft","getTopRight","neProjected","project","swProjected","boundsProjected","_calculateImageSize","top","latLngToLayerPoint","bottom","ImageMapLayer","transparent","setPixelType","pixelType","getPixelType","setBandIds","bandIds","isArray","getBandIds","setNoData","noData","noDataInterpretation","getNoData","getNoDataInterpretation","identifyRequest","parseInt","bboxSR","imageSR","interpolation","compressionQuality","fullUrl","href","DynamicMapLayer","timeOptions","getDynamicLayers","setDynamicLayers","setLayers","getLayerDefs","setLayerDefs","getTimeOptions","setTimeOptions","dpi","disableCache","_ts","Date","now","imageData","FeatureGrid","cellSize","updateWhenIdle","Browser","mobile","noWrap","keepBuffer","_cells","_activeCells","_resetView","_removeAllCells","_cellZoom","isLoading","_loading","getEvents","events","viewprereset","_invalidateAll","viewreset","moveend","_onMoveEnd","_onMove","move","createCell","removeCell","reuseCell","cellLeave","cellEnter","getCellSize","Point","_pruneCells","cell","retain","current","active","_retainParent","_retainChildren","_removeCell","x2","floor","y2","z2","coords2","_cellCoordsToKey","loaded","animating","pinch","flyTo","_setView","getCenter","center","noPrune","noUpdate","cellZoom","round","_abortLoading","_resetGrid","_noPrune","_cellSize","getPixelWorldBounds","_globalCellRange","_pxBoundsToCellRange","_wrapX","wrapLng","ceil","_wrapY","wrapLat","_getCelldPixelBounds","mapZoom","_animateToZoom","scale","getZoomScale","pixelCenter","halfSize","divideBy","Bounds","add","cellRange","cellCenter","queue","margin","noPruneRange","_isValidCell","distanceTo","_key","_coords","_keyToCellCoords","_reuseCell","_createCell","infinite","cellBounds","_cellCoordsToBounds","_keyToBounds","_cellCoordsToNwSe","nwPoint","scaleBy","sePoint","bp","wrapLatLngBounds","k","wrappedCoords","_wrapCoords","requestAnimFrame","_cellReady","_getCellPos","newCoords","wrapNum","unscaleBy","BinarySearchIndex","concat","index","getIndex","dirty","currentIndex","currentElement","minIndex","maxIndex","startIndex","endIndex","insert","item","splice","bulkAdd","items","FeatureManager","timeField","timeFilterMode","simplifyFactor","fetchAllFeatures","oidCheck","_startTimeIndex","_endTimeIndex","_timeIndex","_cache","_currentSnapshot","_activeRequests","supportedFormats","forceJsonFormat","supportedQueryFormats","_handleZoomChange","_visibleZoom","_requestFeatures","originalWhere","_buildQuery","exceededTransferLimit","_addFeatures","_postProcessFeatures","_cacheKey","_buildTimeIndexes","createLayers","isNaN","setWhere","oldSnapshot","newSnapshot","pendingRequests","requestError","requestCallback","removeLayers","addLayers","getWhere","oldFrom","oldTo","_filterExistingFeatures","refresh","newFrom","newTo","layersToRemove","_getFeaturesInTimeRange","layersToAdd","shouldRemoveLayer","startTimes","endTimes","search","startTimeEntries","endTimeEntries","timeEntries","_featureWithinTimeRange","date","startDate","endDate","_getMetadata","_metadata","responseArray","FeatureLayer","cacheLayers","_originalStyle","_layers","permanent","createNewLayer","geometryToLayer","defaultOptions","_updateLayer","latlngs","coordsToLatLng","coordsToLatLngs","setLatLngs","newLayer","hasLayer","onEachFeature","setFeatureStyle","_zooming","cacheKey","cellKey","mapBounds","removable","resetStyle","eachFeature","resetFeatureStyle","setStyle","Path","eachActiveFeature","activeBounds","getFeature","_redraw","updatedIcon","updatedStyle","setIcon","pointToLayer","icon","version","packageInfo"],"mappings":";;;4SAAWA,EAASC,OAAOC,gBAAkB,oBAAqB,IAAID,OAAOC,eAClEC,EAAiE,KAAjDC,SAASC,gBAAgBC,MAAMH,cAE/CI,EAAU,CACnBP,KAAMA,EACNG,cAAeA,GCLNK,EAAU,CACnBC,uBAAwB,ICEtBC,EAAY,EAEhB,SAASC,EAAWC,GAClB,IAMQC,EACAC,EACAC,EARJC,EAAO,GAIX,IAAK,IAAIC,KAFTL,EAAOM,EAAIN,EAAOM,GAAK,OAEPN,EAAQ,CAClBA,EAAOO,eAAeF,KACpBJ,EAAQD,EAAOK,GACfH,EAAOM,OAAOC,UAAUC,SAASC,KAAKV,GAGtCG,EAAKQ,SACPR,GAAQ,KAIRD,EADW,mBAATD,EACoD,oBAA7CM,OAAOC,UAAUC,SAASC,KAAKV,EAAM,IAA6BY,KAAKC,UAAUb,GAASA,EAAMc,KAAK,KAC5F,oBAATb,EACDW,KAAKC,UAAUb,GACL,kBAATC,EACDD,EAAMe,UAENf,EAGVG,GAAQa,mBAAmBZ,GAAO,IAAMY,mBAAmBd,IAI/D,OAAOC,EAGT,SAASc,EAAeC,EAAUC,GAChC,IAAIC,EAAc,IAAIhC,OAAOC,e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