{"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","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","geojsonTypeToArcGIS","geoJsonType","arcgisGeometryType","serialize","params","data","f","key","value","param","Object","prototype","toString","call","JSON","stringify","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","bind","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","isArray","match","join","endpoint","_service","setters","setter","offset","limit","outFields","precision","featureIds","returnGeometry","where","outSr","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","bool","run","_cleanParams","count","returnCountOnly","ids","returnIdsOnly","returnExtentOnly","pixelSize","layer","getLatLng","GeoJSON","getLayers","toGeoJSON","text","sr","layers","dynamicLayers","returnZ","returnM","gdbVersion","layerDefs","Identify","setMosaicRule","setRenderingRule","returnCatalogItems","at","getMosaicRule","mosaicRule","getRenderingRule","renderingRule","setPixelSize","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","onAdd","_logo","Logo","position","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","substr","attributionElement","_container","querySelector","innerHTML","maxWidth","basemapLayer","RasterLayer","opacity","_update","limitExecByInterval","updateInterval","split","bboxSR","imageSR","_popup","_getPopupData","_resetPopupState","bindPopup","fn","popupOptions","_shouldRenderPopup","_lastClick","popup","_popupFunction","unbindPopup","closePopup","_currentImage","removeLayer","addLayer","removeFrom","bringToFront","bringToBack","getOpacity","setOpacity","getTimeRange","from","to","setTimeRange","_renderImage","image","ImageOverlay","once","newImage","oldImage","_bounds","equals","_animatingZoom","_panTransition","_inProgress","_buildExportParams","_requestExport","_renderPopup","content","setLatLng","setContent","openOn","_propagateEvent","DynamicMapLayer","timeOptions","format","transparent","setLayers","getLayerDefs","setLayerDefs","getTimeOptions","setTimeOptions","setTimeout","identifyRequest","project","_northEast","_southWest","dpi","href","getParamString","dynamicMapLayer","ImageMapLayer","setPixelType","pixelType","getPixelType","setBandIds","bandIds","getBandIds","setNoData","noData","noDataInterpretation","getNoData","getNoDataInterpretation","interpolation","compressionQuality","imageMapLayer","TiledMapLayer","tileUrl","tokenQs","tiledMapLayer","FeatureGrid","cellSize","addEventListener","getEvents","_reset","removeEventListener","_removeCells","events","viewreset","moveend","_cells","_activeCells","_cellsToLoad","_cellsTotal","_resetWrap","infinite","_getCellSize","wrapLng","_wrapLng","floor","ceil","wrapLat","_wrapLat","getPixelBounds","cellBounds","min","divideBy","max","_addCells","_removeOtherCells","coords","queue","center","getCenter","Point","z","cellsToLoad","distanceTo","_addCell","_cellCoordsToBounds","nwPoint","multiplyBy","sePoint","add","nw","unproject","wrap","se","_cellCoordsToKey","_keyToCellCoords","kArr","parseInt","_removeCell","cell","cellLeave","_wrapCoords","cellEnter","createCell","wrapNum","BinarySearchIndex","FeatureManager","timeField","timeFilterMode","simplifyFactor","oidCheck","_startTimeIndex","_endTimeIndex","_timeIndex","_currentSnapshot","_activeRequests","_pendingRequests","_requestFeatures","_buildQuery","exceededTransferLimit","_addFeatures","_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","_layers","_leafletIds","_key","random","createNewLayer","geometryToLayer","pointToLayer","coordsToLatLng","newLayer","hasLayer","setLatLngs","updateGeo","getLatLngs","defaultOptions","_leaflet_id","_popupOptions","onEachFeature","resetStyle","permanent","setFeatureStyle","setStyle","eachFeature","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,GAIR,QAASiB,GAAMC,GACb,GAAIC,KACJ,KAAK,GAAIC,KAAKF,GACRA,EAAIG,eAAeD,KACrBD,EAAOC,GAAKF,EAAIE,GAGpB,OAAOD,GAIT,QAASG,GAAYC,EAAGC,GACtB,IAAK,GAAIJ,GAAI,EAAGA,EAAIG,EAAEE,OAAQL,IAC5B,GAAIG,EAAEH,KAAOI,EAAEJ,GACb,OAAO,CAGX,QAAO,EAIT,QAASM,GAAUC,GAIjB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,QAAQoc,UACnCI,EAAIlnB,MAAM+mB,WAAajc,KAAKJ,QAAQqc,WACpCG,EAAIlnB,MAAMgnB,aAAelc,KAAKJ,QAAQsc,aACtCE,EAAIlnB,MAAMinB,YAAcnc,KAAKJ,QAAQuc,YACrCC,EAAIrP,UAAY,iKACTqP,KAIXhoB,YAAYI,SAAS6nB,KAAO,SAASzc,GACnC,MAAO,IAAIzK,GAAEC,KAAKZ,SAASwW,KAAKpL","sourcesContent":["var EsriLeaflet = { //jshint ignore:line\n VERSION: '1.0.0-rc.2',\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}","(function(EsriLeaflet){\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.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);","(function(EsriLeaflet){\n\n var callbacks = 0;\n\n window._EsriLeafletCallbacks = {};\n\n function serialize(params){\n var data = '';\n\n 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]' || 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 (url, options) {\n this.url = EsriLeaflet.Util.cleanUrl(url);\n this._requestQueue = [];\n this._authenticating = false;\n L.Util.setOptions(this, options);\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.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.url + path : this.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.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.url + path,\n params: params,\n response: response,\n method: method\n });\n }\n\n this.fire('requestend', {\n url: this.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(url, params){\n return new EsriLeaflet.Services.Service(url, 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(url, options) {\n return new EsriLeaflet.Services.FeatureLayer(url, 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(url, params){\n return new EsriLeaflet.Services.MapService(url, 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(url, params){\n return new EsriLeaflet.Services.ImageService(url, 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 var isArray = param.match(/([a-zA-Z]+)\\[\\]/);\n\n param = (isArray) ? isArray[1] : param;\n\n if(isArray){\n return L.Util.bind(function(value){\n // this.params[param] = (this.params[param]) ? this.params[param] + ',' : '';\n if (L.Util.isArray(value)) {\n this.params[param] = value.join(',');\n } else {\n this.params[param] = value;\n }\n return this;\n }, context);\n } else {\n return L.Util.bind(function(value){\n this.params[param] = value;\n return this;\n }, context);\n }\n },\n\n initialize: function(endpoint, options){\n // endpoint can be either a url to an ArcGIS Rest Service or an instance of EsriLeaflet.Service\n if(endpoint.url && endpoint.request){\n this._service = endpoint;\n this.url = endpoint.url;\n } else {\n this.url = EsriLeaflet.Util.cleanUrl(endpoint);\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 L.Util.setOptions(this, options);\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.url + path : this.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 'outFields': 'fields[]',\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]).join(',');\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()]).join();\n return this;\n },\n\n fields: function (fields) {\n if (L.Util.isArray(fields)) {\n this.params.outFields = fields.join(',');\n } else {\n this.params.outFields = fields;\n }\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 returnGeometry: function(bool){\n this.params.returnGeometry = bool;\n return this;\n },\n\n run: function(callback, context){\n this._cleanParams();\n return this.request(function(error, response){\n callback.call(context, error, (response && EsriLeaflet.Util.responseToFeatureCollection(response)), response);\n }, context);\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]).join(',');\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(url, params){\n return new EsriLeaflet.Tasks.Query(url, 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 (url, params) {\n return new EsriLeaflet.Tasks.Find(url, 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()]).join(',');\n return this;\n },\n\n returnGeometry: function (returnGeometry) {\n this.params.returnGeometry = returnGeometry;\n return this;\n }\n});\n","EsriLeaflet.Tasks.IdentifyImage = EsriLeaflet.Tasks.Identify.extend({\n setters: {\n 'setMosaicRule': 'mosaicRule',\n 'setRenderingRule': 'renderingRule',\n 'returnCatalogItems': 'returnCatalogItems'\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 setPixelSize: function(pixelSize) {\n this.params.pixelSize = pixelSize.join ? pixelSize.join(',') : pixelSize;\n return this;\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(url, params){\n return new EsriLeaflet.Tasks.IdentifyImage(url, params);\n};","EsriLeaflet.Tasks.IdentifyFeatures = EsriLeaflet.Tasks.Identify.extend({\n setters: {\n 'layers': 'layers',\n 'precision': 'geometryPrecision',\n 'tolerance': 'tolerance'\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].join(',');\n this.params.mapExtent=([extent.xmin, extent.ymin, extent.xmax, extent.ymax]).join(',');\n return this;\n },\n\n at: function(latlng){\n latlng = L.latLng(latlng);\n this.params.geometry = ([latlng.lng, latlng.lat]).join(',');\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(url, params){\n return new EsriLeaflet.Tasks.IdentifyFeatures(url, 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 + '//tiles{s}.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Dark_Gray_Base_Beta/MapServer/tile/{z}/{y}/{x}',\n options: {\n hideLogo: false,\n logoPosition: 'bottomright',\n minZoom: 1,\n maxZoom: 10,\n subdomains: ['1', '2'],\n attribution: 'Esri, DeLorme, HERE'\n }\n },\n DarkGrayLabels: {\n urlTemplate: tileProtocol + '//tiles{s}.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Dark_Gray_Reference_Beta/MapServer/tile/{z}/{y}/{x}',\n options: {\n hideLogo: true,\n logoPosition: 'bottomright',\n //pane: 'esri-label',\n minZoom: 1,\n maxZoom: 10,\n subdomains: ['1', '2']\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 },\n onAdd: function(map){\n if(!this.options.hideLogo){\n this._logo = new EsriLeaflet.Controls.Logo({\n position: this.options.logoPosition\n }).addTo(map);\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 }\n\n L.TileLayer.prototype.onRemove.call(this, map);\n\n map.off('moveend', this._updateMapAttribution, this);\n },\n getAttribution:function(){\n var attribution = '' + this.options.attribution + ''/* + 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 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 var image = new L.ImageOverlay(url, bounds, {\n opacity: 0\n }).addTo(this._map);\n\n image.once('load', function(e){\n var newImage = e.target;\n var oldImage = this._currentImage;\n\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 this._currentImage.setOpacity(this.options.opacity);\n\n if(oldImage){\n this._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 this.url = EsriLeaflet.Util.cleanUrl(url);\n this._service = new EsriLeaflet.Services.MapService(this.url, 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.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 this.url = EsriLeaflet.Util.cleanUrl(url);\n this._service = new EsriLeaflet.Services.ImageService(this.url, 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.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 = 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(this.url, 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 };\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 _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\n if (zoom > this.options.maxZoom ||\n zoom < this.options.minZoom) { return; }\n\n // cell coordinates range for the current view\n var cellBounds = L.bounds(\n bounds.min.divideBy(cellSize).floor(),\n bounds.max.divideBy(cellSize).floor());\n\n this._addCells(cellBounds);\n this._removeOtherCells(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 = L.setOptions(this, options);\n\n this.url = EsriLeaflet.Util.cleanUrl(url);\n\n this._service = new EsriLeaflet.Services.FeatureLayer(this.url, 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._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 this._addFeatures(featureCollection.features, coords);\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 _addFeatures: function(features){\n for (var i = features.length - 1; i >= 0; i--) {\n var id = features[i].id;\n this._currentSnapshot.push(id);\n }\n\n if(this.options.timeField){\n this._buildTimeIndexes(features);\n }\n\n this.createLayers(features);\n },\n\n _buildQuery: function(bounds){\n var query = this._service.query().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 this.removeLayers(oldSnapshot);\n this.addLayers(newShapshot);\n if(callback) {\n callback.call(context, requestError);\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 this.removeLayers(layersToRemove);\n this.addLayers(layersToAdd);\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 /**\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 return EsriLeaflet.Layers.FeatureManager.prototype.onAdd.call(this, map);\n },\n\n onRemove: function(map){\n\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 /**\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 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};\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 = '';\n return div;\n }\n});\n\nEsriLeaflet.Controls.logo = function(options){\n return new L.esri.Controls.Logo(options);\n};\n"]}