{"version":3,"file":"esri-leaflet.js","sources":["../src/EsriLeaflet.js","../src/Util.js","../src/Request.js","../src/Services/Service.js","../src/Services/FeatureLayer.js","../src/Services/MapService.js","../src/Services/ImageService.js","../src/Tasks/Task.js","../src/Tasks/Query.js","../src/Tasks/Find.js","../src/Tasks/Identify.js","../src/Tasks/IdentifyImage.js","../src/Tasks/IdentifyFeatures.js","../src/Layers/BasemapLayer.js","../src/Layers/RasterLayer.js","../src/Layers/DynamicMapLayer.js","../src/Layers/ImageMapLayer.js","../src/Layers/TiledMapLayer.js","../src/Layers/FeatureLayer/FeatureGrid.js","../src/Layers/FeatureLayer/FeatureManager.js","../src/Layers/FeatureLayer/FeatureLayer.js","../src/Controls/Logo.js"],"names":["EsriLeaflet","VERSION","Layers","Services","Controls","Tasks","Util","Support","CORS","window","XMLHttpRequest","pointerEvents","document","documentElement","style","L","esri","clone","obj","target","i","hasOwnProperty","pointsEqual","a","b","length","closeRing","coordinates","push","ringIsClockwise","ringToTest","pt2","total","rLength","pt1","vertexIntersectsVertex","a1","a2","b1","b2","uaT","ubT","uB","ua","ub","arrayIntersectsArray","j","coordinatesContainPoint","point","contains","l","coordinatesContainCoordinates","outer","inner","intersects","convertRingsToGeoJSON","rings","x","outerRing","hole","outerRings","holes","r","ring","slice","polygon","uncontainedHoles","pop","contained","reverse","type","orientRings","poly","output","shift","flattenMultiPolygonRings","raf","requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","msRequestAnimationFrame","cb","setTimeout","extentToBounds","extent","sw","LatLng","ymin","xmin","ne","ymax","xmax","LatLngBounds","boundsToExtent","bounds","latLngBounds","getSouthWest","lng","lat","getNorthEast","spatialReference","wkid","arcgisToGeojson","arcgis","idAttribute","geojson","y","points","paths","geometry","attributes","properties","id","OBJECTID","FID","geojsonToArcGIS","result","features","geometries","responseToFeatureCollection","response","objectIdField","objectIdFieldName","fields","name","featureCollection","results","cleanUrl","url","replace","isArcgisOnline","test","geojsonTypeToArcGIS","geoJsonType","arcgisGeometryType","bind","serialize","params","data","f","key","value","param","Object","prototype","toString","call","JSON","stringify","join","valueOf","encodeURIComponent","createRequest","callback","context","httpRequest","onerror","error","code","message","onreadystatechange","readyState","parse","responseText","e","callbacks","_EsriLeafletCallbacks","Request","request","paramString","requestLength","open","send","setRequestHeader","get","JSONP","console","warn","post","XMLHTTP","callbackId","script","DomUtil","create","body","src","responseType","abort","_callback","Service","Class","extend","includes","Mixin","Events","options","proxy","useCors","initialize","this","_requestQueue","_authenticating","setOptions","path","_request","metadata","authenticate","token","_runQueue","method","fire","wrappedCallback","_createServiceCallback","apply","service","FeatureLayer","query","Query","addFeature","feature","addResults","undefined","updateFeature","updateResults","deleteFeature","objectIds","deleteResults","featureLayer","MapService","identify","identifyFeatures","find","Find","mapService","ImageService","IdentifyImage","imageService","Task","generateSetter","endpoint","_service","setters","setter","offset","limit","precision","featureIds","returnGeometry","where","outSr","outFields","within","_setGeometry","spatialRel","overlaps","nearby","latlng","radius","latLng","geometryType","units","distance","inSr","string","between","start","end","time","simplify","map","factor","mapWidth","Math","abs","getBounds","getWest","getEast","maxAllowableOffset","getSize","orderBy","fieldName","order","orderByFields","run","_cleanParams","count","returnCountOnly","ids","returnIdsOnly","returnExtentOnly","pixelSize","layer","getLatLng","GeoJSON","getLayers","toGeoJSON","text","sr","layers","dynamicLayers","returnZ","returnM","gdbVersion","layerDefs","Identify","setMosaicRule","setRenderingRule","setPixelSize","returnCatalogItems","at","getMosaicRule","mosaicRule","getRenderingRule","renderingRule","getPixelSize","_responseToGeoJSON","location","catalogItems","catalogItemVisibilities","geoJSON","pixel","crs","objectId","Values","values","catalogItemVisibility","identifyImage","IdentifyFeatures","tolerance","on","size","imageDisplay","mapExtent","layerDef","tileProtocol","protocol","BasemapLayer","TileLayer","statics","TILES","Streets","urlTemplate","attributionUrl","hideLogo","logoPosition","minZoom","maxZoom","subdomains","attribution","Topographic","Oceans","OceansLabels","NationalGeographic","DarkGray","DarkGrayLabels","Gray","GrayLabels","Imagery","ImageryLabels","ImageryTransportation","ShadedRelief","ShadedReliefLabels","Terrain","TerrainLabels","config","Error","tileOptions","_getAttributionData","_logo","Logo","position","onAdd","_hasEsriLogo","addTo","_updateMapAttribution","onRemove","removeControl","off","getAttribution","attributions","_attributions","c","contributors","contributor","coverageAreas","coverageArea","southWest","bbox","northEast","score","zoomMin","zoomMax","sort","_map","attributionControl","newAttributions","zoom","getZoom","match","substr","attributionElement","_container","querySelector","innerHTML","maxWidth","basemapLayer","RasterLayer","opacity","_update","limitExecByInterval","updateInterval","split","bboxSR","imageSR","_currentImage","_bounds","equals","addLayer","removeLayer","_popup","_getPopupData","_resetPopupState","bindPopup","fn","popupOptions","_shouldRenderPopup","_lastClick","popup","_popupFunction","unbindPopup","closePopup","removeFrom","bringToFront","bringToBack","getOpacity","setOpacity","getTimeRange","from","to","setTimeRange","_renderImage","image","ImageOverlay","once","newImage","oldImage","_animatingZoom","_panTransition","_inProgress","_buildExportParams","_requestExport","_renderPopup","content","setLatLng","setContent","openOn","_propagateEvent","DynamicMapLayer","timeOptions","format","transparent","setLayers","getLayerDefs","setLayerDefs","getTimeOptions","setTimeOptions","identifyRequest","project","_northEast","_southWest","dpi","href","getParamString","dynamicMapLayer","ImageMapLayer","setPixelType","pixelType","getPixelType","setBandIds","bandIds","isArray","getBandIds","setNoData","noData","noDataInterpretation","getNoData","getNoDataInterpretation","interpolation","compressionQuality","imageMapLayer","TiledMapLayer","tileUrl","tokenQs","tiledMapLayer","FeatureGrid","cellSize","addEventListener","getEvents","_reset","removeEventListener","_removeCells","events","viewreset","moveend","zoomend","_onZoom","hasLayer","_cells","_activeCells","_cellsToLoad","_cellsTotal","_resetWrap","infinite","_getCellSize","wrapLng","_wrapLng","floor","ceil","wrapLat","_wrapLat","getPixelBounds","cellPadding","topLeft","min","subtract","divideBy","max","cellBounds","add","_removeOtherCells","_addCells","coords","queue","center","getCenter","Point","z","cellsToLoad","distanceTo","_addCell","_cellCoordsToBounds","nwPoint","multiplyBy","sePoint","nw","unproject","wrap","se","_cellCoordsToKey","_keyToCellCoords","kArr","parseInt","_removeCell","cell","cellLeave","_wrapCoords","cellEnter","createCell","wrapNum","BinarySearchIndex","FeatureManager","timeField","timeFilterMode","simplifyFactor","oidCheck","_startTimeIndex","_endTimeIndex","_timeIndex","_cache","_currentSnapshot","_activeRequests","_pendingRequests","_requestFeatures","_buildQuery","exceededTransferLimit","_addFeatures","_cacheKey","_buildTimeIndexes","createLayers","setWhere","oldSnapshot","newShapshot","pendingRequests","requestError","requestCallback","removeLayers","addLayers","getWhere","oldFrom","oldTo","_filterExistingFeatures","refresh","newFrom","newTo","layersToRemove","_getFeaturesInTimeRange","layersToAdd","indexOf","shouldRemoveLayer","splice","search","startTimes","endTimes","concat","startTimeEntries","endTimeEntries","Date","bulkAdd","timeEntries","_featureWithinTimeRange","date","startDate","endDate","_query","currentIndex","currentElement","resultIndex","minIndex","maxIndex","round","dirty","startIndex","endIndex","items","EVENTS","cacheLayers","_layers","_leafletIds","_key","random","_zooming","createNewLayer","geometryToLayer","pointToLayer","coordsToLatLng","newLayer","setLatLngs","updateGeo","getLatLngs","defaultOptions","_leaflet_id","_popupOptions","onEachFeature","resetStyle","permanent","cacheKey","cellKey","mapBounds","removable","setFeatureStyle","setStyle","eachFeature","Path","fill","popupContent","groupLayers","gLayer","getFeature","Control","marginTop","marginLeft","marginBottom","marginRight","div","logo"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,GAAIA,cACFC,QAAS,aACTC,UACAC,YACAC,YACAC,SACAC,QACAC,SACEC,QAASC,OAAOC,gBAAkB,mBAAqB,IAAIA,iBAC3DC,cAAgE,KAAjDC,SAASC,gBAAgBC,MAAMH,eAI7B,oBAAXF,SAA0BA,OAAOM,IACzCN,OAAOM,EAAEC,KAAOhB,aCdlB,SAAUA,GAWR,QAASiB,GAAMC,GACb,GAAIC,KACJ,KAAK,GAAIC,KAAKF,GACRA,EAAIG,eAAeD,KACrBD,EAAOC,GAAKF,EAAIE,GAG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,KACXA,KAAKW,KAAK9C,EAAE9F,KAAM8F,MAItBpK,YAAYuN,aAAevN,YAAYE,OAAOqN,aAE9CvN,YAAYE,OAAOiO,aAAe,SAASnG,EAAKmE,GAC9C,MAAO,IAAInM,aAAYE,OAAOqN,aAAavF,EAAKmE,IAGlDnM,YAAYmO,aAAe,SAASnG,EAAKmE,GACvC,MAAO,IAAInM,aAAYE,OAAOqN,aAAavF,EAAKmE,ICxSlDnM,YAAYI,SAAS6W,KAAOlW,EAAEmoB,QAAQnd,QACpCI,SACE+K,SAAU,cACViS,UAAW,EACXC,WAAY,EACZC,aAAc,EACdC,YAAa,GAEfnS,MAAO,WACL,GAAIoS,GAAMxoB,EAAEuK,QAAQC,OAAO,MAAO,oBAMlC,OALAge,GAAIzoB,MAAMqoB,UAAY5c,KAAKJ,QAAQgd,UACnCI,EAAIzoB,MAAMsoB,WAAa7c,KAAKJ,QAAQid,WACpCG,EAAIzoB,MAAMuoB,aAAe9c,KAAKJ,QAAQkd,aACtCE,EAAIzoB,MAAMwoB,YAAc/c,KAAKJ,QAAQmd,YACrCC,EAAIpQ,UAAY,8JACToQ,KAIXvpB,YAAYI,SAASopB,KAAO,SAASrd,GACnC,MAAO,IAAIpL,GAAEC,KAAKZ,SAAS6W,KAAK9K","sourcesContent":["var EsriLeaflet = { //jshint ignore:line\n  VERSION: '1.0.0-rc.5',\n  Layers: {},\n  Services: {},\n  Controls: {},\n  Tasks: {},\n  Util: {},\n  Support: {\n    CORS: !!(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()),\n    pointerEvents: document.documentElement.style.pointerEvents === ''\n  }\n};\n\nif(typeof window !== 'undefined' && window.L){\n  window.L.esri = EsriLeaflet;\n}\n","(function(EsriLeaflet){\n\n  // normalize request animation frame\n  var raf = window.requestAnimationFrame ||\n     window.webkitRequestAnimationFrame ||\n     window.mozRequestAnimationFrame ||\n     window.msRequestAnimationFrame ||\n     function(cb) { return window.setTimeout(cb, 1000 / 60); };\n\n  // shallow object clone for feature properties and attributes\n  // from http://jsperf.com/cloning-an-object/2\n  function clone(obj) {\n    var target = {};\n    for (var i in obj) {\n      if (obj.hasOwnProperty(i)) {\n        target[i] = obj[i];\n      }\n    }\n    return target;\n  }\n\n  // checks if 2 x,y points are equal\n  function pointsEqual(a, b) {\n    for (var i = 0; i < a.length; i++) {\n      if (a[i] !== b[i]) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  // checks if the first and last points of a ring are equal and closes the ring\n  function 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\n  function ringIsClockwise(ringToTest) {\n    var total = 0,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\n  function 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 ( 0 <= ua && ua <= 1 && 0 <= ub && 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\n  function arrayIntersectsArray(a, b) {\n    for (var i = 0; i < a.length - 1; i++) {\n      for (var j = 0; j < b.length - 1; j++) {\n        if (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\n  function 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\n  function 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\n  function convertRingsToGeoJSON(rings){\n    var outerRings = [];\n    var holes = [];\n    var x; // iterator\n    var outerRing; // current outer ring being evaluated\n    var hole; // current hole being evaluated\n\n    // for each ring\n    for (var r = 0; r < rings.length; r++) {\n      var ring = closeRing(rings[r].slice(0));\n      if(ring.length < 4){\n        continue;\n      }\n      // is this ring an outer ring? is it clockwise?\n      if(ringIsClockwise(ring)){\n        var polygon = [ ring ];\n        outerRings.push(polygon); // push to outer rings\n      } else {\n        holes.push(ring); // counterclockwise push to holes\n      }\n    }\n\n    var uncontainedHoles = [];\n\n    // while there are holes left...\n    while(holes.length){\n      // pop a hole off out stack\n      hole = holes.pop();\n\n      // loop over all outer rings and see if they contain our hole.\n      var contained = false;\n      for (x = outerRings.length - 1; x >= 0; x--) {\n        outerRing = outerRings[x][0];\n        if(coordinatesContainCoordinates(outerRing, hole)){\n          // the hole is contained push it into our polygon\n          outerRings[x].push(hole);\n          contained = true;\n          break;\n        }\n      }\n\n      // ring is not contained in any outer ring\n      // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320\n      if(!contained){\n        uncontainedHoles.push(hole);\n      }\n    }\n\n    // if we couldn't match any holes using contains we can try intersects...\n    while(uncontainedHoles.length){\n      // pop a hole off out stack\n      hole = uncontainedHoles.pop();\n\n      // loop over all outer rings and see if any intersect our hole.\n      var intersects = false;\n      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\n  function 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\n  function 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  // convert an extent (ArcGIS) to LatLngBounds (Leaflet)\n  EsriLeaflet.Util.extentToBounds = function(extent){\n    var sw = new L.LatLng(extent.ymin, extent.xmin);\n    var ne = new L.LatLng(extent.ymax, extent.xmax);\n    return new L.LatLngBounds(sw, ne);\n  };\n\n  // convert an LatLngBounds (Leaflet) to extent (ArcGIS)\n  EsriLeaflet.Util.boundsToExtent = function(bounds) {\n    bounds = L.latLngBounds(bounds);\n    return {\n      'xmin': bounds.getSouthWest().lng,\n      'ymin': bounds.getSouthWest().lat,\n      'xmax': bounds.getNorthEast().lng,\n      'ymax': bounds.getNorthEast().lat,\n      'spatialReference': {\n        'wkid' : 4326\n      }\n    };\n  };\n\n  EsriLeaflet.Util.arcgisToGeojson = function (arcgis, idAttribute){\n    var geojson = {};\n\n    if(typeof arcgis.x === 'number' && typeof arcgis.y === 'number'){\n      geojson.type = 'Point';\n      geojson.coordinates = [arcgis.x, arcgis.y];\n    }\n\n    if(arcgis.points){\n      geojson.type = 'MultiPoint';\n      geojson.coordinates = arcgis.points.slice(0);\n    }\n\n    if(arcgis.paths) {\n      if(arcgis.paths.length === 1){\n        geojson.type = 'LineString';\n        geojson.coordinates = arcgis.paths[0].slice(0);\n      } else {\n        geojson.type = 'MultiLineString';\n        geojson.coordinates = arcgis.paths.slice(0);\n      }\n    }\n\n    if(arcgis.rings) {\n      geojson = convertRingsToGeoJSON(arcgis.rings.slice(0));\n    }\n\n    if(arcgis.geometry || arcgis.attributes) {\n      geojson.type = 'Feature';\n      geojson.geometry = (arcgis.geometry) ? EsriLeaflet.Util.arcgisToGeojson(arcgis.geometry) : null;\n      geojson.properties = (arcgis.attributes) ? clone(arcgis.attributes) : null;\n      if(arcgis.attributes) {\n        geojson.id =  arcgis.attributes[idAttribute] || arcgis.attributes.OBJECTID || arcgis.attributes.FID;\n      }\n    }\n\n    return geojson;\n  };\n\n  // GeoJSON -> ArcGIS\n  EsriLeaflet.Util.geojsonToArcGIS = function(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 = EsriLeaflet.Util.geojsonToArcGIS(geojson.geometry, idAttribute);\n      }\n      result.attributes = (geojson.properties) ? clone(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(EsriLeaflet.Util.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(EsriLeaflet.Util.geojsonToArcGIS(geojson.geometries[i], idAttribute));\n      }\n      break;\n    }\n\n    return result;\n  };\n\n  EsriLeaflet.Util.responseToFeatureCollection = function(response, idAttribute){\n    var objectIdField;\n\n    if(idAttribute){\n      objectIdField = idAttribute;\n    } else if(response.objectIdFieldName){\n      objectIdField = response.objectIdFieldName;\n    } else if(response.fields) {\n      for (var j = 0; j <= response.fields.length - 1; j++) {\n        if(response.fields[j].type === 'esriFieldTypeOID') {\n          objectIdField = response.fields[j].name;\n          break;\n        }\n      }\n    } else {\n      objectIdField = 'OBJECTID';\n    }\n\n    var featureCollection = {\n      type: 'FeatureCollection',\n      features: []\n    };\n    var features = response.features || response.results;\n    if(features.length){\n      for (var i = features.length - 1; i >= 0; i--) {\n        featureCollection.features.push(EsriLeaflet.Util.arcgisToGeojson(features[i], objectIdField));\n      }\n    }\n\n    return featureCollection;\n  };\n\n    // trim whitespace and add a tailing slash is needed to a url\n  EsriLeaflet.Util.cleanUrl = function(url){\n    url = url.replace(/\\s\\s*/g, '');\n\n    //add a trailing slash to the url if the user omitted it\n    if(url[url.length-1] !== '/'){\n      url += '/';\n    }\n\n    return url;\n  };\n\n  EsriLeaflet.Util.isArcgisOnline = function(url){\n    return (/\\.arcgis\\.com/g).test(url);\n  };\n\n  EsriLeaflet.Util.geojsonTypeToArcGIS = function (geoJsonType) {\n    var arcgisGeometryType;\n    switch (geoJsonType) {\n    case 'Point':\n      arcgisGeometryType = 'esriGeometryPoint';\n      break;\n    case 'MultiPoint':\n      arcgisGeometryType = 'esriGeometryMultipoint';\n      break;\n    case 'LineString':\n      arcgisGeometryType = 'esriGeometryPolyline';\n      break;\n    case 'MultiLineString':\n      arcgisGeometryType = 'esriGeometryPolyline';\n      break;\n    case 'Polygon':\n      arcgisGeometryType = 'esriGeometryPolygon';\n      break;\n    case 'MultiPolygon':\n      arcgisGeometryType = 'esriGeometryPolygon';\n      break;\n    }\n    return arcgisGeometryType;\n  };\n\n  EsriLeaflet.Util.requestAnimationFrame = L.Util.bind(raf, window);\n\n})(EsriLeaflet);","(function(EsriLeaflet){\n\n  var callbacks = 0;\n\n  window._EsriLeafletCallbacks = {};\n\n  function serialize(params){\n    var data = '';\n\n    params.f = params.f || 'json';\n\n    for (var key in params){\n      if(params.hasOwnProperty(key)){\n        var param = params[key];\n        var type = Object.prototype.toString.call(param);\n        var value;\n\n        if(data.length){\n          data += '&';\n        }\n\n        if (type === '[object Array]'){\n          value = (Object.prototype.toString.call(param[0]) === '[object Object]') ? JSON.stringify(param) : param.join(',');\n        } else if (type === '[object Object]') {\n          value = JSON.stringify(param);\n        } else if (type === '[object Date]'){\n          value = param.valueOf();\n        } else {\n          value = param;\n        }\n\n        data += encodeURIComponent(key) + '=' + encodeURIComponent(value);\n      }\n    }\n\n    return data;\n  }\n\n  function createRequest(callback, context){\n    var httpRequest = new XMLHttpRequest();\n\n    httpRequest.onerror = function(e) {\n      callback.call(context, {\n        error: {\n          code: 500,\n          message: 'XMLHttpRequest error'\n        }\n      }, null);\n    };\n\n    httpRequest.onreadystatechange = function(){\n      var response;\n      var error;\n\n      if (httpRequest.readyState === 4) {\n        try {\n          response = JSON.parse(httpRequest.responseText);\n        } catch(e) {\n          response = null;\n          error = {\n            code: 500,\n            message: 'Could not parse response as JSON.'\n          };\n        }\n\n        if (!error && response.error) {\n          error = response.error;\n          response = null;\n        }\n\n        callback.call(context, error, response);\n      }\n    };\n\n    return httpRequest;\n  }\n\n  // AJAX handlers for CORS (modern browsers) or JSONP (older browsers)\n  EsriLeaflet.Request = {\n    request: function(url, params, callback, context){\n      var paramString = serialize(params);\n      var httpRequest = createRequest(callback, context);\n      var requestLength = (url + '?' + paramString).length;\n\n      // request is less then 2000 characters and the browser supports CORS, make GET request with XMLHttpRequest\n      if(requestLength <= 2000 && L.esri.Support.CORS){\n        httpRequest.open('GET', url + '?' + paramString);\n        httpRequest.send(null);\n\n      // request is less more then 2000 characters and the browser supports CORS, make POST request with XMLHttpRequest\n      } else if (requestLength > 2000 && L.esri.Support.CORS){\n        httpRequest.open('POST', url);\n        httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n        httpRequest.send(paramString);\n\n      // request is less more then 2000 characters and the browser does not support CORS, make a JSONP request\n      } else if(requestLength <= 2000 && !L.esri.Support.CORS){\n        return L.esri.Request.get.JSONP(url, params, callback, context);\n\n      // request is longer then 2000 characters and the browser does not support CORS, log a warning\n      } else {\n        if(console && console.warn){\n          console.warn('a request to ' + url + ' was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html');\n          return;\n        }\n      }\n\n      return httpRequest;\n    },\n    post: {\n      XMLHTTP: function (url, params, callback, context) {\n        var httpRequest = createRequest(callback, context);\n        httpRequest.open('POST', url);\n        httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n        httpRequest.send(serialize(params));\n\n        return httpRequest;\n      }\n    },\n\n    get: {\n      CORS: function (url, params, callback, context) {\n        var httpRequest = createRequest(callback, context);\n\n        httpRequest.open('GET', url + '?' + serialize(params), true);\n        httpRequest.send(null);\n\n        return httpRequest;\n      },\n      JSONP: function(url, params, callback, context){\n        var callbackId = 'c' + callbacks;\n\n        params.callback = 'window._EsriLeafletCallbacks.' + callbackId;\n\n        var script = L.DomUtil.create('script', null, document.body);\n        script.type = 'text/javascript';\n        script.src = url + '?' +  serialize(params);\n        script.id = callbackId;\n\n        window._EsriLeafletCallbacks[callbackId] = function(response){\n          if(window._EsriLeafletCallbacks[callbackId] !== true){\n            var error;\n            var responseType = Object.prototype.toString.call(response);\n\n            if(!(responseType === '[object Object]' || responseType === '[object Array]')){\n              error = {\n                error: {\n                  code: 500,\n                  message: 'Expected array or object as JSONP response'\n                }\n              };\n              response = null;\n            }\n\n            if (!error && response.error) {\n              error = response;\n              response = null;\n            }\n\n            callback.call(context, error, response);\n            window._EsriLeafletCallbacks[callbackId] = true;\n          }\n        };\n\n        callbacks++;\n\n        return {\n          id: callbackId,\n          url: script.src,\n          abort: function(){\n            window._EsriLeafletCallbacks._callback[callbackId]({\n              code: 0,\n              message: 'Request aborted.'\n            });\n          }\n        };\n      }\n    }\n  };\n\n  // choose the correct AJAX handler depending on CORS support\n  EsriLeaflet.get = (EsriLeaflet.Support.CORS) ? EsriLeaflet.Request.get.CORS : EsriLeaflet.Request.get.JSONP;\n\n  // always use XMLHttpRequest for posts\n  EsriLeaflet.post = EsriLeaflet.Request.post.XMLHTTP;\n\n  // expose a common request method the uses GET\\POST based on request length\n  EsriLeaflet.request = EsriLeaflet.Request.request;\n\n})(EsriLeaflet);","EsriLeaflet.Services.Service = L.Class.extend({\n\n  includes: L.Mixin.Events,\n\n  options: {\n    proxy: false,\n    useCors: EsriLeaflet.Support.CORS\n  },\n\n  initialize: function (options) {\n    options = options || {};\n    this._requestQueue = [];\n    this._authenticating = false;\n    L.Util.setOptions(this, options);\n    this.options.url = EsriLeaflet.Util.cleanUrl(this.options.url);\n  },\n\n  get: function (path, params, callback, context) {\n    return this._request('get', path, params, callback, context);\n  },\n\n  post: function (path, params, callback, context) {\n    return this._request('post', path, params, callback, context);\n  },\n\n  request: function (path, params, callback, context) {\n    return this._request('request', path, params, callback, context);\n  },\n\n  metadata: function (callback, context) {\n    return this._request('get', '', {}, callback, context);\n  },\n\n  authenticate: function(token){\n    this._authenticating = false;\n    this.options.token = token;\n    this._runQueue();\n    return this;\n  },\n\n  _request: function(method, path, params, callback, context){\n    this.fire('requeststart', {\n      url: this.options.url + path,\n      params: params,\n      method: method\n    });\n\n    var wrappedCallback = this._createServiceCallback(method, path, params, callback, context);\n\n    if (this.options.token) {\n      params.token = this.options.token;\n    }\n\n    if (this._authenticating) {\n      this._requestQueue.push([method, path, params, callback, context]);\n      return;\n    } else {\n      var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\n\n      if((method === 'get' || method === 'request') && !this.options.useCors){\n        return EsriLeaflet.Request.get.JSONP(url, params, wrappedCallback);\n      } else {\n        return EsriLeaflet[method](url, params, wrappedCallback);\n      }\n    }\n  },\n\n  _createServiceCallback: function(method, path, params, callback, context){\n    var request = [method, path, params, callback, context];\n\n    return L.Util.bind(function(error, response){\n\n      if (error && (error.code === 499 || error.code === 498)) {\n        this._authenticating = true;\n\n        this._requestQueue.push(request);\n\n        this.fire('authenticationrequired', {\n          authenticate: L.Util.bind(this.authenticate, this)\n        });\n      } else {\n        callback.call(context, error, response);\n\n        if(error) {\n          this.fire('requesterror', {\n            url: this.options.url + path,\n            params: params,\n            message: error.message,\n            code: error.code,\n            method: method\n          });\n        } else {\n          this.fire('requestsuccess', {\n            url: this.options.url + path,\n            params: params,\n            response: response,\n            method: method\n          });\n        }\n\n        this.fire('requestend', {\n          url: this.options.url + path,\n          params: params,\n          method: method\n        });\n      }\n    }, this);\n  },\n\n  _runQueue: function(){\n    for (var i = this._requestQueue.length - 1; i >= 0; i--) {\n      var request = this._requestQueue[i];\n      var method = request.shift();\n      this[method].apply(this, request);\n    }\n    this._requestQueue = [];\n  }\n\n});\n\nEsriLeaflet.Services.service = function(params){\n  return new EsriLeaflet.Services.Service(params);\n};","EsriLeaflet.Services.FeatureLayer = EsriLeaflet.Services.Service.extend({\n\n  options: {\n    idAttribute: 'OBJECTID'\n  },\n\n  query: function(){\n    return new EsriLeaflet.Tasks.Query(this);\n  },\n\n  addFeature: function(feature, callback, context) {\n    delete feature.id;\n\n    feature = EsriLeaflet.Util.geojsonToArcGIS(feature);\n\n    return this.post('addFeatures', {\n      features: [feature]\n    }, function(error, response){\n      var result = (response && response.addResults) ? response.addResults[0] : undefined;\n      if(callback){\n        callback.call(this, error || response.addResults[0].error, result);\n      }\n    }, context);\n  },\n\n  updateFeature: function(feature, callback, context) {\n    feature = EsriLeaflet.Util.geojsonToArcGIS(feature, this.options.idAttribute);\n\n    return this.post('updateFeatures', {\n      features: [feature]\n    }, function(error, response){\n      var result = (response && response.updateResults) ? response.updateResults[0] : undefined;\n      if(callback){\n        callback.call(context, error || response.updateResults[0].error, result);\n      }\n    }, context);\n  },\n\n  deleteFeature: function(id, callback, context) {\n    return this.post('deleteFeatures', {\n      objectIds: id\n    }, function(error, response){\n      var result = (response && response.deleteResults) ? response.deleteResults[0] : undefined;\n      if(callback){\n        callback.call(context, error || response.deleteResults[0].error, result);\n      }\n    }, context);\n  }\n\n});\n\nEsriLeaflet.Services.featureLayer = function(options) {\n  return new EsriLeaflet.Services.FeatureLayer(options);\n};","EsriLeaflet.Services.MapService = EsriLeaflet.Services.Service.extend({\n\n  identify: function () {\n    return new EsriLeaflet.Tasks.identifyFeatures(this);\n  },\n\n  find: function () {\n    return new EsriLeaflet.Tasks.Find(this);\n  },\n\n  query: function () {\n    return new EsriLeaflet.Tasks.Query(this);\n  }\n\n});\n\nEsriLeaflet.Services.mapService = function(params){\n  return new EsriLeaflet.Services.MapService(params);\n};","EsriLeaflet.Services.ImageService = EsriLeaflet.Services.Service.extend({\n\n  query: function () {\n    return new EsriLeaflet.Tasks.Query(this);\n  },\n\n  identify: function() {\n    return new EsriLeaflet.Tasks.IdentifyImage(this);\n  }\n});\n\nEsriLeaflet.Services.imageService = function(params){\n  return new EsriLeaflet.Services.ImageService(params);\n};","EsriLeaflet.Tasks.Task = L.Class.extend({\n\n  options: {\n    proxy: false,\n    useCors: EsriLeaflet.Support.CORS\n  },\n\n  //Generate a method for each methodName:paramName in the setters for this task.\n  generateSetter: function(param, context){\n    return L.Util.bind(function(value){\n      this.params[param] = value;\n      return this;\n    }, context);\n  },\n\n  initialize: function(endpoint){\n    // endpoint can be either a url (and options) for an ArcGIS Rest Service or an instance of EsriLeaflet.Service\n    if(endpoint.request && endpoint.options){\n      this._service = endpoint;\n      L.Util.setOptions(this, endpoint.options);\n    } else {\n      L.Util.setOptions(this, endpoint);\n      this.options.url = L.esri.Util.cleanUrl(endpoint.url);\n    }\n\n    // clone default params into this object\n    this.params = L.Util.extend({}, this.params || {});\n\n    // generate setter methods based on the setters object implimented a child class\n    if(this.setters){\n      for (var setter in this.setters){\n        var param = this.setters[setter];\n        this[setter] = this.generateSetter(param, this);\n      }\n    }\n  },\n\n  token: function(token){\n    if(this._service){\n      this._service.authenticate(token);\n    } else {\n      this.params.token = token;\n    }\n    return this;\n  },\n\n  request: function(callback, context){\n    if(this._service){\n      return this._service.request(this.path, this.params, callback, context);\n    } else {\n      return this._request('request', this.path, this.params, callback, context);\n    }\n  },\n\n  _request: function(method, path, params, callback, context){\n    var url = (this.options.proxy) ? this.options.proxy + '?' + this.options.url + path : this.options.url + path;\n    if((method === 'get' || method === 'request') && !this.options.useCors){\n      return EsriLeaflet.Request.get.JSONP(url, params, callback, context);\n    } else{\n      return EsriLeaflet[method](url, params, callback, context);\n    }\n  }\n});","EsriLeaflet.Tasks.Query = EsriLeaflet.Tasks.Task.extend({\n  setters: {\n    'offset': 'offset',\n    'limit': 'limit',\n    'fields': 'outFields',\n    'precision': 'geometryPrecision',\n    'featureIds': 'objectIds',\n    'returnGeometry': 'returnGeometry',\n    'token': 'token'\n  },\n\n  path: 'query',\n\n  params: {\n    returnGeometry: true,\n    where: '1=1',\n    outSr: 4326,\n    outFields: '*'\n  },\n\n  within: function(geometry){\n    this._setGeometry(geometry);\n    this.params.spatialRel = 'esriSpatialRelContains'; // will make code read layer within geometry, to the api this will reads geometry contains layer\n    return this;\n  },\n\n  intersects: function(geometry){\n    this._setGeometry(geometry);\n    this.params.spatialRel = 'esriSpatialRelIntersects';\n    return this;\n  },\n\n  contains: function(geometry){\n    this._setGeometry(geometry);\n    this.params.spatialRel = 'esriSpatialRelWithin'; // will make code read layer contains geometry, to the api this will reads geometry within layer\n    return this;\n  },\n\n  // crosses: function(geometry){\n  //   this._setGeometry(geometry);\n  //   this.params.spatialRel = 'esriSpatialRelCrosses';\n  //   return this;\n  // },\n\n  // touches: function(geometry){\n  //   this._setGeometry(geometry);\n  //   this.params.spatialRel = 'esriSpatialRelTouches';\n  //   return this;\n  // },\n\n  overlaps: function(geometry){\n    this._setGeometry(geometry);\n    this.params.spatialRel = 'esriSpatialRelOverlaps';\n    return this;\n  },\n\n  // only valid for Feature Services running on ArcGIS Server 10.3 or ArcGIS Online\n  nearby: function(latlng, radius){\n    latlng = L.latLng(latlng);\n    this.params.geometry = [latlng.lng, latlng.lat];\n    this.params.geometryType = 'esriGeometryPoint';\n    this.params.spatialRel = 'esriSpatialRelIntersects';\n    this.params.units = 'esriSRUnit_Meter';\n    this.params.distance = radius;\n    this.params.inSr = 4326;\n    return this;\n  },\n\n  where: function(string){\n    this.params.where = string.replace(/\"/g, \"\\'\"); // jshint ignore:line\n    return this;\n  },\n\n  between: function(start, end){\n    this.params.time = [start.valueOf(), end.valueOf()];\n    return this;\n  },\n\n  simplify: function(map, factor){\n    var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\n    this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\n    return this;\n  },\n\n  orderBy: function(fieldName, order){\n    order = order || 'ASC';\n    this.params.orderByFields = (this.params.orderByFields) ? this.params.orderByFields + ',' : '';\n    this.params.orderByFields += ([fieldName, order]).join(' ');\n    return this;\n  },\n\n  run: function(callback, context){\n    this._cleanParams();\n\n    // if the service is hosted on arcgis online request geojson directly\n    if(EsriLeaflet.Util.isArcgisOnline(this.options.url)){\n      this.params.f = 'geojson';\n\n      return this.request(function(error, response){\n        callback.call(context, error, response, response);\n      }, context);\n\n    // otherwise convert it in the callback then pass it on\n    } else {\n      return this.request(function(error, response){\n        callback.call(context, error, (response && EsriLeaflet.Util.responseToFeatureCollection(response)), response);\n      }, context);\n    }\n  },\n\n  count: function(callback, context){\n    this._cleanParams();\n    this.params.returnCountOnly = true;\n    return this.request(function(error, response){\n      callback.call(this, error, (response && response.count), response);\n    }, context);\n  },\n\n  ids: function(callback, context){\n    this._cleanParams();\n    this.params.returnIdsOnly = true;\n    return this.request(function(error, response){\n      callback.call(this, error, (response && response.objectIds), response);\n    }, context);\n  },\n\n  // only valid for Feature Services running on ArcGIS Server 10.3 or ArcGIS Online\n  bounds: function(callback, context){\n    this._cleanParams();\n    this.params.returnExtentOnly = true;\n    return this.request(function(error, response){\n      callback.call(context, error, (response && response.extent && EsriLeaflet.Util.extentToBounds(response.extent)), response);\n    }, context);\n  },\n\n  // only valid for image services\n  pixelSize: function(point){\n    point = L.point(point);\n    this.params.pixelSize = [point.x,point.y];\n    return this;\n  },\n\n  // only valid for map services\n  layer: function(layer){\n    this.path = layer + '/query';\n    return this;\n  },\n\n  _cleanParams: function(){\n    delete this.params.returnIdsOnly;\n    delete this.params.returnExtentOnly;\n    delete this.params.returnCountOnly;\n  },\n\n  _setGeometry: function(geometry) {\n    this.params.inSr = 4326;\n\n    // convert bounds to extent and finish\n    if ( geometry instanceof L.LatLngBounds ) {\n      // set geometry + geometryType\n      this.params.geometry = EsriLeaflet.Util.boundsToExtent(geometry);\n      this.params.geometryType = 'esriGeometryEnvelope';\n      return;\n    }\n\n    // convert L.Marker > L.LatLng\n    if(geometry.getLatLng){\n      geometry = geometry.getLatLng();\n    }\n\n    // convert L.LatLng to a geojson point and continue;\n    if (geometry instanceof L.LatLng) {\n      geometry = {\n        type: 'Point',\n        coordinates: [geometry.lng, geometry.lat]\n      };\n    }\n\n    // handle L.GeoJSON, pull out the first geometry\n    if ( geometry instanceof L.GeoJSON ) {\n      //reassign geometry to the GeoJSON value  (we are assuming that only one feature is present)\n      geometry = geometry.getLayers()[0].feature.geometry;\n      this.params.geometry = EsriLeaflet.Util.geojsonToArcGIS(geometry);\n      this.params.geometryType = EsriLeaflet.Util.geojsonTypeToArcGIS(geometry.type);\n    }\n\n    // Handle L.Polyline and L.Polygon\n    if (geometry.toGeoJSON) {\n      geometry = geometry.toGeoJSON();\n    }\n\n    // handle GeoJSON feature by pulling out the geometry\n    if ( geometry.type === 'Feature' ) {\n      // get the geometry of the geojson feature\n      geometry = geometry.geometry;\n    }\n\n    // confirm that our GeoJSON is a point, line or polygon\n    if ( geometry.type === 'Point' ||  geometry.type === 'LineString' || geometry.type === 'Polygon') {\n      this.params.geometry = EsriLeaflet.Util.geojsonToArcGIS(geometry);\n      this.params.geometryType = EsriLeaflet.Util.geojsonTypeToArcGIS(geometry.type);\n      return;\n    }\n\n    // warn the user if we havn't found a\n    /* global console */\n    if(console && console.warn) {\n      console.warn('invalid geometry passed to spatial query. Should be an L.LatLng, L.LatLngBounds or L.Marker or a GeoJSON Point Line or Polygon object');\n    }\n\n    return;\n  }\n});\n\nEsriLeaflet.Tasks.query = function(params){\n  return new EsriLeaflet.Tasks.Query(params);\n};","EsriLeaflet.Tasks.Find = EsriLeaflet.Tasks.Task.extend({\n  setters: {\n    // method name > param name\n    'contains': 'contains',\n    'text': 'searchText',\n    'fields': 'searchFields', // denote an array or single string\n    'spatialReference': 'sr',\n    'sr': 'sr',\n    'layers': 'layers',\n    'returnGeometry': 'returnGeometry',\n    'maxAllowableOffset': 'maxAllowableOffset',\n    'precision': 'geometryPrecision',\n    'dynamicLayers': 'dynamicLayers',\n    'returnZ' : 'returnZ',\n    'returnM' : 'returnM',\n    'gdbVersion' : 'gdbVersion',\n    'token' : 'token'\n  },\n\n  path: 'find',\n\n  params: {\n    sr: 4326,\n    contains: true,\n    returnGeometry: true,\n    returnZ: true,\n    returnM: false\n  },\n\n  layerDefs: function (id, where) {\n    this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\n    this.params.layerDefs += ([id, where]).join(':');\n    return this;\n  },\n\n  simplify: function(map, factor){\n    var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\n    this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * factor;\n    return this;\n  },\n\n  run: function (callback, context) {\n    return this.request(function(error, response){\n      callback.call(context, error, (response && EsriLeaflet.Util.responseToFeatureCollection(response)), response);\n    }, context);\n  }\n});\n\nEsriLeaflet.Tasks.find = function (params) {\n  return new EsriLeaflet.Tasks.Find(params);\n};","EsriLeaflet.Tasks.Identify = EsriLeaflet.Tasks.Task.extend({\n  path: 'identify',\n\n  between: function(start, end){\n    this.params.time = [start.valueOf(), end.valueOf()];\n    return this;\n  }\n});\n","EsriLeaflet.Tasks.IdentifyImage = EsriLeaflet.Tasks.Identify.extend({\n  setters: {\n    'setMosaicRule': 'mosaicRule',\n    'setRenderingRule': 'renderingRule',\n    'setPixelSize': 'pixelSize',\n    'returnCatalogItems': 'returnCatalogItems',\n    'returnGeometry': 'returnGeometry'\n  },\n\n  params: {\n    returnGeometry: false\n  },\n\n  at: function(latlng){\n    latlng = L.latLng(latlng);\n    this.params.geometry = JSON.stringify({\n      x: latlng.lng,\n      y: latlng.lat,\n      spatialReference:{\n        wkid: 4326\n      }\n    });\n    this.params.geometryType = 'esriGeometryPoint';\n    return this;\n  },\n\n  getMosaicRule: function() {\n    return this.params.mosaicRule;\n  },\n\n  getRenderingRule: function() {\n    return this.params.renderingRule;\n  },\n\n  getPixelSize: function() {\n    return this.params.pixelSize;\n  },\n\n  run: function (callback, context){\n    return this.request(function(error, response){\n      callback.call(context, error, (response && this._responseToGeoJSON(response)), response);\n    }, this);\n  },\n\n  // get pixel data and return as geoJSON point\n  // populate catalog items (if any)\n  // merging in any catalogItemVisibilities as a propery of each feature\n  _responseToGeoJSON: function(response) {\n    var location = response.location;\n    var catalogItems = response.catalogItems;\n    var catalogItemVisibilities = response.catalogItemVisibilities;\n    var geoJSON =  {\n      'pixel': {\n        'type': 'Feature',\n        'geometry': {\n          'type': 'Point',\n          'coordinates': [location.x, location.y]\n        },\n        'crs': {\n          'type': 'EPSG',\n          'properties': {\n            'code': location.spatialReference.wkid\n          }\n        },\n        'properties': {\n          'OBJECTID': response.objectId,\n          'name': response.name,\n          'value': response.value\n        },\n        'id': response.objectId\n      }\n    };\n    if (response.properties && response.properties.Values) {\n      geoJSON.pixel.properties.values = response.properties.Values;\n    }\n    if (catalogItems && catalogItems.features) {\n      geoJSON.catalogItems = EsriLeaflet.Util.responseToFeatureCollection(catalogItems);\n      if (catalogItemVisibilities && catalogItemVisibilities.length === geoJSON.catalogItems.features.length) {\n        for (var i = catalogItemVisibilities.length - 1; i >= 0; i--) {\n          geoJSON.catalogItems.features[i].properties.catalogItemVisibility = catalogItemVisibilities[i];\n        }\n      }\n    }\n    return geoJSON;\n  }\n\n});\n\nEsriLeaflet.Tasks.identifyImage = function(params){\n  return new EsriLeaflet.Tasks.IdentifyImage(params);\n};","EsriLeaflet.Tasks.IdentifyFeatures = EsriLeaflet.Tasks.Identify.extend({\n  setters: {\n    'layers': 'layers',\n    'precision': 'geometryPrecision',\n    'tolerance': 'tolerance',\n    'returnGeometry': 'returnGeometry'\n  },\n\n  params: {\n    sr: 4326,\n    layers: 'all',\n    tolerance: 3,\n    returnGeometry: true\n  },\n\n  on: function(map){\n    var extent = EsriLeaflet.Util.boundsToExtent(map.getBounds());\n    var size = map.getSize();\n    this.params.imageDisplay = [size.x, size.y, 96];\n    this.params.mapExtent = [extent.xmin, extent.ymin, extent.xmax, extent.ymax];\n    return this;\n  },\n\n  at: function(latlng){\n    latlng = L.latLng(latlng);\n    this.params.geometry = [latlng.lng, latlng.lat];\n    this.params.geometryType = 'esriGeometryPoint';\n    return this;\n  },\n\n  layerDef: function (id, where){\n    this.params.layerDefs = (this.params.layerDefs) ? this.params.layerDefs + ';' : '';\n    this.params.layerDefs += ([id, where]).join(':');\n    return this;\n  },\n\n  simplify: function(map, factor){\n    var mapWidth = Math.abs(map.getBounds().getWest() - map.getBounds().getEast());\n    this.params.maxAllowableOffset = (mapWidth / map.getSize().y) * (1 - factor);\n    return this;\n  },\n\n  run: function (callback, context){\n    return this.request(function(error, response){\n      callback.call(context, error, (response && EsriLeaflet.Util.responseToFeatureCollection(response)), response);\n    }, context);\n  }\n\n});\n\nEsriLeaflet.Tasks.identifyFeatures = function(params){\n  return new EsriLeaflet.Tasks.IdentifyFeatures(params);\n};","(function(EsriLeaflet){\n\n  var tileProtocol = (window.location.protocol !== 'https:') ? 'http:' : 'https:';\n\n  EsriLeaflet.Layers.BasemapLayer = L.TileLayer.extend({\n    statics: {\n      TILES: {\n        Streets: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',\n          attributionUrl: 'https://static.arcgis.com/attribution/World_Street_Map',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 19,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri'\n          }\n        },\n        Topographic: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',\n          attributionUrl: 'https://static.arcgis.com/attribution/World_Topo_Map',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 19,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri'\n          }\n        },\n        Oceans: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}',\n          attributionUrl: 'https://static.arcgis.com/attribution/Ocean_Basemap',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 16,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri'\n          }\n        },\n        OceansLabels: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: true,\n            logoPosition: 'bottomright',\n            //pane: 'esri-label',\n            minZoom: 1,\n            maxZoom: 16,\n            subdomains: ['server', 'services']\n          }\n        },\n        NationalGeographic: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 16,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri'\n          }\n        },\n        DarkGray: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 16,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri, DeLorme, HERE'\n          }\n        },\n        DarkGrayLabels: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: true,\n            logoPosition: 'bottomright',\n            //pane: 'esri-label',\n            minZoom: 1,\n            maxZoom: 16,\n            subdomains: ['server', 'services']\n          }\n        },\n        Gray: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 16,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri, NAVTEQ, DeLorme'\n          }\n        },\n        GrayLabels: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: true,\n            logoPosition: 'bottomright',\n            //pane: 'esri-label',\n            minZoom: 1,\n            maxZoom: 16,\n            subdomains: ['server', 'services']\n          }\n        },\n        Imagery: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 19,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community'\n          }\n        },\n        ImageryLabels: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: true,\n            logoPosition: 'bottomright',\n            //pane: 'esri-label',\n            minZoom: 1,\n            maxZoom: 19,\n            subdomains: ['server', 'services']\n          }\n        },\n        ImageryTransportation: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}',\n          //pane: 'esri-label',\n          options: {\n            hideLogo: true,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 19,\n            subdomains: ['server', 'services']\n          }\n        },\n        ShadedRelief: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 13,\n            subdomains: ['server', 'services'],\n            attribution: 'ESRI, NAVTEQ, DeLorme'\n          }\n        },\n        ShadedReliefLabels: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: true,\n            logoPosition: 'bottomright',\n            //pane: 'esri-label',\n            minZoom: 1,\n            maxZoom: 12,\n            subdomains: ['server', 'services']\n          }\n        },\n        Terrain: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: false,\n            logoPosition: 'bottomright',\n            minZoom: 1,\n            maxZoom: 13,\n            subdomains: ['server', 'services'],\n            attribution: 'Esri, USGS, NOAA'\n          }\n        },\n        TerrainLabels: {\n          urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}',\n          options: {\n            hideLogo: true,\n            logoPosition: 'bottomright',\n            //pane: 'esri-label',\n            minZoom: 1,\n            maxZoom: 13,\n            subdomains: ['server', 'services']\n          }\n        }\n      }\n    },\n    initialize: function(key, options){\n      var config;\n\n      // set the config variable with the appropriate config object\n      if (typeof key === 'object' && key.urlTemplate && key.options){\n        config = key;\n      } else if(typeof key === 'string' && EsriLeaflet.BasemapLayer.TILES[key]){\n        config = EsriLeaflet.BasemapLayer.TILES[key];\n      } else {\n        throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of \"Streets\", \"Topographic\", \"Oceans\", \"OceansLabels\", \"NationalGeographic\", \"Gray\", \"GrayLabels\", \"DarkGray\", \"DarkGrayLabels\", \"Imagery\", \"ImageryLabels\", \"ImageryTransportation\", \"ShadedRelief\", \"ShadedReliefLabels\", \"Terrain\" or \"TerrainLabels\"');\n      }\n\n      // merge passed options into the config options\n      var tileOptions = L.Util.extend(config.options, options);\n\n      // call the initialize method on L.TileLayer to set everything up\n      L.TileLayer.prototype.initialize.call(this, config.urlTemplate, L.Util.setOptions(this, tileOptions));\n\n      // if this basemap requires dynamic attribution set it up\n      if(config.attributionUrl){\n        this._getAttributionData(config.attributionUrl);\n      }\n      this._logo = new EsriLeaflet.Controls.Logo({\n        position: this.options.logoPosition\n      });\n    },\n    onAdd: function(map){\n      if(!this.options.hideLogo && !map._hasEsriLogo){\n        this._logo.addTo(map);\n        map._hasEsriLogo = true;\n      }\n\n      // if(this.options.pane && EsriLeaflet.Support.pointerEvents){\n      //   this._initPane();\n      // }\n\n      L.TileLayer.prototype.onAdd.call(this, map);\n\n      map.on('moveend', this._updateMapAttribution, this);\n    },\n    onRemove: function(map){\n      if(this._logo){\n        map.removeControl(this._logo);\n        map._hasEsriLogo = false;\n      }\n\n      L.TileLayer.prototype.onRemove.call(this, map);\n\n      map.off('moveend', this._updateMapAttribution, this);\n    },\n    getAttribution:function(){\n      var attribution = '<span class=\"esri-attributions\" style=\"line-height:14px; vertical-align: -3px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; display:inline-block;\">' + this.options.attribution + '</span>'/* + logo*/;\n      return attribution;\n    },\n    // _initPane: function(){\n    //   if(!this._map.getPane(this.options.pane)){\n    //     var pane = this._map.createPane(this.options.pane);\n    //     pane.style.pointerEvents = 'none';\n    //     pane.style.zIndex = 5;\n    //   }\n    // },\n    _getAttributionData: function(url){\n      EsriLeaflet.get(url, {}, function(error, attributions){\n        this._attributions = [];\n        for (var c = 0; c < attributions.contributors.length; c++) {\n          var contributor = attributions.contributors[c];\n          for (var i = 0; i < contributor.coverageAreas.length; i++) {\n            var coverageArea = contributor.coverageAreas[i];\n            var southWest = new L.LatLng(coverageArea.bbox[0], coverageArea.bbox[1]);\n            var northEast = new L.LatLng(coverageArea.bbox[2], coverageArea.bbox[3]);\n            this._attributions.push({\n              attribution: contributor.attribution,\n              score: coverageArea.score,\n              bounds: new L.LatLngBounds(southWest, northEast),\n              minZoom: coverageArea.zoomMin,\n              maxZoom: coverageArea.zoomMax\n            });\n          }\n        }\n\n        this._attributions.sort(function(a, b){\n          return b.score - a.score;\n        });\n\n        this._updateMapAttribution();\n      }, this);\n    },\n    _updateMapAttribution: function(){\n      if(this._map && this._map.attributionControl && this._attributions){\n        var newAttributions = '';\n        var bounds = this._map.getBounds();\n        var zoom = this._map.getZoom();\n\n        for (var i = 0; i < this._attributions.length; i++) {\n          var attribution = this._attributions[i];\n          var text = attribution.attribution;\n          if(!newAttributions.match(text) && bounds.intersects(attribution.bounds) && zoom >= attribution.minZoom && zoom <= attribution.maxZoom) {\n            newAttributions += (', ' + text);\n          }\n        }\n        newAttributions = newAttributions.substr(2);\n        var attributionElement = this._map.attributionControl._container.querySelector('.esri-attributions');\n        attributionElement.innerHTML = newAttributions;\n        attributionElement.style.maxWidth =  (this._map.getSize().x * 0.65) + 'px';\n        this.fire('attributionupdated', {\n          attribution: newAttributions\n        });\n      }\n    }\n  });\n\n  EsriLeaflet.BasemapLayer = EsriLeaflet.Layers.BasemapLayer;\n\n  EsriLeaflet.Layers.basemapLayer = function(key, options){\n    return new EsriLeaflet.Layers.BasemapLayer(key, options);\n  };\n\n  EsriLeaflet.basemapLayer = function(key, options){\n    return new EsriLeaflet.Layers.BasemapLayer(key, options);\n  };\n\n})(EsriLeaflet);","EsriLeaflet.Layers.RasterLayer =  L.Class.extend({\n  includes: L.Mixin.Events,\n\n  options: {\n    opacity: 1,\n    position: 'front',\n    f: 'image'\n  },\n\n  onAdd: function (map) {\n    this._map = map;\n\n    this._update = L.Util.limitExecByInterval(this._update, this.options.updateInterval, this);\n\n    if (map.options.crs && map.options.crs.code) {\n      var sr = map.options.crs.code.split(':')[1];\n      this.options.bboxSR = sr;\n      this.options.imageSR = sr;\n    }\n\n    map.on('moveend', this._update, this);\n\n    // if we had an image loaded and it matches the\n    // current bounds show the image otherwise remove it\n    if(this._currentImage && this._currentImage._bounds.equals(this._map.getBounds())){\n      map.addLayer(this._currentImage);\n    } else if(this._currentImage) {\n      this._map.removeLayer(this._currentImage);\n      this._currentImage = null;\n    }\n\n    this._update();\n\n    if(this._popup){\n      this._map.on('click', this._getPopupData, this);\n      this._map.on('dblclick', this._resetPopupState, this);\n    }\n  },\n\n  bindPopup: function(fn, popupOptions){\n    this._shouldRenderPopup = false;\n    this._lastClick = false;\n    this._popup = L.popup(popupOptions);\n    this._popupFunction = fn;\n    if(this._map){\n      this._map.on('click', this._getPopupData, this);\n      this._map.on('dblclick', this._resetPopupState, this);\n    }\n    return this;\n  },\n\n  unbindPopup: function(){\n    if(this._map){\n      this._map.closePopup(this._popup);\n      this._map.off('click', this._getPopupData, this);\n      this._map.off('dblclick', this._resetPopupState, this);\n    }\n    this._popup = false;\n    return this;\n  },\n\n  onRemove: function (map) {\n    if (this._currentImage) {\n      this._map.removeLayer(this._currentImage);\n    }\n\n    if(this._popup){\n      this._map.off('click', this._getPopupData, this);\n      this._map.off('dblclick', this._resetPopupState, this);\n    }\n\n    this._map.off('moveend', this._update, this);\n    this._map = null;\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  bringToFront: function(){\n    this.options.position = 'front';\n    if(this._currentImage){\n      this._currentImage.bringToFront();\n    }\n    return this;\n  },\n\n  bringToBack: function(){\n    this.options.position = 'back';\n    if(this._currentImage){\n      this._currentImage.bringToBack();\n    }\n    return this;\n  },\n\n  getAttribution: function () {\n    return this.options.attribution;\n  },\n\n  getOpacity: function(){\n    return this.options.opacity;\n  },\n\n  setOpacity: function(opacity){\n    this.options.opacity = opacity;\n    this._currentImage.setOpacity(opacity);\n    return this;\n  },\n\n  getTimeRange: function(){\n    return [this.options.from, this.options.to];\n  },\n\n  setTimeRange: function(from, to){\n    this.options.from = from;\n    this.options.to = to;\n    this._update();\n    return this;\n  },\n\n  metadata: function(callback, context){\n    this._service.metadata(callback, context);\n    return this;\n  },\n\n  authenticate: function(token){\n    this._service.authenticate(token);\n    return this;\n  },\n\n  _renderImage: function(url, bounds){\n    if(this._map){\n      // create a new image overlay and add it to the map\n      // to start loading the image\n      // opacity is 0 while the image is loading\n      var image = new L.ImageOverlay(url, bounds, {\n        opacity: 0\n      }).addTo(this._map);\n\n      // once the image loads\n      image.once('load', function(e){\n        var newImage = e.target;\n        var oldImage = this._currentImage;\n\n        // if the bounds of this image matches the bounds that\n        // _renderImage was called with and we have a map\n        // hide the old image if there is one and set the opacity\n        // of the new image otherwise remove the new image\n        if(newImage._bounds.equals(bounds)){\n          this._currentImage = newImage;\n\n          if(this.options.position === 'front'){\n            this.bringToFront();\n          } else {\n            this.bringToBack();\n          }\n\n          if(this._map && this._currentImage._map){\n            this._currentImage.setOpacity(this.options.opacity);\n          } else {\n            this._currentImage._map.removeLayer(this._currentImage);\n          }\n\n          if(oldImage && this._map) {\n            this._map.removeLayer(oldImage);\n          }\n\n          if(oldImage && oldImage._map){\n            oldImage._map.removeLayer(oldImage);\n          }\n        } else {\n          this._map.removeLayer(newImage);\n        }\n\n        this.fire('load', {\n          bounds: bounds\n        });\n\n      }, this);\n\n      this.fire('loading', {\n        bounds: bounds\n      });\n    }\n  },\n\n  _update: function () {\n    if(!this._map){\n      return;\n    }\n\n    var zoom = this._map.getZoom();\n    var bounds = this._map.getBounds();\n\n    if(this._animatingZoom){\n      return;\n    }\n\n    if (this._map._panTransition && this._map._panTransition._inProgress) {\n      return;\n    }\n\n    if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {\n      return;\n    }\n    var params = this._buildExportParams();\n\n    this._requestExport(params, bounds);\n  },\n\n  // TODO: refactor these into raster layer\n  _renderPopup: function(latlng, error, results, response){\n    latlng = L.latLng(latlng);\n    if(this._shouldRenderPopup && this._lastClick.equals(latlng)){\n      //add the popup to the map where the mouse was clicked at\n      var content = this._popupFunction(error, results, response);\n      if (content) {\n        this._popup.setLatLng(latlng).setContent(content).openOn(this._map);\n      }\n    }\n  },\n\n  _resetPopupState: function(e){\n    this._shouldRenderPopup = false;\n    this._lastClick = e.latlng;\n  },\n\n  // from https://github.com/Leaflet/Leaflet/blob/v0.7.2/src/layer/FeatureGroup.js\n  // @TODO remove at Leaflet 0.8\n  _propagateEvent: function (e) {\n    e = L.extend({\n      layer: e.target,\n      target: this\n    }, e);\n    this.fire(e.type, e);\n  }\n});","EsriLeaflet.Layers.DynamicMapLayer = EsriLeaflet.Layers.RasterLayer.extend({\n\n  options: {\n    updateInterval: 150,\n    layers: false,\n    layerDefs: false,\n    timeOptions: false,\n    format: 'png24',\n    transparent: true\n  },\n\n  initialize: function (url, options) {\n    options = options || {};\n    options.url = EsriLeaflet.Util.cleanUrl(url);\n    this._service = new EsriLeaflet.Services.MapService(options);\n    this._service.on('authenticationrequired requeststart requestend requesterror requestsuccess', this._propagateEvent, this);\n    L.Util.setOptions(this, options);\n  },\n\n  getLayers: function(){\n    return this.options.layers;\n  },\n\n  setLayers: function(layers){\n    this.options.layers = layers;\n    this._update();\n    return this;\n  },\n\n  getLayerDefs: function(){\n    return this.options.layerDefs;\n  },\n\n  setLayerDefs: function(layerDefs){\n    this.options.layerDefs = layerDefs;\n    this._update();\n    return this;\n  },\n\n  getTimeOptions: function(){\n    return this.options.timeOptions;\n  },\n\n  setTimeOptions: function(timeOptions){\n    this.options.timeOptions = timeOptions;\n    this._update();\n    return this;\n  },\n\n  query: function(){\n    return this._service.query();\n  },\n\n  identify: function(){\n    return this._service.identify();\n  },\n\n  find: function(){\n    return this._service.find();\n  },\n\n  _getPopupData: function(e){\n    var callback = L.Util.bind(function(error, featureCollection, response) {\n      setTimeout(L.Util.bind(function(){\n        this._renderPopup(e.latlng, error, featureCollection, response);\n      }, this), 300);\n    }, this);\n\n    var identifyRequest = this.identify().on(this._map).at(e.latlng);\n\n    if(this.options.layers){\n      identifyRequest.layers('visible:' + this.options.layers.join(','));\n    } else {\n      identifyRequest.layers('visible');\n    }\n\n    identifyRequest.run(callback);\n\n    // set the flags to show the popup\n    this._shouldRenderPopup = true;\n    this._lastClick = e.latlng;\n  },\n\n  _buildExportParams: function () {\n    var bounds = this._map.getBounds();\n    var size = this._map.getSize();\n    var ne = this._map.options.crs.project(bounds._northEast);\n    var sw = this._map.options.crs.project(bounds._southWest);\n\n    var params = {\n      bbox: [sw.x, sw.y, ne.x, ne.y].join(','),\n      size: size.x + ',' + size.y,\n      dpi: 96,\n      format: this.options.format,\n      transparent: this.options.transparent,\n      bboxSR: this.options.bboxSR,\n      imageSR: this.options.imageSR\n    };\n\n    if(this.options.layers){\n      params.layers = 'show:' + this.options.layers.join(',');\n    }\n\n    if(this.options.layerDefs){\n      params.layerDefs = JSON.stringify(this.options.layerDefs);\n    }\n\n    if(this.options.timeOptions){\n      params.timeOptions = JSON.stringify(this.options.timeOptions);\n    }\n\n    if(this.options.from && this.options.to){\n      params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\n    }\n\n    if(this._service.options.token) {\n      params.token = this._service.options.token;\n    }\n\n    return params;\n  },\n\n  _requestExport: function (params, bounds) {\n    if(this.options.f === 'json'){\n      this._service.get('export', params, function(error, response){\n        this._renderImage(response.href, bounds);\n      }, this);\n    } else {\n      params.f = 'image';\n      this._renderImage(this.options.url + 'export' + L.Util.getParamString(params), bounds);\n    }\n  }\n});\n\nEsriLeaflet.DynamicMapLayer = EsriLeaflet.Layers.DynamicMapLayer;\n\nEsriLeaflet.Layers.dynamicMapLayer = function(url, options){\n  return new EsriLeaflet.Layers.DynamicMapLayer(url, options);\n};\n\nEsriLeaflet.dynamicMapLayer = function(url, options){\n  return new EsriLeaflet.Layers.DynamicMapLayer(url, options);\n};","EsriLeaflet.Layers.ImageMapLayer = EsriLeaflet.Layers.RasterLayer.extend({\n\n  options: {\n    updateInterval: 150,\n    format: 'jpgpng'\n  },\n\n  query: function(){\n    return this._service.query();\n  },\n\n  identify: function(){\n    return this._service.identify();\n  },\n\n  initialize: function (url, options) {\n    options = options || {};\n    options.url = EsriLeaflet.Util.cleanUrl(url);\n    this._service = new EsriLeaflet.Services.ImageService(options);\n    this._service.on('authenticationrequired requeststart requestend requesterror requestsuccess', this._propagateEvent, this);\n    L.Util.setOptions(this, options);\n  },\n\n  setPixelType: function (pixelType) {\n    this.options.pixelType = pixelType;\n    this._update();\n    return this;\n  },\n\n  getPixelType: function () {\n    return this.options.pixelType;\n  },\n\n  setBandIds: function (bandIds) {\n    if (L.Util.isArray(bandIds)) {\n      this.options.bandIds = bandIds.join(',');\n    } else {\n      this.options.bandIds = bandIds.toString();\n    }\n    this._update();\n    return this;\n  },\n\n  getBandIds: function () {\n    return this.options.bandIds;\n  },\n\n  setNoData: function (noData, noDataInterpretation) {\n    if (L.Util.isArray(noData)) {\n      this.options.noData = noData.join(',');\n    } else {\n      this.options.noData = noData.toString();\n    }\n    if (noDataInterpretation) {\n      this.options.noDataInterpretation = noDataInterpretation;\n    }\n    this._update();\n    return this;\n  },\n\n  getNoData: function () {\n    return this.options.noData;\n  },\n\n  getNoDataInterpretation: function () {\n    return this.options.noDataInterpretation;\n  },\n\n  setRenderingRule: function(renderingRule) {\n    this.options.renderingRule = renderingRule;\n    this._update();\n  },\n\n  getRenderingRule: function() {\n    return this.options.renderingRule;\n  },\n\n  setMosaicRule: function(mosaicRule) {\n    this.options.mosaicRule = mosaicRule;\n    this._update();\n  },\n\n  getMosaicRule: function() {\n    return this.options.mosaicRule;\n  },\n\n  _getPopupData: function(e){\n    var callback = L.Util.bind(function(error, results, response) {\n      setTimeout(L.Util.bind(function(){\n        this._renderPopup(e.latlng, error, results, response);\n      }, this), 300);\n    }, this);\n\n    var identifyRequest = this.identify().at(e.latlng);\n\n    // set mosaic rule for identify task if it is set for layer\n    if (this.options.mosaicRule) {\n      identifyRequest.setMosaicRule(this.options.mosaicRule);\n      // @TODO: force return catalog items too?\n    }\n\n    // @TODO: set rendering rule? Not sure,\n    // sometimes you want raw pixel values\n    // if (this.options.renderingRule) {\n    //   identifyRequest.setRenderingRule(this.options.renderingRule);\n    // }\n\n    identifyRequest.run(callback);\n\n    // set the flags to show the popup\n    this._shouldRenderPopup = true;\n    this._lastClick = e.latlng;\n  },\n\n  _buildExportParams: function () {\n    var bounds = this._map.getBounds();\n    var size = this._map.getSize();\n    var ne = this._map.options.crs.project(bounds._northEast);\n    var sw = this._map.options.crs.project(bounds._southWest);\n\n    var params = {\n      bbox: [sw.x, sw.y, ne.x, ne.y].join(','),\n      size: size.x + ',' + size.y,\n      format: this.options.format,\n      bboxSR: this.options.bboxSR,\n      imageSR: this.options.imageSR\n    };\n\n    if (this.options.from && this.options.to) {\n      params.time = this.options.from.valueOf() + ',' + this.options.to.valueOf();\n    }\n\n    if (this.options.pixelType) {\n      params.pixelType = this.options.pixelType;\n    }\n\n    if (this.options.interpolation) {\n      params.interpolation = this.options.interpolation;\n    }\n\n    if (this.options.compressionQuality) {\n      params.compressionQuality = this.options.compressionQuality;\n    }\n\n    if (this.options.bandIds) {\n      params.bandIds = this.options.bandIds;\n    }\n\n    if (this.options.noData) {\n      params.noData = this.options.noData;\n    }\n\n    if (this.options.noDataInterpretation) {\n      params.noDataInterpretation = this.options.noDataInterpretation;\n    }\n\n    if (this._service.options.token) {\n      params.token = this._service.options.token;\n    }\n\n    if(this.options.renderingRule) {\n      params.renderingRule = JSON.stringify(this.options.renderingRule);\n    }\n\n    if(this.options.mosaicRule) {\n      params.mosaicRule = JSON.stringify(this.options.mosaicRule);\n    }\n\n    return params;\n  },\n\n  _requestExport: function (params, bounds) {\n    if (this.options.f === 'json') {\n      this._service.get('exportImage', params, function(error, response){\n        this._renderImage(response.href, bounds);\n      }, this);\n    } else {\n      params.f = 'image';\n      this._renderImage(this.options.url + 'exportImage' + L.Util.getParamString(params), bounds);\n    }\n  }\n});\n\nEsriLeaflet.ImageMapLayer = EsriLeaflet.Layers.ImageMapLayer;\n\nEsriLeaflet.Layers.imageMapLayer = function (url, options) {\n  return new EsriLeaflet.Layers.ImageMapLayer(url, options);\n};\n\nEsriLeaflet.imageMapLayer = function (url, options) {\n  return new EsriLeaflet.Layers.ImageMapLayer(url, options);\n};","EsriLeaflet.Layers.TiledMapLayer = L.TileLayer.extend({\n  initialize: function(url, options){\n    options = options || {};\n    options.url = EsriLeaflet.Util.cleanUrl(url);\n    options = L.Util.setOptions(this, options);\n\n    // set the urls\n    //this.url = L.esri.Util.cleanUrl(url);\n    this.tileUrl = L.esri.Util.cleanUrl(url) + 'tile/{z}/{y}/{x}';\n    this._service = new L.esri.Services.MapService(options);\n    this._service.on('authenticationrequired requeststart requestend requesterror requestsuccess', this._propagateEvent, this);\n\n    //if this is looking at the AGO tiles subdomain insert the subdomain placeholder\n    if(this.tileUrl.match('://tiles.arcgisonline.com')){\n      this.tileUrl = this.tileUrl.replace('://tiles.arcgisonline.com', '://tiles{s}.arcgisonline.com');\n      options.subdomains = ['1', '2', '3', '4'];\n    }\n\n    if(this.options.token) {\n      this.tileUrl += ('?token=' + this.options.token);\n    }\n\n    // init layer by calling TileLayers initialize method\n    L.TileLayer.prototype.initialize.call(this, this.tileUrl, options);\n  },\n\n  metadata: function(callback, context){\n    this._service.metadata(callback, context);\n    return this;\n  },\n\n  identify: function(){\n    return this._service.identify();\n  },\n\n  authenticate: function(token){\n    var tokenQs = '?token=' + token;\n    this.tileUrl = (this.options.token) ? this.tileUrl.replace(/\\?token=(.+)/g, tokenQs) : this.tileUrl + tokenQs;\n    this.options.token = token;\n    this._service.authenticate(token);\n    return this;\n  },\n\n  // from https://github.com/Leaflet/Leaflet/blob/v0.7.2/src/layer/FeatureGroup.js\n  // @TODO remove at Leaflet 0.8\n  _propagateEvent: function (e) {\n    e = L.extend({\n      layer: e.target,\n      target: this\n    }, e);\n    this.fire(e.type, e);\n  }\n});\n\nL.esri.TiledMapLayer = L.esri.Layers.tiledMapLayer;\n\nL.esri.Layers.tiledMapLayer = function(url, options){\n  return new L.esri.Layers.TiledMapLayer(url, options);\n};\n\nL.esri.tiledMapLayer = function(url, options){\n  return new L.esri.Layers.TiledMapLayer(url, options);\n};","EsriLeaflet.Layers.FeatureGrid = L.Class.extend({\n\n  includes: L.Mixin.Events,\n\n  options: {\n    cellSize: 512,\n    updateInterval: 150\n  },\n\n  initialize: function (options) {\n    options = L.setOptions(this, options);\n  },\n\n  onAdd: function (map) {\n    this._map = map;\n    this._update = L.Util.limitExecByInterval(this._update, this.options.updateInterval, this);\n\n    // @TODO remove for leaflet 0.8\n    this._map.addEventListener(this.getEvents(), this);\n\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      viewreset: this._reset,\n      moveend: this._update,\n      zoomend : this._onZoom\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  _onZoom : function () {\n    var zoom = this._map.getZoom();\n\n    if (zoom > this.options.maxZoom ||\n        zoom < this.options.minZoom) {\n      this.removeFrom(this._map);\n      this._map.addEventListener('zoomend', this.getEvents().zoomend, this);\n    } else if (!this._map.hasLayer(this)) {\n      this._map.removeEventListener('zoomend', this.getEvents().zoomend, this);\n      this.addTo(this._map);\n    }\n\n  },\n\n  _reset: function () {\n    this._removeCells();\n\n    this._cells = {};\n    this._activeCells = {};\n    this._cellsToLoad = 0;\n    this._cellsTotal = 0;\n\n    // @TODO enable at Leaflet 0.8\n    // this._cellNumBounds = this._getCellNumBounds();\n\n    this._resetWrap();\n  },\n\n  _resetWrap: function () {\n    var map = this._map,\n        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) { return; }\n\n    var bounds = this._map.getPixelBounds(),\n        zoom = this._map.getZoom(),\n        cellSize = this._getCellSize(),\n        cellPadding = [cellSize/2,cellSize/2];\n        // cellPadding = [0,0]\n\n    if (zoom > this.options.maxZoom ||\n        zoom < this.options.minZoom) { return; }\n\n    // cell coordinates range for the current view\n    var topLeft = bounds.min.subtract(cellPadding).divideBy(cellSize).floor();\n    topLeft.x = Math.max(topLeft.x, 0);\n    topLeft.y = Math.max(topLeft.y, 0);\n\n    var cellBounds = L.bounds(topLeft, bounds.max.add(cellPadding).divideBy(cellSize).floor());\n\n    // remove any present cells that are off the specified bounds\n    this._removeOtherCells(cellBounds);\n    this._addCells(cellBounds);\n  },\n\n  _addCells: function (bounds) {\n    var queue = [],\n        center = bounds.getCenter(),\n        zoom = this._map.getZoom();\n\n    var j, i, coords;\n    // create a queue of coordinates to load cells from\n    for (j = bounds.min.y; j <= bounds.max.y; j++) {\n      for (i = bounds.min.x; i <= bounds.max.x; i++) {\n        coords = new L.Point(i, j);\n        coords.z = zoom;\n\n        // @TODO enable at Leaflet 0.8\n        // if (this._isValidCell(coords)) {\n        //   queue.push(coords);\n        // }\n\n        queue.push(coords);\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  // @TODO enable at Leaflet 0.8\n  // _isValidCell: function (coords) {\n  //   var crs = this._map.options.crs;\n\n  //   if (!crs.infinite) {\n  //     // don't load cell if it's out of bounds and not wrapped\n  //     var bounds = this._cellNumBounds;\n  //     if (\n  //       (!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||\n  //       (!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))\n  //     ) {\n  //       return false;\n  //     }\n  //   }\n\n  //   if (!this.options.bounds) {\n  //     return true;\n  //   }\n\n  //   // don't load cell if it doesn't intersect the bounds in options\n  //   var cellBounds = this._cellCoordsToBounds(coords);\n  //   return L.latLngBounds(this.options.bounds).intersects(cellBounds);\n  // },\n\n  // converts cell coordinates to its geographical bounds\n  _cellCoordsToBounds: function (coords) {\n    var map = this._map,\n        cellSize = this.options.cellSize,\n\n        nwPoint = coords.multiplyBy(cellSize),\n        sePoint = nwPoint.add([cellSize, cellSize]),\n\n        // @TODO for Leaflet 0.8\n        // nw = map.wrapLatLng(map.unproject(nwPoint, coords.z)),\n        // se = map.wrapLatLng(map.unproject(sePoint, coords.z));\n\n        nw = map.unproject(nwPoint, coords.z).wrap(),\n        se = map.unproject(sePoint, coords.z).wrap();\n\n    return new L.LatLngBounds(nw, se);\n  },\n\n  // converts cell coordinates to key for the cell cache\n  _cellCoordsToKey: function (coords) {\n    return coords.x + ':' + coords.y;\n  },\n\n  // converts cell cache key to coordiantes\n  _keyToCellCoords: function (key) {\n    var kArr = key.split(':'),\n        x = parseInt(kArr[0], 10),\n        y = parseInt(kArr[1], 10);\n\n    return new L.Point(x, y);\n  },\n\n  // remove any present cells that are off the specified bounds\n  _removeOtherCells: function (bounds) {\n    for (var key in this._cells) {\n      if (!bounds.contains(this._keyToCellCoords(key))) {\n        this._removeCell(key);\n      }\n    }\n  },\n\n  _removeCell: function (key) {\n    var cell = this._activeCells[key];\n    if(cell){\n      delete this._activeCells[key];\n\n      if (this.cellLeave) {\n        this.cellLeave(cell.bounds, cell.coords);\n      }\n\n      this.fire('cellleave', {\n        bounds: cell.bounds,\n        coords: cell.coords\n      });\n    }\n  },\n\n  _removeCells: function(){\n    for (var key in this._cells) {\n      var bounds = this._cells[key].bounds;\n      var coords = this._cells[key].coords;\n\n      if (this.cellLeave) {\n        this.cellLeave(bounds, coords);\n      }\n\n      this.fire('cellleave', {\n        bounds: bounds,\n        coords: coords\n      });\n    }\n  },\n\n  _addCell: function (coords) {\n\n    // wrap cell coords if necessary (depending on CRS)\n    this._wrapCoords(coords);\n\n    // generate the cell key\n    var key = this._cellCoordsToKey(coords);\n\n    // get the cell from the cache\n    var cell = this._cells[key];\n    // if this cell should be shown as isnt active yet (enter)\n\n    if (cell && !this._activeCells[key]) {\n      if (this.cellEnter) {\n        this.cellEnter(cell.bounds, coords);\n      }\n\n      this.fire('cellenter', {\n        bounds: cell.bounds,\n        coords: coords\n      });\n\n      this._activeCells[key] = cell;\n    }\n\n    // if we dont have this cell in the cache yet (create)\n    if (!cell) {\n      cell = {\n        coords: coords,\n        bounds: this._cellCoordsToBounds(coords)\n      };\n\n      this._cells[key] = cell;\n      this._activeCells[key] = cell;\n\n      if(this.createCell){\n        this.createCell(cell.bounds, coords);\n      }\n\n      this.fire('cellcreate', {\n        bounds: cell.bounds,\n        coords: coords\n      });\n    }\n  },\n\n  _wrapCoords: function (coords) {\n    coords.x = this._wrapLng ? L.Util.wrapNum(coords.x, this._wrapLng) : coords.x;\n    coords.y = this._wrapLat ? L.Util.wrapNum(coords.y, this._wrapLat) : coords.y;\n  }\n\n  // get the global cell coordinates range for the current zoom\n  // @TODO enable at Leaflet 0.8\n  // _getCellNumBounds: function () {\n  //   // @TODO for Leaflet 0.8\n  //   // var bounds = this._map.getPixelWorldBounds(),\n  //   //     size = this._getCellSize();\n  //   //\n  //   // return bounds ? L.bounds(\n  //   //     bounds.min.divideBy(size).floor(),\n  //   //     bounds.max.divideBy(size).ceil().subtract([1, 1])) : null;\n  // }\n\n});","(function(EsriLeaflet){\n\n  EsriLeaflet.Layers.FeatureManager = EsriLeaflet.Layers.FeatureGrid.extend({\n\n    /**\n     * Options\n     */\n\n    options: {\n      where: '1=1',\n      fields: ['*'],\n      from: false,\n      to: false,\n      timeField: false,\n      timeFilterMode: 'server',\n      simplifyFactor: 0,\n      precision: 6\n    },\n\n    /**\n     * Constructor\n     */\n\n    initialize: function (url, options) {\n      EsriLeaflet.Layers.FeatureGrid.prototype.initialize.call(this, options);\n\n      options = options || {};\n      options.url = EsriLeaflet.Util.cleanUrl(url);\n      options = L.setOptions(this, options);\n\n      this._service = new EsriLeaflet.Services.FeatureLayer(options);\n\n      //use case insensitive regex to look for common fieldnames used for indexing\n      /*global console */\n      if (this.options.fields[0] !== '*'){\n        var oidCheck = false;\n        for (var i = 0; i < this.options.fields.length; i++){\n          if (this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i)){\n            oidCheck = true;\n          }\n        }\n        if (oidCheck === false && console && console.warn){\n          console.warn('no known esriFieldTypeOID field detected in fields Array.  Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.');\n        }\n      }\n\n      // Leaflet 0.8 change to new propagation\n      this._service.on('authenticationrequired requeststart requestend requesterror requestsuccess', function (e) {\n        e = L.extend({\n          target: this\n        }, e);\n        this.fire(e.type, e);\n      }, this);\n\n      if(this.options.timeField.start && this.options.timeField.end){\n        this._startTimeIndex = new BinarySearchIndex();\n        this._endTimeIndex = new BinarySearchIndex();\n      } else if(this.options.timeField){\n        this._timeIndex = new BinarySearchIndex();\n      }\n\n      this._cache = {};\n      this._currentSnapshot = []; // cache of what layers should be active\n      this._activeRequests = 0;\n      this._pendingRequests = [];\n    },\n\n    /**\n     * Layer Interface\n     */\n\n    onAdd: function(map){\n      return EsriLeaflet.Layers.FeatureGrid.prototype.onAdd.call(this, map);\n    },\n\n    onRemove: function(map){\n      return EsriLeaflet.Layers.FeatureGrid.prototype.onRemove.call(this, map);\n    },\n\n    getAttribution: function () {\n      return this.options.attribution;\n    },\n\n    /**\n     * Feature Managment\n     */\n\n    createCell: function(bounds, coords){\n      this._requestFeatures(bounds, coords);\n    },\n\n    _requestFeatures: function(bounds, coords, callback){\n      this._activeRequests++;\n\n      // our first active request fires loading\n      if(this._activeRequests === 1){\n        this.fire('loading', {\n          bounds: bounds\n        });\n      }\n\n      return this._buildQuery(bounds).run(function(error, featureCollection, response){\n        if(response && response.exceededTransferLimit){\n          this.fire('drawlimitexceeded');\n        }\n\n        //deincriment the request counter\n        this._activeRequests--;\n\n        if(!error && featureCollection.features.length){\n          // schedule adding features until the next animation frame\n          EsriLeaflet.Util.requestAnimationFrame(L.Util.bind(function(){\n            this._addFeatures(featureCollection.features, coords);\n          }, this));\n        }\n\n        if(callback){\n          callback.call(this, error, featureCollection);\n        }\n\n        // if there are no more active requests fire a load event for this view\n        if(this._activeRequests <= 0){\n          this.fire('load', {\n            bounds: bounds\n          });\n        }\n      }, this);\n    },\n\n    _cacheKey: function (coords){\n      return coords.z + ':' + coords.x + ':' +coords.y;\n    },\n\n    _addFeatures: function(features, coords){\n      var key = this._cacheKey(coords);\n      this._cache[key] = this._cache[key] || [];\n\n      for (var i = features.length - 1; i >= 0; i--) {\n        var id = features[i].id;\n        this._currentSnapshot.push(id);\n        this._cache[key].push(id);\n      }\n\n      if(this.options.timeField){\n        this._buildTimeIndexes(features);\n      }\n\n      var zoom = this._map.getZoom();\n\n      if (zoom > this.options.maxZoom ||\n          zoom < this.options.minZoom) { return; }\n\n      this.createLayers(features);\n    },\n\n    _buildQuery: function(bounds){\n      var query = this._service.query().intersects(bounds).where(this.options.where).fields(this.options.fields).precision(this.options.precision);\n\n      if(this.options.simplifyFactor){\n        query.simplify(this._map, this.options.simplifyFactor);\n      }\n\n      if(this.options.timeFilterMode === 'server' && this.options.from && this.options.to){\n        query.between(this.options.from, this.options.to);\n      }\n\n      return query;\n    },\n\n    /**\n     * Where Methods\n     */\n\n    setWhere: function(where, callback, context){\n\n      this.options.where = (where && where.length) ? where : '1=1';\n\n      var oldSnapshot = [];\n      var newShapshot = [];\n      var pendingRequests = 0;\n      var requestError = null;\n      var requestCallback = L.Util.bind(function(error, featureCollection){\n        if(error){\n          requestError = error;\n        }\n\n        if(featureCollection){\n          for (var i = featureCollection.features.length - 1; i >= 0; i--) {\n            newShapshot.push(featureCollection.features[i].id);\n          }\n        }\n\n        pendingRequests--;\n\n        if(pendingRequests <= 0){\n          this._currentSnapshot = newShapshot;\n          // schedule adding features until the next animation frame\n          EsriLeaflet.Util.requestAnimationFrame(L.Util.bind(function(){\n            this.removeLayers(oldSnapshot);\n            this.addLayers(newShapshot);\n            if(callback) {\n              callback.call(context, requestError);\n            }\n          }, this));\n\n        }\n      }, this);\n\n      for (var i = this._currentSnapshot.length - 1; i >= 0; i--) {\n        oldSnapshot.push(this._currentSnapshot[i]);\n      }\n\n      for(var key in this._activeCells){\n        pendingRequests++;\n        var coords = this._keyToCellCoords(key);\n        var bounds = this._cellCoordsToBounds(coords);\n        this._requestFeatures(bounds, key, requestCallback);\n      }\n\n      return this;\n    },\n\n    getWhere: function(){\n      return this.options.where;\n    },\n\n    /**\n     * Time Range Methods\n     */\n\n    getTimeRange: function(){\n      return [this.options.from, this.options.to];\n    },\n\n    setTimeRange: function(from, to, callback, context){\n      var oldFrom = this.options.from;\n      var oldTo = this.options.to;\n      var pendingRequests = 0;\n      var requestError = null;\n      var requestCallback = L.Util.bind(function(error){\n        if(error){\n          requestError = error;\n        }\n        this._filterExistingFeatures(oldFrom, oldTo, from, to);\n\n        pendingRequests--;\n\n        if(callback && pendingRequests <= 0){\n          callback.call(context, requestError);\n        }\n      }, this);\n\n      this.options.from = from;\n      this.options.to = to;\n\n      this._filterExistingFeatures(oldFrom, oldTo, from, to);\n\n      if(this.options.timeFilterMode === 'server') {\n        for(var key in this._activeCells){\n          pendingRequests++;\n          var coords = this._keyToCellCoords(key);\n          var bounds = this._cellCoordsToBounds(coords);\n          this._requestFeatures(bounds, key, requestCallback);\n        }\n      }\n    },\n\n    refresh: function(){\n      for(var key in this._activeCells){\n        var coords = this._keyToCellCoords(key);\n        var bounds = this._cellCoordsToBounds(coords);\n        this._requestFeatures(bounds, key);\n      }\n    },\n\n    _filterExistingFeatures: function (oldFrom, oldTo, newFrom, newTo) {\n      var layersToRemove = (oldFrom && oldTo) ? this._getFeaturesInTimeRange(oldFrom, oldTo) : this._currentSnapshot;\n      var layersToAdd = this._getFeaturesInTimeRange(newFrom, newTo);\n\n      if(layersToAdd.indexOf){\n        for (var i = 0; i < layersToAdd.length; i++) {\n          var shouldRemoveLayer = layersToRemove.indexOf(layersToAdd[i]);\n          if(shouldRemoveLayer >= 0){\n            layersToRemove.splice(shouldRemoveLayer, 1);\n          }\n        }\n      }\n\n      // schedule adding features until the next animation frame\n      EsriLeaflet.Util.requestAnimationFrame(L.Util.bind(function(){\n        this.removeLayers(layersToRemove);\n        this.addLayers(layersToAdd);\n      }, this));\n    },\n\n    _getFeaturesInTimeRange: function(start, end){\n      var ids = [];\n      var search;\n\n      if(this.options.timeField.start && this.options.timeField.end){\n        var startTimes = this._startTimeIndex.between(start, end);\n        var endTimes = this._endTimeIndex.between(start, end);\n        search = startTimes.concat(endTimes);\n      } else {\n        search = this._timeIndex.between(start, end);\n      }\n\n      for (var i = search.length - 1; i >= 0; i--) {\n        ids.push(search[i].id);\n      }\n\n      return ids;\n    },\n\n    _buildTimeIndexes: function(geojson){\n      var i;\n      var feature;\n      if(this.options.timeField.start && this.options.timeField.end){\n        var startTimeEntries = [];\n        var endTimeEntries = [];\n        for (i = geojson.length - 1; i >= 0; i--) {\n          feature = geojson[i];\n          startTimeEntries.push( {\n            id: feature.id,\n            value: new Date(feature.properties[this.options.timeField.start])\n          });\n          endTimeEntries.push( {\n            id: feature.id,\n            value: new Date(feature.properties[this.options.timeField.end])\n          });\n        }\n        this._startTimeIndex.bulkAdd(startTimeEntries);\n        this._endTimeIndex.bulkAdd(endTimeEntries);\n      } else {\n        var timeEntries = [];\n        for (i = geojson.length - 1; i >= 0; i--) {\n          feature = geojson[i];\n          timeEntries.push( {\n            id: feature.id,\n            value: new Date(feature.properties[this.options.timeField])\n          });\n        }\n\n        this._timeIndex.bulkAdd(timeEntries);\n      }\n    },\n\n    _featureWithinTimeRange: function(feature){\n      if(!this.options.from || !this.options.to){\n        return true;\n      }\n\n      var from = +this.options.from.valueOf();\n      var to = +this.options.to.valueOf();\n\n      if(typeof this.options.timeField === 'string'){\n        var date = +feature.properties[this.options.timeField];\n        return (date >= from) && (date <= to);\n      }\n\n      if(this.options.timeField.start &&  this.options.timeField.end){\n        var startDate = +feature.properties[this.options.timeField.start];\n        var endDate = +feature.properties[this.options.timeField.end];\n        return ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to));\n      }\n    },\n\n    /**\n     * Service Methods\n     */\n\n    authenticate: function(token){\n      this._service.authenticate(token);\n      return this;\n    },\n\n    metadata: function(callback, context){\n      this._service.metadata(callback, context);\n      return this;\n    },\n\n    query: function(){\n      return this._service.query();\n    },\n\n    addFeature: function(feature, callback, context){\n      this._service.addFeature(feature, function(error, response){\n        if(!error){\n          this.refresh();\n        }\n        if(callback){\n          callback.call(context, error, response);\n        }\n      }, this);\n      return this;\n    },\n\n    updateFeature: function(feature, callback, context){\n      return this._service.updateFeature(feature, function(error, response){\n        if(!error){\n          this.refresh();\n        }\n        if(callback){\n          callback.call(context, error, response);\n        }\n      }, this);\n    },\n\n    deleteFeature: function(id, callback, context){\n      return this._service.deleteFeature(id, function(error, response){\n        if(!error && response.objectId){\n          this.removeLayers([response.objectId], true);\n        }\n        if(callback){\n          callback.call(context, error, response);\n        }\n      }, this);\n    }\n  });\n\n  /**\n   * Temporal Binary Search Index\n   */\n\n  function BinarySearchIndex(values) {\n    this.values = values || [];\n  }\n\n  BinarySearchIndex.prototype._query = function(query){\n    var minIndex = 0;\n    var maxIndex = this.values.length - 1;\n    var currentIndex;\n    var currentElement;\n    var resultIndex;\n\n    while (minIndex <= maxIndex) {\n      resultIndex = currentIndex = (minIndex + maxIndex) / 2 | 0;\n      currentElement = this.values[Math.round(currentIndex)];\n      if (+currentElement.value < +query) {\n        minIndex = currentIndex + 1;\n      } else if (+currentElement.value > +query) {\n        maxIndex = currentIndex - 1;\n      } else {\n        return currentIndex;\n      }\n    }\n\n    return ~maxIndex;\n  };\n\n  BinarySearchIndex.prototype.sort = function(){\n    this.values.sort(function(a, b) {\n      return +b.value - +a.value;\n    }).reverse();\n    this.dirty = false;\n  };\n\n  BinarySearchIndex.prototype.between = function(start, end){\n    if(this.dirty){\n      this.sort();\n    }\n\n    var startIndex = this._query(start);\n    var endIndex = this._query(end);\n\n    if(startIndex === 0 && endIndex === 0){\n      return [];\n    }\n\n    startIndex = Math.abs(startIndex);\n    endIndex = (endIndex < 0) ? Math.abs(endIndex): endIndex + 1;\n\n    return this.values.slice(startIndex, endIndex);\n  };\n\n  BinarySearchIndex.prototype.bulkAdd = function(items){\n    this.dirty = true;\n    this.values = this.values.concat(items);\n  };\n\n})(EsriLeaflet);","EsriLeaflet.Layers.FeatureLayer = EsriLeaflet.Layers.FeatureManager.extend({\n\n  statics: {\n    EVENTS: 'click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose'\n  },\n\n  options: {\n    cacheLayers: true\n  },\n\n  /**\n   * Constructor\n   */\n\n  initialize: function (url, options) {\n    EsriLeaflet.Layers.FeatureManager.prototype.initialize.call(this, url, options);\n\n    options = L.setOptions(this, options);\n\n    this._layers = {};\n    this._leafletIds = {};\n    this._key = 'c'+(Math.random() * 1e9).toString(36).replace('.', '_');\n  },\n\n  /**\n   * Layer Interface\n   */\n\n  onAdd: function(map){\n    map.on('zoomstart zoomend', function(e){\n      this._zooming = (e.type === 'zoomstart');\n    }, this);\n    return EsriLeaflet.Layers.FeatureManager.prototype.onAdd.call(this, map);\n  },\n\n  onRemove: function(map){\n    for (var i in this._layers) {\n      map.removeLayer(this._layers[i]);\n    }\n\n    return EsriLeaflet.Layers.FeatureManager.prototype.onRemove.call(this, map);\n  },\n\n  createNewLayer: function(geojson){\n    // @TODO Leaflet 0.8\n    //newLayer = L.GeoJSON.geometryToLayer(geojson, this.options);\n    return L.GeoJSON.geometryToLayer(geojson, this.options.pointToLayer, L.GeoJSON.coordsToLatLng, this.options);\n  },\n\n  /**\n   * Feature Managment Methods\n   */\n\n  createLayers: function(features){\n    for (var i = features.length - 1; i >= 0; i--) {\n\n      var geojson = features[i];\n\n      var layer = this._layers[geojson.id];\n      var newLayer;\n\n      if(layer && !this._map.hasLayer(layer)){\n        this._map.addLayer(layer);\n      }\n\n      if (layer && layer.setLatLngs) {\n        // @TODO Leaflet 0.8\n        //newLayer = L.GeoJSON.geometryToLayer(geojson, this.options);\n\n        var updateGeo = this.createNewLayer(geojson);\n        layer.setLatLngs(updateGeo.getLatLngs());\n      }\n\n      if(!layer){\n        // @TODO Leaflet 0.8\n        //newLayer = L.GeoJSON.geometryToLayer(geojson, this.options);\n\n        newLayer =  this.createNewLayer(geojson);\n        newLayer.feature = geojson;\n        newLayer.defaultOptions = newLayer.options;\n        newLayer._leaflet_id = this._key + '_' + geojson.id;\n\n        this._leafletIds[newLayer._leaflet_id] = geojson.id;\n\n        // bubble events from layers to this\n        // @TODO Leaflet 0.8\n        // newLayer.addEventParent(this);\n\n        newLayer.on(EsriLeaflet.Layers.FeatureLayer.EVENTS, this._propagateEvent, this);\n\n        // bind a popup if we have one\n        if(this._popup && newLayer.bindPopup){\n          newLayer.bindPopup(this._popup(newLayer.feature, newLayer), this._popupOptions);\n        }\n\n        if(this.options.onEachFeature){\n          this.options.onEachFeature(newLayer.feature, newLayer);\n        }\n\n        // cache the layer\n        this._layers[newLayer.feature.id] = newLayer;\n\n        // style the layer\n        this.resetStyle(newLayer.feature.id);\n\n        this.fire('createfeature', {\n          feature: newLayer.feature\n        });\n\n        // add the layer if it is within the time bounds or our layer is not time enabled\n        if(!this.options.timeField || (this.options.timeField && this._featureWithinTimeRange(geojson)) ){\n          this._map.addLayer(newLayer);\n        }\n      }\n    }\n  },\n\n  addLayers: function(ids){\n    for (var i = ids.length - 1; i >= 0; i--) {\n      var layer = this._layers[ids[i]];\n      if(layer){\n        this.fire('addfeature', {\n          feature: layer.feature\n        });\n        this._map.addLayer(layer);\n      }\n    }\n  },\n\n  removeLayers: function(ids, permanent){\n    for (var i = ids.length - 1; i >= 0; i--) {\n      var id = ids[i];\n      var layer = this._layers[id];\n      if(layer){\n        this.fire('removefeature', {\n          feature: layer.feature,\n          permanent: permanent\n        });\n        this._map.removeLayer(layer);\n      }\n      if(layer && permanent){\n        delete this._layers[id];\n      }\n    }\n  },\n\n  cellEnter: function(bounds, coords){\n    if(!this._zooming){\n      EsriLeaflet.Util.requestAnimationFrame(L.Util.bind(function(){\n        var cacheKey = this._cacheKey(coords);\n        var cellKey = this._cellCoordsToKey(coords);\n        var layers = this._cache[cacheKey];\n        if(this._activeCells[cellKey] && layers){\n          this.addLayers(layers);\n        }\n      }, this));\n    }\n  },\n\n  cellLeave: function(bounds, coords){\n    if(!this._zooming){\n      EsriLeaflet.Util.requestAnimationFrame(L.Util.bind(function(){\n        var cacheKey = this._cacheKey(coords);\n        var cellKey = this._cellCoordsToKey(coords);\n        var layers = this._cache[cacheKey];\n        var mapBounds = this._map.getBounds();\n        if(!this._activeCells[cellKey] && layers){\n          var removable = true;\n\n          for (var i = 0; i < layers.length; i++) {\n            var layer = this._layers[layers[i]];\n            if(layer && layer.getBounds && mapBounds.intersects(layer.getBounds())){\n              removable = false;\n            }\n          }\n\n          if(removable){\n            this.removeLayers(layers, !this.options.cacheLayers);\n          }\n\n          if(!this.options.cacheLayers && removable){\n            delete this._cache[cacheKey];\n            delete this._cells[cellKey];\n            delete this._activeCells[cellKey];\n          }\n        }\n      }, this));\n    }\n  },\n\n  /**\n   * Styling Methods\n   */\n\n  resetStyle: function (id) {\n    var layer = this._layers[id];\n\n    if(layer){\n      layer.options = layer.defaultOptions;\n      this.setFeatureStyle(layer.feature.id, this.options.style);\n    }\n\n    return this;\n  },\n\n  setStyle: function (style) {\n    this.options.style = style;\n    this.eachFeature(function (layer) {\n      this.setFeatureStyle(layer.feature.id, style);\n    }, this);\n    return this;\n  },\n\n  setFeatureStyle: function (id, style) {\n    var layer = this._layers[id];\n\n    if (typeof style === 'function') {\n      style = style(layer.feature);\n    }\n\n    /*trap inability to access default style options from MultiLine/MultiPolygon\n    please revisit at Leaflet 1.0*/\n    else if (!style && !layer.defaultOptions) {\n      var dummyPath = new L.Path();\n      style = L.Path.prototype.options;\n      style.fill = true; //not set by default\n    }\n\n    if (layer.setStyle) {\n      layer.setStyle(style);\n    }\n  },\n\n  /**\n   * Popup Methods\n   */\n\n  bindPopup: function (fn, options) {\n    this._popup = fn;\n    this._popupOptions = options;\n    for (var i in this._layers) {\n      var layer = this._layers[i];\n      var popupContent = this._popup(layer.feature, layer);\n      layer.bindPopup(popupContent, options);\n    }\n    return this;\n  },\n\n  unbindPopup: function () {\n    this._popup =  false;\n    for (var i in this._layers) {\n      var layer = this._layers[i];\n      if (layer.unbindPopup) {\n        layer.unbindPopup();\n      } else if (layer.getLayers) {\n        var groupLayers = layer.getLayers();\n        for (var j in groupLayers) {\n          var gLayer = groupLayers[j];\n          gLayer.unbindPopup();\n        }\n      }\n    }\n    return this;\n  },\n\n  /**\n   * Utility Methods\n   */\n\n  eachFeature: function (fn, context) {\n    for (var i in this._layers) {\n      fn.call(context, this._layers[i]);\n    }\n    return this;\n  },\n\n  getFeature: function (id) {\n    return this._layers[id];\n  },\n\n  // from https://github.com/Leaflet/Leaflet/blob/v0.7.2/src/layer/FeatureGroup.js\n  // @TODO remove at Leaflet 0.8\n  _propagateEvent: function (e) {\n    e.layer = this._layers[this._leafletIds[e.target._leaflet_id]];\n    e.target = this;\n    this.fire(e.type, e);\n  }\n});\n\nEsriLeaflet.FeatureLayer = EsriLeaflet.Layers.FeatureLayer;\n\nEsriLeaflet.Layers.featureLayer = function(url, options){\n  return new EsriLeaflet.Layers.FeatureLayer(url, options);\n};\n\nEsriLeaflet.featureLayer = function(url, options){\n  return new EsriLeaflet.Layers.FeatureLayer(url, options);\n};","EsriLeaflet.Controls.Logo = L.Control.extend({\n  options: {\n    position: 'bottomright',\n    marginTop: 0,\n    marginLeft: 0,\n    marginBottom: 0,\n    marginRight: 0\n  },\n  onAdd: function () {\n    var div = L.DomUtil.create('div', 'esri-leaflet-logo');\n    div.style.marginTop = this.options.marginTop;\n    div.style.marginLeft = this.options.marginLeft;\n    div.style.marginBottom = this.options.marginBottom;\n    div.style.marginRight = this.options.marginRight;\n    div.innerHTML = '<a href=\"https://developers.arcgis.com\" style=\"border: none;\"><img src=\"https://js.arcgis.com/3.11/esri/images/map/logo-med.png\" style=\"border: none;\"></a>';\n    return div;\n  }\n});\n\nEsriLeaflet.Controls.logo = function(options){\n  return new L.esri.Controls.Logo(options);\n};\n"]}