From 4b0df92dcaafcc1f4a3e19a4427982c2d12b920d Mon Sep 17 00:00:00 2001 From: Gavin Rehkemper Date: Thu, 10 Oct 2019 14:37:01 -0500 Subject: [PATCH] build 2.3.1 --- dist/esri-leaflet-debug.js | 4354 ++++++++++++++++++++++++++++++++ dist/esri-leaflet-debug.js.map | 1 + dist/esri-leaflet.js | 5 + dist/esri-leaflet.js.map | 1 + 4 files changed, 4361 insertions(+) create mode 100644 dist/esri-leaflet-debug.js create mode 100644 dist/esri-leaflet-debug.js.map create mode 100644 dist/esri-leaflet.js create mode 100644 dist/esri-leaflet.js.map diff --git a/dist/esri-leaflet-debug.js b/dist/esri-leaflet-debug.js new file mode 100644 index 000000000..be340837c --- /dev/null +++ b/dist/esri-leaflet-debug.js @@ -0,0 +1,4354 @@ +/* esri-leaflet - v2.3.1 - Thu Oct 10 2019 14:36:17 GMT-0500 (Central Daylight Time) + * Copyright (c) 2019 Environmental Systems Research Institute, Inc. + * Apache-2.0 */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('leaflet')) : + typeof define === 'function' && define.amd ? define(['exports', 'leaflet'], factory) : + (factory((global.L = global.L || {}, global.L.esri = {}),global.L)); +}(this, (function (exports,leaflet) { 'use strict'; + +var version = "2.3.1"; + +var cors = ((window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest())); +var pointerEvents = document.documentElement.style.pointerEvents === ''; + +var Support = { + cors: cors, + pointerEvents: pointerEvents +}; + +var options = { + attributionWidthOffset: 55 +}; + +var callbacks = 0; + +function serialize (params) { + var data = ''; + + params.f = params.f || 'json'; + + for (var key in params) { + if (params.hasOwnProperty(key)) { + var param = params[key]; + var type = Object.prototype.toString.call(param); + var value; + + if (data.length) { + data += '&'; + } + + if (type === '[object Array]') { + value = (Object.prototype.toString.call(param[0]) === '[object Object]') ? JSON.stringify(param) : param.join(','); + } else if (type === '[object Object]') { + value = JSON.stringify(param); + } else if (type === '[object Date]') { + value = param.valueOf(); + } else { + value = param; + } + + data += encodeURIComponent(key) + '=' + encodeURIComponent(value); + } + } + + return data; +} + +function createRequest (callback, context) { + var httpRequest = new window.XMLHttpRequest(); + + httpRequest.onerror = function (e) { + httpRequest.onreadystatechange = leaflet.Util.falseFn; + + callback.call(context, { + error: { + code: 500, + message: 'XMLHttpRequest error' + } + }, null); + }; + + httpRequest.onreadystatechange = function () { + var response; + var error; + + if (httpRequest.readyState === 4) { + try { + response = JSON.parse(httpRequest.responseText); + } catch (e) { + response = null; + error = { + code: 500, + message: 'Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error.' + }; + } + + if (!error && response.error) { + error = response.error; + response = null; + } + + httpRequest.onerror = leaflet.Util.falseFn; + + callback.call(context, error, response); + } + }; + + httpRequest.ontimeout = function () { + this.onerror(); + }; + + return httpRequest; +} + +function xmlHttpPost (url, params, callback, context) { + var httpRequest = createRequest(callback, context); + httpRequest.open('POST', url); + + if (typeof context !== 'undefined' && context !== null) { + if (typeof context.options !== 'undefined') { + httpRequest.timeout = context.options.timeout; + } + } + httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + httpRequest.send(serialize(params)); + + return httpRequest; +} + +function xmlHttpGet (url, params, callback, context) { + var httpRequest = createRequest(callback, context); + httpRequest.open('GET', url + '?' + serialize(params), true); + + if (typeof context !== 'undefined' && context !== null) { + if (typeof context.options !== 'undefined') { + httpRequest.timeout = context.options.timeout; + } + } + httpRequest.send(null); + + return httpRequest; +} + +// AJAX handlers for CORS (modern browsers) or JSONP (older browsers) +function request (url, params, callback, context) { + var paramString = serialize(params); + var httpRequest = createRequest(callback, context); + var requestLength = (url + '?' + paramString).length; + + // ie10/11 require the request be opened before a timeout is applied + if (requestLength <= 2000 && Support.cors) { + httpRequest.open('GET', url + '?' + paramString); + } else if (requestLength > 2000 && Support.cors) { + httpRequest.open('POST', url); + httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + } + + if (typeof context !== 'undefined' && context !== null) { + if (typeof context.options !== 'undefined') { + httpRequest.timeout = context.options.timeout; + } + } + + // request is less than 2000 characters and the browser supports CORS, make GET request with XMLHttpRequest + if (requestLength <= 2000 && Support.cors) { + httpRequest.send(null); + + // request is more than 2000 characters and the browser supports CORS, make POST request with XMLHttpRequest + } else if (requestLength > 2000 && Support.cors) { + httpRequest.send(paramString); + + // request is less than 2000 characters and the browser does not support CORS, make a JSONP request + } else if (requestLength <= 2000 && !Support.cors) { + return jsonp(url, params, callback, context); + + // request is longer then 2000 characters and the browser does not support CORS, log a warning + } else { + 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'); + return; + } + + return httpRequest; +} + +function jsonp (url, params, callback, context) { + window._EsriLeafletCallbacks = window._EsriLeafletCallbacks || {}; + var callbackId = 'c' + callbacks; + params.callback = 'window._EsriLeafletCallbacks.' + callbackId; + + window._EsriLeafletCallbacks[callbackId] = function (response) { + if (window._EsriLeafletCallbacks[callbackId] !== true) { + var error; + var responseType = Object.prototype.toString.call(response); + + if (!(responseType === '[object Object]' || responseType === '[object Array]')) { + error = { + error: { + code: 500, + message: 'Expected array or object as JSONP response' + } + }; + response = null; + } + + if (!error && response.error) { + error = response; + response = null; + } + + callback.call(context, error, response); + window._EsriLeafletCallbacks[callbackId] = true; + } + }; + + var script = leaflet.DomUtil.create('script', null, document.body); + script.type = 'text/javascript'; + script.src = url + '?' + serialize(params); + script.id = callbackId; + script.onerror = function (error) { + if (error && window._EsriLeafletCallbacks[callbackId] !== true) { + // Can't get true error code: it can be 404, or 401, or 500 + var err = { + error: { + code: 500, + message: 'An unknown error occurred' + } + }; + + callback.call(context, err); + window._EsriLeafletCallbacks[callbackId] = true; + } + }; + leaflet.DomUtil.addClass(script, 'esri-leaflet-jsonp'); + + callbacks++; + + return { + id: callbackId, + url: script.src, + abort: function () { + window._EsriLeafletCallbacks._callback[callbackId]({ + code: 0, + message: 'Request aborted.' + }); + } + }; +} + +var get = ((Support.cors) ? xmlHttpGet : jsonp); +get.CORS = xmlHttpGet; +get.JSONP = jsonp; + +// export the Request object to call the different handlers for debugging +var Request = { + request: request, + get: get, + post: xmlHttpPost +}; + +/* + * Copyright 2017 Esri + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// checks if 2 x,y points are equal +function pointsEqual (a, b) { + for (var i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { + return false; + } + } + return true; +} + +// checks if the first and last points of a ring are equal and closes the ring +function closeRing (coordinates) { + if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) { + coordinates.push(coordinates[0]); + } + return coordinates; +} + +// determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring +// or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon- +// points-are-in-clockwise-order +function ringIsClockwise (ringToTest) { + var total = 0; + var i = 0; + var rLength = ringToTest.length; + var pt1 = ringToTest[i]; + var pt2; + for (i; i < rLength - 1; i++) { + pt2 = ringToTest[i + 1]; + total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]); + pt1 = pt2; + } + return (total >= 0); +} + +// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L504-L519 +function vertexIntersectsVertex (a1, a2, b1, b2) { + var uaT = ((b2[0] - b1[0]) * (a1[1] - b1[1])) - ((b2[1] - b1[1]) * (a1[0] - b1[0])); + var ubT = ((a2[0] - a1[0]) * (a1[1] - b1[1])) - ((a2[1] - a1[1]) * (a1[0] - b1[0])); + var uB = ((b2[1] - b1[1]) * (a2[0] - a1[0])) - ((b2[0] - b1[0]) * (a2[1] - a1[1])); + + if (uB !== 0) { + var ua = uaT / uB; + var ub = ubT / uB; + + if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) { + return true; + } + } + + return false; +} + +// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L521-L531 +function arrayIntersectsArray (a, b) { + for (var i = 0; i < a.length - 1; i++) { + for (var j = 0; j < b.length - 1; j++) { + if (vertexIntersectsVertex(a[i], a[i + 1], b[j], b[j + 1])) { + return true; + } + } + } + + return false; +} + +// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L470-L480 +function coordinatesContainPoint (coordinates, point) { + var contains = false; + for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) { + 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])) { + contains = !contains; + } + } + return contains; +} + +// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L106-L113 +function coordinatesContainCoordinates (outer, inner) { + var intersects = arrayIntersectsArray(outer, inner); + var contains = coordinatesContainPoint(outer, inner[0]); + if (!intersects && contains) { + return true; + } + return false; +} + +// do any polygons in this array contain any other polygons in this array? +// used for checking for holes in arcgis rings +// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L117-L172 +function convertRingsToGeoJSON (rings) { + var outerRings = []; + var holes = []; + var x; // iterator + var outerRing; // current outer ring being evaluated + var hole; // current hole being evaluated + + // for each ring + for (var r = 0; r < rings.length; r++) { + var ring = closeRing(rings[r].slice(0)); + if (ring.length < 4) { + continue; + } + // is this ring an outer ring? is it clockwise? + if (ringIsClockwise(ring)) { + var polygon = [ ring.slice().reverse() ]; // wind outer rings counterclockwise for RFC 7946 compliance + outerRings.push(polygon); // push to outer rings + } else { + holes.push(ring.slice().reverse()); // wind inner rings clockwise for RFC 7946 compliance + } + } + + var uncontainedHoles = []; + + // while there are holes left... + while (holes.length) { + // pop a hole off out stack + hole = holes.pop(); + + // loop over all outer rings and see if they contain our hole. + var contained = false; + for (x = outerRings.length - 1; x >= 0; x--) { + outerRing = outerRings[x][0]; + if (coordinatesContainCoordinates(outerRing, hole)) { + // the hole is contained push it into our polygon + outerRings[x].push(hole); + contained = true; + break; + } + } + + // ring is not contained in any outer ring + // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320 + if (!contained) { + uncontainedHoles.push(hole); + } + } + + // if we couldn't match any holes using contains we can try intersects... + while (uncontainedHoles.length) { + // pop a hole off out stack + hole = uncontainedHoles.pop(); + + // loop over all outer rings and see if any intersect our hole. + var intersects = false; + + for (x = outerRings.length - 1; x >= 0; x--) { + outerRing = outerRings[x][0]; + if (arrayIntersectsArray(outerRing, hole)) { + // the hole is contained push it into our polygon + outerRings[x].push(hole); + intersects = true; + break; + } + } + + if (!intersects) { + outerRings.push([hole.reverse()]); + } + } + + if (outerRings.length === 1) { + return { + type: 'Polygon', + coordinates: outerRings[0] + }; + } else { + return { + type: 'MultiPolygon', + coordinates: outerRings + }; + } +} + +// This function ensures that rings are oriented in the right directions +// outer rings are clockwise, holes are counterclockwise +// used for converting GeoJSON Polygons to ArcGIS Polygons +function orientRings (poly) { + var output = []; + var polygon = poly.slice(0); + var outerRing = closeRing(polygon.shift().slice(0)); + if (outerRing.length >= 4) { + if (!ringIsClockwise(outerRing)) { + outerRing.reverse(); + } + + output.push(outerRing); + + for (var i = 0; i < polygon.length; i++) { + var hole = closeRing(polygon[i].slice(0)); + if (hole.length >= 4) { + if (ringIsClockwise(hole)) { + hole.reverse(); + } + output.push(hole); + } + } + } + + return output; +} + +// This function flattens holes in multipolygons to one array of polygons +// used for converting GeoJSON Polygons to ArcGIS Polygons +function flattenMultiPolygonRings (rings) { + var output = []; + for (var i = 0; i < rings.length; i++) { + var polygon = orientRings(rings[i]); + for (var x = polygon.length - 1; x >= 0; x--) { + var ring = polygon[x].slice(0); + output.push(ring); + } + } + return output; +} + +// shallow object clone for feature properties and attributes +// from http://jsperf.com/cloning-an-object/2 +function shallowClone (obj) { + var target = {}; + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + target[i] = obj[i]; + } + } + return target; +} + +function getId (attributes, idAttribute) { + var keys = idAttribute ? [idAttribute, 'OBJECTID', 'FID'] : ['OBJECTID', 'FID']; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if ( + key in attributes && + (typeof attributes[key] === 'string' || + typeof attributes[key] === 'number') + ) { + return attributes[key]; + } + } + throw Error('No valid id attribute found'); +} + +function arcgisToGeoJSON (arcgis, idAttribute) { + var geojson = {}; + + if (arcgis.features) { + geojson.type = 'FeatureCollection'; + geojson.features = []; + for (var i = 0; i < arcgis.features.length; i++) { + geojson.features.push(arcgisToGeoJSON(arcgis.features[i], idAttribute)); + } + } + + if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') { + geojson.type = 'Point'; + geojson.coordinates = [arcgis.x, arcgis.y]; + if (typeof arcgis.z === 'number') { + geojson.coordinates.push(arcgis.z); + } + } + + if (arcgis.points) { + geojson.type = 'MultiPoint'; + geojson.coordinates = arcgis.points.slice(0); + } + + if (arcgis.paths) { + if (arcgis.paths.length === 1) { + geojson.type = 'LineString'; + geojson.coordinates = arcgis.paths[0].slice(0); + } else { + geojson.type = 'MultiLineString'; + geojson.coordinates = arcgis.paths.slice(0); + } + } + + if (arcgis.rings) { + geojson = convertRingsToGeoJSON(arcgis.rings.slice(0)); + } + + if ( + typeof arcgis.xmin === 'number' && + typeof arcgis.ymin === 'number' && + typeof arcgis.xmax === 'number' && + typeof arcgis.ymax === 'number' + ) { + geojson.type = 'Polygon'; + geojson.coordinates = [[ + [arcgis.xmax, arcgis.ymax], + [arcgis.xmin, arcgis.ymax], + [arcgis.xmin, arcgis.ymin], + [arcgis.xmax, arcgis.ymin], + [arcgis.xmax, arcgis.ymax] + ]]; + } + + if (arcgis.geometry || arcgis.attributes) { + geojson.type = 'Feature'; + geojson.geometry = (arcgis.geometry) ? arcgisToGeoJSON(arcgis.geometry) : null; + geojson.properties = (arcgis.attributes) ? shallowClone(arcgis.attributes) : null; + if (arcgis.attributes) { + try { + geojson.id = getId(arcgis.attributes, idAttribute); + } catch (err) { + // don't set an id + } + } + } + + // if no valid geometry was encountered + if (JSON.stringify(geojson.geometry) === JSON.stringify({})) { + geojson.geometry = null; + } + + if ( + arcgis.spatialReference && + arcgis.spatialReference.wkid && + arcgis.spatialReference.wkid !== 4326 + ) { + console.warn('Object converted in non-standard crs - ' + JSON.stringify(arcgis.spatialReference)); + } + + return geojson; +} + +function geojsonToArcGIS (geojson, idAttribute) { + idAttribute = idAttribute || 'OBJECTID'; + var spatialReference = { wkid: 4326 }; + var result = {}; + var i; + + switch (geojson.type) { + case 'Point': + result.x = geojson.coordinates[0]; + result.y = geojson.coordinates[1]; + result.spatialReference = spatialReference; + break; + case 'MultiPoint': + result.points = geojson.coordinates.slice(0); + result.spatialReference = spatialReference; + break; + case 'LineString': + result.paths = [geojson.coordinates.slice(0)]; + result.spatialReference = spatialReference; + break; + case 'MultiLineString': + result.paths = geojson.coordinates.slice(0); + result.spatialReference = spatialReference; + break; + case 'Polygon': + result.rings = orientRings(geojson.coordinates.slice(0)); + result.spatialReference = spatialReference; + break; + case 'MultiPolygon': + result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0)); + result.spatialReference = spatialReference; + break; + case 'Feature': + if (geojson.geometry) { + result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute); + } + result.attributes = (geojson.properties) ? shallowClone(geojson.properties) : {}; + if (geojson.id) { + result.attributes[idAttribute] = geojson.id; + } + break; + case 'FeatureCollection': + result = []; + for (i = 0; i < geojson.features.length; i++) { + result.push(geojsonToArcGIS(geojson.features[i], idAttribute)); + } + break; + case 'GeometryCollection': + result = []; + for (i = 0; i < geojson.geometries.length; i++) { + result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute)); + } + break; + } + + return result; +} + +function geojsonToArcGIS$1 (geojson, idAttr) { + return geojsonToArcGIS(geojson, idAttr); +} + +function arcgisToGeoJSON$1 (arcgis, idAttr) { + return arcgisToGeoJSON(arcgis, idAttr); +} + +// convert an extent (ArcGIS) to LatLngBounds (Leaflet) +function extentToBounds (extent) { + // "NaN" coordinates from ArcGIS Server indicate a null geometry + if (extent.xmin !== 'NaN' && extent.ymin !== 'NaN' && extent.xmax !== 'NaN' && extent.ymax !== 'NaN') { + var sw = leaflet.latLng(extent.ymin, extent.xmin); + var ne = leaflet.latLng(extent.ymax, extent.xmax); + return leaflet.latLngBounds(sw, ne); + } else { + return null; + } +} + +// convert an LatLngBounds (Leaflet) to extent (ArcGIS) +function boundsToExtent (bounds) { + bounds = leaflet.latLngBounds(bounds); + return { + 'xmin': bounds.getSouthWest().lng, + 'ymin': bounds.getSouthWest().lat, + 'xmax': bounds.getNorthEast().lng, + 'ymax': bounds.getNorthEast().lat, + 'spatialReference': { + 'wkid': 4326 + } + }; +} + +var knownFieldNames = /^(OBJECTID|FID|OID|ID)$/i; + +// Attempts to find the ID Field from response +function _findIdAttributeFromResponse (response) { + var result; + + if (response.objectIdFieldName) { + // Find Id Field directly + result = response.objectIdFieldName; + } else if (response.fields) { + // Find ID Field based on field type + for (var j = 0; j <= response.fields.length - 1; j++) { + if (response.fields[j].type === 'esriFieldTypeOID') { + result = response.fields[j].name; + break; + } + } + if (!result) { + // If no field was marked as being the esriFieldTypeOID try well known field names + for (j = 0; j <= response.fields.length - 1; j++) { + if (response.fields[j].name.match(knownFieldNames)) { + result = response.fields[j].name; + break; + } + } + } + } + return result; +} + +// This is the 'last' resort, find the Id field from the specified feature +function _findIdAttributeFromFeature (feature) { + for (var key in feature.attributes) { + if (key.match(knownFieldNames)) { + return key; + } + } +} + +function responseToFeatureCollection (response, idAttribute) { + var objectIdField; + var features = response.features || response.results; + var count = features.length; + + if (idAttribute) { + objectIdField = idAttribute; + } else { + objectIdField = _findIdAttributeFromResponse(response); + } + + var featureCollection = { + type: 'FeatureCollection', + features: [] + }; + + if (count) { + for (var i = features.length - 1; i >= 0; i--) { + var feature = arcgisToGeoJSON$1(features[i], objectIdField || _findIdAttributeFromFeature(features[i])); + featureCollection.features.push(feature); + } + } + + return featureCollection; +} + + // trim url whitespace and add a trailing slash if needed +function cleanUrl (url) { + // trim leading and trailing spaces, but not spaces inside the url + url = leaflet.Util.trim(url); + + // add a trailing slash to the url if the user omitted it + if (url[url.length - 1] !== '/') { + url += '/'; + } + + return url; +} + +/* Extract url params if any and store them in requestParams attribute. + Return the options params updated */ +function getUrlParams (options$$1) { + if (options$$1.url.indexOf('?') !== -1) { + options$$1.requestParams = options$$1.requestParams || {}; + var queryString = options$$1.url.substring(options$$1.url.indexOf('?') + 1); + options$$1.url = options$$1.url.split('?')[0]; + options$$1.requestParams = JSON.parse('{"' + decodeURI(queryString).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}'); + } + options$$1.url = cleanUrl(options$$1.url.split('?')[0]); + return options$$1; +} + +function isArcgisOnline (url) { + /* hosted feature services support geojson as an output format + utility.arcgis.com services are proxied from a variety of ArcGIS Server vintages, and may not */ + return (/^(?!.*utility\.arcgis\.com).*\.arcgis\.com.*FeatureServer/i).test(url); +} + +function geojsonTypeToArcGIS (geoJsonType) { + var arcgisGeometryType; + switch (geoJsonType) { + case 'Point': + arcgisGeometryType = 'esriGeometryPoint'; + break; + case 'MultiPoint': + arcgisGeometryType = 'esriGeometryMultipoint'; + break; + case 'LineString': + arcgisGeometryType = 'esriGeometryPolyline'; + break; + case 'MultiLineString': + arcgisGeometryType = 'esriGeometryPolyline'; + break; + case 'Polygon': + arcgisGeometryType = 'esriGeometryPolygon'; + break; + case 'MultiPolygon': + arcgisGeometryType = 'esriGeometryPolygon'; + break; + } + + return arcgisGeometryType; +} + +function warn () { + if (console && console.warn) { + console.warn.apply(console, arguments); + } +} + +function calcAttributionWidth (map) { + // either crop at 55px or user defined buffer + return (map.getSize().x - options.attributionWidthOffset) + 'px'; +} + +function setEsriAttribution (map) { + if (map.attributionControl && !map.attributionControl._esriAttributionAdded) { + map.attributionControl.setPrefix('Leaflet | Powered by Esri'); + + var hoverAttributionStyle = document.createElement('style'); + hoverAttributionStyle.type = 'text/css'; + hoverAttributionStyle.innerHTML = '.esri-truncated-attribution:hover {' + + 'white-space: normal;' + + '}'; + + document.getElementsByTagName('head')[0].appendChild(hoverAttributionStyle); + leaflet.DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution:hover'); + + // define a new css class in JS to trim attribution into a single line + var attributionStyle = document.createElement('style'); + attributionStyle.type = 'text/css'; + attributionStyle.innerHTML = '.esri-truncated-attribution {' + + 'vertical-align: -3px;' + + 'white-space: nowrap;' + + 'overflow: hidden;' + + 'text-overflow: ellipsis;' + + 'display: inline-block;' + + 'transition: 0s white-space;' + + 'transition-delay: 1s;' + + 'max-width: ' + calcAttributionWidth(map) + ';' + + '}'; + + document.getElementsByTagName('head')[0].appendChild(attributionStyle); + leaflet.DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution'); + + // update the width used to truncate when the map itself is resized + map.on('resize', function (e) { + map.attributionControl._container.style.maxWidth = calcAttributionWidth(e.target); + }); + + map.attributionControl._esriAttributionAdded = true; + } +} + +function _setGeometry (geometry) { + var params = { + geometry: null, + geometryType: null + }; + + // convert bounds to extent and finish + if (geometry instanceof leaflet.LatLngBounds) { + // set geometry + geometryType + params.geometry = boundsToExtent(geometry); + params.geometryType = 'esriGeometryEnvelope'; + return params; + } + + // convert L.Marker > L.LatLng + if (geometry.getLatLng) { + geometry = geometry.getLatLng(); + } + + // convert L.LatLng to a geojson point and continue; + if (geometry instanceof leaflet.LatLng) { + geometry = { + type: 'Point', + coordinates: [geometry.lng, geometry.lat] + }; + } + + // handle L.GeoJSON, pull out the first geometry + if (geometry instanceof leaflet.GeoJSON) { + // reassign geometry to the GeoJSON value (we are assuming that only one feature is present) + geometry = geometry.getLayers()[0].feature.geometry; + params.geometry = geojsonToArcGIS$1(geometry); + params.geometryType = geojsonTypeToArcGIS(geometry.type); + } + + // Handle L.Polyline and L.Polygon + if (geometry.toGeoJSON) { + geometry = geometry.toGeoJSON(); + } + + // handle GeoJSON feature by pulling out the geometry + if (geometry.type === 'Feature') { + // get the geometry of the geojson feature + geometry = geometry.geometry; + } + + // confirm that our GeoJSON is a point, line or polygon + if (geometry.type === 'Point' || geometry.type === 'LineString' || geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') { + params.geometry = geojsonToArcGIS$1(geometry); + params.geometryType = geojsonTypeToArcGIS(geometry.type); + return params; + } + + // warn the user if we havn't found an appropriate object + warn('invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object'); + + return; +} + +function _getAttributionData (url, map) { + if (Support.cors) { + request(url, {}, leaflet.Util.bind(function (error, attributions) { + if (error) { return; } + map._esriAttributions = []; + for (var c = 0; c < attributions.contributors.length; c++) { + var contributor = attributions.contributors[c]; + + for (var i = 0; i < contributor.coverageAreas.length; i++) { + var coverageArea = contributor.coverageAreas[i]; + var southWest = leaflet.latLng(coverageArea.bbox[0], coverageArea.bbox[1]); + var northEast = leaflet.latLng(coverageArea.bbox[2], coverageArea.bbox[3]); + map._esriAttributions.push({ + attribution: contributor.attribution, + score: coverageArea.score, + bounds: leaflet.latLngBounds(southWest, northEast), + minZoom: coverageArea.zoomMin, + maxZoom: coverageArea.zoomMax + }); + } + } + + map._esriAttributions.sort(function (a, b) { + return b.score - a.score; + }); + + // pass the same argument as the map's 'moveend' event + var obj = { target: map }; + _updateMapAttribution(obj); + }, this)); + } +} + +function _updateMapAttribution (evt) { + var map = evt.target; + var oldAttributions = map._esriAttributions; + + if (!map || !map.attributionControl) return; + + var attributionElement = map.attributionControl._container.querySelector('.esri-dynamic-attribution'); + + if (attributionElement && oldAttributions) { + var newAttributions = ''; + var bounds = map.getBounds(); + var wrappedBounds = leaflet.latLngBounds( + bounds.getSouthWest().wrap(), + bounds.getNorthEast().wrap() + ); + var zoom = map.getZoom(); + + for (var i = 0; i < oldAttributions.length; i++) { + var attribution = oldAttributions[i]; + var text = attribution.attribution; + + if (!newAttributions.match(text) && attribution.bounds.intersects(wrappedBounds) && zoom >= attribution.minZoom && zoom <= attribution.maxZoom) { + newAttributions += (', ' + text); + } + } + + newAttributions = newAttributions.substr(2); + attributionElement.innerHTML = newAttributions; + attributionElement.style.maxWidth = calcAttributionWidth(map); + + map.fire('attributionupdated', { + attribution: newAttributions + }); + } +} + +var EsriUtil = { + warn: warn, + cleanUrl: cleanUrl, + getUrlParams: getUrlParams, + isArcgisOnline: isArcgisOnline, + geojsonTypeToArcGIS: geojsonTypeToArcGIS, + responseToFeatureCollection: responseToFeatureCollection, + geojsonToArcGIS: geojsonToArcGIS$1, + arcgisToGeoJSON: arcgisToGeoJSON$1, + boundsToExtent: boundsToExtent, + extentToBounds: extentToBounds, + calcAttributionWidth: calcAttributionWidth, + setEsriAttribution: setEsriAttribution, + _setGeometry: _setGeometry, + _getAttributionData: _getAttributionData, + _updateMapAttribution: _updateMapAttribution, + _findIdAttributeFromFeature: _findIdAttributeFromFeature, + _findIdAttributeFromResponse: _findIdAttributeFromResponse +}; + +var Task = leaflet.Class.extend({ + + options: { + proxy: false, + useCors: cors + }, + + // Generate a method for each methodName:paramName in the setters for this task. + generateSetter: function (param, context) { + return leaflet.Util.bind(function (value) { + this.params[param] = value; + return this; + }, context); + }, + + initialize: function (endpoint) { + // endpoint can be either a url (and options) for an ArcGIS Rest Service or an instance of EsriLeaflet.Service + if (endpoint.request && endpoint.options) { + this._service = endpoint; + leaflet.Util.setOptions(this, endpoint.options); + } else { + leaflet.Util.setOptions(this, endpoint); + this.options.url = cleanUrl(endpoint.url); + } + + // clone default params into this object + this.params = leaflet.Util.extend({}, this.params || {}); + + // generate setter methods based on the setters object implimented a child class + if (this.setters) { + for (var setter in this.setters) { + var param = this.setters[setter]; + this[setter] = this.generateSetter(param, this); + } + } + }, + + token: function (token) { + if (this._service) { + this._service.authenticate(token); + } else { + this.params.token = token; + } + return this; + }, + + // ArcGIS Server Find/Identify 10.5+ + format: function (boolean) { + // use double negative to expose a more intuitive positive method name + this.params.returnUnformattedValues = !boolean; + return this; + }, + + request: function (callback, context) { + if (this.options.requestParams) { + leaflet.Util.extend(this.params, this.options.requestParams); + } + if (this._service) { + return this._service.request(this.path, this.params, callback, context); + } + + return this._request('request', this.path, this.params, callback, context); + }, + + _request: function (method, path, params, callback, context) { + var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path; + + if ((method === 'get' || method === 'request') && !this.options.useCors) { + return Request.get.JSONP(url, params, callback, context); + } + + return Request[method](url, params, callback, context); + } +}); + +function task (options) { + options = getUrlParams(options); + return new Task(options); +} + +var Query = Task.extend({ + setters: { + 'offset': 'resultOffset', + 'limit': 'resultRecordCount', + 'fields': 'outFields', + 'precision': 'geometryPrecision', + 'featureIds': 'objectIds', + 'returnGeometry': 'returnGeometry', + 'returnM': 'returnM', + 'transform': 'datumTransformation', + 'token': 'token' + }, + + path: 'query', + + params: { + returnGeometry: true, + where: '1=1', + outSR: 4326, + outFields: '*' + }, + + // Returns a feature if its shape is wholly contained within the search geometry. Valid for all shape type combinations. + within: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelContains'; // to the REST api this reads geometry **contains** layer + return this; + }, + + // Returns a feature if any spatial relationship is found. Applies to all shape type combinations. + intersects: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelIntersects'; + return this; + }, + + // Returns a feature if its shape wholly contains the search geometry. Valid for all shape type combinations. + contains: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelWithin'; // to the REST api this reads geometry **within** layer + return this; + }, + + // 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. + crosses: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelCrosses'; + return this; + }, + + // 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. + touches: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelTouches'; + return this; + }, + + // 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. + overlaps: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelOverlaps'; + return this; + }, + + // Returns a feature if the envelope of the two shapes intersects. + bboxIntersects: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelEnvelopeIntersects'; + return this; + }, + + // if someone can help decipher the ArcObjects explanation and translate to plain speak, we should mention this method in the doc + indexIntersects: function (geometry) { + this._setGeometryParams(geometry); + this.params.spatialRel = 'esriSpatialRelIndexIntersects'; // Returns a feature if the envelope of the query geometry intersects the index entry for the target geometry + return this; + }, + + // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online + nearby: function (latlng, radius) { + latlng = leaflet.latLng(latlng); + this.params.geometry = [latlng.lng, latlng.lat]; + this.params.geometryType = 'esriGeometryPoint'; + this.params.spatialRel = 'esriSpatialRelIntersects'; + this.params.units = 'esriSRUnit_Meter'; + this.params.distance = radius; + this.params.inSr = 4326; + return this; + }, + + where: function (string) { + // instead of converting double-quotes to single quotes, pass as is, and provide a more informative message if a 400 is encountered + this.params.where = string; + return this; + }, + + between: function (start, end) { + this.params.time = [start.valueOf(), end.valueOf()]; + return this; + }, + + simplify: function (map, factor) { + var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast()); + this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor; + return this; + }, + + orderBy: function (fieldName, order) { + order = order || 'ASC'; + this.params.orderByFields = (this.params.orderByFields) ? this.params.orderByFields + ',' : ''; + this.params.orderByFields += ([fieldName, order]).join(' '); + return this; + }, + + run: function (callback, context) { + this._cleanParams(); + + // services hosted on ArcGIS Online and ArcGIS Server 10.3.1+ support requesting geojson directly + if (this.options.isModern || isArcgisOnline(this.options.url)) { + this.params.f = 'geojson'; + + return this.request(function (error, response) { + this._trapSQLerrors(error); + callback.call(context, error, response, response); + }, this); + + // otherwise convert it in the callback then pass it on + } else { + return this.request(function (error, response) { + this._trapSQLerrors(error); + callback.call(context, error, (response && responseToFeatureCollection(response)), response); + }, this); + } + }, + + count: function (callback, context) { + this._cleanParams(); + this.params.returnCountOnly = true; + return this.request(function (error, response) { + callback.call(this, error, (response && response.count), response); + }, context); + }, + + ids: function (callback, context) { + this._cleanParams(); + this.params.returnIdsOnly = true; + return this.request(function (error, response) { + callback.call(this, error, (response && response.objectIds), response); + }, context); + }, + + // only valid for Feature Services running on ArcGIS Server 10.3+ or ArcGIS Online + bounds: function (callback, context) { + this._cleanParams(); + this.params.returnExtentOnly = true; + return this.request(function (error, response) { + if (response && response.extent && extentToBounds(response.extent)) { + callback.call(context, error, extentToBounds(response.extent), response); + } else { + error = { + message: 'Invalid Bounds' + }; + callback.call(context, error, null, response); + } + }, context); + }, + + distinct: function () { + // geometry must be omitted for queries requesting distinct values + this.params.returnGeometry = false; + this.params.returnDistinctValues = true; + return this; + }, + + // only valid for image services + pixelSize: function (rawPoint) { + var castPoint = leaflet.point(rawPoint); + this.params.pixelSize = [castPoint.x, castPoint.y]; + return this; + }, + + // only valid for map services + layer: function (layer) { + this.path = layer + '/query'; + return this; + }, + + _trapSQLerrors: function (error) { + if (error) { + if (error.code === '400') { + warn('one common syntax error in query requests is encasing string values in double quotes instead of single quotes'); + } + } + }, + + _cleanParams: function () { + delete this.params.returnIdsOnly; + delete this.params.returnExtentOnly; + delete this.params.returnCountOnly; + }, + + _setGeometryParams: function (geometry) { + this.params.inSr = 4326; + var converted = _setGeometry(geometry); + this.params.geometry = converted.geometry; + this.params.geometryType = converted.geometryType; + } + +}); + +function query (options) { + return new Query(options); +} + +var Find = Task.extend({ + setters: { + // method name > param name + 'contains': 'contains', + 'text': 'searchText', + 'fields': 'searchFields', // denote an array or single string + 'spatialReference': 'sr', + 'sr': 'sr', + 'layers': 'layers', + 'returnGeometry': 'returnGeometry', + 'maxAllowableOffset': 'maxAllowableOffset', + 'precision': 'geometryPrecision', + 'dynamicLayers': 'dynamicLayers', + 'returnZ': 'returnZ', + 'returnM': 'returnM', + 'gdbVersion': 'gdbVersion', + // skipped implementing this (for now) because the REST service implementation isnt consistent between operations + // 'transform': 'datumTransformations', + 'token': 'token' + }, + + path: 'find', + + params: { + sr: 4326, + contains: true, + returnGeometry: true, + returnZ: true, + returnM: false + }, + + layerDefs: function (id, where) { + this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : ''; + this.params.layerDefs += ([id, where]).join(':'); + return this; + }, + + simplify: function (map, factor) { + var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast()); + this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor; + return this; + }, + + run: function (callback, context) { + return this.request(function (error, response) { + callback.call(context, error, (response && responseToFeatureCollection(response)), response); + }, context); + } +}); + +function find (options) { + return new Find(options); +} + +var Identify = Task.extend({ + path: 'identify', + + between: function (start, end) { + this.params.time = [start.valueOf(), end.valueOf()]; + return this; + } +}); + +function identify (options) { + return new Identify(options); +} + +var IdentifyFeatures = Identify.extend({ + setters: { + 'layers': 'layers', + 'precision': 'geometryPrecision', + 'tolerance': 'tolerance', + // skipped implementing this (for now) because the REST service implementation isnt consistent between operations. + // 'transform': 'datumTransformations' + 'returnGeometry': 'returnGeometry' + }, + + params: { + sr: 4326, + layers: 'all', + tolerance: 3, + returnGeometry: true + }, + + on: function (map) { + var extent = boundsToExtent(map.getBounds()); + var size = map.getSize(); + this.params.imageDisplay = [size.x, size.y, 96]; + this.params.mapExtent = [extent.xmin, extent.ymin, extent.xmax, extent.ymax]; + return this; + }, + + at: function (geometry) { + // cast lat, long pairs in raw array form manually + if (geometry.length === 2) { + geometry = leaflet.latLng(geometry); + } + this._setGeometryParams(geometry); + return this; + }, + + layerDef: function (id, where) { + this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : ''; + this.params.layerDefs += ([id, where]).join(':'); + return this; + }, + + simplify: function (map, factor) { + var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast()); + this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor; + return this; + }, + + run: function (callback, context) { + return this.request(function (error, response) { + // immediately invoke with an error + if (error) { + callback.call(context, error, undefined, response); + return; + + // ok no error lets just assume we have features... + } else { + var featureCollection = responseToFeatureCollection(response); + response.results = response.results.reverse(); + for (var i = 0; i < featureCollection.features.length; i++) { + var feature = featureCollection.features[i]; + feature.layerId = response.results[i].layerId; + } + callback.call(context, undefined, featureCollection, response); + } + }); + }, + + _setGeometryParams: function (geometry) { + var converted = _setGeometry(geometry); + this.params.geometry = converted.geometry; + this.params.geometryType = converted.geometryType; + } +}); + +function identifyFeatures (options) { + return new IdentifyFeatures(options); +} + +var IdentifyImage = Identify.extend({ + setters: { + 'setMosaicRule': 'mosaicRule', + 'setRenderingRule': 'renderingRule', + 'setPixelSize': 'pixelSize', + 'returnCatalogItems': 'returnCatalogItems', + 'returnGeometry': 'returnGeometry' + }, + + params: { + returnGeometry: false + }, + + at: function (latlng) { + latlng = leaflet.latLng(latlng); + this.params.geometry = JSON.stringify({ + x: latlng.lng, + y: latlng.lat, + spatialReference: { + wkid: 4326 + } + }); + this.params.geometryType = 'esriGeometryPoint'; + return this; + }, + + getMosaicRule: function () { + return this.params.mosaicRule; + }, + + getRenderingRule: function () { + return this.params.renderingRule; + }, + + getPixelSize: function () { + return this.params.pixelSize; + }, + + run: function (callback, context) { + return this.request(function (error, response) { + callback.call(context, error, (response && this._responseToGeoJSON(response)), response); + }, this); + }, + + // get pixel data and return as geoJSON point + // populate catalog items (if any) + // merging in any catalogItemVisibilities as a propery of each feature + _responseToGeoJSON: function (response) { + var location = response.location; + var catalogItems = response.catalogItems; + var catalogItemVisibilities = response.catalogItemVisibilities; + var geoJSON = { + 'pixel': { + 'type': 'Feature', + 'geometry': { + 'type': 'Point', + 'coordinates': [location.x, location.y] + }, + 'crs': { + 'type': 'EPSG', + 'properties': { + 'code': location.spatialReference.wkid + } + }, + 'properties': { + 'OBJECTID': response.objectId, + 'name': response.name, + 'value': response.value + }, + 'id': response.objectId + } + }; + + if (response.properties && response.properties.Values) { + geoJSON.pixel.properties.values = response.properties.Values; + } + + if (catalogItems && catalogItems.features) { + geoJSON.catalogItems = responseToFeatureCollection(catalogItems); + if (catalogItemVisibilities && catalogItemVisibilities.length === geoJSON.catalogItems.features.length) { + for (var i = catalogItemVisibilities.length - 1; i >= 0; i--) { + geoJSON.catalogItems.features[i].properties.catalogItemVisibility = catalogItemVisibilities[i]; + } + } + } + return geoJSON; + } + +}); + +function identifyImage (params) { + return new IdentifyImage(params); +} + +var Service = leaflet.Evented.extend({ + + options: { + proxy: false, + useCors: cors, + timeout: 0 + }, + + initialize: function (options) { + options = options || {}; + this._requestQueue = []; + this._authenticating = false; + leaflet.Util.setOptions(this, options); + this.options.url = cleanUrl(this.options.url); + }, + + get: function (path, params, callback, context) { + return this._request('get', path, params, callback, context); + }, + + post: function (path, params, callback, context) { + return this._request('post', path, params, callback, context); + }, + + request: function (path, params, callback, context) { + return this._request('request', path, params, callback, context); + }, + + metadata: function (callback, context) { + return this._request('get', '', {}, callback, context); + }, + + authenticate: function (token) { + this._authenticating = false; + this.options.token = token; + this._runQueue(); + return this; + }, + + getTimeout: function () { + return this.options.timeout; + }, + + setTimeout: function (timeout) { + this.options.timeout = timeout; + }, + + _request: function (method, path, params, callback, context) { + this.fire('requeststart', { + url: this.options.url + path, + params: params, + method: method + }, true); + + var wrappedCallback = this._createServiceCallback(method, path, params, callback, context); + + if (this.options.token) { + params.token = this.options.token; + } + if (this.options.requestParams) { + leaflet.Util.extend(params, this.options.requestParams); + } + if (this._authenticating) { + this._requestQueue.push([method, path, params, callback, context]); + return; + } else { + var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path; + + if ((method === 'get' || method === 'request') && !this.options.useCors) { + return Request.get.JSONP(url, params, wrappedCallback, context); + } else { + return Request[method](url, params, wrappedCallback, context); + } + } + }, + + _createServiceCallback: function (method, path, params, callback, context) { + return leaflet.Util.bind(function (error, response) { + if (error && (error.code === 499 || error.code === 498)) { + this._authenticating = true; + + this._requestQueue.push([method, path, params, callback, context]); + + // fire an event for users to handle and re-authenticate + this.fire('authenticationrequired', { + authenticate: leaflet.Util.bind(this.authenticate, this) + }, true); + + // if the user has access to a callback they can handle the auth error + error.authenticate = leaflet.Util.bind(this.authenticate, this); + } + + callback.call(context, error, response); + + if (error) { + this.fire('requesterror', { + url: this.options.url + path, + params: params, + message: error.message, + code: error.code, + method: method + }, true); + } else { + this.fire('requestsuccess', { + url: this.options.url + path, + params: params, + response: response, + method: method + }, true); + } + + this.fire('requestend', { + url: this.options.url + path, + params: params, + method: method + }, true); + }, this); + }, + + _runQueue: function () { + for (var i = this._requestQueue.length - 1; i >= 0; i--) { + var request$$1 = this._requestQueue[i]; + var method = request$$1.shift(); + this[method].apply(this, request$$1); + } + this._requestQueue = []; + } +}); + +function service (options) { + options = getUrlParams(options); + return new Service(options); +} + +var MapService = Service.extend({ + + identify: function () { + return identifyFeatures(this); + }, + + find: function () { + return find(this); + }, + + query: function () { + return query(this); + } + +}); + +function mapService (options) { + return new MapService(options); +} + +var ImageService = Service.extend({ + + query: function () { + return query(this); + }, + + identify: function () { + return identifyImage(this); + } +}); + +function imageService (options) { + return new ImageService(options); +} + +var FeatureLayerService = Service.extend({ + + options: { + idAttribute: 'OBJECTID' + }, + + query: function () { + return query(this); + }, + + addFeature: function (feature, callback, context) { + this.addFeatures(feature, callback, context); + }, + + addFeatures: function (features, callback, context) { + var featuresArray = features.features ? features.features : [features]; + for (var i = featuresArray.length - 1; i >= 0; i--) { + delete featuresArray[i].id; + } + features = geojsonToArcGIS$1(features); + features = featuresArray.length > 1 ? features : [features]; + return this.post('addFeatures', { + features: features + }, function (error, response) { + // For compatibility reason with former addFeature function, + // we return the object in the array and not the array itself + var result = (response && response.addResults) ? response.addResults.length > 1 ? response.addResults : response.addResults[0] : undefined; + if (callback) { + callback.call(context, error || response.addResults[0].error, result); + } + }, context); + }, + + updateFeature: function (feature, callback, context) { + this.updateFeatures(feature, callback, context); + }, + + updateFeatures: function (features, callback, context) { + var featuresArray = features.features ? features.features : [features]; + features = geojsonToArcGIS$1(features, this.options.idAttribute); + features = featuresArray.length > 1 ? features : [features]; + + return this.post('updateFeatures', { + features: features + }, function (error, response) { + // For compatibility reason with former updateFeature function, + // we return the object in the array and not the array itself + var result = (response && response.updateResults) ? response.updateResults.length > 1 ? response.updateResults : response.updateResults[0] : undefined; + if (callback) { + callback.call(context, error || response.updateResults[0].error, result); + } + }, context); + }, + + deleteFeature: function (id, callback, context) { + this.deleteFeatures(id, callback, context); + }, + + deleteFeatures: function (ids, callback, context) { + return this.post('deleteFeatures', { + objectIds: ids + }, function (error, response) { + // For compatibility reason with former deleteFeature function, + // we return the object in the array and not the array itself + var result = (response && response.deleteResults) ? response.deleteResults.length > 1 ? response.deleteResults : response.deleteResults[0] : undefined; + if (callback) { + callback.call(context, error || response.deleteResults[0].error, result); + } + }, context); + } +}); + +function featureLayerService (options) { + return new FeatureLayerService(options); +} + +var tileProtocol = (window.location.protocol !== 'https:') ? 'http:' : 'https:'; + +var BasemapLayer = leaflet.TileLayer.extend({ + statics: { + TILES: { + Streets: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 19, + subdomains: ['server', 'services'], + attribution: 'USGS, NOAA', + attributionUrl: 'https://static.arcgis.com/attribution/World_Street_Map' + } + }, + Topographic: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 19, + subdomains: ['server', 'services'], + attribution: 'USGS, NOAA', + attributionUrl: 'https://static.arcgis.com/attribution/World_Topo_Map' + } + }, + Oceans: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 16, + subdomains: ['server', 'services'], + attribution: 'USGS, NOAA', + attributionUrl: 'https://static.arcgis.com/attribution/Ocean_Basemap' + } + }, + OceansLabels: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 16, + subdomains: ['server', 'services'], + pane: (pointerEvents) ? 'esri-labels' : 'tilePane', + attribution: '' + } + }, + NationalGeographic: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 16, + subdomains: ['server', 'services'], + attribution: 'National Geographic, DeLorme, HERE, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, increment P Corp.' + } + }, + DarkGray: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 16, + subdomains: ['server', 'services'], + attribution: 'HERE, DeLorme, MapmyIndia, © OpenStreetMap contributors' + } + }, + DarkGrayLabels: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 16, + subdomains: ['server', 'services'], + pane: (pointerEvents) ? 'esri-labels' : 'tilePane', + attribution: '' + + } + }, + Gray: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 16, + subdomains: ['server', 'services'], + attribution: 'HERE, DeLorme, MapmyIndia, © OpenStreetMap contributors' + } + }, + GrayLabels: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 16, + subdomains: ['server', 'services'], + pane: (pointerEvents) ? 'esri-labels' : 'tilePane', + attribution: '' + } + }, + Imagery: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 22, + maxNativeZoom: 22, + downsampled: false, + subdomains: ['server', 'services'], + attribution: 'DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community', + attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery' + } + }, + ImageryLabels: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 19, + subdomains: ['server', 'services'], + pane: (pointerEvents) ? 'esri-labels' : 'tilePane', + attribution: '' + } + }, + ImageryTransportation: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 19, + subdomains: ['server', 'services'], + pane: (pointerEvents) ? 'esri-labels' : 'tilePane', + attribution: '' + } + }, + ShadedRelief: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 13, + subdomains: ['server', 'services'], + attribution: 'USGS' + } + }, + ShadedReliefLabels: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 12, + subdomains: ['server', 'services'], + pane: (pointerEvents) ? 'esri-labels' : 'tilePane', + attribution: '' + } + }, + Terrain: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 13, + subdomains: ['server', 'services'], + attribution: 'USGS, NOAA' + } + }, + TerrainLabels: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 13, + subdomains: ['server', 'services'], + pane: (pointerEvents) ? 'esri-labels' : 'tilePane', + attribution: '' + } + }, + USATopo: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 15, + subdomains: ['server', 'services'], + attribution: 'USGS, National Geographic Society, i-cubed' + } + }, + ImageryClarity: { + urlTemplate: tileProtocol + '//clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 19, + attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community' + } + }, + Physical: { + urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 8, + subdomains: ['server', 'services'], + attribution: 'U.S. National Park Service' + } + }, + ImageryFirefly: { + urlTemplate: tileProtocol + '//fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{z}/{y}/{x}', + options: { + minZoom: 1, + maxZoom: 19, + attribution: 'Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community', + attributionUrl: 'https://static.arcgis.com/attribution/World_Imagery' + } + } + } + }, + + initialize: function (key, options) { + var config; + + // set the config variable with the appropriate config object + if (typeof key === 'object' && key.urlTemplate && key.options) { + config = key; + } else if (typeof key === 'string' && BasemapLayer.TILES[key]) { + config = BasemapLayer.TILES[key]; + } else { + 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"'); + } + + // merge passed options into the config options + var tileOptions = leaflet.Util.extend(config.options, options); + + leaflet.Util.setOptions(this, tileOptions); + + if (this.options.token && config.urlTemplate.indexOf('token=') === -1) { + config.urlTemplate += ('?token=' + this.options.token); + } + if (this.options.proxy) { + config.urlTemplate = this.options.proxy + '?' + config.urlTemplate; + } + + // call the initialize method on L.TileLayer to set everything up + leaflet.TileLayer.prototype.initialize.call(this, config.urlTemplate, tileOptions); + }, + + onAdd: function (map) { + // include 'Powered by Esri' in map attribution + setEsriAttribution(map); + + if (this.options.pane === 'esri-labels') { + this._initPane(); + } + // some basemaps can supply dynamic attribution + if (this.options.attributionUrl) { + _getAttributionData((this.options.proxy ? this.options.proxy + '?' : '') + this.options.attributionUrl, map); + } + + map.on('moveend', _updateMapAttribution); + + // Esri World Imagery is cached all the way to zoom 22 in select regions + if (this._url.indexOf('World_Imagery') !== -1) { + map.on('zoomanim', _fetchTilemap, this); + } + + leaflet.TileLayer.prototype.onAdd.call(this, map); + }, + + onRemove: function (map) { + map.off('moveend', _updateMapAttribution); + leaflet.TileLayer.prototype.onRemove.call(this, map); + }, + + _initPane: function () { + if (!this._map.getPane(this.options.pane)) { + var pane = this._map.createPane(this.options.pane); + pane.style.pointerEvents = 'none'; + pane.style.zIndex = 500; + } + }, + + getAttribution: function () { + if (this.options.attribution) { + var attribution = '' + this.options.attribution + ''; + } + return attribution; + } +}); + +function _fetchTilemap (evt) { + var map = evt.target; + if (!map) { return; } + + var oldZoom = map.getZoom(); + var newZoom = evt.zoom; + var newCenter = map.wrapLatLng(evt.center); + + if (newZoom > oldZoom && newZoom > 13 && !this.options.downsampled) { + // convert wrapped lat/long into tile coordinates and use them to generate the tilemap url + var tilePoint = map.project(newCenter, newZoom).divideBy(256).floor(); + + // use new coords to determine the tilemap url + var tileUrl = leaflet.Util.template(this._url, leaflet.Util.extend({ + s: this._getSubdomain(tilePoint), + x: tilePoint.x, + y: tilePoint.y, + z: newZoom + }, this.options)); + + // 8x8 grids are cached + var tilemapUrl = tileUrl.replace(/tile/, 'tilemap') + '/8/8'; + + // an array of booleans in the response indicate missing tiles + L.esri.request(tilemapUrl, {}, function (err, response) { + if (!err) { + for (var i = 0; i < response.data.length; i++) { + if (!response.data[i]) { + // if necessary, resample a lower zoom + this.options.maxNativeZoom = newZoom - 1; + this.options.downsampled = true; + break; + } + // if no tiles are missing, reset the original maxZoom + this.options.maxNativeZoom = 22; + } + } + }, this); + } else if (newZoom < 13) { + // if the user moves to a new region, time for a fresh test + this.options.downsampled = false; + } +} + +function basemapLayer (key, options) { + return new BasemapLayer(key, options); +} + +var TiledMapLayer = leaflet.TileLayer.extend({ + options: { + zoomOffsetAllowance: 0.1, + errorTileUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEABAMAAACuXLVVAAAAA1BMVEUzNDVszlHHAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAAAAAAAAAB6mUWpAAAADZJREFUeJztwQEBAAAAgiD/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7waBAAABw08RwAAAAABJRU5ErkJggg==' + }, + + statics: { + MercatorZoomLevels: { + '0': 156543.03392799999, + '1': 78271.516963999893, + '2': 39135.758482000099, + '3': 19567.879240999901, + '4': 9783.9396204999593, + '5': 4891.9698102499797, + '6': 2445.9849051249898, + '7': 1222.9924525624899, + '8': 611.49622628138002, + '9': 305.74811314055802, + '10': 152.874056570411, + '11': 76.437028285073197, + '12': 38.218514142536598, + '13': 19.109257071268299, + '14': 9.5546285356341496, + '15': 4.7773142679493699, + '16': 2.38865713397468, + '17': 1.1943285668550501, + '18': 0.59716428355981699, + '19': 0.29858214164761698, + '20': 0.14929107082381, + '21': 0.07464553541191, + '22': 0.0373227677059525, + '23': 0.0186613838529763 + } + }, + + initialize: function (options) { + options = leaflet.Util.setOptions(this, options); + + // set the urls + options = getUrlParams(options); + this.tileUrl = (options.proxy ? options.proxy + '?' : '') + options.url + 'tile/{z}/{y}/{x}' + (options.requestParams && Object.keys(options.requestParams).length > 0 ? leaflet.Util.getParamString(options.requestParams) : ''); + // Remove subdomain in url + // https://github.com/Esri/esri-leaflet/issues/991 + if (options.url.indexOf('{s}') !== -1 && options.subdomains) { + options.url = options.url.replace('{s}', options.subdomains[0]); + } + this.service = mapService(options); + this.service.addEventParent(this); + + var arcgisonline = new RegExp(/tiles.arcgis(online)?\.com/g); + if (arcgisonline.test(options.url)) { + this.tileUrl = this.tileUrl.replace('://tiles', '://tiles{s}'); + options.subdomains = ['1', '2', '3', '4']; + } + + if (this.options.token) { + this.tileUrl += ('?token=' + this.options.token); + } + + // init layer by calling TileLayers initialize method + leaflet.TileLayer.prototype.initialize.call(this, this.tileUrl, options); + }, + + getTileUrl: function (tilePoint) { + var zoom = this._getZoomForUrl(); + + return leaflet.Util.template(this.tileUrl, leaflet.Util.extend({ + s: this._getSubdomain(tilePoint), + x: tilePoint.x, + y: tilePoint.y, + // try lod map first, then just default to zoom level + z: (this._lodMap && this._lodMap[zoom]) ? this._lodMap[zoom] : zoom + }, this.options)); + }, + + createTile: function (coords, done) { + var tile = document.createElement('img'); + + leaflet.DomEvent.on(tile, 'load', leaflet.Util.bind(this._tileOnLoad, this, done, tile)); + leaflet.DomEvent.on(tile, 'error', leaflet.Util.bind(this._tileOnError, this, done, tile)); + + if (this.options.crossOrigin) { + tile.crossOrigin = ''; + } + + /* + Alt tag is set to empty string to keep screen readers from reading URL and for compliance reasons + http://www.w3.org/TR/WCAG20-TECHS/H67 + */ + tile.alt = ''; + + // if there is no lod map or an lod map with a proper zoom load the tile + // otherwise wait for the lod map to become available + if (!this._lodMap || (this._lodMap && this._lodMap[this._getZoomForUrl()])) { + tile.src = this.getTileUrl(coords); + } else { + this.once('lodmap', function () { + tile.src = this.getTileUrl(coords); + }, this); + } + + return tile; + }, + + onAdd: function (map) { + // include 'Powered by Esri' in map attribution + setEsriAttribution(map); + + if (!this._lodMap) { + this.metadata(function (error, metadata) { + if (!error && metadata.spatialReference) { + var sr = metadata.spatialReference.latestWkid || metadata.spatialReference.wkid; + // display the copyright text from the service using leaflet's attribution control + if (!this.options.attribution && map.attributionControl && metadata.copyrightText) { + this.options.attribution = metadata.copyrightText; + map.attributionControl.addAttribution(this.getAttribution()); + } + + // if the service tiles were published in web mercator using conventional LODs but missing levels, we can try and remap them + if (map.options.crs === leaflet.CRS.EPSG3857 && (sr === 102100 || sr === 3857)) { + this._lodMap = {}; + // create the zoom level data + var arcgisLODs = metadata.tileInfo.lods; + var correctResolutions = TiledMapLayer.MercatorZoomLevels; + + for (var i = 0; i < arcgisLODs.length; i++) { + var arcgisLOD = arcgisLODs[i]; + for (var ci in correctResolutions) { + var correctRes = correctResolutions[ci]; + + if (this._withinPercentage(arcgisLOD.resolution, correctRes, this.options.zoomOffsetAllowance)) { + this._lodMap[ci] = arcgisLOD.level; + break; + } + } + } + + this.fire('lodmap'); + } else if (map.options.crs && map.options.crs.code && (map.options.crs.code.indexOf(sr) > -1)) { + // if the projection is WGS84, or the developer is using Proj4 to define a custom CRS, no action is required + } else { + // 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 + 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'); + } + } + }, this); + } + + leaflet.TileLayer.prototype.onAdd.call(this, map); + }, + + metadata: function (callback, context) { + this.service.metadata(callback, context); + return this; + }, + + identify: function () { + return this.service.identify(); + }, + + find: function () { + return this.service.find(); + }, + + query: function () { + return this.service.query(); + }, + + authenticate: function (token) { + var tokenQs = '?token=' + token; + this.tileUrl = (this.options.token) ? this.tileUrl.replace(/\?token=(.+)/g, tokenQs) : this.tileUrl + tokenQs; + this.options.token = token; + this.service.authenticate(token); + return this; + }, + + _withinPercentage: function (a, b, percentage) { + var diff = Math.abs((a / b) - 1); + return diff < percentage; + } +}); + +function tiledMapLayer (url, options) { + return new TiledMapLayer(url, options); +} + +var Overlay = leaflet.ImageOverlay.extend({ + onAdd: function (map) { + this._topLeft = map.getPixelBounds().min; + leaflet.ImageOverlay.prototype.onAdd.call(this, map); + }, + _reset: function () { + if (this._map.options.crs === leaflet.CRS.EPSG3857) { + leaflet.ImageOverlay.prototype._reset.call(this); + } else { + leaflet.DomUtil.setPosition(this._image, this._topLeft.subtract(this._map.getPixelOrigin())); + } + } +}); + +var RasterLayer = leaflet.Layer.extend({ + options: { + opacity: 1, + position: 'front', + f: 'image', + useCors: cors, + attribution: null, + interactive: false, + alt: '' + }, + + onAdd: function (map) { + // include 'Powered by Esri' in map attribution + setEsriAttribution(map); + + if (this.options.zIndex) { + this.options.position = null; + } + + this._update = leaflet.Util.throttle(this._update, this.options.updateInterval, this); + + map.on('moveend', this._update, this); + + // if we had an image loaded and it matches the + // current bounds show the image otherwise remove it + if (this._currentImage && this._currentImage._bounds.equals(this._map.getBounds())) { + map.addLayer(this._currentImage); + } else if (this._currentImage) { + this._map.removeLayer(this._currentImage); + this._currentImage = null; + } + + this._update(); + + if (this._popup) { + this._map.on('click', this._getPopupData, this); + this._map.on('dblclick', this._resetPopupState, this); + } + + // add copyright text listed in service metadata + this.metadata(function (err, metadata) { + if (!err && !this.options.attribution && map.attributionControl && metadata.copyrightText) { + this.options.attribution = metadata.copyrightText; + map.attributionControl.addAttribution(this.getAttribution()); + } + }, this); + }, + + onRemove: function (map) { + if (this._currentImage) { + this._map.removeLayer(this._currentImage); + } + + if (this._popup) { + this._map.off('click', this._getPopupData, this); + this._map.off('dblclick', this._resetPopupState, this); + } + + this._map.off('moveend', this._update, this); + }, + + bindPopup: function (fn, popupOptions) { + this._shouldRenderPopup = false; + this._lastClick = false; + this._popup = leaflet.popup(popupOptions); + this._popupFunction = fn; + if (this._map) { + this._map.on('click', this._getPopupData, this); + this._map.on('dblclick', this._resetPopupState, this); + } + return this; + }, + + unbindPopup: function () { + if (this._map) { + this._map.closePopup(this._popup); + this._map.off('click', this._getPopupData, this); + this._map.off('dblclick', this._resetPopupState, this); + } + this._popup = false; + return this; + }, + + bringToFront: function () { + this.options.position = 'front'; + if (this._currentImage) { + this._currentImage.bringToFront(); + this._setAutoZIndex(Math.max); + } + return this; + }, + + bringToBack: function () { + this.options.position = 'back'; + if (this._currentImage) { + this._currentImage.bringToBack(); + this._setAutoZIndex(Math.min); + } + return this; + }, + + setZIndex: function (value) { + this.options.zIndex = value; + if (this._currentImage) { + this._currentImage.setZIndex(value); + } + return this; + }, + + _setAutoZIndex: function (compare) { + // go through all other layers of the same pane, set zIndex to max + 1 (front) or min - 1 (back) + if (!this._currentImage) { + return; + } + var layers = this._currentImage.getPane().children; + var edgeZIndex = -compare(-Infinity, Infinity); // -Infinity for max, Infinity for min + for (var i = 0, len = layers.length, zIndex; i < len; i++) { + zIndex = layers[i].style.zIndex; + if (layers[i] !== this._currentImage._image && zIndex) { + edgeZIndex = compare(edgeZIndex, +zIndex); + } + } + + if (isFinite(edgeZIndex)) { + this.options.zIndex = edgeZIndex + compare(-1, 1); + this.setZIndex(this.options.zIndex); + } + }, + + getAttribution: function () { + return this.options.attribution; + }, + + getOpacity: function () { + return this.options.opacity; + }, + + setOpacity: function (opacity) { + this.options.opacity = opacity; + if (this._currentImage) { + this._currentImage.setOpacity(opacity); + } + return this; + }, + + getTimeRange: function () { + return [this.options.from, this.options.to]; + }, + + setTimeRange: function (from, to) { + this.options.from = from; + this.options.to = to; + this._update(); + return this; + }, + + metadata: function (callback, context) { + this.service.metadata(callback, context); + return this; + }, + + authenticate: function (token) { + this.service.authenticate(token); + return this; + }, + + redraw: function () { + this._update(); + }, + + _renderImage: function (url, bounds, contentType) { + if (this._map) { + // if no output directory has been specified for a service, MIME data will be returned + if (contentType) { + url = 'data:' + contentType + ';base64,' + url; + } + + // if server returns an inappropriate response, abort. + if (!url) return; + + // create a new image overlay and add it to the map + // to start loading the image + // opacity is 0 while the image is loading + var image = new Overlay(url, bounds, { + opacity: 0, + crossOrigin: this.options.useCors, + alt: this.options.alt, + pane: this.options.pane || this.getPane(), + interactive: this.options.interactive + }).addTo(this._map); + + var onOverlayError = function () { + this._map.removeLayer(image); + this.fire('error'); + image.off('load', onOverlayLoad, this); + }; + + var onOverlayLoad = function (e) { + image.off('error', onOverlayLoad, this); + if (this._map) { + var newImage = e.target; + var oldImage = this._currentImage; + + // if the bounds of this image matches the bounds that + // _renderImage was called with and we have a map with the same bounds + // hide the old image if there is one and set the opacity + // of the new image otherwise remove the new image + if (newImage._bounds.equals(bounds) && newImage._bounds.equals(this._map.getBounds())) { + this._currentImage = newImage; + + if (this.options.position === 'front') { + this.bringToFront(); + } else if (this.options.position === 'back') { + this.bringToBack(); + } + + if (this.options.zIndex) { + this.setZIndex(this.options.zIndex); + } + + if (this._map && this._currentImage._map) { + this._currentImage.setOpacity(this.options.opacity); + } else { + this._currentImage._map.removeLayer(this._currentImage); + } + + if (oldImage && this._map) { + this._map.removeLayer(oldImage); + } + + if (oldImage && oldImage._map) { + oldImage._map.removeLayer(oldImage); + } + } else { + this._map.removeLayer(newImage); + } + } + + this.fire('load', { + bounds: bounds + }); + }; + + // If loading the image fails + image.once('error', onOverlayError, this); + + // once the image loads + image.once('load', onOverlayLoad, this); + } + }, + + _update: function () { + if (!this._map) { + return; + } + + var zoom = this._map.getZoom(); + var bounds = this._map.getBounds(); + + if (this._animatingZoom) { + return; + } + + if (this._map._panTransition && this._map._panTransition._inProgress) { + return; + } + + if (zoom > this.options.maxZoom || zoom < this.options.minZoom) { + if (this._currentImage) { + this._currentImage._map.removeLayer(this._currentImage); + this._currentImage = null; + } + return; + } + + var params = this._buildExportParams(); + leaflet.Util.extend(params, this.options.requestParams); + + if (params) { + this._requestExport(params, bounds); + + this.fire('loading', { + bounds: bounds + }); + } else if (this._currentImage) { + this._currentImage._map.removeLayer(this._currentImage); + this._currentImage = null; + } + }, + + _renderPopup: function (latlng, error, results, response) { + latlng = leaflet.latLng(latlng); + if (this._shouldRenderPopup && this._lastClick.equals(latlng)) { + // add the popup to the map where the mouse was clicked at + var content = this._popupFunction(error, results, response); + if (content) { + this._popup.setLatLng(latlng).setContent(content).openOn(this._map); + } + } + }, + + _resetPopupState: function (e) { + this._shouldRenderPopup = false; + this._lastClick = e.latlng; + }, + + _calculateBbox: function () { + var pixelBounds = this._map.getPixelBounds(); + + var sw = this._map.unproject(pixelBounds.getBottomLeft()); + var ne = this._map.unproject(pixelBounds.getTopRight()); + + var neProjected = this._map.options.crs.project(ne); + var swProjected = this._map.options.crs.project(sw); + + // this ensures ne/sw are switched in polar maps where north/top bottom/south is inverted + var boundsProjected = leaflet.bounds(neProjected, swProjected); + + return [boundsProjected.getBottomLeft().x, boundsProjected.getBottomLeft().y, boundsProjected.getTopRight().x, boundsProjected.getTopRight().y].join(','); + }, + + _calculateImageSize: function () { + // ensure that we don't ask ArcGIS Server for a taller image than we have actual map displaying within the div + var bounds = this._map.getPixelBounds(); + var size = this._map.getSize(); + + var sw = this._map.unproject(bounds.getBottomLeft()); + var ne = this._map.unproject(bounds.getTopRight()); + + var top = this._map.latLngToLayerPoint(ne).y; + var bottom = this._map.latLngToLayerPoint(sw).y; + + if (top > 0 || bottom < size.y) { + size.y = bottom - top; + } + + return size.x + ',' + size.y; + } +}); + +var ImageMapLayer = RasterLayer.extend({ + + options: { + updateInterval: 150, + format: 'jpgpng', + transparent: true, + f: 'image' + }, + + query: function () { + return this.service.query(); + }, + + identify: function () { + return this.service.identify(); + }, + + initialize: function (options) { + options = getUrlParams(options); + this.service = imageService(options); + this.service.addEventParent(this); + + leaflet.Util.setOptions(this, options); + }, + + setPixelType: function (pixelType) { + this.options.pixelType = pixelType; + this._update(); + return this; + }, + + getPixelType: function () { + return this.options.pixelType; + }, + + setBandIds: function (bandIds) { + if (leaflet.Util.isArray(bandIds)) { + this.options.bandIds = bandIds.join(','); + } else { + this.options.bandIds = bandIds.toString(); + } + this._update(); + return this; + }, + + getBandIds: function () { + return this.options.bandIds; + }, + + setNoData: function (noData, noDataInterpretation) { + if (leaflet.Util.isArray(noData)) { + this.options.noData = noData.join(','); + } else { + this.options.noData = noData.toString(); + } + if (noDataInterpretation) { + this.options.noDataInterpretation = noDataInterpretation; + } + this._update(); + return this; + }, + + getNoData: function () { + return this.options.noData; + }, + + getNoDataInterpretation: function () { + return this.options.noDataInterpretation; + }, + + setRenderingRule: function (renderingRule) { + this.options.renderingRule = renderingRule; + this._update(); + }, + + getRenderingRule: function () { + return this.options.renderingRule; + }, + + setMosaicRule: function (mosaicRule) { + this.options.mosaicRule = mosaicRule; + this._update(); + }, + + getMosaicRule: function () { + return this.options.mosaicRule; + }, + + _getPopupData: function (e) { + var callback = leaflet.Util.bind(function (error, results, response) { + if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire + setTimeout(leaflet.Util.bind(function () { + this._renderPopup(e.latlng, error, results, response); + }, this), 300); + }, this); + + var identifyRequest = this.identify().at(e.latlng); + + // set mosaic rule for identify task if it is set for layer + if (this.options.mosaicRule) { + identifyRequest.setMosaicRule(this.options.mosaicRule); + // @TODO: force return catalog items too? + } + + // @TODO: set rendering rule? Not sure, + // sometimes you want raw pixel values + // if (this.options.renderingRule) { + // identifyRequest.setRenderingRule(this.options.renderingRule); + // } + + identifyRequest.run(callback); + + // set the flags to show the popup + this._shouldRenderPopup = true; + this._lastClick = e.latlng; + }, + + _buildExportParams: function () { + var sr = parseInt(this._map.options.crs.code.split(':')[1], 10); + + var params = { + bbox: this._calculateBbox(), + size: this._calculateImageSize(), + format: this.options.format, + transparent: this.options.transparent, + bboxSR: sr, + imageSR: sr + }; + + if (this.options.from && this.options.to) { + params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf(); + } + + if (this.options.pixelType) { + params.pixelType = this.options.pixelType; + } + + if (this.options.interpolation) { + params.interpolation = this.options.interpolation; + } + + if (this.options.compressionQuality) { + params.compressionQuality = this.options.compressionQuality; + } + + if (this.options.bandIds) { + params.bandIds = this.options.bandIds; + } + + // 0 is falsy *and* a valid input parameter + if (this.options.noData === 0 || this.options.noData) { + params.noData = this.options.noData; + } + + if (this.options.noDataInterpretation) { + params.noDataInterpretation = this.options.noDataInterpretation; + } + + if (this.service.options.token) { + params.token = this.service.options.token; + } + + if (this.options.renderingRule) { + params.renderingRule = JSON.stringify(this.options.renderingRule); + } + + if (this.options.mosaicRule) { + params.mosaicRule = JSON.stringify(this.options.mosaicRule); + } + + return params; + }, + + _requestExport: function (params, bounds) { + if (this.options.f === 'json') { + this.service.request('exportImage', params, function (error, response) { + if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire + if (this.options.token) { + response.href += ('?token=' + this.options.token); + } + if (this.options.proxy) { + response.href = this.options.proxy + '?' + response.href; + } + this._renderImage(response.href, bounds); + }, this); + } else { + params.f = 'image'; + this._renderImage(this.options.url + 'exportImage' + leaflet.Util.getParamString(params), bounds); + } + } +}); + +function imageMapLayer (url, options) { + return new ImageMapLayer(url, options); +} + +var DynamicMapLayer = RasterLayer.extend({ + + options: { + updateInterval: 150, + layers: false, + layerDefs: false, + timeOptions: false, + format: 'png24', + transparent: true, + f: 'json' + }, + + initialize: function (options) { + options = getUrlParams(options); + this.service = mapService(options); + this.service.addEventParent(this); + + if ((options.proxy || options.token) && options.f !== 'json') { + options.f = 'json'; + } + + leaflet.Util.setOptions(this, options); + }, + + getDynamicLayers: function () { + return this.options.dynamicLayers; + }, + + setDynamicLayers: function (dynamicLayers) { + this.options.dynamicLayers = dynamicLayers; + this._update(); + return this; + }, + + getLayers: function () { + return this.options.layers; + }, + + setLayers: function (layers) { + this.options.layers = layers; + this._update(); + return this; + }, + + getLayerDefs: function () { + return this.options.layerDefs; + }, + + setLayerDefs: function (layerDefs) { + this.options.layerDefs = layerDefs; + this._update(); + return this; + }, + + getTimeOptions: function () { + return this.options.timeOptions; + }, + + setTimeOptions: function (timeOptions) { + this.options.timeOptions = timeOptions; + this._update(); + return this; + }, + + query: function () { + return this.service.query(); + }, + + identify: function () { + return this.service.identify(); + }, + + find: function () { + return this.service.find(); + }, + + _getPopupData: function (e) { + var callback = leaflet.Util.bind(function (error, featureCollection, response) { + if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire + setTimeout(leaflet.Util.bind(function () { + this._renderPopup(e.latlng, error, featureCollection, response); + }, this), 300); + }, this); + + var identifyRequest; + if (this.options.popup) { + identifyRequest = this.options.popup.on(this._map).at(e.latlng); + } else { + identifyRequest = this.identify().on(this._map).at(e.latlng); + } + + // remove extraneous vertices from response features if it has not already been done + identifyRequest.params.maxAllowableOffset ? true : identifyRequest.simplify(this._map, 0.5); + + if (!(this.options.popup && this.options.popup.params && this.options.popup.params.layers)) { + if (this.options.layers) { + identifyRequest.layers('visible:' + this.options.layers.join(',')); + } else { + identifyRequest.layers('visible'); + } + } + + // if present, pass layer ids and sql filters through to the identify task + if (this.options.layerDefs && typeof this.options.layerDefs !== 'string' && !identifyRequest.params.layerDefs) { + for (var id in this.options.layerDefs) { + if (this.options.layerDefs.hasOwnProperty(id)) { + identifyRequest.layerDef(id, this.options.layerDefs[id]); + } + } + } + + identifyRequest.run(callback); + + // set the flags to show the popup + this._shouldRenderPopup = true; + this._lastClick = e.latlng; + }, + + _buildExportParams: function () { + var sr = parseInt(this._map.options.crs.code.split(':')[1], 10); + + var params = { + bbox: this._calculateBbox(), + size: this._calculateImageSize(), + dpi: 96, + format: this.options.format, + transparent: this.options.transparent, + bboxSR: sr, + imageSR: sr + }; + + if (this.options.dynamicLayers) { + params.dynamicLayers = this.options.dynamicLayers; + } + + if (this.options.layers) { + if (this.options.layers.length === 0) { + return; + } else { + params.layers = 'show:' + this.options.layers.join(','); + } + } + + if (this.options.layerDefs) { + params.layerDefs = typeof this.options.layerDefs === 'string' ? this.options.layerDefs : JSON.stringify(this.options.layerDefs); + } + + if (this.options.timeOptions) { + params.timeOptions = JSON.stringify(this.options.timeOptions); + } + + if (this.options.from && this.options.to) { + params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf(); + } + + if (this.service.options.token) { + params.token = this.service.options.token; + } + + if (this.options.proxy) { + params.proxy = this.options.proxy; + } + + // use a timestamp to bust server cache + if (this.options.disableCache) { + params._ts = Date.now(); + } + + return params; + }, + + _requestExport: function (params, bounds) { + if (this.options.f === 'json') { + this.service.request('export', params, function (error, response) { + if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire + + if (this.options.token && response.href) { + response.href += ('?token=' + this.options.token); + } + if (this.options.proxy && response.href) { + response.href = this.options.proxy + '?' + response.href; + } + if (response.href) { + this._renderImage(response.href, bounds); + } else { + this._renderImage(response.imageData, bounds, response.contentType); + } + }, this); + } else { + params.f = 'image'; + this._renderImage(this.options.url + 'export' + leaflet.Util.getParamString(params), bounds); + } + } +}); + +function dynamicMapLayer (url, options) { + return new DynamicMapLayer(url, options); +} + +var VirtualGrid = leaflet.Layer.extend({ + + options: { + cellSize: 512, + updateInterval: 150 + }, + + initialize: function (options) { + options = leaflet.setOptions(this, options); + this._zooming = false; + }, + + onAdd: function (map) { + this._map = map; + this._update = leaflet.Util.throttle(this._update, this.options.updateInterval, this); + this._reset(); + this._update(); + }, + + onRemove: function () { + this._map.removeEventListener(this.getEvents(), this); + this._removeCells(); + }, + + getEvents: function () { + var events = { + moveend: this._update, + zoomstart: this._zoomstart, + zoomend: this._reset + }; + + return events; + }, + + addTo: function (map) { + map.addLayer(this); + return this; + }, + + removeFrom: function (map) { + map.removeLayer(this); + return this; + }, + + _zoomstart: function () { + this._zooming = true; + }, + + _reset: function () { + this._removeCells(); + + this._cells = {}; + this._activeCells = {}; + this._cellsToLoad = 0; + this._cellsTotal = 0; + this._cellNumBounds = this._getCellNumBounds(); + + this._resetWrap(); + this._zooming = false; + }, + + _resetWrap: function () { + var map = this._map; + var crs = map.options.crs; + + if (crs.infinite) { return; } + + var cellSize = this._getCellSize(); + + if (crs.wrapLng) { + this._wrapLng = [ + Math.floor(map.project([0, crs.wrapLng[0]]).x / cellSize), + Math.ceil(map.project([0, crs.wrapLng[1]]).x / cellSize) + ]; + } + + if (crs.wrapLat) { + this._wrapLat = [ + Math.floor(map.project([crs.wrapLat[0], 0]).y / cellSize), + Math.ceil(map.project([crs.wrapLat[1], 0]).y / cellSize) + ]; + } + }, + + _getCellSize: function () { + return this.options.cellSize; + }, + + _update: function () { + if (!this._map) { + return; + } + + var mapBounds = this._map.getPixelBounds(); + var cellSize = this._getCellSize(); + + // cell coordinates range for the current view + var cellBounds = leaflet.bounds( + mapBounds.min.divideBy(cellSize).floor(), + mapBounds.max.divideBy(cellSize).floor()); + + this._removeOtherCells(cellBounds); + this._addCells(cellBounds); + + this.fire('cellsupdated'); + }, + + _addCells: function (cellBounds) { + var queue = []; + var center = cellBounds.getCenter(); + var zoom = this._map.getZoom(); + + var j, i, coords; + // create a queue of coordinates to load cells from + for (j = cellBounds.min.y; j <= cellBounds.max.y; j++) { + for (i = cellBounds.min.x; i <= cellBounds.max.x; i++) { + coords = leaflet.point(i, j); + coords.z = zoom; + + if (this._isValidCell(coords)) { + queue.push(coords); + } + } + } + + var cellsToLoad = queue.length; + + if (cellsToLoad === 0) { return; } + + this._cellsToLoad += cellsToLoad; + this._cellsTotal += cellsToLoad; + + // sort cell queue to load cells in order of their distance to center + queue.sort(function (a, b) { + return a.distanceTo(center) - b.distanceTo(center); + }); + + for (i = 0; i < cellsToLoad; i++) { + this._addCell(queue[i]); + } + }, + + _isValidCell: function (coords) { + var crs = this._map.options.crs; + + if (!crs.infinite) { + // don't load cell if it's out of bounds and not wrapped + var cellNumBounds = this._cellNumBounds; + + if (!cellNumBounds) return false; + if ( + (!crs.wrapLng && (coords.x < cellNumBounds.min.x || coords.x > cellNumBounds.max.x)) || + (!crs.wrapLat && (coords.y < cellNumBounds.min.y || coords.y > cellNumBounds.max.y)) + ) { + return false; + } + } + + if (!this.options.bounds) { + return true; + } + + // don't load cell if it doesn't intersect the bounds in options + var cellBounds = this._cellCoordsToBounds(coords); + return leaflet.latLngBounds(this.options.bounds).intersects(cellBounds); + }, + + // converts cell coordinates to its geographical bounds + _cellCoordsToBounds: function (coords) { + var map = this._map; + var cellSize = this.options.cellSize; + var nwPoint = coords.multiplyBy(cellSize); + var sePoint = nwPoint.add([cellSize, cellSize]); + var nw = map.wrapLatLng(map.unproject(nwPoint, coords.z)); + var se = map.wrapLatLng(map.unproject(sePoint, coords.z)); + + return leaflet.latLngBounds(nw, se); + }, + + // converts cell coordinates to key for the cell cache + _cellCoordsToKey: function (coords) { + return coords.x + ':' + coords.y; + }, + + // converts cell cache key to coordiantes + _keyToCellCoords: function (key) { + var kArr = key.split(':'); + var x = parseInt(kArr[0], 10); + var y = parseInt(kArr[1], 10); + + return leaflet.point(x, y); + }, + + // remove any present cells that are off the specified bounds + _removeOtherCells: function (bounds) { + for (var key in this._cells) { + if (!bounds.contains(this._keyToCellCoords(key))) { + this._removeCell(key); + } + } + }, + + _removeCell: function (key) { + var cell = this._activeCells[key]; + + if (cell) { + delete this._activeCells[key]; + + if (this.cellLeave) { + this.cellLeave(cell.bounds, cell.coords); + } + + this.fire('cellleave', { + bounds: cell.bounds, + coords: cell.coords + }); + } + }, + + _removeCells: function () { + for (var key in this._cells) { + var cellBounds = this._cells[key].bounds; + var coords = this._cells[key].coords; + + if (this.cellLeave) { + this.cellLeave(cellBounds, coords); + } + + this.fire('cellleave', { + bounds: cellBounds, + coords: coords + }); + } + }, + + _addCell: function (coords) { + // wrap cell coords if necessary (depending on CRS) + this._wrapCoords(coords); + + // generate the cell key + var key = this._cellCoordsToKey(coords); + + // get the cell from the cache + var cell = this._cells[key]; + // if this cell should be shown as isnt active yet (enter) + + if (cell && !this._activeCells[key]) { + if (this.cellEnter) { + this.cellEnter(cell.bounds, coords); + } + + this.fire('cellenter', { + bounds: cell.bounds, + coords: coords + }); + + this._activeCells[key] = cell; + } + + // if we dont have this cell in the cache yet (create) + if (!cell) { + cell = { + coords: coords, + bounds: this._cellCoordsToBounds(coords) + }; + + this._cells[key] = cell; + this._activeCells[key] = cell; + + if (this.createCell) { + this.createCell(cell.bounds, coords); + } + + this.fire('cellcreate', { + bounds: cell.bounds, + coords: coords + }); + } + }, + + _wrapCoords: function (coords) { + coords.x = this._wrapLng ? leaflet.Util.wrapNum(coords.x, this._wrapLng) : coords.x; + coords.y = this._wrapLat ? leaflet.Util.wrapNum(coords.y, this._wrapLat) : coords.y; + }, + + // get the global cell coordinates range for the current zoom + _getCellNumBounds: function () { + var worldBounds = this._map.getPixelWorldBounds(); + var size = this._getCellSize(); + + return worldBounds ? leaflet.bounds( + worldBounds.min.divideBy(size).floor(), + worldBounds.max.divideBy(size).ceil().subtract([1, 1])) : null; + } +}); + +function BinarySearchIndex (values) { + this.values = [].concat(values || []); +} + +BinarySearchIndex.prototype.query = function (value) { + var index = this.getIndex(value); + return this.values[index]; +}; + +BinarySearchIndex.prototype.getIndex = function getIndex (value) { + if (this.dirty) { + this.sort(); + } + + var minIndex = 0; + var maxIndex = this.values.length - 1; + var currentIndex; + var currentElement; + + while (minIndex <= maxIndex) { + currentIndex = (minIndex + maxIndex) / 2 | 0; + currentElement = this.values[Math.round(currentIndex)]; + if (+currentElement.value < +value) { + minIndex = currentIndex + 1; + } else if (+currentElement.value > +value) { + maxIndex = currentIndex - 1; + } else { + return currentIndex; + } + } + + return Math.abs(~maxIndex); +}; + +BinarySearchIndex.prototype.between = function between (start, end) { + var startIndex = this.getIndex(start); + var endIndex = this.getIndex(end); + + if (startIndex === 0 && endIndex === 0) { + return []; + } + + while (this.values[startIndex - 1] && this.values[startIndex - 1].value === start) { + startIndex--; + } + + while (this.values[endIndex + 1] && this.values[endIndex + 1].value === end) { + endIndex++; + } + + if (this.values[endIndex] && this.values[endIndex].value === end && this.values[endIndex + 1]) { + endIndex++; + } + + return this.values.slice(startIndex, endIndex); +}; + +BinarySearchIndex.prototype.insert = function insert (item) { + this.values.splice(this.getIndex(item.value), 0, item); + return this; +}; + +BinarySearchIndex.prototype.bulkAdd = function bulkAdd (items, sort) { + this.values = this.values.concat([].concat(items || [])); + + if (sort) { + this.sort(); + } else { + this.dirty = true; + } + + return this; +}; + +BinarySearchIndex.prototype.sort = function sort () { + this.values.sort(function (a, b) { + return +b.value - +a.value; + }).reverse(); + this.dirty = false; + return this; +}; + +var FeatureManager = VirtualGrid.extend({ + /** + * Options + */ + + options: { + attribution: null, + where: '1=1', + fields: ['*'], + from: false, + to: false, + timeField: false, + timeFilterMode: 'server', + simplifyFactor: 0, + precision: 6 + }, + + /** + * Constructor + */ + + initialize: function (options) { + VirtualGrid.prototype.initialize.call(this, options); + + options = getUrlParams(options); + options = leaflet.Util.setOptions(this, options); + + this.service = featureLayerService(options); + this.service.addEventParent(this); + + // use case insensitive regex to look for common fieldnames used for indexing + if (this.options.fields[0] !== '*') { + var oidCheck = false; + for (var i = 0; i < this.options.fields.length; i++) { + if (this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i)) { + oidCheck = true; + } + } + if (oidCheck === false) { + warn('no known esriFieldTypeOID field detected in fields Array. Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.'); + } + } + + if (this.options.timeField.start && this.options.timeField.end) { + this._startTimeIndex = new BinarySearchIndex(); + this._endTimeIndex = new BinarySearchIndex(); + } else if (this.options.timeField) { + this._timeIndex = new BinarySearchIndex(); + } + + this._cache = {}; + this._currentSnapshot = []; // cache of what layers should be active + this._activeRequests = 0; + }, + + /** + * Layer Interface + */ + + onAdd: function (map) { + // include 'Powered by Esri' in map attribution + setEsriAttribution(map); + + this.service.metadata(function (err, metadata) { + if (!err) { + var supportedFormats = metadata.supportedQueryFormats; + + // Check if someone has requested that we don't use geoJSON, even if it's available + var forceJsonFormat = false; + if (this.service.options.isModern === false) { + forceJsonFormat = true; + } + + // Unless we've been told otherwise, check to see whether service can emit GeoJSON natively + if (!forceJsonFormat && supportedFormats && supportedFormats.indexOf('geoJSON') !== -1) { + this.service.options.isModern = true; + } + + if (metadata.objectIdField) { + this.service.options.idAttribute = metadata.objectIdField; + } + + // add copyright text listed in service metadata + if (!this.options.attribution && map.attributionControl && metadata.copyrightText) { + this.options.attribution = metadata.copyrightText; + map.attributionControl.addAttribution(this.getAttribution()); + } + } + }, this); + + map.on('zoomend', this._handleZoomChange, this); + + return VirtualGrid.prototype.onAdd.call(this, map); + }, + + onRemove: function (map) { + map.off('zoomend', this._handleZoomChange, this); + + return VirtualGrid.prototype.onRemove.call(this, map); + }, + + getAttribution: function () { + return this.options.attribution; + }, + + /** + * Feature Management + */ + + createCell: function (bounds, coords) { + // dont fetch features outside the scale range defined for the layer + if (this._visibleZoom()) { + this._requestFeatures(bounds, coords); + } + }, + + _requestFeatures: function (bounds, coords, callback) { + this._activeRequests++; + + // our first active request fires loading + if (this._activeRequests === 1) { + this.fire('loading', { + bounds: bounds + }, true); + } + + return this._buildQuery(bounds).run(function (error, featureCollection, response) { + if (response && response.exceededTransferLimit) { + this.fire('drawlimitexceeded'); + } + + // no error, features + if (!error && featureCollection && featureCollection.features.length) { + // schedule adding features until the next animation frame + leaflet.Util.requestAnimFrame(leaflet.Util.bind(function () { + this._addFeatures(featureCollection.features, coords); + this._postProcessFeatures(bounds); + }, this)); + } + + // no error, no features + if (!error && featureCollection && !featureCollection.features.length) { + this._postProcessFeatures(bounds); + } + + if (error) { + this._postProcessFeatures(bounds); + } + + if (callback) { + callback.call(this, error, featureCollection); + } + }, this); + }, + + _postProcessFeatures: function (bounds) { + // deincrement the request counter now that we have processed features + this._activeRequests--; + + // if there are no more active requests fire a load event for this view + if (this._activeRequests <= 0) { + this.fire('load', { + bounds: bounds + }); + } + }, + + _cacheKey: function (coords) { + return coords.z + ':' + coords.x + ':' + coords.y; + }, + + _addFeatures: function (features, coords) { + var key = this._cacheKey(coords); + this._cache[key] = this._cache[key] || []; + + for (var i = features.length - 1; i >= 0; i--) { + var id = features[i].id; + + if (this._currentSnapshot.indexOf(id) === -1) { + this._currentSnapshot.push(id); + } + if (this._cache[key].indexOf(id) === -1) { + this._cache[key].push(id); + } + } + + if (this.options.timeField) { + this._buildTimeIndexes(features); + } + + this.createLayers(features); + }, + + _buildQuery: function (bounds) { + var query = this.service.query() + .intersects(bounds) + .where(this.options.where) + .fields(this.options.fields) + .precision(this.options.precision); + + if (this.options.requestParams) { + leaflet.Util.extend(query.params, this.options.requestParams); + } + + if (this.options.simplifyFactor) { + query.simplify(this._map, this.options.simplifyFactor); + } + + if (this.options.timeFilterMode === 'server' && this.options.from && this.options.to) { + query.between(this.options.from, this.options.to); + } + + return query; + }, + + /** + * Where Methods + */ + + setWhere: function (where, callback, context) { + this.options.where = (where && where.length) ? where : '1=1'; + + var oldSnapshot = []; + var newSnapshot = []; + var pendingRequests = 0; + var requestError = null; + var requestCallback = leaflet.Util.bind(function (error, featureCollection) { + if (error) { + requestError = error; + } + + if (featureCollection) { + for (var i = featureCollection.features.length - 1; i >= 0; i--) { + newSnapshot.push(featureCollection.features[i].id); + } + } + + pendingRequests--; + + if (pendingRequests <= 0 && this._visibleZoom()) { + this._currentSnapshot = newSnapshot; + // schedule adding features for the next animation frame + leaflet.Util.requestAnimFrame(leaflet.Util.bind(function () { + this.removeLayers(oldSnapshot); + this.addLayers(newSnapshot); + if (callback) { + callback.call(context, requestError); + } + }, this)); + } + }, this); + + for (var i = this._currentSnapshot.length - 1; i >= 0; i--) { + oldSnapshot.push(this._currentSnapshot[i]); + } + + for (var key in this._activeCells) { + pendingRequests++; + var coords = this._keyToCellCoords(key); + var bounds = this._cellCoordsToBounds(coords); + this._requestFeatures(bounds, key, requestCallback); + } + + return this; + }, + + getWhere: function () { + return this.options.where; + }, + + /** + * Time Range Methods + */ + + getTimeRange: function () { + return [this.options.from, this.options.to]; + }, + + setTimeRange: function (from, to, callback, context) { + var oldFrom = this.options.from; + var oldTo = this.options.to; + var pendingRequests = 0; + var requestError = null; + var requestCallback = leaflet.Util.bind(function (error) { + if (error) { + requestError = error; + } + this._filterExistingFeatures(oldFrom, oldTo, from, to); + + pendingRequests--; + + if (callback && pendingRequests <= 0) { + callback.call(context, requestError); + } + }, this); + + this.options.from = from; + this.options.to = to; + + this._filterExistingFeatures(oldFrom, oldTo, from, to); + + if (this.options.timeFilterMode === 'server') { + for (var key in this._activeCells) { + pendingRequests++; + var coords = this._keyToCellCoords(key); + var bounds = this._cellCoordsToBounds(coords); + this._requestFeatures(bounds, key, requestCallback); + } + } + + return this; + }, + + refresh: function () { + for (var key in this._activeCells) { + var coords = this._keyToCellCoords(key); + var bounds = this._cellCoordsToBounds(coords); + this._requestFeatures(bounds, key); + } + + if (this.redraw) { + this.once('load', function () { + this.eachFeature(function (layer) { + this._redraw(layer.feature.id); + }, this); + }, this); + } + }, + + _filterExistingFeatures: function (oldFrom, oldTo, newFrom, newTo) { + var layersToRemove = (oldFrom && oldTo) ? this._getFeaturesInTimeRange(oldFrom, oldTo) : this._currentSnapshot; + var layersToAdd = this._getFeaturesInTimeRange(newFrom, newTo); + + if (layersToAdd.indexOf) { + for (var i = 0; i < layersToAdd.length; i++) { + var shouldRemoveLayer = layersToRemove.indexOf(layersToAdd[i]); + if (shouldRemoveLayer >= 0) { + layersToRemove.splice(shouldRemoveLayer, 1); + } + } + } + + // schedule adding features until the next animation frame + leaflet.Util.requestAnimFrame(leaflet.Util.bind(function () { + this.removeLayers(layersToRemove); + this.addLayers(layersToAdd); + }, this)); + }, + + _getFeaturesInTimeRange: function (start, end) { + var ids = []; + var search; + + if (this.options.timeField.start && this.options.timeField.end) { + var startTimes = this._startTimeIndex.between(start, end); + var endTimes = this._endTimeIndex.between(start, end); + search = startTimes.concat(endTimes); + } else if (this._timeIndex) { + search = this._timeIndex.between(start, end); + } else { + warn('You must set timeField in the layer constructor in order to manipulate the start and end time filter.'); + return []; + } + + for (var i = search.length - 1; i >= 0; i--) { + ids.push(search[i].id); + } + + return ids; + }, + + _buildTimeIndexes: function (geojson) { + var i; + var feature; + if (this.options.timeField.start && this.options.timeField.end) { + var startTimeEntries = []; + var endTimeEntries = []; + for (i = geojson.length - 1; i >= 0; i--) { + feature = geojson[i]; + startTimeEntries.push({ + id: feature.id, + value: new Date(feature.properties[this.options.timeField.start]) + }); + endTimeEntries.push({ + id: feature.id, + value: new Date(feature.properties[this.options.timeField.end]) + }); + } + this._startTimeIndex.bulkAdd(startTimeEntries); + this._endTimeIndex.bulkAdd(endTimeEntries); + } else { + var timeEntries = []; + for (i = geojson.length - 1; i >= 0; i--) { + feature = geojson[i]; + timeEntries.push({ + id: feature.id, + value: new Date(feature.properties[this.options.timeField]) + }); + } + + this._timeIndex.bulkAdd(timeEntries); + } + }, + + _featureWithinTimeRange: function (feature) { + if (!this.options.from || !this.options.to) { + return true; + } + + var from = +this.options.from.valueOf(); + var to = +this.options.to.valueOf(); + + if (typeof this.options.timeField === 'string') { + var date = +feature.properties[this.options.timeField]; + return (date >= from) && (date <= to); + } + + if (this.options.timeField.start && this.options.timeField.end) { + var startDate = +feature.properties[this.options.timeField.start]; + var endDate = +feature.properties[this.options.timeField.end]; + return ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to)); + } + }, + + _visibleZoom: function () { + // check to see whether the current zoom level of the map is within the optional limit defined for the FeatureLayer + if (!this._map) { + return false; + } + var zoom = this._map.getZoom(); + if (zoom > this.options.maxZoom || zoom < this.options.minZoom) { + return false; + } else { return true; } + }, + + _handleZoomChange: function () { + if (!this._visibleZoom()) { + this.removeLayers(this._currentSnapshot); + this._currentSnapshot = []; + } else { + /* + for every cell in this._activeCells + 1. Get the cache key for the coords of the cell + 2. If this._cache[key] exists it will be an array of feature IDs. + 3. Call this.addLayers(this._cache[key]) to instruct the feature layer to add the layers back. + */ + for (var i in this._activeCells) { + var coords = this._activeCells[i].coords; + var key = this._cacheKey(coords); + if (this._cache[key]) { + this.addLayers(this._cache[key]); + } + } + } + }, + + /** + * Service Methods + */ + + authenticate: function (token) { + this.service.authenticate(token); + return this; + }, + + metadata: function (callback, context) { + this.service.metadata(callback, context); + return this; + }, + + query: function () { + return this.service.query(); + }, + + _getMetadata: function (callback) { + if (this._metadata) { + var error; + callback(error, this._metadata); + } else { + this.metadata(leaflet.Util.bind(function (error, response) { + this._metadata = response; + callback(error, this._metadata); + }, this)); + } + }, + + addFeature: function (feature, callback, context) { + this.addFeatures(feature, callback, context); + }, + + addFeatures: function (features, callback, context) { + this._getMetadata(leaflet.Util.bind(function (error, metadata) { + if (error) { + if (callback) { callback.call(this, error, null); } + return; + } + // GeoJSON featureCollection or simple feature + var featuresArray = features.features ? features.features : [features]; + + this.service.addFeatures(features, leaflet.Util.bind(function (error, response) { + if (!error) { + for (var i = featuresArray.length - 1; i >= 0; i--) { + // assign ID from result to appropriate objectid field from service metadata + featuresArray[i].properties[metadata.objectIdField] = featuresArray.length > 1 ? response[i].objectId : response.objectId; + // we also need to update the geojson id for createLayers() to function + featuresArray[i].id = featuresArray.length > 1 ? response[i].objectId : response.objectId; + } + this.createLayers(featuresArray); + } + + if (callback) { + callback.call(context, error, response); + } + }, this)); + }, this)); + }, + + updateFeature: function (feature, callback, context) { + this.updateFeatures(feature, callback, context); + }, + + updateFeatures: function (features, callback, context) { + // GeoJSON featureCollection or simple feature + var featuresArray = features.features ? features.features : [features]; + this.service.updateFeatures(features, function (error, response) { + if (!error) { + for (var i = featuresArray.length - 1; i >= 0; i--) { + this.removeLayers([featuresArray[i].id], true); + } + this.createLayers(featuresArray); + } + + if (callback) { + callback.call(context, error, response); + } + }, this); + }, + + deleteFeature: function (id, callback, context) { + this.deleteFeatures(id, callback, context); + }, + + deleteFeatures: function (ids, callback, context) { + return this.service.deleteFeatures(ids, function (error, response) { + var responseArray = response.length ? response : [response]; + if (!error && responseArray.length > 0) { + for (var i = responseArray.length - 1; i >= 0; i--) { + this.removeLayers([responseArray[i].objectId], true); + } + } + if (callback) { + callback.call(context, error, response); + } + }, this); + } +}); + +var FeatureLayer = FeatureManager.extend({ + + options: { + cacheLayers: true + }, + + /** + * Constructor + */ + initialize: function (options) { + FeatureManager.prototype.initialize.call(this, options); + this._originalStyle = this.options.style; + this._layers = {}; + }, + + /** + * Layer Interface + */ + + onRemove: function (map) { + for (var i in this._layers) { + map.removeLayer(this._layers[i]); + // trigger the event when the entire featureLayer is removed from the map + this.fire('removefeature', { + feature: this._layers[i].feature, + permanent: false + }, true); + } + + return FeatureManager.prototype.onRemove.call(this, map); + }, + + createNewLayer: function (geojson) { + var layer = leaflet.GeoJSON.geometryToLayer(geojson, this.options); + // trap for GeoJSON without geometry + if (layer) { + layer.defaultOptions = layer.options; + } + return layer; + }, + + _updateLayer: function (layer, geojson) { + // convert the geojson coordinates into a Leaflet LatLng array/nested arrays + // pass it to setLatLngs to update layer geometries + var latlngs = []; + var coordsToLatLng = this.options.coordsToLatLng || leaflet.GeoJSON.coordsToLatLng; + + // copy new attributes, if present + if (geojson.properties) { + layer.feature.properties = geojson.properties; + } + + switch (geojson.geometry.type) { + case 'Point': + latlngs = leaflet.GeoJSON.coordsToLatLng(geojson.geometry.coordinates); + layer.setLatLng(latlngs); + break; + case 'LineString': + latlngs = leaflet.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 0, coordsToLatLng); + layer.setLatLngs(latlngs); + break; + case 'MultiLineString': + latlngs = leaflet.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng); + layer.setLatLngs(latlngs); + break; + case 'Polygon': + latlngs = leaflet.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng); + layer.setLatLngs(latlngs); + break; + case 'MultiPolygon': + latlngs = leaflet.GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 2, coordsToLatLng); + layer.setLatLngs(latlngs); + break; + } + }, + + /** + * Feature Management Methods + */ + + createLayers: function (features) { + for (var i = features.length - 1; i >= 0; i--) { + var geojson = features[i]; + + var layer = this._layers[geojson.id]; + var newLayer; + + if (this._visibleZoom() && layer && !this._map.hasLayer(layer) && (!this.options.timeField || this._featureWithinTimeRange(geojson))) { + this._map.addLayer(layer); + this.fire('addfeature', { + feature: layer.feature + }, true); + } + + // update geometry if necessary + if (layer && this.options.simplifyFactor > 0 && (layer.setLatLngs || layer.setLatLng)) { + this._updateLayer(layer, geojson); + } + + if (!layer) { + newLayer = this.createNewLayer(geojson); + + if (!newLayer) { + warn('invalid GeoJSON encountered'); + } else { + newLayer.feature = geojson; + + // bubble events from individual layers to the feature layer + newLayer.addEventParent(this); + + if (this.options.onEachFeature) { + this.options.onEachFeature(newLayer.feature, newLayer); + } + + // cache the layer + this._layers[newLayer.feature.id] = newLayer; + + // style the layer + this.setFeatureStyle(newLayer.feature.id, this.options.style); + + this.fire('createfeature', { + feature: newLayer.feature + }, true); + + // 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 + if (this._visibleZoom() && (!this.options.timeField || (this.options.timeField && this._featureWithinTimeRange(geojson)))) { + this._map.addLayer(newLayer); + } + } + } + } + }, + + addLayers: function (ids) { + for (var i = ids.length - 1; i >= 0; i--) { + var layer = this._layers[ids[i]]; + if (layer && (!this.options.timeField || this._featureWithinTimeRange(layer.feature))) { + this._map.addLayer(layer); + } + } + }, + + removeLayers: function (ids, permanent) { + for (var i = ids.length - 1; i >= 0; i--) { + var id = ids[i]; + var layer = this._layers[id]; + if (layer) { + this.fire('removefeature', { + feature: layer.feature, + permanent: permanent + }, true); + this._map.removeLayer(layer); + } + if (layer && permanent) { + delete this._layers[id]; + } + } + }, + + cellEnter: function (bounds, coords) { + if (this._visibleZoom() && !this._zooming && this._map) { + leaflet.Util.requestAnimFrame(leaflet.Util.bind(function () { + var cacheKey = this._cacheKey(coords); + var cellKey = this._cellCoordsToKey(coords); + var layers = this._cache[cacheKey]; + if (this._activeCells[cellKey] && layers) { + this.addLayers(layers); + } + }, this)); + } + }, + + cellLeave: function (bounds, coords) { + if (!this._zooming) { + leaflet.Util.requestAnimFrame(leaflet.Util.bind(function () { + if (this._map) { + var cacheKey = this._cacheKey(coords); + var cellKey = this._cellCoordsToKey(coords); + var layers = this._cache[cacheKey]; + var mapBounds = this._map.getBounds(); + if (!this._activeCells[cellKey] && layers) { + var removable = true; + + for (var i = 0; i < layers.length; i++) { + var layer = this._layers[layers[i]]; + if (layer && layer.getBounds && mapBounds.intersects(layer.getBounds())) { + removable = false; + } + } + + if (removable) { + this.removeLayers(layers, !this.options.cacheLayers); + } + + if (!this.options.cacheLayers && removable) { + delete this._cache[cacheKey]; + delete this._cells[cellKey]; + delete this._activeCells[cellKey]; + } + } + } + }, this)); + } + }, + + /** + * Styling Methods + */ + + resetStyle: function () { + this.options.style = this._originalStyle; + this.eachFeature(function (layer) { + this.resetFeatureStyle(layer.feature.id); + }, this); + return this; + }, + + setStyle: function (style) { + this.options.style = style; + this.eachFeature(function (layer) { + this.setFeatureStyle(layer.feature.id, style); + }, this); + return this; + }, + + resetFeatureStyle: function (id) { + var layer = this._layers[id]; + var style = this._originalStyle || leaflet.Path.prototype.options; + if (layer) { + leaflet.Util.extend(layer.options, layer.defaultOptions); + this.setFeatureStyle(id, style); + } + return this; + }, + + setFeatureStyle: function (id, style) { + var layer = this._layers[id]; + if (typeof style === 'function') { + style = style(layer.feature); + } + if (layer.setStyle) { + layer.setStyle(style); + } + return this; + }, + + /** + * Utility Methods + */ + + eachActiveFeature: function (fn, context) { + // figure out (roughly) which layers are in view + if (this._map) { + var activeBounds = this._map.getBounds(); + for (var i in this._layers) { + if (this._currentSnapshot.indexOf(this._layers[i].feature.id) !== -1) { + // a simple point in poly test for point geometries + if (typeof this._layers[i].getLatLng === 'function' && activeBounds.contains(this._layers[i].getLatLng())) { + fn.call(context, this._layers[i]); + } else if (typeof this._layers[i].getBounds === 'function' && activeBounds.intersects(this._layers[i].getBounds())) { + // intersecting bounds check for polyline and polygon geometries + fn.call(context, this._layers[i]); + } + } + } + } + return this; + }, + + eachFeature: function (fn, context) { + for (var i in this._layers) { + fn.call(context, this._layers[i]); + } + return this; + }, + + getFeature: function (id) { + return this._layers[id]; + }, + + bringToBack: function () { + this.eachFeature(function (layer) { + if (layer.bringToBack) { + layer.bringToBack(); + } + }); + }, + + bringToFront: function () { + this.eachFeature(function (layer) { + if (layer.bringToFront) { + layer.bringToFront(); + } + }); + }, + + redraw: function (id) { + if (id) { + this._redraw(id); + } + return this; + }, + + _redraw: function (id) { + var layer = this._layers[id]; + var geojson = layer.feature; + + // if this looks like a marker + if (layer && layer.setIcon && this.options.pointToLayer) { + // update custom symbology, if necessary + if (this.options.pointToLayer) { + var getIcon = this.options.pointToLayer(geojson, leaflet.latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0])); + var updatedIcon = getIcon.options.icon; + layer.setIcon(updatedIcon); + } + } + + // looks like a vector marker (circleMarker) + if (layer && layer.setStyle && this.options.pointToLayer) { + var getStyle = this.options.pointToLayer(geojson, leaflet.latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0])); + var updatedStyle = getStyle.options; + this.setFeatureStyle(geojson.id, updatedStyle); + } + + // looks like a path (polygon/polyline) + if (layer && layer.setStyle && this.options.style) { + this.resetStyle(geojson.id); + } + } +}); + +function featureLayer (options) { + return new FeatureLayer(options); +} + +// export version + +exports.VERSION = version; +exports.Support = Support; +exports.options = options; +exports.Util = EsriUtil; +exports.get = get; +exports.post = xmlHttpPost; +exports.request = request; +exports.Task = Task; +exports.task = task; +exports.Query = Query; +exports.query = query; +exports.Find = Find; +exports.find = find; +exports.Identify = Identify; +exports.identify = identify; +exports.IdentifyFeatures = IdentifyFeatures; +exports.identifyFeatures = identifyFeatures; +exports.IdentifyImage = IdentifyImage; +exports.identifyImage = identifyImage; +exports.Service = Service; +exports.service = service; +exports.MapService = MapService; +exports.mapService = mapService; +exports.ImageService = ImageService; +exports.imageService = imageService; +exports.FeatureLayerService = FeatureLayerService; +exports.featureLayerService = featureLayerService; +exports.BasemapLayer = BasemapLayer; +exports.basemapLayer = basemapLayer; +exports.TiledMapLayer = TiledMapLayer; +exports.tiledMapLayer = tiledMapLayer; +exports.RasterLayer = RasterLayer; +exports.ImageMapLayer = ImageMapLayer; +exports.imageMapLayer = imageMapLayer; +exports.DynamicMapLayer = DynamicMapLayer; +exports.dynamicMapLayer = dynamicMapLayer; +exports.FeatureManager = FeatureManager; +exports.FeatureLayer = FeatureLayer; +exports.featureLayer = featureLayer; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=esri-leaflet-debug.js.map diff --git a/dist/esri-leaflet-debug.js.map b/dist/esri-leaflet-debug.js.map new file mode 100644 index 000000000..d060d5252 --- /dev/null +++ b/dist/esri-leaflet-debug.js.map @@ -0,0 +1 @@ +{"version":3,"file":"esri-leaflet-debug.js","sources":["../src/Support.js","../src/Options.js","../src/Request.js","../node_modules/@esri/arcgis-to-geojson-utils/index.js","../src/Util.js","../src/Tasks/Task.js","../src/Tasks/Query.js","../src/Tasks/Find.js","../src/Tasks/Identify.js","../src/Tasks/IdentifyFeatures.js","../src/Tasks/IdentifyImage.js","../src/Services/Service.js","../src/Services/MapService.js","../src/Services/ImageService.js","../src/Services/FeatureLayerService.js","../src/Layers/BasemapLayer.js","../src/Layers/TiledMapLayer.js","../src/Layers/RasterLayer.js","../src/Layers/ImageMapLayer.js","../src/Layers/DynamicMapLayer.js","../node_modules/leaflet-virtual-grid/src/virtual-grid.js","../node_modules/tiny-binary-search/index.js","../src/Layers/FeatureLayer/FeatureManager.js","../src/Layers/FeatureLayer/FeatureLayer.js","../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\nimport { warn } from './Util';\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 }\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 }\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\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","/*\n * Copyright 2017 Esri\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// checks if 2 x,y points are equal\nfunction pointsEqual (a, b) {\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\n// checks if the first and last points of a ring are equal and closes the ring\nfunction closeRing (coordinates) {\n if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) {\n coordinates.push(coordinates[0]);\n }\n return coordinates;\n}\n\n// determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring\n// or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-\n// points-are-in-clockwise-order\nfunction ringIsClockwise (ringToTest) {\n var total = 0;\n var i = 0;\n var rLength = ringToTest.length;\n var pt1 = ringToTest[i];\n var pt2;\n for (i; i < rLength - 1; i++) {\n pt2 = ringToTest[i + 1];\n total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);\n pt1 = pt2;\n }\n return (total >= 0);\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L504-L519\nfunction vertexIntersectsVertex (a1, a2, b1, b2) {\n var uaT = ((b2[0] - b1[0]) * (a1[1] - b1[1])) - ((b2[1] - b1[1]) * (a1[0] - b1[0]));\n var ubT = ((a2[0] - a1[0]) * (a1[1] - b1[1])) - ((a2[1] - a1[1]) * (a1[0] - b1[0]));\n var uB = ((b2[1] - b1[1]) * (a2[0] - a1[0])) - ((b2[0] - b1[0]) * (a2[1] - a1[1]));\n\n if (uB !== 0) {\n var ua = uaT / uB;\n var ub = ubT / uB;\n\n if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {\n return true;\n }\n }\n\n return false;\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L521-L531\nfunction arrayIntersectsArray (a, b) {\n for (var i = 0; i < a.length - 1; i++) {\n for (var j = 0; j < b.length - 1; j++) {\n if (vertexIntersectsVertex(a[i], a[i + 1], b[j], b[j + 1])) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L470-L480\nfunction coordinatesContainPoint (coordinates, point) {\n var contains = false;\n for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) {\n if (((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1]) ||\n (coordinates[j][1] <= point[1] && point[1] < coordinates[i][1])) &&\n (point[0] < (((coordinates[j][0] - coordinates[i][0]) * (point[1] - coordinates[i][1])) / (coordinates[j][1] - coordinates[i][1])) + coordinates[i][0])) {\n contains = !contains;\n }\n }\n return contains;\n}\n\n// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L106-L113\nfunction coordinatesContainCoordinates (outer, inner) {\n var intersects = arrayIntersectsArray(outer, inner);\n var contains = coordinatesContainPoint(outer, inner[0]);\n if (!intersects && contains) {\n return true;\n }\n return false;\n}\n\n// do any polygons in this array contain any other polygons in this array?\n// used for checking for holes in arcgis rings\n// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L117-L172\nfunction convertRingsToGeoJSON (rings) {\n var outerRings = [];\n var holes = [];\n var x; // iterator\n var outerRing; // current outer ring being evaluated\n var hole; // current hole being evaluated\n\n // for each ring\n for (var r = 0; r < rings.length; r++) {\n var ring = closeRing(rings[r].slice(0));\n if (ring.length < 4) {\n continue;\n }\n // is this ring an outer ring? is it clockwise?\n if (ringIsClockwise(ring)) {\n var polygon = [ ring.slice().reverse() ]; // wind outer rings counterclockwise for RFC 7946 compliance\n outerRings.push(polygon); // push to outer rings\n } else {\n holes.push(ring.slice().reverse()); // wind inner rings clockwise for RFC 7946 compliance\n }\n }\n\n var uncontainedHoles = [];\n\n // while there are holes left...\n while (holes.length) {\n // pop a hole off out stack\n hole = holes.pop();\n\n // loop over all outer rings and see if they contain our hole.\n var contained = false;\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n if (coordinatesContainCoordinates(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n contained = true;\n break;\n }\n }\n\n // ring is not contained in any outer ring\n // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320\n if (!contained) {\n uncontainedHoles.push(hole);\n }\n }\n\n // if we couldn't match any holes using contains we can try intersects...\n while (uncontainedHoles.length) {\n // pop a hole off out stack\n hole = uncontainedHoles.pop();\n\n // loop over all outer rings and see if any intersect our hole.\n var intersects = false;\n\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n if (arrayIntersectsArray(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n intersects = true;\n break;\n }\n }\n\n if (!intersects) {\n outerRings.push([hole.reverse()]);\n }\n }\n\n if (outerRings.length === 1) {\n return {\n type: 'Polygon',\n coordinates: outerRings[0]\n };\n } else {\n return {\n type: 'MultiPolygon',\n coordinates: outerRings\n };\n }\n}\n\n// This function ensures that rings are oriented in the right directions\n// outer rings are clockwise, holes are counterclockwise\n// used for converting GeoJSON Polygons to ArcGIS Polygons\nfunction orientRings (poly) {\n var output = [];\n var polygon = poly.slice(0);\n var outerRing = closeRing(polygon.shift().slice(0));\n if (outerRing.length >= 4) {\n if (!ringIsClockwise(outerRing)) {\n outerRing.reverse();\n }\n\n output.push(outerRing);\n\n for (var i = 0; i < polygon.length; i++) {\n var hole = closeRing(polygon[i].slice(0));\n if (hole.length >= 4) {\n if (ringIsClockwise(hole)) {\n hole.reverse();\n }\n output.push(hole);\n }\n }\n }\n\n return output;\n}\n\n// This function flattens holes in multipolygons to one array of polygons\n// used for converting GeoJSON Polygons to ArcGIS Polygons\nfunction flattenMultiPolygonRings (rings) {\n var output = [];\n for (var i = 0; i < rings.length; i++) {\n var polygon = orientRings(rings[i]);\n for (var x = polygon.length - 1; x >= 0; x--) {\n var ring = polygon[x].slice(0);\n output.push(ring);\n }\n }\n return output;\n}\n\n// shallow object clone for feature properties and attributes\n// from http://jsperf.com/cloning-an-object/2\nfunction shallowClone (obj) {\n var target = {};\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) {\n target[i] = obj[i];\n }\n }\n return target;\n}\n\nfunction getId (attributes, idAttribute) {\n var keys = idAttribute ? [idAttribute, 'OBJECTID', 'FID'] : ['OBJECTID', 'FID'];\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (\n key in attributes &&\n (typeof attributes[key] === 'string' ||\n typeof attributes[key] === 'number')\n ) {\n return attributes[key];\n }\n }\n throw Error('No valid id attribute found');\n}\n\nexport function arcgisToGeoJSON (arcgis, idAttribute) {\n var geojson = {};\n\n if (arcgis.features) {\n geojson.type = 'FeatureCollection';\n geojson.features = [];\n for (var i = 0; i < arcgis.features.length; i++) {\n geojson.features.push(arcgisToGeoJSON(arcgis.features[i], idAttribute));\n }\n }\n\n if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') {\n geojson.type = 'Point';\n geojson.coordinates = [arcgis.x, arcgis.y];\n if (typeof arcgis.z === 'number') {\n geojson.coordinates.push(arcgis.z);\n }\n }\n\n if (arcgis.points) {\n geojson.type = 'MultiPoint';\n geojson.coordinates = arcgis.points.slice(0);\n }\n\n if (arcgis.paths) {\n if (arcgis.paths.length === 1) {\n geojson.type = 'LineString';\n geojson.coordinates = arcgis.paths[0].slice(0);\n } else {\n geojson.type = 'MultiLineString';\n geojson.coordinates = arcgis.paths.slice(0);\n }\n }\n\n if (arcgis.rings) {\n geojson = convertRingsToGeoJSON(arcgis.rings.slice(0));\n }\n\n if (\n typeof arcgis.xmin === 'number' &&\n typeof arcgis.ymin === 'number' &&\n typeof arcgis.xmax === 'number' &&\n typeof arcgis.ymax === 'number'\n ) {\n geojson.type = 'Polygon';\n geojson.coordinates = [[\n [arcgis.xmax, arcgis.ymax],\n [arcgis.xmin, arcgis.ymax],\n [arcgis.xmin, arcgis.ymin],\n [arcgis.xmax, arcgis.ymin],\n [arcgis.xmax, arcgis.ymax]\n ]];\n }\n\n if (arcgis.geometry || arcgis.attributes) {\n geojson.type = 'Feature';\n geojson.geometry = (arcgis.geometry) ? arcgisToGeoJSON(arcgis.geometry) : null;\n geojson.properties = (arcgis.attributes) ? shallowClone(arcgis.attributes) : null;\n if (arcgis.attributes) {\n try {\n geojson.id = getId(arcgis.attributes, idAttribute);\n } catch (err) {\n // don't set an id\n }\n }\n }\n\n // if no valid geometry was encountered\n if (JSON.stringify(geojson.geometry) === JSON.stringify({})) {\n geojson.geometry = null;\n }\n\n if (\n arcgis.spatialReference &&\n arcgis.spatialReference.wkid &&\n arcgis.spatialReference.wkid !== 4326\n ) {\n console.warn('Object converted in non-standard crs - ' + JSON.stringify(arcgis.spatialReference));\n }\n\n return geojson;\n}\n\nexport function geojsonToArcGIS (geojson, idAttribute) {\n idAttribute = idAttribute || 'OBJECTID';\n var spatialReference = { wkid: 4326 };\n var result = {};\n var i;\n\n switch (geojson.type) {\n case 'Point':\n result.x = geojson.coordinates[0];\n result.y = geojson.coordinates[1];\n result.spatialReference = spatialReference;\n break;\n case 'MultiPoint':\n result.points = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n case 'LineString':\n result.paths = [geojson.coordinates.slice(0)];\n result.spatialReference = spatialReference;\n break;\n case 'MultiLineString':\n result.paths = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n case 'Polygon':\n result.rings = orientRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n case 'MultiPolygon':\n result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n case 'Feature':\n if (geojson.geometry) {\n result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);\n }\n result.attributes = (geojson.properties) ? shallowClone(geojson.properties) : {};\n if (geojson.id) {\n result.attributes[idAttribute] = geojson.id;\n }\n break;\n case 'FeatureCollection':\n result = [];\n for (i = 0; i < geojson.features.length; i++) {\n result.push(geojsonToArcGIS(geojson.features[i], idAttribute));\n }\n break;\n case 'GeometryCollection':\n result = [];\n for (i = 0; i < geojson.geometries.length; i++) {\n result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute));\n }\n break;\n }\n\n return result;\n}\n\nexport default { arcgisToGeoJSON: arcgisToGeoJSON, geojsonToArcGIS: geojsonToArcGIS };\n","import { latLng, latLngBounds, LatLng, LatLngBounds, Util, DomUtil, GeoJSON } from 'leaflet';\r\nimport { request } 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 '@esri/arcgis-to-geojson-utils';\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.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 warn () {\r\n if (console && console.warn) {\r\n console.warn.apply(console, arguments);\r\n }\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 && !map.attributionControl._esriAttributionAdded) {\r\n map.attributionControl.setPrefix('Leaflet | Powered by Esri');\r\n\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\r\n document.getElementsByTagName('head')[0].appendChild(hoverAttributionStyle);\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution:hover');\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\r\n document.getElementsByTagName('head')[0].appendChild(attributionStyle);\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution');\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 map.attributionControl._container.style.maxWidth = calcAttributionWidth(e.target);\r\n });\r\n\r\n map.attributionControl._esriAttributionAdded = true;\r\n }\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\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 // 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)) {\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 _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: 22,\r\n maxNativeZoom: 22,\r\n downsampled: false,\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 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 // Esri World Imagery is cached all the way to zoom 22 in select regions\r\n if (this._url.indexOf('World_Imagery') !== -1) {\r\n map.on('zoomanim', _fetchTilemap, this);\r\n }\r\n\r\n TileLayer.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n map.off('moveend', _updateMapAttribution);\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\nfunction _fetchTilemap (evt) {\r\n var map = evt.target;\r\n if (!map) { return; }\r\n\r\n var oldZoom = map.getZoom();\r\n var newZoom = evt.zoom;\r\n var newCenter = map.wrapLatLng(evt.center);\r\n\r\n if (newZoom > oldZoom && newZoom > 13 && !this.options.downsampled) {\r\n // convert wrapped lat/long into tile coordinates and use them to generate the tilemap url\r\n var tilePoint = map.project(newCenter, newZoom).divideBy(256).floor();\r\n\r\n // use new coords to determine the tilemap url\r\n var tileUrl = Util.template(this._url, Util.extend({\r\n s: this._getSubdomain(tilePoint),\r\n x: tilePoint.x,\r\n y: tilePoint.y,\r\n z: newZoom\r\n }, this.options));\r\n\r\n // 8x8 grids are cached\r\n var tilemapUrl = tileUrl.replace(/tile/, 'tilemap') + '/8/8';\r\n\r\n // an array of booleans in the response indicate missing tiles\r\n L.esri.request(tilemapUrl, {}, function (err, response) {\r\n if (!err) {\r\n for (var i = 0; i < response.data.length; i++) {\r\n if (!response.data[i]) {\r\n // if necessary, resample a lower zoom\r\n this.options.maxNativeZoom = newZoom - 1;\r\n this.options.downsampled = true;\r\n break;\r\n }\r\n // if no tiles are missing, reset the original maxZoom\r\n this.options.maxNativeZoom = 22;\r\n }\r\n }\r\n }, this);\r\n } else if (newZoom < 13) {\r\n // if the user moves to a new region, time for a fresh test\r\n this.options.downsampled = false;\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 } 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 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 } 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 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.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 this._renderImage(this.options.url + 'exportImage' + Util.getParamString(params), 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: 'png24',\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 if ((options.proxy || options.token) && options.f !== 'json') {\r\n options.f = 'json';\r\n }\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 this._renderImage(this.options.url + 'export' + Util.getParamString(params), 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 {\n bounds,\n latLngBounds,\n point,\n Layer,\n setOptions,\n Util\n} from 'leaflet';\n\nvar VirtualGrid = Layer.extend({\n\n options: {\n cellSize: 512,\n updateInterval: 150\n },\n\n initialize: function (options) {\n options = setOptions(this, options);\n this._zooming = false;\n },\n\n onAdd: function (map) {\n this._map = map;\n this._update = Util.throttle(this._update, this.options.updateInterval, this);\n this._reset();\n this._update();\n },\n\n onRemove: function () {\n this._map.removeEventListener(this.getEvents(), this);\n this._removeCells();\n },\n\n getEvents: function () {\n var events = {\n moveend: this._update,\n zoomstart: this._zoomstart,\n zoomend: this._reset\n };\n\n return events;\n },\n\n addTo: function (map) {\n map.addLayer(this);\n return this;\n },\n\n removeFrom: function (map) {\n map.removeLayer(this);\n return this;\n },\n\n _zoomstart: function () {\n this._zooming = true;\n },\n\n _reset: function () {\n this._removeCells();\n\n this._cells = {};\n this._activeCells = {};\n this._cellsToLoad = 0;\n this._cellsTotal = 0;\n this._cellNumBounds = this._getCellNumBounds();\n\n this._resetWrap();\n this._zooming = false;\n },\n\n _resetWrap: function () {\n var map = this._map;\n var crs = map.options.crs;\n\n if (crs.infinite) { return; }\n\n var cellSize = this._getCellSize();\n\n if (crs.wrapLng) {\n this._wrapLng = [\n Math.floor(map.project([0, crs.wrapLng[0]]).x / cellSize),\n Math.ceil(map.project([0, crs.wrapLng[1]]).x / cellSize)\n ];\n }\n\n if (crs.wrapLat) {\n this._wrapLat = [\n Math.floor(map.project([crs.wrapLat[0], 0]).y / cellSize),\n Math.ceil(map.project([crs.wrapLat[1], 0]).y / cellSize)\n ];\n }\n },\n\n _getCellSize: function () {\n return this.options.cellSize;\n },\n\n _update: function () {\n if (!this._map) {\n return;\n }\n\n var mapBounds = this._map.getPixelBounds();\n var cellSize = this._getCellSize();\n\n // cell coordinates range for the current view\n var cellBounds = bounds(\n mapBounds.min.divideBy(cellSize).floor(),\n mapBounds.max.divideBy(cellSize).floor());\n\n this._removeOtherCells(cellBounds);\n this._addCells(cellBounds);\n\n this.fire('cellsupdated');\n },\n\n _addCells: function (cellBounds) {\n var queue = [];\n var center = cellBounds.getCenter();\n var zoom = this._map.getZoom();\n\n var j, i, coords;\n // create a queue of coordinates to load cells from\n for (j = cellBounds.min.y; j <= cellBounds.max.y; j++) {\n for (i = cellBounds.min.x; i <= cellBounds.max.x; i++) {\n coords = point(i, j);\n coords.z = zoom;\n\n if (this._isValidCell(coords)) {\n queue.push(coords);\n }\n }\n }\n\n var cellsToLoad = queue.length;\n\n if (cellsToLoad === 0) { return; }\n\n this._cellsToLoad += cellsToLoad;\n this._cellsTotal += cellsToLoad;\n\n // sort cell queue to load cells in order of their distance to center\n queue.sort(function (a, b) {\n return a.distanceTo(center) - b.distanceTo(center);\n });\n\n for (i = 0; i < cellsToLoad; i++) {\n this._addCell(queue[i]);\n }\n },\n\n _isValidCell: function (coords) {\n var crs = this._map.options.crs;\n\n if (!crs.infinite) {\n // don't load cell if it's out of bounds and not wrapped\n var cellNumBounds = this._cellNumBounds;\n\n if (!cellNumBounds) return false;\n if (\n (!crs.wrapLng && (coords.x < cellNumBounds.min.x || coords.x > cellNumBounds.max.x)) ||\n (!crs.wrapLat && (coords.y < cellNumBounds.min.y || coords.y > cellNumBounds.max.y))\n ) {\n return false;\n }\n }\n\n if (!this.options.bounds) {\n return true;\n }\n\n // don't load cell if it doesn't intersect the bounds in options\n var cellBounds = this._cellCoordsToBounds(coords);\n return latLngBounds(this.options.bounds).intersects(cellBounds);\n },\n\n // converts cell coordinates to its geographical bounds\n _cellCoordsToBounds: function (coords) {\n var map = this._map;\n var cellSize = this.options.cellSize;\n var nwPoint = coords.multiplyBy(cellSize);\n var sePoint = nwPoint.add([cellSize, cellSize]);\n var nw = map.wrapLatLng(map.unproject(nwPoint, coords.z));\n var se = map.wrapLatLng(map.unproject(sePoint, coords.z));\n\n return latLngBounds(nw, se);\n },\n\n // converts cell coordinates to key for the cell cache\n _cellCoordsToKey: function (coords) {\n return coords.x + ':' + coords.y;\n },\n\n // converts cell cache key to coordiantes\n _keyToCellCoords: function (key) {\n var kArr = key.split(':');\n var x = parseInt(kArr[0], 10);\n var y = parseInt(kArr[1], 10);\n\n return point(x, y);\n },\n\n // remove any present cells that are off the specified bounds\n _removeOtherCells: function (bounds) {\n for (var key in this._cells) {\n if (!bounds.contains(this._keyToCellCoords(key))) {\n this._removeCell(key);\n }\n }\n },\n\n _removeCell: function (key) {\n var cell = this._activeCells[key];\n\n if (cell) {\n delete this._activeCells[key];\n\n if (this.cellLeave) {\n this.cellLeave(cell.bounds, cell.coords);\n }\n\n this.fire('cellleave', {\n bounds: cell.bounds,\n coords: cell.coords\n });\n }\n },\n\n _removeCells: function () {\n for (var key in this._cells) {\n var cellBounds = this._cells[key].bounds;\n var coords = this._cells[key].coords;\n\n if (this.cellLeave) {\n this.cellLeave(cellBounds, coords);\n }\n\n this.fire('cellleave', {\n bounds: cellBounds,\n coords: coords\n });\n }\n },\n\n _addCell: function (coords) {\n // wrap cell coords if necessary (depending on CRS)\n this._wrapCoords(coords);\n\n // generate the cell key\n var key = this._cellCoordsToKey(coords);\n\n // get the cell from the cache\n var cell = this._cells[key];\n // if this cell should be shown as isnt active yet (enter)\n\n if (cell && !this._activeCells[key]) {\n if (this.cellEnter) {\n this.cellEnter(cell.bounds, coords);\n }\n\n this.fire('cellenter', {\n bounds: cell.bounds,\n coords: coords\n });\n\n this._activeCells[key] = cell;\n }\n\n // if we dont have this cell in the cache yet (create)\n if (!cell) {\n cell = {\n coords: coords,\n bounds: this._cellCoordsToBounds(coords)\n };\n\n this._cells[key] = cell;\n this._activeCells[key] = cell;\n\n if (this.createCell) {\n this.createCell(cell.bounds, coords);\n }\n\n this.fire('cellcreate', {\n bounds: cell.bounds,\n coords: coords\n });\n }\n },\n\n _wrapCoords: function (coords) {\n coords.x = this._wrapLng ? Util.wrapNum(coords.x, this._wrapLng) : coords.x;\n coords.y = this._wrapLat ? Util.wrapNum(coords.y, this._wrapLat) : coords.y;\n },\n\n // get the global cell coordinates range for the current zoom\n _getCellNumBounds: function () {\n var worldBounds = this._map.getPixelWorldBounds();\n var size = this._getCellSize();\n\n return worldBounds ? bounds(\n worldBounds.min.divideBy(size).floor(),\n worldBounds.max.divideBy(size).ceil().subtract([1, 1])) : null;\n }\n});\n\nexport default VirtualGrid;\n","function BinarySearchIndex (values) {\n this.values = [].concat(values || []);\n}\n\nBinarySearchIndex.prototype.query = function (value) {\n var index = this.getIndex(value);\n return this.values[index];\n};\n\nBinarySearchIndex.prototype.getIndex = function getIndex (value) {\n if (this.dirty) {\n this.sort();\n }\n\n var minIndex = 0;\n var maxIndex = this.values.length - 1;\n var currentIndex;\n var currentElement;\n\n while (minIndex <= maxIndex) {\n currentIndex = (minIndex + maxIndex) / 2 | 0;\n currentElement = this.values[Math.round(currentIndex)];\n if (+currentElement.value < +value) {\n minIndex = currentIndex + 1;\n } else if (+currentElement.value > +value) {\n maxIndex = currentIndex - 1;\n } else {\n return currentIndex;\n }\n }\n\n return Math.abs(~maxIndex);\n};\n\nBinarySearchIndex.prototype.between = function between (start, end) {\n var startIndex = this.getIndex(start);\n var endIndex = this.getIndex(end);\n\n if (startIndex === 0 && endIndex === 0) {\n return [];\n }\n\n while (this.values[startIndex - 1] && this.values[startIndex - 1].value === start) {\n startIndex--;\n }\n\n while (this.values[endIndex + 1] && this.values[endIndex + 1].value === end) {\n endIndex++;\n }\n\n if (this.values[endIndex] && this.values[endIndex].value === end && this.values[endIndex + 1]) {\n endIndex++;\n }\n\n return this.values.slice(startIndex, endIndex);\n};\n\nBinarySearchIndex.prototype.insert = function insert (item) {\n this.values.splice(this.getIndex(item.value), 0, item);\n return this;\n};\n\nBinarySearchIndex.prototype.bulkAdd = function bulkAdd (items, sort) {\n this.values = this.values.concat([].concat(items || []));\n\n if (sort) {\n this.sort();\n } else {\n this.dirty = true;\n }\n\n return this;\n};\n\nBinarySearchIndex.prototype.sort = function sort () {\n this.values.sort(function (a, b) {\n return +b.value - +a.value;\n }).reverse();\n this.dirty = false;\n return this;\n};\n\nexport default BinarySearchIndex;\n","import { Util } from 'leaflet';\r\nimport featureLayerService from '../../Services/FeatureLayerService';\r\nimport { getUrlParams, warn, setEsriAttribution } from '../../Util';\r\nimport VirtualGrid from 'leaflet-virtual-grid';\r\nimport BinarySearchIndex from 'tiny-binary-search';\r\n\r\nexport var FeatureManager = VirtualGrid.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 },\r\n\r\n /**\r\n * Constructor\r\n */\r\n\r\n initialize: function (options) {\r\n VirtualGrid.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('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 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 (this.service.options.isModern === false) {\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 (!forceJsonFormat && supportedFormats && supportedFormats.indexOf('geoJSON') !== -1) {\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 (!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 }, this);\r\n\r\n map.on('zoomend', this._handleZoomChange, this);\r\n\r\n return VirtualGrid.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n map.off('zoomend', this._handleZoomChange, this);\r\n\r\n return VirtualGrid.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) {\r\n this._activeRequests++;\r\n\r\n // our first active request fires loading\r\n if (this._activeRequests === 1) {\r\n this.fire('loading', {\r\n bounds: bounds\r\n }, true);\r\n }\r\n\r\n return this._buildQuery(bounds).run(function (error, featureCollection, response) {\r\n if (response && response.exceededTransferLimit) {\r\n this.fire('drawlimitexceeded');\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(Util.bind(function () {\r\n this._addFeatures(featureCollection.features, coords);\r\n this._postProcessFeatures(bounds);\r\n }, this));\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 }, 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 var key = this._cacheKey(coords);\r\n this._cache[key] = this._cache[key] || [];\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 (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) {\r\n var query = this.service.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.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 (this.options.timeFilterMode === 'server' && this.options.from && this.options.to) {\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 (pendingRequests <= 0 && this._visibleZoom()) {\r\n this._currentSnapshot = newSnapshot;\r\n // schedule adding features for the next animation frame\r\n Util.requestAnimFrame(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 }, 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 for (var key in this._activeCells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, key, 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._activeCells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, key, requestCallback);\r\n }\r\n }\r\n\r\n return this;\r\n },\r\n\r\n refresh: function () {\r\n for (var key in this._activeCells) {\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, key);\r\n }\r\n\r\n if (this.redraw) {\r\n this.once('load', function () {\r\n this.eachFeature(function (layer) {\r\n this._redraw(layer.feature.id);\r\n }, this);\r\n }, this);\r\n }\r\n },\r\n\r\n _filterExistingFeatures: function (oldFrom, oldTo, newFrom, newTo) {\r\n var layersToRemove = (oldFrom && oldTo) ? this._getFeaturesInTimeRange(oldFrom, oldTo) : 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(Util.bind(function () {\r\n this.removeLayers(layersToRemove);\r\n this.addLayers(layersToAdd);\r\n }, this));\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('You must set timeField in the layer constructor in order to manipulate the start and end time filter.');\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 ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to));\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 { return true; }\r\n },\r\n\r\n _handleZoomChange: function () {\r\n if (!this._visibleZoom()) {\r\n this.removeLayers(this._currentSnapshot);\r\n this._currentSnapshot = [];\r\n } else {\r\n /*\r\n for every cell in this._activeCells\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._activeCells) {\r\n var coords = this._activeCells[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(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 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(Util.bind(function (error, metadata) {\r\n if (error) {\r\n if (callback) { callback.call(this, error, null); }\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(features, 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] = featuresArray.length > 1 ? response[i].objectId : response.objectId;\r\n // we also need to update the geojson id for createLayers() to function\r\n featuresArray[i].id = featuresArray.length > 1 ? response[i].objectId : response.objectId;\r\n }\r\n this.createLayers(featuresArray);\r\n }\r\n\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n }, this));\r\n }, this));\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(features, 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.createLayers(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\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(ids, 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 }, this);\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\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 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('removefeature', {\r\n feature: this._layers[i].feature,\r\n permanent: false\r\n }, true);\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(geojson.geometry.coordinates, 0, coordsToLatLng);\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiLineString':\r\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng);\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'Polygon':\r\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng);\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiPolygon':\r\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 2, coordsToLatLng);\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 (this._visibleZoom() && layer && !this._map.hasLayer(layer) && (!this.options.timeField || this._featureWithinTimeRange(geojson))) {\r\n this._map.addLayer(layer);\r\n this.fire('addfeature', {\r\n feature: layer.feature\r\n }, true);\r\n }\r\n\r\n // update geometry if necessary\r\n if (layer && this.options.simplifyFactor > 0 && (layer.setLatLngs || layer.setLatLng)) {\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('createfeature', {\r\n feature: newLayer.feature\r\n }, true);\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 (this._visibleZoom() && (!this.options.timeField || (this.options.timeField && this._featureWithinTimeRange(geojson)))) {\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 (layer && (!this.options.timeField || this._featureWithinTimeRange(layer.feature))) {\r\n this._map.addLayer(layer);\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('removefeature', {\r\n feature: layer.feature,\r\n permanent: permanent\r\n }, true);\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(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 cellLeave: function (bounds, coords) {\r\n if (!this._zooming) {\r\n Util.requestAnimFrame(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 (layer && layer.getBounds && mapBounds.intersects(layer.getBounds())) {\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 * 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 (typeof this._layers[i].getLatLng === 'function' && activeBounds.contains(this._layers[i].getLatLng())) {\r\n fn.call(context, this._layers[i]);\r\n } else if (typeof this._layers[i].getBounds === 'function' && activeBounds.intersects(this._layers[i].getBounds())) {\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(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));\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(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));\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\nexport {version as VERSION} from '../package.json';\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":["Util","DomUtil","geojsonToArcGIS","g2a","arcgisToGeoJSON","a2g","latLng","latLngBounds","options","LatLngBounds","LatLng","GeoJSON","Class","point","Evented","request","TileLayer","DomEvent","CRS","ImageOverlay","Layer","popup","bounds","setOptions","Path"],"mappings":";;;;;;;;;;;AAAO,IAAI,IAAI,KAAK,MAAM,CAAC,cAAc,IAAI,iBAAiB,IAAI,IAAI,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC;AAChG,AAAO,IAAI,aAAa,GAAG,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,aAAa,KAAK,EAAE,CAAC;;AAE/E,AAAU,IAAC,OAAO,GAAG;EACnB,IAAI,EAAE,IAAI;EACV,aAAa,EAAE,aAAa;CAC7B;;ACNS,IAAC,OAAO,GAAG;EACnB,sBAAsB,EAAE,EAAE;CAC3B;;ACED,IAAI,SAAS,GAAG,CAAC,CAAC;;AAElB,SAAS,SAAS,EAAE,MAAM,EAAE;EAC1B,IAAI,IAAI,GAAG,EAAE,CAAC;;EAEd,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC;;EAE9B,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;IACtB,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;MAC9B,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;MACxB,IAAI,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;MACjD,IAAI,KAAK,CAAC;;MAEV,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,IAAI,IAAI,GAAG,CAAC;OACb;;MAED,IAAI,IAAI,KAAK,gBAAgB,EAAE;QAC7B,KAAK,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,iBAAiB,IAAI,IAAI,CAAC,S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,OAAO,CAAC;MACpC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;KAChD;;;IAGD,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;MACjD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;KAC7B;GACF;CACF,CAAC,CAAC;;AAEH,AAAO,SAAS,YAAY,EAAE,OAAO,EAAE;EACrC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;CAClC;;ACjVD,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/esri-leaflet.js b/dist/esri-leaflet.js new file mode 100644 index 000000000..e2c249e76 --- /dev/null +++ b/dist/esri-leaflet.js @@ -0,0 +1,5 @@ +/* esri-leaflet - v2.3.1 - Thu Oct 10 2019 14:36:18 GMT-0500 (Central Daylight Time) + * Copyright (c) 2019 Environmental Systems Research Institute, Inc. + * Apache-2.0 */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],e):e((t.L=t.L||{},t.L.esri={}),t.L)}(this,function(t,e){"use strict";var i=window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest,s=""===document.documentElement.style.pointerEvents,r={cors:i,pointerEvents:s},n={attributionWidthOffset:55},o=0;function a(t){var e="";for(var i in t.f=t.f||"json",t)if(t.hasOwnProperty(i)){var s,r=t[i],n=Object.prototype.toString.call(r);e.length&&(e+="&"),s="[object Array]"===n?"[object Object]"===Object.prototype.toString.call(r[0])?JSON.stringify(r):r.join(","):"[object Object]"===n?JSON.stringify(r):"[object Date]"===n?r.valueOf():r,e+=encodeURIComponent(i)+"="+encodeURIComponent(s)}return e}function u(t,i){var s=new window.XMLHttpRequest;return s.onerror=function(r){s.onreadystatechange=e.Util.falseFn,t.call(i,{error:{code:500,message:"XMLHttpRequest error"}},null)},s.onreadystatechange=function(){var r,n;if(4===s.readyState){try{r=JSON.parse(s.responseText)}catch(t){r=null,n={code:500,message:"Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error."}}!n&&r.error&&(n=r.error,r=null),s.onerror=e.Util.falseFn,t.call(i,n,r)}},s.ontimeout=function(){this.onerror()},s}function l(t,e,i,s){var r=u(i,s);return r.open("POST",t),void 0!==s&&null!==s&&void 0!==s.options&&(r.timeout=s.options.timeout),r.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),r.send(a(e)),r}function h(t,e,i,s){var r=u(i,s);return r.open("GET",t+"?"+a(e),!0),void 0!==s&&null!==s&&void 0!==s.options&&(r.timeout=s.options.timeout),r.send(null),r}function p(t,e,i,s){var n=a(e),o=u(i,s),l=(t+"?"+n).length;if(l<=2e3&&r.cors?o.open("GET",t+"?"+n):l>2e3&&r.cors&&(o.open("POST",t),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")),void 0!==s&&null!==s&&void 0!==s.options&&(o.timeout=s.options.timeout),l<=2e3&&r.cors)o.send(null);else{if(!(l>2e3&&r.cors))return l<=2e3&&!r.cors?c(t,e,i,s):void q("a request to "+t+" 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");o.send(n)}return o}function c(t,i,s,r){window._EsriLeafletCallbacks=window._EsriLeafletCallbacks||{};var n="c"+o;i.callback="window._EsriLeafletCallbacks."+n,window._EsriLeafletCallbacks[n]=function(t){if(!0!==window._EsriLeafletCallbacks[n]){var e,i=Object.prototype.toString.call(t);"[object Object]"!==i&&"[object Array]"!==i&&(e={error:{code:500,message:"Expected array or object as JSONP response"}},t=null),!e&&t.error&&(e=t,t=null),s.call(r,e,t),window._EsriLeafletCallbacks[n]=!0}};var u=e.DomUtil.create("script",null,document.body);return u.type="text/javascript",u.src=t+"?"+a(i),u.id=n,u.onerror=function(t){if(t&&!0!==window._EsriLeafletCallbacks[n]){s.call(r,{error:{code:500,message:"An unknown error occurred"}}),window._EsriLeafletCallbacks[n]=!0}},e.DomUtil.addClass(u,"esri-leaflet-jsonp"),o++,{id:n,url:u.src,abort:function(){window._EsriLeafletCallbacks._callback[n]({code:0,message:"Request aborted."})}}}var m=r.cors?h:c;m.CORS=h,m.JSONP=c;var d={request:p,get:m,post:l};function f(t){return function(t,e){for(var i=0;i=0}function g(t,e,i,s){var r=(s[0]-i[0])*(t[1]-i[1])-(s[1]-i[1])*(t[0]-i[0]),n=(e[0]-t[0])*(t[1]-i[1])-(e[1]-t[1])*(t[0]-i[0]),o=(s[1]-i[1])*(e[0]-t[0])-(s[0]-i[0])*(e[1]-t[1]);if(0!==o){var a=r/o,u=n/o;if(a>=0&&a<=1&&u>=0&&u<=1)return!0}return!1}function v(t,e){for(var i=0;i=4){y(s)||s.reverse(),e.push(s);for(var r=0;r=4&&(y(n)&&n.reverse(),e.push(n))}}return e}function x(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function S(t,e){var i={};if(t.features){i.type="FeatureCollection",i.features=[];for(var s=0;s=0;e--)if(_(s[e][0],i)){s[e].push(i),l=!0;break}l||u.push(i)}for(;u.length;){i=u.pop();var h=!1;for(e=s.length-1;e>=0;e--)if(v(s[e][0],i)){s[e].push(i),h=!0;break}h||s.push([i.reverse()])}return 1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s}}(t.rings.slice(0))),"number"==typeof t.xmin&&"number"==typeof t.ymin&&"number"==typeof t.xmax&&"number"==typeof t.ymax&&(i.type="Polygon",i.coordinates=[[[t.xmax,t.ymax],[t.xmin,t.ymax],[t.xmin,t.ymin],[t.xmax,t.ymin],[t.xmax,t.ymax]]]),(t.geometry||t.attributes)&&(i.type="Feature",i.geometry=t.geometry?S(t.geometry):null,i.properties=t.attributes?x(t.attributes):null,t.attributes))try{i.id=function(t,e){for(var i=e?[e,"OBJECTID","FID"]:["OBJECTID","FID"],s=0;s=0;r--){var n=s[r].slice(0);e.push(n)}return e}(t.coordinates.slice(0)),r.spatialReference=s;break;case"Feature":t.geometry&&(r.geometry=I(t.geometry,e)),r.attributes=t.properties?x(t.properties):{},t.id&&(r.attributes[e]=t.id);break;case"FeatureCollection":for(r=[],i=0;i=0;o--){var a=T(s[o],i||C(s[o]));n.features.push(a)}return n}function U(t){return"/"!==(t=e.Util.trim(t))[t.length-1]&&(t+="/"),t}function k(t){if(-1!==t.url.indexOf("?")){t.requestParams=t.requestParams||{};var e=t.url.substring(t.url.indexOf("?")+1);t.url=t.url.split("?")[0],t.requestParams=JSON.parse('{"'+decodeURI(e).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')}return t.url=U(t.url.split("?")[0]),t}function G(t){return/^(?!.*utility\.arcgis\.com).*\.arcgis\.com.*FeatureServer/i.test(t)}function M(t){var e;switch(t){case"Point":e="esriGeometryPoint";break;case"MultiPoint":e="esriGeometryMultipoint";break;case"LineString":case"MultiLineString":e="esriGeometryPolyline";break;case"Polygon":case"MultiPolygon":e="esriGeometryPolygon"}return e}function q(){console&&console.warn&&console.warn.apply(console,arguments)}function D(t){return t.getSize().x-n.attributionWidthOffset+"px"}function E(t){if(t.attributionControl&&!t.attributionControl._esriAttributionAdded){t.attributionControl.setPrefix('Leaflet | Powered by Esri');var i=document.createElement("style");i.type="text/css",i.innerHTML=".esri-truncated-attribution:hover {white-space: normal;}",document.getElementsByTagName("head")[0].appendChild(i),e.DomUtil.addClass(t.attributionControl._container,"esri-truncated-attribution:hover");var s=document.createElement("style");s.type="text/css",s.innerHTML=".esri-truncated-attribution {vertical-align: -3px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: inline-block;transition: 0s white-space;transition-delay: 1s;max-width: "+D(t)+";}",document.getElementsByTagName("head")[0].appendChild(s),e.DomUtil.addClass(t.attributionControl._container,"esri-truncated-attribution"),t.on("resize",function(e){t.attributionControl._container.style.maxWidth=D(e.target)}),t.attributionControl._esriAttributionAdded=!0}}function z(t){var i={geometry:null,geometryType:null};return t instanceof e.LatLngBounds?(i.geometry=R(t),i.geometryType="esriGeometryEnvelope",i):(t.getLatLng&&(t=t.getLatLng()),t instanceof e.LatLng&&(t={type:"Point",coordinates:[t.lng,t.lat]}),t instanceof e.GeoJSON&&(t=t.getLayers()[0].feature.geometry,i.geometry=A(t),i.geometryType=M(t.type)),t.toGeoJSON&&(t=t.toGeoJSON()),"Feature"===t.type&&(t=t.geometry),"Point"===t.type||"LineString"===t.type||"Polygon"===t.type||"MultiPolygon"===t.type?(i.geometry=A(t),i.geometryType=M(t.type),i):void q("invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object"))}function B(t,i){r.cors&&p(t,{},e.Util.bind(function(t,s){if(!t){i._esriAttributions=[];for(var r=0;r=h.minZoom&&u<=h.maxZoom&&(n+=", "+p)}n=n.substr(2),r.innerHTML=n,r.style.maxWidth=D(i),i.fire("attributionupdated",{attribution:n})}}}var Z={warn:q,cleanUrl:U,getUrlParams:k,isArcgisOnline:G,geojsonTypeToArcGIS:M,responseToFeatureCollection:F,geojsonToArcGIS:A,arcgisToGeoJSON:T,boundsToExtent:R,extentToBounds:w,calcAttributionWidth:D,setEsriAttribution:E,_setGeometry:z,_getAttributionData:B,_updateMapAttribution:N,_findIdAttributeFromFeature:C,_findIdAttributeFromResponse:P},j=e.Class.extend({options:{proxy:!1,useCors:i},generateSetter:function(t,i){return e.Util.bind(function(e){return this.params[t]=e,this},i)},initialize:function(t){if(t.request&&t.options?(this._service=t,e.Util.setOptions(this,t.options)):(e.Util.setOptions(this,t),this.options.url=U(t.url)),this.params=e.Util.extend({},this.params||{}),this.setters)for(var i in this.setters){var s=this.setters[i];this[i]=this.generateSetter(s,this)}},token:function(t){return this._service?this._service.authenticate(t):this.params.token=t,this},format:function(t){return this.params.returnUnformattedValues=!t,this},request:function(t,i){return this.options.requestParams&&e.Util.extend(this.params,this.options.requestParams),this._service?this._service.request(this.path,this.params,t,i):this._request("request",this.path,this.params,t,i)},_request:function(t,e,i,s,r){var n=this.options.proxy?this.options.proxy+"?"+this.options.url+e:this.options.url+e;return"get"!==t&&"request"!==t||this.options.useCors?d[t](n,i,s,r):d.get.JSONP(n,i,s,r)}});var W=j.extend({setters:{offset:"resultOffset",limit:"resultRecordCount",fields:"outFields",precision:"geometryPrecision",featureIds:"objectIds",returnGeometry:"returnGeometry",returnM:"returnM",transform:"datumTransformation",token:"token"},path:"query",params:{returnGeometry:!0,where:"1=1",outSR:4326,outFields:"*"},within:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelContains",this},intersects:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelIntersects",this},contains:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelWithin",this},crosses:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelCrosses",this},touches:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelTouches",this},overlaps:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelOverlaps",this},bboxIntersects:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelEnvelopeIntersects",this},indexIntersects:function(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelIndexIntersects",this},nearby:function(t,i){return t=e.latLng(t),this.params.geometry=[t.lng,t.lat],this.params.geometryType="esriGeometryPoint",this.params.spatialRel="esriSpatialRelIntersects",this.params.units="esriSRUnit_Meter",this.params.distance=i,this.params.inSr=4326,this},where:function(t){return this.params.where=t,this},between:function(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},orderBy:function(t,e){return e=e||"ASC",this.params.orderByFields=this.params.orderByFields?this.params.orderByFields+",":"",this.params.orderByFields+=[t,e].join(" "),this},run:function(t,e){return this._cleanParams(),this.options.isModern||G(this.options.url)?(this.params.f="geojson",this.request(function(i,s){this._trapSQLerrors(i),t.call(e,i,s,s)},this)):this.request(function(i,s){this._trapSQLerrors(i),t.call(e,i,s&&F(s),s)},this)},count:function(t,e){return this._cleanParams(),this.params.returnCountOnly=!0,this.request(function(e,i){t.call(this,e,i&&i.count,i)},e)},ids:function(t,e){return this._cleanParams(),this.params.returnIdsOnly=!0,this.request(function(e,i){t.call(this,e,i&&i.objectIds,i)},e)},bounds:function(t,e){return this._cleanParams(),this.params.returnExtentOnly=!0,this.request(function(i,s){s&&s.extent&&w(s.extent)?t.call(e,i,w(s.extent),s):(i={message:"Invalid Bounds"},t.call(e,i,null,s))},e)},distinct:function(){return this.params.returnGeometry=!1,this.params.returnDistinctValues=!0,this},pixelSize:function(t){var i=e.point(t);return this.params.pixelSize=[i.x,i.y],this},layer:function(t){return this.path=t+"/query",this},_trapSQLerrors:function(t){t&&"400"===t.code&&q("one common syntax error in query requests is encasing string values in double quotes instead of single quotes")},_cleanParams:function(){delete this.params.returnIdsOnly,delete this.params.returnExtentOnly,delete this.params.returnCountOnly},_setGeometryParams:function(t){this.params.inSr=4326;var e=z(t);this.params.geometry=e.geometry,this.params.geometryType=e.geometryType}});function J(t){return new W(t)}var Q=j.extend({setters:{contains:"contains",text:"searchText",fields:"searchFields",spatialReference:"sr",sr:"sr",layers:"layers",returnGeometry:"returnGeometry",maxAllowableOffset:"maxAllowableOffset",precision:"geometryPrecision",dynamicLayers:"dynamicLayers",returnZ:"returnZ",returnM:"returnM",gdbVersion:"gdbVersion",token:"token"},path:"find",params:{sr:4326,contains:!0,returnGeometry:!0,returnZ:!0,returnM:!1},layerDefs:function(t,e){return this.params.layerDefs=this.params.layerDefs?this.params.layerDefs+";":"",this.params.layerDefs+=[t,e].join(":"),this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},run:function(t,e){return this.request(function(i,s){t.call(e,i,s&&F(s),s)},e)}});function V(t){return new Q(t)}var H=j.extend({path:"identify",between:function(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this}});var K=H.extend({setters:{layers:"layers",precision:"geometryPrecision",tolerance:"tolerance",returnGeometry:"returnGeometry"},params:{sr:4326,layers:"all",tolerance:3,returnGeometry:!0},on:function(t){var e=R(t.getBounds()),i=t.getSize();return this.params.imageDisplay=[i.x,i.y,96],this.params.mapExtent=[e.xmin,e.ymin,e.xmax,e.ymax],this},at:function(t){return 2===t.length&&(t=e.latLng(t)),this._setGeometryParams(t),this},layerDef:function(t,e){return this.params.layerDefs=this.params.layerDefs?this.params.layerDefs+";":"",this.params.layerDefs+=[t,e].join(":"),this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},run:function(t,e){return this.request(function(i,s){if(i)t.call(e,i,void 0,s);else{var r=F(s);s.results=s.results.reverse();for(var n=0;n=0;n--)r.catalogItems.features[n].properties.catalogItemVisibility=s[n];return r}});function $(t){return new Y(t)}var tt=e.Evented.extend({options:{proxy:!1,useCors:i,timeout:0},initialize:function(t){t=t||{},this._requestQueue=[],this._authenticating=!1,e.Util.setOptions(this,t),this.options.url=U(this.options.url)},get:function(t,e,i,s){return this._request("get",t,e,i,s)},post:function(t,e,i,s){return this._request("post",t,e,i,s)},request:function(t,e,i,s){return this._request("request",t,e,i,s)},metadata:function(t,e){return this._request("get","",{},t,e)},authenticate:function(t){return this._authenticating=!1,this.options.token=t,this._runQueue(),this},getTimeout:function(){return this.options.timeout},setTimeout:function(t){this.options.timeout=t},_request:function(t,i,s,r,n){this.fire("requeststart",{url:this.options.url+i,params:s,method:t},!0);var o=this._createServiceCallback(t,i,s,r,n);if(this.options.token&&(s.token=this.options.token),this.options.requestParams&&e.Util.extend(s,this.options.requestParams),!this._authenticating){var a=this.options.proxy?this.options.proxy+"?"+this.options.url+i:this.options.url+i;return"get"!==t&&"request"!==t||this.options.useCors?d[t](a,s,o,n):d.get.JSONP(a,s,o,n)}this._requestQueue.push([t,i,s,r,n])},_createServiceCallback:function(t,i,s,r,n){return e.Util.bind(function(o,a){!o||499!==o.code&&498!==o.code||(this._authenticating=!0,this._requestQueue.push([t,i,s,r,n]),this.fire("authenticationrequired",{authenticate:e.Util.bind(this.authenticate,this)},!0),o.authenticate=e.Util.bind(this.authenticate,this)),r.call(n,o,a),o?this.fire("requesterror",{url:this.options.url+i,params:s,message:o.message,code:o.code,method:t},!0):this.fire("requestsuccess",{url:this.options.url+i,params:s,response:a,method:t},!0),this.fire("requestend",{url:this.options.url+i,params:s,method:t},!0)},this)},_runQueue:function(){for(var t=this._requestQueue.length-1;t>=0;t--){var e=this._requestQueue[t];this[e.shift()].apply(this,e)}this._requestQueue=[]}});var et=tt.extend({identify:function(){return X(this)},find:function(){return V(this)},query:function(){return J(this)}});function it(t){return new et(t)}var st=tt.extend({query:function(){return J(this)},identify:function(){return $(this)}});function rt(t){return new st(t)}var nt=tt.extend({options:{idAttribute:"OBJECTID"},query:function(){return J(this)},addFeature:function(t,e,i){this.addFeatures(t,e,i)},addFeatures:function(t,e,i){for(var s=t.features?t.features:[t],r=s.length-1;r>=0;r--)delete s[r].id;return t=A(t),t=s.length>1?t:[t],this.post("addFeatures",{features:t},function(t,s){var r=s&&s.addResults?s.addResults.length>1?s.addResults:s.addResults[0]:void 0;e&&e.call(i,t||s.addResults[0].error,r)},i)},updateFeature:function(t,e,i){this.updateFeatures(t,e,i)},updateFeatures:function(t,e,i){var s=t.features?t.features:[t];return t=A(t,this.options.idAttribute),t=s.length>1?t:[t],this.post("updateFeatures",{features:t},function(t,s){var r=s&&s.updateResults?s.updateResults.length>1?s.updateResults:s.updateResults[0]:void 0;e&&e.call(i,t||s.updateResults[0].error,r)},i)},deleteFeature:function(t,e,i){this.deleteFeatures(t,e,i)},deleteFeatures:function(t,e,i){return this.post("deleteFeatures",{objectIds:t},function(t,s){var r=s&&s.deleteResults?s.deleteResults.length>1?s.deleteResults:s.deleteResults[0]:void 0;e&&e.call(i,t||s.deleteResults[0].error,r)},i)}});function ot(t){return new nt(t)}var at="https:"!==window.location.protocol?"http:":"https:",ut=e.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"USGS, NOAA",attributionUrl:"https://static.arcgis.com/attribution/World_Street_Map"}},Topographic:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"USGS, NOAA",attributionUrl:"https://static.arcgis.com/attribution/World_Topo_Map"}},Oceans:{urlTemplate:at+"//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"USGS, NOAA",attributionUrl:"https://static.arcgis.com/attribution/Ocean_Basemap"}},OceansLabels:{urlTemplate:at+"//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:s?"esri-labels":"tilePane",attribution:""}},NationalGeographic:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"National Geographic, DeLorme, HERE, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, increment P Corp."}},DarkGray:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"HERE, DeLorme, MapmyIndia, © OpenStreetMap contributors"}},DarkGrayLabels:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:s?"esri-labels":"tilePane",attribution:""}},Gray:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"HERE, DeLorme, MapmyIndia, © OpenStreetMap contributors"}},GrayLabels:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:s?"esri-labels":"tilePane",attribution:""}},Imagery:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:22,maxNativeZoom:22,downsampled:!1,subdomains:["server","services"],attribution:"DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community",attributionUrl:"https://static.arcgis.com/attribution/World_Imagery"}},ImageryLabels:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,subdomains:["server","services"],pane:s?"esri-labels":"tilePane",attribution:""}},ImageryTransportation:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,subdomains:["server","services"],pane:s?"esri-labels":"tilePane",attribution:""}},ShadedRelief:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:13,subdomains:["server","services"],attribution:"USGS"}},ShadedReliefLabels:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:12,subdomains:["server","services"],pane:s?"esri-labels":"tilePane",attribution:""}},Terrain:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:13,subdomains:["server","services"],attribution:"USGS, NOAA"}},TerrainLabels:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:13,subdomains:["server","services"],pane:s?"esri-labels":"tilePane",attribution:""}},USATopo:{urlTemplate:at+"//{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:15,subdomains:["server","services"],attribution:"USGS, National Geographic Society, i-cubed"}},ImageryClarity:{urlTemplate:at+"//clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community"}},Physical:{urlTemplate:at+"//{s}.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:8,subdomains:["server","services"],attribution:"U.S. National Park Service"}},ImageryFirefly:{urlTemplate:at+"//fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community",attributionUrl:"https://static.arcgis.com/attribution/World_Imagery"}}}},initialize:function(t,i){var s;if("object"==typeof t&&t.urlTemplate&&t.options)s=t;else{if("string"!=typeof t||!ut.TILES[t])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"');s=ut.TILES[t]}var r=e.Util.extend(s.options,i);e.Util.setOptions(this,r),this.options.token&&-1===s.urlTemplate.indexOf("token=")&&(s.urlTemplate+="?token="+this.options.token),this.options.proxy&&(s.urlTemplate=this.options.proxy+"?"+s.urlTemplate),e.TileLayer.prototype.initialize.call(this,s.urlTemplate,r)},onAdd:function(t){E(t),"esri-labels"===this.options.pane&&this._initPane(),this.options.attributionUrl&&B((this.options.proxy?this.options.proxy+"?":"")+this.options.attributionUrl,t),t.on("moveend",N),-1!==this._url.indexOf("World_Imagery")&&t.on("zoomanim",lt,this),e.TileLayer.prototype.onAdd.call(this,t)},onRemove:function(t){t.off("moveend",N),e.TileLayer.prototype.onRemove.call(this,t)},_initPane:function(){if(!this._map.getPane(this.options.pane)){var t=this._map.createPane(this.options.pane);t.style.pointerEvents="none",t.style.zIndex=500}},getAttribution:function(){if(this.options.attribution)var t=''+this.options.attribution+"";return t}});function lt(t){var i=t.target;if(i){var s=i.getZoom(),r=t.zoom,n=i.wrapLatLng(t.center);if(r>s&&r>13&&!this.options.downsampled){var o=i.project(n,r).divideBy(256).floor(),a=e.Util.template(this._url,e.Util.extend({s:this._getSubdomain(o),x:o.x,y:o.y,z:r},this.options)).replace(/tile/,"tilemap")+"/8/8";L.esri.request(a,{},function(t,e){if(!t)for(var i=0;i0?e.Util.getParamString(t.requestParams):""),-1!==t.url.indexOf("{s}")&&t.subdomains&&(t.url=t.url.replace("{s}",t.subdomains[0])),this.service=it(t),this.service.addEventParent(this),new RegExp(/tiles.arcgis(online)?\.com/g).test(t.url)&&(this.tileUrl=this.tileUrl.replace("://tiles","://tiles{s}"),t.subdomains=["1","2","3","4"]),this.options.token&&(this.tileUrl+="?token="+this.options.token),e.TileLayer.prototype.initialize.call(this,this.tileUrl,t)},getTileUrl:function(t){var i=this._getZoomForUrl();return e.Util.template(this.tileUrl,e.Util.extend({s:this._getSubdomain(t),x:t.x,y:t.y,z:this._lodMap&&this._lodMap[i]?this._lodMap[i]:i},this.options))},createTile:function(t,i){var s=document.createElement("img");return e.DomEvent.on(s,"load",e.Util.bind(this._tileOnLoad,this,i,s)),e.DomEvent.on(s,"error",e.Util.bind(this._tileOnError,this,i,s)),this.options.crossOrigin&&(s.crossOrigin=""),s.alt="",!this._lodMap||this._lodMap&&this._lodMap[this._getZoomForUrl()]?s.src=this.getTileUrl(t):this.once("lodmap",function(){s.src=this.getTileUrl(t)},this),s},onAdd:function(t){E(t),this._lodMap||this.metadata(function(i,s){if(!i&&s.spatialReference){var r=s.spatialReference.latestWkid||s.spatialReference.wkid;if(!this.options.attribution&&t.attributionControl&&s.copyrightText&&(this.options.attribution=s.copyrightText,t.attributionControl.addAttribution(this.getAttribution())),t.options.crs!==e.CRS.EPSG3857||102100!==r&&3857!==r)t.options.crs&&t.options.crs.code&&t.options.crs.code.indexOf(r)>-1||q("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");else{this._lodMap={};for(var n=s.tileInfo.lods,o=ht.MercatorZoomLevels,a=0;athis.options.maxZoom||t0||ns.max.x)||!i.wrapLat&&(t.ys.max.y))return!1}if(!this.options.bounds)return!0;var r=this._cellCoordsToBounds(t);return e.latLngBounds(this.options.bounds).intersects(r)},_cellCoordsToBounds:function(t){var i=this._map,s=this.options.cellSize,r=t.multiplyBy(s),n=r.add([s,s]),o=i.wrapLatLng(i.unproject(r,t.z)),a=i.wrapLatLng(i.unproject(n,t.z));return e.latLngBounds(o,a)},_cellCoordsToKey:function(t){return t.x+":"+t.y},_keyToCellCoords:function(t){var i=t.split(":"),s=parseInt(i[0],10),r=parseInt(i[1],10);return e.point(s,r)},_removeOtherCells:function(t){for(var e in this._cells)t.contains(this._keyToCellCoords(e))||this._removeCell(e)},_removeCell:function(t){var e=this._activeCells[t];e&&(delete this._activeCells[t],this.cellLeave&&this.cellLeave(e.bounds,e.coords),this.fire("cellleave",{bounds:e.bounds,coords:e.coords}))},_removeCells:function(){for(var t in this._cells){var e=this._cells[t].bounds,i=this._cells[t].coords;this.cellLeave&&this.cellLeave(e,i),this.fire("cellleave",{bounds:e,coords:i})}},_addCell:function(t){this._wrapCoords(t);var e=this._cellCoordsToKey(t),i=this._cells[e];i&&!this._activeCells[e]&&(this.cellEnter&&this.cellEnter(i.bounds,t),this.fire("cellenter",{bounds:i.bounds,coords:t}),this._activeCells[e]=i),i||(i={coords:t,bounds:this._cellCoordsToBounds(t)},this._cells[e]=i,this._activeCells[e]=i,this.createCell&&this.createCell(i.bounds,t),this.fire("cellcreate",{bounds:i.bounds,coords:t}))},_wrapCoords:function(t){t.x=this._wrapLng?e.Util.wrapNum(t.x,this._wrapLng):t.x,t.y=this._wrapLat?e.Util.wrapNum(t.y,this._wrapLat):t.y},_getCellNumBounds:function(){var t=this._map.getPixelWorldBounds(),i=this._getCellSize();return t?e.bounds(t.min.divideBy(i).floor(),t.max.divideBy(i).ceil().subtract([1,1])):null}});function yt(t){this.values=[].concat(t||[])}yt.prototype.query=function(t){var e=this.getIndex(t);return this.values[e]},yt.prototype.getIndex=function(t){this.dirty&&this.sort();for(var e,i,s=0,r=this.values.length-1;s<=r;)if(e=(s+r)/2|0,+(i=this.values[Math.round(e)]).value<+t)s=e+1;else{if(!(+i.value>+t))return e;r=e-1}return Math.abs(~r)},yt.prototype.between=function(t,e){var i=this.getIndex(t),s=this.getIndex(e);if(0===i&&0===s)return[];for(;this.values[i-1]&&this.values[i-1].value===t;)i--;for(;this.values[s+1]&&this.values[s+1].value===e;)s++;return this.values[s]&&this.values[s].value===e&&this.values[s+1]&&s++,this.values.slice(i,s)},yt.prototype.insert=function(t){return this.values.splice(this.getIndex(t.value),0,t),this},yt.prototype.bulkAdd=function(t,e){return this.values=this.values.concat([].concat(t||[])),e?this.sort():this.dirty=!0,this},yt.prototype.sort=function(){return this.values.sort(function(t,e){return+e.value-+t.value}).reverse(),this.dirty=!1,this};var gt=ft.extend({options:{attribution:null,where:"1=1",fields:["*"],from:!1,to:!1,timeField:!1,timeFilterMode:"server",simplifyFactor:0,precision:6},initialize:function(t){if(ft.prototype.initialize.call(this,t),t=k(t),t=e.Util.setOptions(this,t),this.service=ot(t),this.service.addEventParent(this),"*"!==this.options.fields[0]){for(var i=!1,s=0;s=0;s--){var r=t[s].id;-1===this._currentSnapshot.indexOf(r)&&this._currentSnapshot.push(r),-1===this._cache[i].indexOf(r)&&this._cache[i].push(r)}this.options.timeField&&this._buildTimeIndexes(t),this.createLayers(t)},_buildQuery:function(t){var i=this.service.query().intersects(t).where(this.options.where).fields(this.options.fields).precision(this.options.precision);return this.options.requestParams&&e.Util.extend(i.params,this.options.requestParams),this.options.simplifyFactor&&i.simplify(this._map,this.options.simplifyFactor),"server"===this.options.timeFilterMode&&this.options.from&&this.options.to&&i.between(this.options.from,this.options.to),i},setWhere:function(t,i,s){this.options.where=t&&t.length?t:"1=1";for(var r=[],n=[],o=0,a=null,u=e.Util.bind(function(t,u){if(t&&(a=t),u)for(var l=u.features.length-1;l>=0;l--)n.push(u.features[l].id);--o<=0&&this._visibleZoom()&&(this._currentSnapshot=n,e.Util.requestAnimFrame(e.Util.bind(function(){this.removeLayers(r),this.addLayers(n),i&&i.call(s,a)},this)))},this),l=this._currentSnapshot.length-1;l>=0;l--)r.push(this._currentSnapshot[l]);for(var h in this._activeCells){o++;var p=this._keyToCellCoords(h),c=this._cellCoordsToBounds(p);this._requestFeatures(c,h,u)}return this},getWhere:function(){return this.options.where},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(t,i,s,r){var n=this.options.from,o=this.options.to,a=0,u=null,l=e.Util.bind(function(e){e&&(u=e),this._filterExistingFeatures(n,o,t,i),a--,s&&a<=0&&s.call(r,u)},this);if(this.options.from=t,this.options.to=i,this._filterExistingFeatures(n,o,t,i),"server"===this.options.timeFilterMode)for(var h in this._activeCells){a++;var p=this._keyToCellCoords(h),c=this._cellCoordsToBounds(p);this._requestFeatures(c,h,l)}return this},refresh:function(){for(var t in this._activeCells){var e=this._keyToCellCoords(t),i=this._cellCoordsToBounds(e);this._requestFeatures(i,t)}this.redraw&&this.once("load",function(){this.eachFeature(function(t){this._redraw(t.feature.id)},this)},this)},_filterExistingFeatures:function(t,i,s,r){var n=t&&i?this._getFeaturesInTimeRange(t,i):this._currentSnapshot,o=this._getFeaturesInTimeRange(s,r);if(o.indexOf)for(var a=0;a=0&&n.splice(u,1)}e.Util.requestAnimFrame(e.Util.bind(function(){this.removeLayers(n),this.addLayers(o)},this))},_getFeaturesInTimeRange:function(t,e){var i,s=[];if(this.options.timeField.start&&this.options.timeField.end){var r=this._startTimeIndex.between(t,e),n=this._endTimeIndex.between(t,e);i=r.concat(n)}else{if(!this._timeIndex)return q("You must set timeField in the layer constructor in order to manipulate the start and end time filter."),[];i=this._timeIndex.between(t,e)}for(var o=i.length-1;o>=0;o--)s.push(i[o].id);return s},_buildTimeIndexes:function(t){var e,i;if(this.options.timeField.start&&this.options.timeField.end){var s=[],r=[];for(e=t.length-1;e>=0;e--)i=t[e],s.push({id:i.id,value:new Date(i.properties[this.options.timeField.start])}),r.push({id:i.id,value:new Date(i.properties[this.options.timeField.end])});this._startTimeIndex.bulkAdd(s),this._endTimeIndex.bulkAdd(r)}else{var n=[];for(e=t.length-1;e>=0;e--)i=t[e],n.push({id:i.id,value:new Date(i.properties[this.options.timeField])});this._timeIndex.bulkAdd(n)}},_featureWithinTimeRange:function(t){if(!this.options.from||!this.options.to)return!0;var e=+this.options.from.valueOf(),i=+this.options.to.valueOf();if("string"==typeof this.options.timeField){var s=+t.properties[this.options.timeField];return s>=e&&s<=i}if(this.options.timeField.start&&this.options.timeField.end){var r=+t.properties[this.options.timeField.start],n=+t.properties[this.options.timeField.end];return r>=e&&r<=i||n>=e&&n<=i}},_visibleZoom:function(){if(!this._map)return!1;var t=this._map.getZoom();return!(t>this.options.maxZoom||t=0;r--)o[r].properties[n.objectIdField]=o.length>1?e[r].objectId:e.objectId,o[r].id=o.length>1?e[r].objectId:e.objectId;this.createLayers(o)}i&&i.call(s,t,e)},this))}},this))},updateFeature:function(t,e,i){this.updateFeatures(t,e,i)},updateFeatures:function(t,e,i){var s=t.features?t.features:[t];this.service.updateFeatures(t,function(t,r){if(!t){for(var n=s.length-1;n>=0;n--)this.removeLayers([s[n].id],!0);this.createLayers(s)}e&&e.call(i,t,r)},this)},deleteFeature:function(t,e,i){this.deleteFeatures(t,e,i)},deleteFeatures:function(t,e,i){return this.service.deleteFeatures(t,function(t,s){var r=s.length?s:[s];if(!t&&r.length>0)for(var n=r.length-1;n>=0;n--)this.removeLayers([r[n].objectId],!0);e&&e.call(i,t,s)},this)}}),vt=gt.extend({options:{cacheLayers:!0},initialize:function(t){gt.prototype.initialize.call(this,t),this._originalStyle=this.options.style,this._layers={}},onRemove:function(t){for(var e in this._layers)t.removeLayer(this._layers[e]),this.fire("removefeature",{feature:this._layers[e].feature,permanent:!1},!0);return gt.prototype.onRemove.call(this,t)},createNewLayer:function(t){var i=e.GeoJSON.geometryToLayer(t,this.options);return i&&(i.defaultOptions=i.options),i},_updateLayer:function(t,i){var s=[],r=this.options.coordsToLatLng||e.GeoJSON.coordsToLatLng;switch(i.properties&&(t.feature.properties=i.properties),i.geometry.type){case"Point":s=e.GeoJSON.coordsToLatLng(i.geometry.coordinates),t.setLatLng(s);break;case"LineString":s=e.GeoJSON.coordsToLatLngs(i.geometry.coordinates,0,r),t.setLatLngs(s);break;case"MultiLineString":case"Polygon":s=e.GeoJSON.coordsToLatLngs(i.geometry.coordinates,1,r),t.setLatLngs(s);break;case"MultiPolygon":s=e.GeoJSON.coordsToLatLngs(i.geometry.coordinates,2,r),t.setLatLngs(s)}},createLayers:function(t){for(var e=t.length-1;e>=0;e--){var i,s=t[e],r=this._layers[s.id];!this._visibleZoom()||!r||this._map.hasLayer(r)||this.options.timeField&&!this._featureWithinTimeRange(s)||(this._map.addLayer(r),this.fire("addfeature",{feature:r.feature},!0)),r&&this.options.simplifyFactor>0&&(r.setLatLngs||r.setLatLng)&&this._updateLayer(r,s),r||((i=this.createNewLayer(s))?(i.feature=s,i.addEventParent(this),this.options.onEachFeature&&this.options.onEachFeature(i.feature,i),this._layers[i.feature.id]=i,this.setFeatureStyle(i.feature.id,this.options.style),this.fire("createfeature",{feature:i.feature},!0),this._visibleZoom()&&(!this.options.timeField||this.options.timeField&&this._featureWithinTimeRange(s))&&this._map.addLayer(i)):q("invalid GeoJSON encountered"))}},addLayers:function(t){for(var e=t.length-1;e>=0;e--){var i=this._layers[t[e]];!i||this.options.timeField&&!this._featureWithinTimeRange(i.feature)||this._map.addLayer(i)}},removeLayers:function(t,e){for(var i=t.length-1;i>=0;i--){var s=t[i],r=this._layers[s];r&&(this.fire("removefeature",{feature:r.feature,permanent:e},!0),this._map.removeLayer(r)),r&&e&&delete this._layers[s]}},cellEnter:function(t,i){this._visibleZoom()&&!this._zooming&&this._map&&e.Util.requestAnimFrame(e.Util.bind(function(){var t=this._cacheKey(i),e=this._cellCoordsToKey(i),s=this._cache[t];this._activeCells[e]&&s&&this.addLayers(s)},this))},cellLeave:function(t,i){this._zooming||e.Util.requestAnimFrame(e.Util.bind(function(){if(this._map){var t=this._cacheKey(i),e=this._cellCoordsToKey(i),s=this._cache[t],r=this._map.getBounds();if(!this._activeCells[e]&&s){for(var n=!0,o=0;o 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 }\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\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","/*\n * Copyright 2017 Esri\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// checks if 2 x,y points are equal\nfunction pointsEqual (a, b) {\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\n// checks if the first and last points of a ring are equal and closes the ring\nfunction closeRing (coordinates) {\n if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) {\n coordinates.push(coordinates[0]);\n }\n return coordinates;\n}\n\n// determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring\n// or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-\n// points-are-in-clockwise-order\nfunction ringIsClockwise (ringToTest) {\n var total = 0;\n var i = 0;\n var rLength = ringToTest.length;\n var pt1 = ringToTest[i];\n var pt2;\n for (i; i < rLength - 1; i++) {\n pt2 = ringToTest[i + 1];\n total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);\n pt1 = pt2;\n }\n return (total >= 0);\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L504-L519\nfunction vertexIntersectsVertex (a1, a2, b1, b2) {\n var uaT = ((b2[0] - b1[0]) * (a1[1] - b1[1])) - ((b2[1] - b1[1]) * (a1[0] - b1[0]));\n var ubT = ((a2[0] - a1[0]) * (a1[1] - b1[1])) - ((a2[1] - a1[1]) * (a1[0] - b1[0]));\n var uB = ((b2[1] - b1[1]) * (a2[0] - a1[0])) - ((b2[0] - b1[0]) * (a2[1] - a1[1]));\n\n if (uB !== 0) {\n var ua = uaT / uB;\n var ub = ubT / uB;\n\n if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {\n return true;\n }\n }\n\n return false;\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L521-L531\nfunction arrayIntersectsArray (a, b) {\n for (var i = 0; i < a.length - 1; i++) {\n for (var j = 0; j < b.length - 1; j++) {\n if (vertexIntersectsVertex(a[i], a[i + 1], b[j], b[j + 1])) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n// ported from terraformer.js https://github.com/Esri/Terraformer/blob/master/terraformer.js#L470-L480\nfunction coordinatesContainPoint (coordinates, point) {\n var contains = false;\n for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) {\n if (((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1]) ||\n (coordinates[j][1] <= point[1] && point[1] < coordinates[i][1])) &&\n (point[0] < (((coordinates[j][0] - coordinates[i][0]) * (point[1] - coordinates[i][1])) / (coordinates[j][1] - coordinates[i][1])) + coordinates[i][0])) {\n contains = !contains;\n }\n }\n return contains;\n}\n\n// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L106-L113\nfunction coordinatesContainCoordinates (outer, inner) {\n var intersects = arrayIntersectsArray(outer, inner);\n var contains = coordinatesContainPoint(outer, inner[0]);\n if (!intersects && contains) {\n return true;\n }\n return false;\n}\n\n// do any polygons in this array contain any other polygons in this array?\n// used for checking for holes in arcgis rings\n// ported from terraformer-arcgis-parser.js https://github.com/Esri/terraformer-arcgis-parser/blob/master/terraformer-arcgis-parser.js#L117-L172\nfunction convertRingsToGeoJSON (rings) {\n var outerRings = [];\n var holes = [];\n var x; // iterator\n var outerRing; // current outer ring being evaluated\n var hole; // current hole being evaluated\n\n // for each ring\n for (var r = 0; r < rings.length; r++) {\n var ring = closeRing(rings[r].slice(0));\n if (ring.length < 4) {\n continue;\n }\n // is this ring an outer ring? is it clockwise?\n if (ringIsClockwise(ring)) {\n var polygon = [ ring.slice().reverse() ]; // wind outer rings counterclockwise for RFC 7946 compliance\n outerRings.push(polygon); // push to outer rings\n } else {\n holes.push(ring.slice().reverse()); // wind inner rings clockwise for RFC 7946 compliance\n }\n }\n\n var uncontainedHoles = [];\n\n // while there are holes left...\n while (holes.length) {\n // pop a hole off out stack\n hole = holes.pop();\n\n // loop over all outer rings and see if they contain our hole.\n var contained = false;\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n if (coordinatesContainCoordinates(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n contained = true;\n break;\n }\n }\n\n // ring is not contained in any outer ring\n // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320\n if (!contained) {\n uncontainedHoles.push(hole);\n }\n }\n\n // if we couldn't match any holes using contains we can try intersects...\n while (uncontainedHoles.length) {\n // pop a hole off out stack\n hole = uncontainedHoles.pop();\n\n // loop over all outer rings and see if any intersect our hole.\n var intersects = false;\n\n for (x = outerRings.length - 1; x >= 0; x--) {\n outerRing = outerRings[x][0];\n if (arrayIntersectsArray(outerRing, hole)) {\n // the hole is contained push it into our polygon\n outerRings[x].push(hole);\n intersects = true;\n break;\n }\n }\n\n if (!intersects) {\n outerRings.push([hole.reverse()]);\n }\n }\n\n if (outerRings.length === 1) {\n return {\n type: 'Polygon',\n coordinates: outerRings[0]\n };\n } else {\n return {\n type: 'MultiPolygon',\n coordinates: outerRings\n };\n }\n}\n\n// This function ensures that rings are oriented in the right directions\n// outer rings are clockwise, holes are counterclockwise\n// used for converting GeoJSON Polygons to ArcGIS Polygons\nfunction orientRings (poly) {\n var output = [];\n var polygon = poly.slice(0);\n var outerRing = closeRing(polygon.shift().slice(0));\n if (outerRing.length >= 4) {\n if (!ringIsClockwise(outerRing)) {\n outerRing.reverse();\n }\n\n output.push(outerRing);\n\n for (var i = 0; i < polygon.length; i++) {\n var hole = closeRing(polygon[i].slice(0));\n if (hole.length >= 4) {\n if (ringIsClockwise(hole)) {\n hole.reverse();\n }\n output.push(hole);\n }\n }\n }\n\n return output;\n}\n\n// This function flattens holes in multipolygons to one array of polygons\n// used for converting GeoJSON Polygons to ArcGIS Polygons\nfunction flattenMultiPolygonRings (rings) {\n var output = [];\n for (var i = 0; i < rings.length; i++) {\n var polygon = orientRings(rings[i]);\n for (var x = polygon.length - 1; x >= 0; x--) {\n var ring = polygon[x].slice(0);\n output.push(ring);\n }\n }\n return output;\n}\n\n// shallow object clone for feature properties and attributes\n// from http://jsperf.com/cloning-an-object/2\nfunction shallowClone (obj) {\n var target = {};\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) {\n target[i] = obj[i];\n }\n }\n return target;\n}\n\nfunction getId (attributes, idAttribute) {\n var keys = idAttribute ? [idAttribute, 'OBJECTID', 'FID'] : ['OBJECTID', 'FID'];\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n if (\n key in attributes &&\n (typeof attributes[key] === 'string' ||\n typeof attributes[key] === 'number')\n ) {\n return attributes[key];\n }\n }\n throw Error('No valid id attribute found');\n}\n\nexport function arcgisToGeoJSON (arcgis, idAttribute) {\n var geojson = {};\n\n if (arcgis.features) {\n geojson.type = 'FeatureCollection';\n geojson.features = [];\n for (var i = 0; i < arcgis.features.length; i++) {\n geojson.features.push(arcgisToGeoJSON(arcgis.features[i], idAttribute));\n }\n }\n\n if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') {\n geojson.type = 'Point';\n geojson.coordinates = [arcgis.x, arcgis.y];\n if (typeof arcgis.z === 'number') {\n geojson.coordinates.push(arcgis.z);\n }\n }\n\n if (arcgis.points) {\n geojson.type = 'MultiPoint';\n geojson.coordinates = arcgis.points.slice(0);\n }\n\n if (arcgis.paths) {\n if (arcgis.paths.length === 1) {\n geojson.type = 'LineString';\n geojson.coordinates = arcgis.paths[0].slice(0);\n } else {\n geojson.type = 'MultiLineString';\n geojson.coordinates = arcgis.paths.slice(0);\n }\n }\n\n if (arcgis.rings) {\n geojson = convertRingsToGeoJSON(arcgis.rings.slice(0));\n }\n\n if (\n typeof arcgis.xmin === 'number' &&\n typeof arcgis.ymin === 'number' &&\n typeof arcgis.xmax === 'number' &&\n typeof arcgis.ymax === 'number'\n ) {\n geojson.type = 'Polygon';\n geojson.coordinates = [[\n [arcgis.xmax, arcgis.ymax],\n [arcgis.xmin, arcgis.ymax],\n [arcgis.xmin, arcgis.ymin],\n [arcgis.xmax, arcgis.ymin],\n [arcgis.xmax, arcgis.ymax]\n ]];\n }\n\n if (arcgis.geometry || arcgis.attributes) {\n geojson.type = 'Feature';\n geojson.geometry = (arcgis.geometry) ? arcgisToGeoJSON(arcgis.geometry) : null;\n geojson.properties = (arcgis.attributes) ? shallowClone(arcgis.attributes) : null;\n if (arcgis.attributes) {\n try {\n geojson.id = getId(arcgis.attributes, idAttribute);\n } catch (err) {\n // don't set an id\n }\n }\n }\n\n // if no valid geometry was encountered\n if (JSON.stringify(geojson.geometry) === JSON.stringify({})) {\n geojson.geometry = null;\n }\n\n if (\n arcgis.spatialReference &&\n arcgis.spatialReference.wkid &&\n arcgis.spatialReference.wkid !== 4326\n ) {\n console.warn('Object converted in non-standard crs - ' + JSON.stringify(arcgis.spatialReference));\n }\n\n return geojson;\n}\n\nexport function geojsonToArcGIS (geojson, idAttribute) {\n idAttribute = idAttribute || 'OBJECTID';\n var spatialReference = { wkid: 4326 };\n var result = {};\n var i;\n\n switch (geojson.type) {\n case 'Point':\n result.x = geojson.coordinates[0];\n result.y = geojson.coordinates[1];\n result.spatialReference = spatialReference;\n break;\n case 'MultiPoint':\n result.points = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n case 'LineString':\n result.paths = [geojson.coordinates.slice(0)];\n result.spatialReference = spatialReference;\n break;\n case 'MultiLineString':\n result.paths = geojson.coordinates.slice(0);\n result.spatialReference = spatialReference;\n break;\n case 'Polygon':\n result.rings = orientRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n case 'MultiPolygon':\n result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));\n result.spatialReference = spatialReference;\n break;\n case 'Feature':\n if (geojson.geometry) {\n result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);\n }\n result.attributes = (geojson.properties) ? shallowClone(geojson.properties) : {};\n if (geojson.id) {\n result.attributes[idAttribute] = geojson.id;\n }\n break;\n case 'FeatureCollection':\n result = [];\n for (i = 0; i < geojson.features.length; i++) {\n result.push(geojsonToArcGIS(geojson.features[i], idAttribute));\n }\n break;\n case 'GeometryCollection':\n result = [];\n for (i = 0; i < geojson.geometries.length; i++) {\n result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute));\n }\n break;\n }\n\n return result;\n}\n\nexport default { arcgisToGeoJSON: arcgisToGeoJSON, geojsonToArcGIS: geojsonToArcGIS };\n","import { latLng, latLngBounds, LatLng, LatLngBounds, Util, DomUtil, GeoJSON } from 'leaflet';\r\nimport { request } 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 '@esri/arcgis-to-geojson-utils';\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.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 warn () {\r\n if (console && console.warn) {\r\n console.warn.apply(console, arguments);\r\n }\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 && !map.attributionControl._esriAttributionAdded) {\r\n map.attributionControl.setPrefix('Leaflet | Powered by Esri');\r\n\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\r\n document.getElementsByTagName('head')[0].appendChild(hoverAttributionStyle);\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution:hover');\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\r\n document.getElementsByTagName('head')[0].appendChild(attributionStyle);\r\n DomUtil.addClass(map.attributionControl._container, 'esri-truncated-attribution');\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 map.attributionControl._container.style.maxWidth = calcAttributionWidth(e.target);\r\n });\r\n\r\n map.attributionControl._esriAttributionAdded = true;\r\n }\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\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 // 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)) {\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 _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: 22,\r\n maxNativeZoom: 22,\r\n downsampled: false,\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 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 // Esri World Imagery is cached all the way to zoom 22 in select regions\r\n if (this._url.indexOf('World_Imagery') !== -1) {\r\n map.on('zoomanim', _fetchTilemap, this);\r\n }\r\n\r\n TileLayer.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n map.off('moveend', _updateMapAttribution);\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\nfunction _fetchTilemap (evt) {\r\n var map = evt.target;\r\n if (!map) { return; }\r\n\r\n var oldZoom = map.getZoom();\r\n var newZoom = evt.zoom;\r\n var newCenter = map.wrapLatLng(evt.center);\r\n\r\n if (newZoom > oldZoom && newZoom > 13 && !this.options.downsampled) {\r\n // convert wrapped lat/long into tile coordinates and use them to generate the tilemap url\r\n var tilePoint = map.project(newCenter, newZoom).divideBy(256).floor();\r\n\r\n // use new coords to determine the tilemap url\r\n var tileUrl = Util.template(this._url, Util.extend({\r\n s: this._getSubdomain(tilePoint),\r\n x: tilePoint.x,\r\n y: tilePoint.y,\r\n z: newZoom\r\n }, this.options));\r\n\r\n // 8x8 grids are cached\r\n var tilemapUrl = tileUrl.replace(/tile/, 'tilemap') + '/8/8';\r\n\r\n // an array of booleans in the response indicate missing tiles\r\n L.esri.request(tilemapUrl, {}, function (err, response) {\r\n if (!err) {\r\n for (var i = 0; i < response.data.length; i++) {\r\n if (!response.data[i]) {\r\n // if necessary, resample a lower zoom\r\n this.options.maxNativeZoom = newZoom - 1;\r\n this.options.downsampled = true;\r\n break;\r\n }\r\n // if no tiles are missing, reset the original maxZoom\r\n this.options.maxNativeZoom = 22;\r\n }\r\n }\r\n }, this);\r\n } else if (newZoom < 13) {\r\n // if the user moves to a new region, time for a fresh test\r\n this.options.downsampled = false;\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 } 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 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 } 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 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.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 this._renderImage(this.options.url + 'exportImage' + Util.getParamString(params), 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: 'png24',\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 if ((options.proxy || options.token) && options.f !== 'json') {\r\n options.f = 'json';\r\n }\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 this._renderImage(this.options.url + 'export' + Util.getParamString(params), 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 {\n bounds,\n latLngBounds,\n point,\n Layer,\n setOptions,\n Util\n} from 'leaflet';\n\nvar VirtualGrid = Layer.extend({\n\n options: {\n cellSize: 512,\n updateInterval: 150\n },\n\n initialize: function (options) {\n options = setOptions(this, options);\n this._zooming = false;\n },\n\n onAdd: function (map) {\n this._map = map;\n this._update = Util.throttle(this._update, this.options.updateInterval, this);\n this._reset();\n this._update();\n },\n\n onRemove: function () {\n this._map.removeEventListener(this.getEvents(), this);\n this._removeCells();\n },\n\n getEvents: function () {\n var events = {\n moveend: this._update,\n zoomstart: this._zoomstart,\n zoomend: this._reset\n };\n\n return events;\n },\n\n addTo: function (map) {\n map.addLayer(this);\n return this;\n },\n\n removeFrom: function (map) {\n map.removeLayer(this);\n return this;\n },\n\n _zoomstart: function () {\n this._zooming = true;\n },\n\n _reset: function () {\n this._removeCells();\n\n this._cells = {};\n this._activeCells = {};\n this._cellsToLoad = 0;\n this._cellsTotal = 0;\n this._cellNumBounds = this._getCellNumBounds();\n\n this._resetWrap();\n this._zooming = false;\n },\n\n _resetWrap: function () {\n var map = this._map;\n var crs = map.options.crs;\n\n if (crs.infinite) { return; }\n\n var cellSize = this._getCellSize();\n\n if (crs.wrapLng) {\n this._wrapLng = [\n Math.floor(map.project([0, crs.wrapLng[0]]).x / cellSize),\n Math.ceil(map.project([0, crs.wrapLng[1]]).x / cellSize)\n ];\n }\n\n if (crs.wrapLat) {\n this._wrapLat = [\n Math.floor(map.project([crs.wrapLat[0], 0]).y / cellSize),\n Math.ceil(map.project([crs.wrapLat[1], 0]).y / cellSize)\n ];\n }\n },\n\n _getCellSize: function () {\n return this.options.cellSize;\n },\n\n _update: function () {\n if (!this._map) {\n return;\n }\n\n var mapBounds = this._map.getPixelBounds();\n var cellSize = this._getCellSize();\n\n // cell coordinates range for the current view\n var cellBounds = bounds(\n mapBounds.min.divideBy(cellSize).floor(),\n mapBounds.max.divideBy(cellSize).floor());\n\n this._removeOtherCells(cellBounds);\n this._addCells(cellBounds);\n\n this.fire('cellsupdated');\n },\n\n _addCells: function (cellBounds) {\n var queue = [];\n var center = cellBounds.getCenter();\n var zoom = this._map.getZoom();\n\n var j, i, coords;\n // create a queue of coordinates to load cells from\n for (j = cellBounds.min.y; j <= cellBounds.max.y; j++) {\n for (i = cellBounds.min.x; i <= cellBounds.max.x; i++) {\n coords = point(i, j);\n coords.z = zoom;\n\n if (this._isValidCell(coords)) {\n queue.push(coords);\n }\n }\n }\n\n var cellsToLoad = queue.length;\n\n if (cellsToLoad === 0) { return; }\n\n this._cellsToLoad += cellsToLoad;\n this._cellsTotal += cellsToLoad;\n\n // sort cell queue to load cells in order of their distance to center\n queue.sort(function (a, b) {\n return a.distanceTo(center) - b.distanceTo(center);\n });\n\n for (i = 0; i < cellsToLoad; i++) {\n this._addCell(queue[i]);\n }\n },\n\n _isValidCell: function (coords) {\n var crs = this._map.options.crs;\n\n if (!crs.infinite) {\n // don't load cell if it's out of bounds and not wrapped\n var cellNumBounds = this._cellNumBounds;\n\n if (!cellNumBounds) return false;\n if (\n (!crs.wrapLng && (coords.x < cellNumBounds.min.x || coords.x > cellNumBounds.max.x)) ||\n (!crs.wrapLat && (coords.y < cellNumBounds.min.y || coords.y > cellNumBounds.max.y))\n ) {\n return false;\n }\n }\n\n if (!this.options.bounds) {\n return true;\n }\n\n // don't load cell if it doesn't intersect the bounds in options\n var cellBounds = this._cellCoordsToBounds(coords);\n return latLngBounds(this.options.bounds).intersects(cellBounds);\n },\n\n // converts cell coordinates to its geographical bounds\n _cellCoordsToBounds: function (coords) {\n var map = this._map;\n var cellSize = this.options.cellSize;\n var nwPoint = coords.multiplyBy(cellSize);\n var sePoint = nwPoint.add([cellSize, cellSize]);\n var nw = map.wrapLatLng(map.unproject(nwPoint, coords.z));\n var se = map.wrapLatLng(map.unproject(sePoint, coords.z));\n\n return latLngBounds(nw, se);\n },\n\n // converts cell coordinates to key for the cell cache\n _cellCoordsToKey: function (coords) {\n return coords.x + ':' + coords.y;\n },\n\n // converts cell cache key to coordiantes\n _keyToCellCoords: function (key) {\n var kArr = key.split(':');\n var x = parseInt(kArr[0], 10);\n var y = parseInt(kArr[1], 10);\n\n return point(x, y);\n },\n\n // remove any present cells that are off the specified bounds\n _removeOtherCells: function (bounds) {\n for (var key in this._cells) {\n if (!bounds.contains(this._keyToCellCoords(key))) {\n this._removeCell(key);\n }\n }\n },\n\n _removeCell: function (key) {\n var cell = this._activeCells[key];\n\n if (cell) {\n delete this._activeCells[key];\n\n if (this.cellLeave) {\n this.cellLeave(cell.bounds, cell.coords);\n }\n\n this.fire('cellleave', {\n bounds: cell.bounds,\n coords: cell.coords\n });\n }\n },\n\n _removeCells: function () {\n for (var key in this._cells) {\n var cellBounds = this._cells[key].bounds;\n var coords = this._cells[key].coords;\n\n if (this.cellLeave) {\n this.cellLeave(cellBounds, coords);\n }\n\n this.fire('cellleave', {\n bounds: cellBounds,\n coords: coords\n });\n }\n },\n\n _addCell: function (coords) {\n // wrap cell coords if necessary (depending on CRS)\n this._wrapCoords(coords);\n\n // generate the cell key\n var key = this._cellCoordsToKey(coords);\n\n // get the cell from the cache\n var cell = this._cells[key];\n // if this cell should be shown as isnt active yet (enter)\n\n if (cell && !this._activeCells[key]) {\n if (this.cellEnter) {\n this.cellEnter(cell.bounds, coords);\n }\n\n this.fire('cellenter', {\n bounds: cell.bounds,\n coords: coords\n });\n\n this._activeCells[key] = cell;\n }\n\n // if we dont have this cell in the cache yet (create)\n if (!cell) {\n cell = {\n coords: coords,\n bounds: this._cellCoordsToBounds(coords)\n };\n\n this._cells[key] = cell;\n this._activeCells[key] = cell;\n\n if (this.createCell) {\n this.createCell(cell.bounds, coords);\n }\n\n this.fire('cellcreate', {\n bounds: cell.bounds,\n coords: coords\n });\n }\n },\n\n _wrapCoords: function (coords) {\n coords.x = this._wrapLng ? Util.wrapNum(coords.x, this._wrapLng) : coords.x;\n coords.y = this._wrapLat ? Util.wrapNum(coords.y, this._wrapLat) : coords.y;\n },\n\n // get the global cell coordinates range for the current zoom\n _getCellNumBounds: function () {\n var worldBounds = this._map.getPixelWorldBounds();\n var size = this._getCellSize();\n\n return worldBounds ? bounds(\n worldBounds.min.divideBy(size).floor(),\n worldBounds.max.divideBy(size).ceil().subtract([1, 1])) : null;\n }\n});\n\nexport default VirtualGrid;\n","function BinarySearchIndex (values) {\n this.values = [].concat(values || []);\n}\n\nBinarySearchIndex.prototype.query = function (value) {\n var index = this.getIndex(value);\n return this.values[index];\n};\n\nBinarySearchIndex.prototype.getIndex = function getIndex (value) {\n if (this.dirty) {\n this.sort();\n }\n\n var minIndex = 0;\n var maxIndex = this.values.length - 1;\n var currentIndex;\n var currentElement;\n\n while (minIndex <= maxIndex) {\n currentIndex = (minIndex + maxIndex) / 2 | 0;\n currentElement = this.values[Math.round(currentIndex)];\n if (+currentElement.value < +value) {\n minIndex = currentIndex + 1;\n } else if (+currentElement.value > +value) {\n maxIndex = currentIndex - 1;\n } else {\n return currentIndex;\n }\n }\n\n return Math.abs(~maxIndex);\n};\n\nBinarySearchIndex.prototype.between = function between (start, end) {\n var startIndex = this.getIndex(start);\n var endIndex = this.getIndex(end);\n\n if (startIndex === 0 && endIndex === 0) {\n return [];\n }\n\n while (this.values[startIndex - 1] && this.values[startIndex - 1].value === start) {\n startIndex--;\n }\n\n while (this.values[endIndex + 1] && this.values[endIndex + 1].value === end) {\n endIndex++;\n }\n\n if (this.values[endIndex] && this.values[endIndex].value === end && this.values[endIndex + 1]) {\n endIndex++;\n }\n\n return this.values.slice(startIndex, endIndex);\n};\n\nBinarySearchIndex.prototype.insert = function insert (item) {\n this.values.splice(this.getIndex(item.value), 0, item);\n return this;\n};\n\nBinarySearchIndex.prototype.bulkAdd = function bulkAdd (items, sort) {\n this.values = this.values.concat([].concat(items || []));\n\n if (sort) {\n this.sort();\n } else {\n this.dirty = true;\n }\n\n return this;\n};\n\nBinarySearchIndex.prototype.sort = function sort () {\n this.values.sort(function (a, b) {\n return +b.value - +a.value;\n }).reverse();\n this.dirty = false;\n return this;\n};\n\nexport default BinarySearchIndex;\n","import { Util } from 'leaflet';\r\nimport featureLayerService from '../../Services/FeatureLayerService';\r\nimport { getUrlParams, warn, setEsriAttribution } from '../../Util';\r\nimport VirtualGrid from 'leaflet-virtual-grid';\r\nimport BinarySearchIndex from 'tiny-binary-search';\r\n\r\nexport var FeatureManager = VirtualGrid.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 },\r\n\r\n /**\r\n * Constructor\r\n */\r\n\r\n initialize: function (options) {\r\n VirtualGrid.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('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 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 (this.service.options.isModern === false) {\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 (!forceJsonFormat && supportedFormats && supportedFormats.indexOf('geoJSON') !== -1) {\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 (!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 }, this);\r\n\r\n map.on('zoomend', this._handleZoomChange, this);\r\n\r\n return VirtualGrid.prototype.onAdd.call(this, map);\r\n },\r\n\r\n onRemove: function (map) {\r\n map.off('zoomend', this._handleZoomChange, this);\r\n\r\n return VirtualGrid.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) {\r\n this._activeRequests++;\r\n\r\n // our first active request fires loading\r\n if (this._activeRequests === 1) {\r\n this.fire('loading', {\r\n bounds: bounds\r\n }, true);\r\n }\r\n\r\n return this._buildQuery(bounds).run(function (error, featureCollection, response) {\r\n if (response && response.exceededTransferLimit) {\r\n this.fire('drawlimitexceeded');\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(Util.bind(function () {\r\n this._addFeatures(featureCollection.features, coords);\r\n this._postProcessFeatures(bounds);\r\n }, this));\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 }, 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 var key = this._cacheKey(coords);\r\n this._cache[key] = this._cache[key] || [];\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 (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) {\r\n var query = this.service.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.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 (this.options.timeFilterMode === 'server' && this.options.from && this.options.to) {\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 (pendingRequests <= 0 && this._visibleZoom()) {\r\n this._currentSnapshot = newSnapshot;\r\n // schedule adding features for the next animation frame\r\n Util.requestAnimFrame(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 }, 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 for (var key in this._activeCells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, key, 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._activeCells) {\r\n pendingRequests++;\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, key, requestCallback);\r\n }\r\n }\r\n\r\n return this;\r\n },\r\n\r\n refresh: function () {\r\n for (var key in this._activeCells) {\r\n var coords = this._keyToCellCoords(key);\r\n var bounds = this._cellCoordsToBounds(coords);\r\n this._requestFeatures(bounds, key);\r\n }\r\n\r\n if (this.redraw) {\r\n this.once('load', function () {\r\n this.eachFeature(function (layer) {\r\n this._redraw(layer.feature.id);\r\n }, this);\r\n }, this);\r\n }\r\n },\r\n\r\n _filterExistingFeatures: function (oldFrom, oldTo, newFrom, newTo) {\r\n var layersToRemove = (oldFrom && oldTo) ? this._getFeaturesInTimeRange(oldFrom, oldTo) : 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(Util.bind(function () {\r\n this.removeLayers(layersToRemove);\r\n this.addLayers(layersToAdd);\r\n }, this));\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('You must set timeField in the layer constructor in order to manipulate the start and end time filter.');\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 ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to));\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 { return true; }\r\n },\r\n\r\n _handleZoomChange: function () {\r\n if (!this._visibleZoom()) {\r\n this.removeLayers(this._currentSnapshot);\r\n this._currentSnapshot = [];\r\n } else {\r\n /*\r\n for every cell in this._activeCells\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._activeCells) {\r\n var coords = this._activeCells[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(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 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(Util.bind(function (error, metadata) {\r\n if (error) {\r\n if (callback) { callback.call(this, error, null); }\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(features, 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] = featuresArray.length > 1 ? response[i].objectId : response.objectId;\r\n // we also need to update the geojson id for createLayers() to function\r\n featuresArray[i].id = featuresArray.length > 1 ? response[i].objectId : response.objectId;\r\n }\r\n this.createLayers(featuresArray);\r\n }\r\n\r\n if (callback) {\r\n callback.call(context, error, response);\r\n }\r\n }, this));\r\n }, this));\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(features, 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.createLayers(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\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(ids, 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 }, this);\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\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 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('removefeature', {\r\n feature: this._layers[i].feature,\r\n permanent: false\r\n }, true);\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(geojson.geometry.coordinates, 0, coordsToLatLng);\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiLineString':\r\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng);\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'Polygon':\r\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 1, coordsToLatLng);\r\n layer.setLatLngs(latlngs);\r\n break;\r\n case 'MultiPolygon':\r\n latlngs = GeoJSON.coordsToLatLngs(geojson.geometry.coordinates, 2, coordsToLatLng);\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 (this._visibleZoom() && layer && !this._map.hasLayer(layer) && (!this.options.timeField || this._featureWithinTimeRange(geojson))) {\r\n this._map.addLayer(layer);\r\n this.fire('addfeature', {\r\n feature: layer.feature\r\n }, true);\r\n }\r\n\r\n // update geometry if necessary\r\n if (layer && this.options.simplifyFactor > 0 && (layer.setLatLngs || layer.setLatLng)) {\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('createfeature', {\r\n feature: newLayer.feature\r\n }, true);\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 (this._visibleZoom() && (!this.options.timeField || (this.options.timeField && this._featureWithinTimeRange(geojson)))) {\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 (layer && (!this.options.timeField || this._featureWithinTimeRange(layer.feature))) {\r\n this._map.addLayer(layer);\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('removefeature', {\r\n feature: layer.feature,\r\n permanent: permanent\r\n }, true);\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(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 cellLeave: function (bounds, coords) {\r\n if (!this._zooming) {\r\n Util.requestAnimFrame(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 (layer && layer.getBounds && mapBounds.intersects(layer.getBounds())) {\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 * 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 (typeof this._layers[i].getLatLng === 'function' && activeBounds.contains(this._layers[i].getLatLng())) {\r\n fn.call(context, this._layers[i]);\r\n } else if (typeof this._layers[i].getBounds === 'function' && activeBounds.intersects(this._layers[i].getBounds())) {\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(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));\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(geojson, latLng(geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]));\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"],"names":["cors","window","XMLHttpRequest","pointerEvents","document","documentElement","style","Support","options","attributionWidthOffset","callbacks","serialize","params","data","key","f","hasOwnProperty","value","param","type","Object","prototype","toString","call","length","JSON","stringify","join","valueOf","encodeURIComponent","createRequest","callback","context","httpRequest","onerror","e","onreadystatechange","Util","falseFn","error","code","message","response","readyState","parse","responseText","ontimeout","this","xmlHttpPost","url","open","timeout","setRequestHeader","send","xmlHttpGet","request","paramString","requestLength","jsonp","warn","_EsriLeafletCallbacks","callbackId","responseType","script","DomUtil","create","body","src","id","addClass","abort","_callback","get","CORS","JSONP","Request","post","closeRing","coordinates","a","b","i","pointsEqual","push","ringIsClockwise","ringToTest","pt2","total","rLength","pt1","vertexIntersectsVertex","a1","a2","b1","b2","uaT","ubT","uB","ua","ub","arrayIntersectsArray","j","coordinatesContainCoordinates","outer","inner","intersects","contains","point","l","coordinatesContainPoint","orientRings","poly","output","polygon","slice","outerRing","shift","reverse","hole","shallowClone","obj","target","arcgisToGeoJSON","arcgis","idAttribute","geojson","features","x","y","z","points","paths","rings","outerRings","holes","r","ring","uncontainedHoles","pop","contained","convertRingsToGeoJSON","xmin","ymin","xmax","ymax","geometry","attributes","properties","keys","Error","getId","err","spatialReference","wkid","console","geojsonToArcGIS","result","flattenMultiPolygonRings","geometries","idAttr","g2a","a2g","extentToBounds","extent","sw","latLng","ne","latLngBounds","boundsToExtent","bounds","getSouthWest","lng","lat","getNorthEast","knownFieldNames","_findIdAttributeFromResponse","objectIdFieldName","fields","name","match","_findIdAttributeFromFeature","feature","responseToFeatureCollection","objectIdField","results","count","featureCollection","cleanUrl","trim","getUrlParams","indexOf","requestParams","queryString","substring","split","decodeURI","replace","isArcgisOnline","test","geojsonTypeToArcGIS","geoJsonType","arcgisGeometryType","apply","arguments","calcAttributionWidth","map","getSize","setEsriAttribution","attributionControl","_esriAttributionAdded","setPrefix","hoverAttributionStyle","createElement","innerHTML","getElementsByTagName","appendChild","_container","attributionStyle","on","maxWidth","_setGeometry","geometryType","LatLngBounds","getLatLng","LatLng","GeoJSON","getLayers","toGeoJSON","_getAttributionData","bind","attributions","_esriAttributions","c","contributors","contributor","coverageAreas","coverageArea","southWest","bbox","northEast","attribution","score","minZoom","zoomMin","maxZoom","zoomMax","sort","_updateMapAttribution","evt","oldAttributions","attributionElement","querySelector","newAttributions","getBounds","wrappedBounds","wrap","zoom","getZoom","text","substr","fire","EsriUtil","Task","Class","extend","proxy","useCors","generateSetter","initialize","endpoint","_service","setOptions","setters","setter","token","authenticate","format","boolean","returnUnformattedValues","path","_request","method","Query","offset","limit","precision","featureIds","returnGeometry","returnM","transform","where","outSR","outFields","within","_setGeometryParams","spatialRel","crosses","touches","overlaps","bboxIntersects","indexIntersects","nearby","latlng","radius","units","distance","inSr","string","between","start","end","time","simplify","factor","mapWidth","Math","abs","getWest","getEast","maxAllowableOffset","orderBy","fieldName","order","orderByFields","run","_cleanParams","isModern","_trapSQLerrors","returnCountOnly","ids","returnIdsOnly","objectIds","returnExtentOnly","distinct","returnDistinctValues","pixelSize","rawPoint","castPoint","layer","converted","query","Find","sr","layers","dynamicLayers","returnZ","gdbVersion","layerDefs","find","Identify","IdentifyFeatures","tolerance","size","imageDisplay","mapExtent","at","layerDef","undefined","layerId","identifyFeatures","IdentifyImage","setMosaicRule","setRenderingRule","setPixelSize","returnCatalogItems","getMosaicRule","mosaicRule","getRenderingRule","renderingRule","getPixelSize","_responseToGeoJSON","location","catalogItems","catalogItemVisibilities","geoJSON","pixel","crs","OBJECTID","objectId","Values","values","catalogItemVisibility","identifyImage","Service","Evented","_requestQueue","_authenticating","metadata","_runQueue","getTimeout","setTimeout","wrappedCallback","_createServiceCallback","MapService","identify","mapService","ImageService","imageService","FeatureLayerService","addFeature","addFeatures","featuresArray","addResults","updateFeature","updateFeatures","updateResults","deleteFeature","deleteFeatures","deleteResults","featureLayerService","tileProtocol","protocol","BasemapLayer","TileLayer","statics","TILES","Streets","urlTemplate","subdomains","attributionUrl","Topographic","Oceans","OceansLabels","pane","NationalGeographic","DarkGray","DarkGrayLabels","Gray","GrayLabels","Imagery","maxNativeZoom","downsampled","ImageryLabels","ImageryTransportation","ShadedRelief","ShadedReliefLabels","Terrain","TerrainLabels","USATopo","ImageryClarity","Physical","ImageryFirefly","config","tileOptions","onAdd","_initPane","_url","_fetchTilemap","onRemove","off","_map","getPane","createPane","zIndex","getAttribution","oldZoom","newZoom","newCenter","wrapLatLng","center","tilePoint","project","divideBy","floor","tilemapUrl","template","s","_getSubdomain","L","esri","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","_getZoomForUrl","_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","swProjected","boundsProjected","_calculateImageSize","top","latLngToLayerPoint","bottom","ImageMapLayer","transparent","setPixelType","pixelType","getPixelType","setBandIds","bandIds","isArray","getBandIds","setNoData","noData","noDataInterpretation","getNoData","getNoDataInterpretation","identifyRequest","parseInt","bboxSR","imageSR","interpolation","compressionQuality","href","DynamicMapLayer","timeOptions","getDynamicLayers","setDynamicLayers","setLayers","getLayerDefs","setLayerDefs","getTimeOptions","setTimeOptions","dpi","disableCache","_ts","Date","now","imageData","VirtualGrid","cellSize","_zooming","removeEventListener","getEvents","_removeCells","moveend","zoomstart","_zoomstart","zoomend","removeFrom","_cells","_activeCells","_cellsToLoad","_cellsTotal","_cellNumBounds","_getCellNumBounds","_resetWrap","infinite","_getCellSize","wrapLng","_wrapLng","ceil","wrapLat","_wrapLat","mapBounds","cellBounds","_removeOtherCells","_addCells","queue","getCenter","_isValidCell","cellsToLoad","distanceTo","_addCell","cellNumBounds","_cellCoordsToBounds","nwPoint","multiplyBy","sePoint","add","nw","se","_cellCoordsToKey","_keyToCellCoords","kArr","_removeCell","cell","cellLeave","_wrapCoords","cellEnter","createCell","wrapNum","worldBounds","getPixelWorldBounds","BinarySearchIndex","concat","index","getIndex","dirty","currentIndex","currentElement","minIndex","maxIndex","round","startIndex","endIndex","insert","item","splice","bulkAdd","items","FeatureManager","timeField","timeFilterMode","simplifyFactor","oidCheck","_startTimeIndex","_endTimeIndex","_timeIndex","_cache","_currentSnapshot","_activeRequests","supportedFormats","supportedQueryFormats","forceJsonFormat","_handleZoomChange","_visibleZoom","_requestFeatures","_buildQuery","exceededTransferLimit","requestAnimFrame","_addFeatures","_postProcessFeatures","_cacheKey","_buildTimeIndexes","createLayers","setWhere","oldSnapshot","newSnapshot","pendingRequests","requestError","requestCallback","removeLayers","addLayers","getWhere","oldFrom","oldTo","_filterExistingFeatures","refresh","eachFeature","_redraw","newFrom","newTo","layersToRemove","_getFeaturesInTimeRange","layersToAdd","shouldRemoveLayer","search","startTimes","endTimes","startTimeEntries","endTimeEntries","timeEntries","_featureWithinTimeRange","date","startDate","endDate","_getMetadata","_metadata","responseArray","FeatureLayer","cacheLayers","_originalStyle","_layers","permanent","createNewLayer","geometryToLayer","defaultOptions","_updateLayer","latlngs","coordsToLatLng","coordsToLatLngs","setLatLngs","newLayer","hasLayer","onEachFeature","setFeatureStyle","cacheKey","cellKey","removable","resetStyle","resetFeatureStyle","setStyle","Path","eachActiveFeature","activeBounds","getFeature","setIcon","pointToLayer","updatedIcon","icon","updatedStyle"],"mappings":";;;8OAAWA,EAASC,OAAOC,gBAAkB,oBAAqB,IAAID,OAAOC,eAClEC,EAAiE,KAAjDC,SAASC,gBAAgBC,MAAMH,cAE/CI,GACTP,KAAMA,EACNG,cAAeA,GCLNK,GACTC,uBAAwB,ICGtBC,EAAY,EAEhB,SAASC,EAAWC,GAClB,IAAIC,EAAO,GAIX,IAAK,IAAIC,KAFTF,EAAOG,EAAIH,EAAOG,GAAK,OAEPH,EACd,GAAIA,EAAOI,eAAeF,GAAM,CAC9B,IAEIG,EAFAC,EAAQN,EAAOE,GACfK,EAAOC,OAAOC,UAAUC,SAASC,KAAKL,GAGtCL,EAAKW,SACPX,GAAQ,KAIRI,EADW,mBAATE,EACoD,oBAA7CC,OAAOC,UAAUC,SAASC,KAAKL,EAAM,IAA6BO,KAAKC,UAAUR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