esri-leaflet
Advanced tools
Comparing version 2.0.0-beta.2 to 2.0.0-beta.3
@@ -1,6 +0,6 @@ | ||
/*! esri-leaflet - v2.0.0-beta.2 - Sun Jul 19 2015 | ||
/*! esri-leaflet - v2.0.0-beta.3 - Sun Jul 19 2015 | ||
* Copyright (c) 2015 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.L.esri={})}(this,function(t){"use strict";function e(t,e){for(var i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function i(t){return e(t[0],t[t.length-1])||t.push(t[0]),t}function s(t){var e,i=0,s=0,r=t.length,o=t[s];for(s;r-1>s;s++)e=t[s+1],i+=(e[0]-o[0])*(e[1]+o[1]),o=e;return i>=0}function r(t,e,i,s){var r=(s[0]-i[0])*(t[1]-i[1])-(s[1]-i[1])*(t[0]-i[0]),o=(e[0]-t[0])*(t[1]-i[1])-(e[1]-t[1])*(t[0]-i[0]),n=(s[1]-i[1])*(e[0]-t[0])-(s[0]-i[0])*(e[1]-t[1]);if(0!==n){var a=r/n,l=o/n;if(a>=0&&1>=a&&l>=0&&1>=l)return!0}return!1}function o(t,e){for(var i=0;i<t.length-1;i++)for(var s=0;s<e.length-1;s++)if(r(t[i],t[i+1],e[s],e[s+1]))return!0;return!1}function n(t,e){for(var i=!1,s=-1,r=t.length,o=r-1;++s<r;o=s)(t[s][1]<=e[1]&&e[1]<t[o][1]||t[o][1]<=e[1]&&e[1]<t[s][1])&&e[0]<(t[o][0]-t[s][0])*(e[1]-t[s][1])/(t[o][1]-t[s][1])+t[s][0]&&(i=!i);return i}function a(t,e){var i=o(t,e),s=n(t,e[0]);return!i&&s?!0:!1}function l(t){for(var e,r,n,l=[],u=[],h=0;h<t.length;h++){var c=i(t[h].slice(0));if(!(c.length<4))if(s(c)){var p=[c];l.push(p)}else u.push(c)}for(var d=[];u.length;){n=u.pop();var m=!1;for(e=l.length-1;e>=0;e--)if(r=l[e][0],a(r,n)){l[e].push(n),m=!0;break}m||d.push(n)}for(;d.length;){n=d.pop();var f=!1;for(e=l.length-1;e>=0;e--)if(r=l[e][0],o(r,n)){l[e].push(n),f=!0;break}f||l.push([n.reverse()])}return 1===l.length?{type:"Polygon",coordinates:l[0]}:{type:"MultiPolygon",coordinates:l}}function u(t){var e=[],r=t.slice(0),o=i(r.shift().slice(0));if(o.length>=4){s(o)||o.reverse(),e.push(o);for(var n=0;n<r.length;n++){var a=i(r[n].slice(0));a.length>=4&&(s(a)&&a.reverse(),e.push(a))}}return e}function h(t){for(var e=[],i=0;i<t.length;i++)for(var s=u(t[i]),r=s.length-1;r>=0;r--){var o=s[r].slice(0);e.push(o)}return e}function c(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function p(t){var e=L.latLng(t.ymin,t.xmin),i=L.latLng(t.ymax,t.xmax);return new L.LatLngBounds(e,i)}function d(t){return t=L.latLngBounds(t),{xmin:t.getSouthWest().lng,ymin:t.getSouthWest().lat,xmax:t.getNorthEast().lng,ymax:t.getNorthEast().lat,spatialReference:{wkid:4326}}}function m(t,e){var i={};return"number"==typeof t.x&&"number"==typeof t.y&&(i.type="Point",i.coordinates=[t.x,t.y]),t.points&&(i.type="MultiPoint",i.coordinates=t.points.slice(0)),t.paths&&(1===t.paths.length?(i.type="LineString",i.coordinates=t.paths[0].slice(0)):(i.type="MultiLineString",i.coordinates=t.paths.slice(0))),t.rings&&(i=l(t.rings.slice(0))),(t.geometry||t.attributes)&&(i.type="Feature",i.geometry=t.geometry?m(t.geometry):null,i.properties=t.attributes?c(t.attributes):null,t.attributes&&(i.id=t.attributes[e]||t.attributes.OBJECTID||t.attributes.FID)),i}function f(t,e){e=e||"OBJECTID";var i,s={wkid:4326},r={};switch(t.type){case"Point":r.x=t.coordinates[0],r.y=t.coordinates[1],r.spatialReference=s;break;case"MultiPoint":r.points=t.coordinates.slice(0),r.spatialReference=s;break;case"LineString":r.paths=[t.coordinates.slice(0)],r.spatialReference=s;break;case"MultiLineString":r.paths=t.coordinates.slice(0),r.spatialReference=s;break;case"Polygon":r.rings=u(t.coordinates.slice(0)),r.spatialReference=s;break;case"MultiPolygon":r.rings=h(t.coordinates.slice(0)),r.spatialReference=s;break;case"Feature":t.geometry&&(r.geometry=f(t.geometry,e)),r.attributes=t.properties?c(t.properties):{},t.id&&(r.attributes[e]=t.id);break;case"FeatureCollection":for(r=[],i=0;i<t.features.length;i++)r.push(f(t.features[i],e));break;case"GeometryCollection":for(r=[],i=0;i<t.geometries.length;i++)r.push(f(t.geometries[i],e))}return r}function y(t,e){var i;if(e)i=e;else if(t.objectIdFieldName)i=t.objectIdFieldName;else if(t.fields){for(var s=0;s<=t.fields.length-1;s++)if("esriFieldTypeOID"===t.fields[s].type){i=t.fields[s].name;break}}else i="OBJECTID";var r={type:"FeatureCollection",features:[]},o=t.features||t.results;if(o.length)for(var n=o.length-1;n>=0;n--)r.features.push(m(o[n],i));return r}function g(t){return t=L.Util.trim(t),"/"!==t[t.length-1]&&(t+="/"),t}function _(t){return/\.arcgis\.com.*?FeatureServer/g.test(t)}function v(t){var e;switch(t){case"Point":e="esriGeometryPoint";break;case"MultiPoint":e="esriGeometryMultipoint";break;case"LineString":e="esriGeometryPolyline";break;case"MultiLineString":e="esriGeometryPolyline";break;case"Polygon":e="esriGeometryPolygon";break;case"MultiPolygon":e="esriGeometryPolygon"}return e}function b(){console&&console.warn&&console.warn.apply(console,arguments)}function x(t){var e="";t.f=t.f||"json";for(var i in t)if(t.hasOwnProperty(i)){var s,r=t[i],o=Object.prototype.toString.call(r);e.length&&(e+="&"),s="[object Array]"===o?"[object Object]"===Object.prototype.toString.call(r[0])?JSON.stringify(r):r.join(","):"[object Object]"===o?JSON.stringify(r):"[object Date]"===o?r.valueOf():r,e+=encodeURIComponent(i)+"="+encodeURIComponent(s)}return e}function S(t,e){var i=new window.XMLHttpRequest;return i.onerror=function(s){i.onreadystatechange=L.Util.falseFn,t.call(e,{error:{code:500,message:"XMLHttpRequest error"}},null)},i.onreadystatechange=function(){var s,r;if(4===i.readyState){try{s=JSON.parse(i.responseText)}catch(o){s=null,r={code:500,message:"Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error."}}!r&&s.error&&(r=s.error,s=null),i.onerror=L.Util.falseFn,t.call(e,r,s)}},i}function T(t,e,i,s){var r=S(i,s);return r.open("POST",t),r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),r.send(x(e)),r}function I(t,e,i,s){var r=S(i,s);return r.open("GET",t+"?"+x(e),!0),r.send(null),r}function w(t,e,i,s){var r=x(e),o=S(i,s),n=(t+"?"+r).length;if(2e3>=n&&Q.cors)o.open("GET",t+"?"+r),o.send(null);else{if(!(n>2e3&&Q.cors))return 2e3>=n&&!Q.cors?R(t,e,i,s):void b("a request to "+t+" was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html");o.open("POST",t),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(r)}return o}function R(t,e,i,s){var r="c"+H;e.callback="window._EsriLeafletCallbacks."+r;var o=L.DomUtil.create("script",null,document.body);return o.type="text/javascript",o.src=t+"?"+x(e),o.id=r,window._EsriLeafletCallbacks[r]=function(t){if(window._EsriLeafletCallbacks[r]!==!0){var e,o=Object.prototype.toString.call(t);"[object Object]"!==o&&"[object Array]"!==o&&(e={error:{code:500,message:"Expected array or object as JSONP response"}},t=null),!e&&t.error&&(e=t,t=null),i.call(s,e,t),window._EsriLeafletCallbacks[r]=!0}},H++,{id:r,url:o.src,abort:function(){window._EsriLeafletCallbacks._callback[r]({code:0,message:"Request aborted."})}}}function P(t){return new $(t)}function F(t){return new Y(t)}function C(t){return new et(t)}function O(t){return new it(t)}function k(t){return new st(t)}function M(t){return new rt(t)}function q(t){return new ot(t)}function G(t){return new nt(t)}function E(t){return new at(t)}function A(t){return new lt(t)}function D(t){return new ut(t)}function j(t,e){return new ct(t,e)}function B(t,e){return new pt(t,e)}function U(t,e){return new mt(t,e)}function z(t,e){return new ft(t,e)}function Z(t){this.values=t||[]}function N(t){return new _t(t)}var W=window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest,J=""===document.documentElement.style.pointerEvents,Q={cors:W,pointerEvents:J};t.Support=Q;var V={shallowClone:c,warn:b,cleanUrl:g,isArcgisOnline:_,geojsonTypeToArcGIS:v,responseToFeatureCollection:y,geojsonToArcGIS:f,arcgisToGeojson:m,boundsToExtent:d,extentToBounds:p};t.Util=V;var H=0;window._EsriLeafletCallbacks={};var K=Q.cors?I:R;K.CORS=I,K.JSONP=R;var X={request:w,get:K,post:T};t.get=K,t.post=T,t.request=w;var $=L.Class.extend({options:{proxy:!1,useCors:W},generateSetter:function(t,e){return L.Util.bind(function(e){return this.params[t]=e,this},e)},initialize:function(t){if(t.request&&t.options?(this._service=t,L.Util.setOptions(this,t.options)):(L.Util.setOptions(this,t),this.options.url=g(t.url)),this.params=L.Util.extend({},this.params||{}),this.setters)for(var e in this.setters){var i=this.setters[e];this[e]=this.generateSetter(i,this)}},token:function(t){return this._service?this._service.authenticate(t):this.params.token=t,this},request:function(t,e){return this._service?this._service.request(this.path,this.params,t,e):this._request("request",this.path,this.params,t,e)},_request:function(t,e,i,s,r){var o=this.options.proxy?this.options.proxy+"?"+this.options.url+e:this.options.url+e;return"get"!==t&&"request"!==t||this.options.useCors?X[t](o,i,s,r):X.get.JSONP(o,i,s,r)}}),Y=$.extend({setters:{offset:"offset",limit:"limit",fields:"outFields",precision:"geometryPrecision",featureIds:"objectIds",returnGeometry:"returnGeometry",token:"token"},path:"query",params:{returnGeometry:!0,where:"1=1",outSr:4326,outFields:"*"},within:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelContains",this},intersects:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelIntersects",this},contains:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelWithin",this},crosses:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelCrosses",this},touches:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelTouches",this},overlaps:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelOverlaps",this},nearby:function(t,e){return t=L.latLng(t),this.params.geometry=[t.lng,t.lat],this.params.geometryType="esriGeometryPoint",this.params.spatialRel="esriSpatialRelIntersects",this.params.units="esriSRUnit_Meter",this.params.distance=e,this.params.inSr=4326,this},where:function(t){return this.params.where=t,this},between:function(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},orderBy:function(t,e){return e=e||"ASC",this.params.orderByFields=this.params.orderByFields?this.params.orderByFields+",":"",this.params.orderByFields+=[t,e].join(" "),this},run:function(t,e){return this._cleanParams(),V.isArcgisOnline(this.options.url)?(this.params.f="geojson",this.request(function(i,s){this._trapSQLerrors(i),t.call(e,i,s,s)},this)):this.request(function(i,s){this._trapSQLerrors(i),t.call(e,i,s&&V.responseToFeatureCollection(s),s)},this)},count:function(t,e){return this._cleanParams(),this.params.returnCountOnly=!0,this.request(function(e,i){t.call(this,e,i&&i.count,i)},e)},ids:function(t,e){return this._cleanParams(),this.params.returnIdsOnly=!0,this.request(function(e,i){t.call(this,e,i&&i.objectIds,i)},e)},bounds:function(t,e){return this._cleanParams(),this.params.returnExtentOnly=!0,this.request(function(i,s){t.call(e,i,s&&s.extent&&V.extentToBounds(s.extent),s)},e)},pixelSize:function(t){return t=L.point(t),this.params.pixelSize=[t.x,t.y],this},layer:function(t){return this.path=t+"/query",this},_trapSQLerrors:function(t){t&&"400"===t.code&&V.warn("one common syntax error in query requests is encasing string values in double quotes instead of single quotes")},_cleanParams:function(){delete this.params.returnIdsOnly,delete this.params.returnExtentOnly,delete this.params.returnCountOnly},_setGeometry:function(t){return this.params.inSr=4326,t instanceof L.LatLngBounds?(this.params.geometry=V.boundsToExtent(t),void(this.params.geometryType="esriGeometryEnvelope")):(t.getLatLng&&(t=t.getLatLng()),t instanceof L.LatLng&&(t={type:"Point",coordinates:[t.lng,t.lat]}),t instanceof L.GeoJSON&&(t=t.getLayers()[0].feature.geometry,this.params.geometry=V.geojsonToArcGIS(t),this.params.geometryType=V.geojsonTypeToArcGIS(t.type)),t.toGeoJSON&&(t=t.toGeoJSON()),"Feature"===t.type&&(t=t.geometry),"Point"===t.type||"LineString"===t.type||"Polygon"===t.type?(this.params.geometry=V.geojsonToArcGIS(t),void(this.params.geometryType=V.geojsonTypeToArcGIS(t.type))):void V.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"))}}),tt=F,et=$.extend({setters:{contains:"contains",text:"searchText",fields:"searchFields",spatialReference:"sr",sr:"sr",layers:"layers",returnGeometry:"returnGeometry",maxAllowableOffset:"maxAllowableOffset",precision:"geometryPrecision",dynamicLayers:"dynamicLayers",returnZ:"returnZ",returnM:"returnM",gdbVersion:"gdbVersion",token:"token"},path:"find",params:{sr:4326,contains:!0,returnGeometry:!0,returnZ:!0,returnM:!1},layerDefs:function(t,e){return this.params.layerDefs=this.params.layerDefs?this.params.layerDefs+";":"",this.params.layerDefs+=[t,e].join(":"),this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},run:function(t,e){return this.request(function(i,s){t.call(e,i,s&&V.responseToFeatureCollection(s),s)},e)}}),it=$.extend({path:"identify",between:function(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this}}),st=it.extend({setters:{layers:"layers",precision:"geometryPrecision",tolerance:"tolerance",returnGeometry:"returnGeometry"},params:{sr:4326,layers:"all",tolerance:3,returnGeometry:!0},on:function(t){var e=V.boundsToExtent(t.getBounds()),i=t.getSize();return this.params.imageDisplay=[i.x,i.y,96],this.params.mapExtent=[e.xmin,e.ymin,e.xmax,e.ymax],this},at:function(t){return t=L.latLng(t),this.params.geometry=[t.lng,t.lat],this.params.geometryType="esriGeometryPoint",this},layerDef:function(t,e){return this.params.layerDefs=this.params.layerDefs?this.params.layerDefs+";":"",this.params.layerDefs+=[t,e].join(":"),this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*(1-e),this},run:function(t,e){return this.request(function(i,s){if(i)return void t.call(e,i,void 0,s);var r=V.responseToFeatureCollection(s);s.results=s.results.reverse();for(var o=0;o<r.features.length;o++){var n=r.features[o];n.layerId=s.results[o].layerId}t.call(e,void 0,r,s)})}}),rt=it.extend({setters:{setMosaicRule:"mosaicRule",setRenderingRule:"renderingRule",setPixelSize:"pixelSize",returnCatalogItems:"returnCatalogItems",returnGeometry:"returnGeometry"},params:{returnGeometry:!1},at:function(t){return t=L.latLng(t),this.params.geometry=JSON.stringify({x:t.lng,y:t.lat,spatialReference:{wkid:4326}}),this.params.geometryType="esriGeometryPoint",this},getMosaicRule:function(){return this.params.mosaicRule},getRenderingRule:function(){return this.params.renderingRule},getPixelSize:function(){return this.params.pixelSize},run:function(t,e){return this.request(function(i,s){t.call(e,i,s&&this._responseToGeoJSON(s),s)},this)},_responseToGeoJSON:function(t){var e=t.location,i=t.catalogItems,s=t.catalogItemVisibilities,r={pixel:{type:"Feature",geometry:{type:"Point",coordinates:[e.x,e.y]},crs:{type:"EPSG",properties:{code:e.spatialReference.wkid}},properties:{OBJECTID:t.objectId,name:t.name,value:t.value},id:t.objectId}};if(t.properties&&t.properties.Values&&(r.pixel.properties.values=t.properties.Values),i&&i.features&&(r.catalogItems=V.responseToFeatureCollection(i),s&&s.length===r.catalogItems.features.length))for(var o=s.length-1;o>=0;o--)r.catalogItems.features[o].properties.catalogItemVisibility=s[o];return r}}),ot=L.Evented.extend({options:{proxy:!1,useCors:W},initialize:function(t){t=t||{},this._requestQueue=[],this._authenticating=!1,L.Util.setOptions(this,t),this.options.url=g(this.options.url)},get:function(t,e,i,s){return this._request("get",t,e,i,s)},post:function(t,e,i,s){return this._request("post",t,e,i,s)},request:function(t,e,i,s){return this._request("request",t,e,i,s)},metadata:function(t,e){return this._request("get","",{},t,e)},authenticate:function(t){return this._authenticating=!1,this.options.token=t,this._runQueue(),this},_request:function(t,e,i,s,r){this.fire("requeststart",{url:this.options.url+e,params:i,method:t},!0);var o=this._createServiceCallback(t,e,i,s,r);if(this.options.token&&(i.token=this.options.token),this._authenticating)return void this._requestQueue.push([t,e,i,s,r]);var n=this.options.proxy?this.options.proxy+"?"+this.options.url+e:this.options.url+e;return"get"!==t&&"request"!==t||this.options.useCors?X[t](n,i,o):X.get.JSONP(n,i,o)},_createServiceCallback:function(t,e,i,s,r){return L.Util.bind(function(o,n){!o||499!==o.code&&498!==o.code||(this._authenticating=!0,this._requestQueue.push([t,e,i,s,r]),this.fire("authenticationrequired",{authenticate:L.Util.bind(this.authenticate,this)},!0),o.authenticate=L.Util.bind(this.authenticate,this)),s.call(r,o,n),o?this.fire("requesterror",{url:this.options.url+e,params:i,message:o.message,code:o.code,method:t},!0):this.fire("requestsuccess",{url:this.options.url+e,params:i,response:n,method:t},!0),this.fire("requestend",{url:this.options.url+e,params:i,method:t},!0)},this)},_runQueue:function(){for(var t=this._requestQueue.length-1;t>=0;t--){var e=this._requestQueue[t],i=e.shift();this[i].apply(this,e)}this._requestQueue=[]}}),nt=ot.extend({identify:function(){return k(this)},find:function(){return C(this)},query:function(){return tt(this)}}),at=ot.extend({query:function(){return tt(this)},identify:function(){return M(this)}}),lt=ot.extend({options:{idAttribute:"OBJECTID"},query:function(){return tt(this)},addFeature:function(t,e,i){return delete t.id,t=f(t),this.post("addFeatures",{features:[t]},function(t,s){var r=s&&s.addResults?s.addResults[0]:void 0;e&&e.call(i,t||s.addResults[0].error,r)},i)},updateFeature:function(t,e,i){return t=f(t,this.options.idAttribute),this.post("updateFeatures",{features:[t]},function(t,s){var r=s&&s.updateResults?s.updateResults[0]:void 0;e&&e.call(i,t||s.updateResults[0].error,r)},i)},deleteFeature:function(t,e,i){return this.post("deleteFeatures",{objectIds:t},function(t,s){var r=s&&s.deleteResults?s.deleteResults[0]:void 0;e&&e.call(i,t||s.deleteResults[0].error,r)},i)},deleteFeatures:function(t,e,i){return this.post("deleteFeatures",{objectIds:t},function(t,s){var r=s&&s.deleteResults?s.deleteResults:void 0;e&&e.call(i,t||s.deleteResults[0].error,r)},i)}}),ut=L.Control.extend({options:{position:"bottomright",marginTop:0,marginLeft:0,marginBottom:0,marginRight:0},onAdd:function(){var t=L.DomUtil.create("div","esri-leaflet-logo");return t.style.marginTop=this.options.marginTop,t.style.marginLeft=this.options.marginLeft,t.style.marginBottom=this.options.marginBottom,t.style.marginRight=this.options.marginRight,t.innerHTML=this._adjustLogo(this._map._size),this._map.on("resize",function(e){t.innerHTML=this._adjustLogo(e.newSize)},this),t},_adjustLogo:function(t){return t.x<=600||t.y<=600?'<a href="https://developers.arcgis.com" style="border: none;"><img src="https://js.arcgis.com/3.13/esri/images/map/logo-sm.png" alt="Powered by Esri" style="border: none;"></a>':'<a href="https://developers.arcgis.com" style="border: none;"><img src="https://js.arcgis.com/3.13/esri/images/map/logo-med.png" alt="Powered by Esri" style="border: none;"></a>'}}),ht="https:"!==window.location.protocol?"http:":"https:",ct=L.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"https://static.arcgis.com/attribution/World_Street_Map",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"Esri"}},Topographic:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"https://static.arcgis.com/attribution/World_Topo_Map",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"Esri"}},Oceans:{urlTemplate:ht+"//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}",attributionUrl:"https://static.arcgis.com/attribution/Ocean_Basemap",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"Esri"}},OceansLabels:{urlTemplate:ht+"//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!0,logoPosition:"bottomright",minZoom:1,maxZoom:16,subdomains:["server","services"],pane:J?"esri-labels":"tilePane"}},NationalGeographic:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"Esri"}},DarkGray:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"Esri, DeLorme, HERE"}},DarkGrayLabels:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!0,logoPosition:"bottomright",minZoom:1,maxZoom:16,subdomains:["server","services"],pane:J?"esri-labels":"tilePane"}},Gray:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"Esri, NAVTEQ, DeLorme"}},GrayLabels:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!0,logoPosition:"bottomright",minZoom:1,maxZoom:16,subdomains:["server","services"],pane:J?"esri-labels":"tilePane"}},Imagery:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community"}},ImageryLabels:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!0,logoPosition:"bottomright",minZoom:1,maxZoom:19,subdomains:["server","services"],pane:J?"esri-labels":"tilePane"}},ImageryTransportation:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!0,logoPosition:"bottomright",minZoom:1,maxZoom:19,subdomains:["server","services"],pane:J?"esri-labels":"tilePane"}},ShadedRelief:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:13,subdomains:["server","services"],attribution:"Esri, NAVTEQ, DeLorme"}},ShadedReliefLabels:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!0,logoPosition:"bottomright",minZoom:1,maxZoom:12,subdomains:["server","services"],pane:J?"esri-labels":"tilePane"}},Terrain:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!1,logoPosition:"bottomright",minZoom:1,maxZoom:13,subdomains:["server","services"],attribution:"Esri, USGS, NOAA"}},TerrainLabels:{urlTemplate:ht+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",options:{hideLogo:!0,logoPosition:"bottomright",minZoom:1,maxZoom:13,subdomains:["server","services"],pane:J?"esri-labels":"tilePane"}}}},initialize:function(t,e){var i;if("object"==typeof t&&t.urlTemplate&&t.options)i=t;else{if("string"!=typeof t||!ct.TILES[t])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"');i=ct.TILES[t]}var s=L.Util.extend(i.options,e);L.TileLayer.prototype.initialize.call(this,i.urlTemplate,L.Util.setOptions(this,s)),i.attributionUrl&&this._getAttributionData(i.attributionUrl),this._logo=D({position:this.options.logoPosition})},onAdd:function(t){this.options.hideLogo||t._hasEsriLogo||(this._logo.addTo(t),t._hasEsriLogo=!0),"esri-labels"===this.options.pane&&this._initPane(),L.TileLayer.prototype.onAdd.call(this,t),t.on("moveend",this._updateMapAttribution,this)},onRemove:function(t){this._logo&&this._logo._container&&(t.removeControl(this._logo),t._hasEsriLogo=!1),L.TileLayer.prototype.onRemove.call(this,t),t.off("moveend",this._updateMapAttribution,this)},getAttribution:function(){var t='<span class="esri-attributions" style="line-height:14px; vertical-align: -3px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; display:inline-block;">'+this.options.attribution+"</span>";return t},_initPane:function(){if(!this._map.getPane(this.options.pane)){var t=this._map.createPane(this.options.pane);t.style.pointerEvents="none",t.style.zIndex=500}},_getAttributionData:function(t){R(t,{},L.Util.bind(function(t,e){if(!t){this._attributions=[];for(var i=0;i<e.contributors.length;i++)for(var s=e.contributors[i],r=0;r<s.coverageAreas.length;r++){var o=s.coverageAreas[r],n=new L.LatLng(o.bbox[0],o.bbox[1]),a=new L.LatLng(o.bbox[2],o.bbox[3]);this._attributions.push({attribution:s.attribution,score:o.score,bounds:new L.LatLngBounds(n,a),minZoom:o.zoomMin,maxZoom:o.zoomMax})}this._attributions.sort(function(t,e){return e.score-t.score}),this._updateMapAttribution()}},this))},_updateMapAttribution:function(){if(this._map&&this._map.attributionControl&&this._attributions){for(var t="",e=this._map.getBounds(),i=this._map.getZoom(),s=0;s<this._attributions.length;s++){var r=this._attributions[s],o=r.attribution;!t.match(o)&&e.intersects(r.bounds)&&i>=r.minZoom&&i<=r.maxZoom&&(t+=", "+o)}t=t.substr(2);var n=this._map.attributionControl._container.querySelector(".esri-attributions");n.innerHTML=t,n.style.maxWidth=.65*this._map.getSize().x+"px",this.fire("attributionupdated",{attribution:t})}}});t.BasemapLayer=ct,t.basemapLayer=j;var pt=L.TileLayer.extend({options:{zoomOffsetAllowance:.1,correctZoomLevels:!0},statics:{MercatorZoomLevels:{0:156543.033928,1:78271.5169639999,2:39135.7584820001,3:19567.8792409999,4:9783.93962049996,5:4891.96981024998,6:2445.98490512499,7:1222.99245256249,8:611.49622628138,9:305.748113140558,10:152.874056570411,11:76.4370282850732,12:38.2185141425366,13:19.1092570712683,14:9.55462853563415,15:4.77731426794937,16:2.38865713397468,17:1.19432856685505,18:.597164283559817,19:.298582141647617,20:.14929107082381,21:.07464553541191,22:.0373227677059525,23:.0186613838529763}},initialize:function(t){t.url=g(t.url),t=L.Util.setOptions(this,t),this.tileUrl=t.url+"tile/{z}/{y}/{x}",this.service=G(t),this.service.addEventParent(this),this.tileUrl.match("://tiles.arcgisonline.com")&&(this.tileUrl=this.tileUrl.replace("://tiles.arcgisonline.com","://tiles{s}.arcgisonline.com"),t.subdomains=["1","2","3","4"]),this.options.token&&(this.tileUrl+="?token="+this.options.token),L.TileLayer.prototype.initialize.call(this,this.tileUrl,t)},getTileUrl:function(t){return L.Util.template(this.tileUrl,L.extend({s:this._getSubdomain(t),z:this._lodMap[t.z]||t.z,x:t.x,y:t.y},this.options))},onAdd:function(t){!this._lodMap&&this.options.correctZoomLevels?(this._lodMap={},this.metadata(function(e,i){if(!e){var s=i.spatialReference.latestWkid||i.spatialReference.wkid;if(102100===s||3857===s)for(var r=i.tileInfo.lods,o=pt.MercatorZoomLevels,n=0;n<r.length;n++){var a=r[n];for(var l in o){var u=o[l];if(this._withinPercentage(a.resolution,u,this.options.zoomOffsetAllowance)){this._lodMap[l]=a.level;break}}}else b("L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html")}L.TileLayer.prototype.onAdd.call(this,t)},this)):L.TileLayer.prototype.onAdd.call(this,t)},metadata:function(t,e){return this.service.metadata(t,e),this},identify:function(){return this.service.identify()},find:function(){return this.service.find()},query:function(){return this.service.query()},authenticate:function(t){var e="?token="+t;return this.tileUrl=this.options.token?this.tileUrl.replace(/\?token=(.+)/g,e):this.tileUrl+e,this.options.token=t,this.service.authenticate(t),this},_withinPercentage:function(t,e,i){var s=Math.abs(t/e-1);return i>s}});t.TiledMapLayer=pt,t.tiledMapLayer=B;var dt=L.Layer.extend({options:{opacity:1,position:"front",f:"image",useCors:W,attribution:null,interactive:!1,alt:""},onAdd:function(t){if(this._update=L.Util.throttle(this._update,this.options.updateInterval,this),t.options.crs&&t.options.crs.code){var e=t.options.crs.code.split(":")[1];this.options.bboxSR=e,this.options.imageSR=e}t.on("moveend",this._update,this),this._currentImage&&this._currentImage._bounds.equals(this._map.getBounds())?t.addLayer(this._currentImage):this._currentImage&&(this._map.removeLayer(this._currentImage),this._currentImage=null),this._update(),this._popup&&(this._map.on("click",this._getPopupData,this),this._map.on("dblclick",this._resetPopupState,this))},onRemove:function(t){this._currentImage&&this._map.removeLayer(this._currentImage),this._popup&&(this._map.off("click",this._getPopupData,this),this._map.off("dblclick",this._resetPopupState,this)),this._map.off("moveend",this._update,this)},getEvents:function(){return{moveend:this._update}},bindPopup:function(t,e){return this._shouldRenderPopup=!1,this._lastClick=!1,this._popup=L.popup(e),this._popupFunction=t,this._map&&(this._map.on("click",this._getPopupData,this),this._map.on("dblclick",this._resetPopupState,this)),this},unbindPopup:function(){return this._map&&(this._map.closePopup(this._popup),this._map.off("click",this._getPopupData,this),this._map.off("dblclick",this._resetPopupState,this)),this._popup=!1,this},bringToFront:function(){return this.options.position="front",this._currentImage&&this._currentImage.bringToFront(),this},bringToBack:function(){return this.options.position="back",this._currentImage&&this._currentImage.bringToBack(),this},getAttribution:function(){return this.options.attribution},getOpacity:function(){return this.options.opacity},setOpacity:function(t){return this.options.opacity=t,this._currentImage.setOpacity(t),this},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(t,e){return this.options.from=t,this.options.to=e,this._update(),this},metadata:function(t,e){return this.service.metadata(t,e),this},authenticate:function(t){return this.service.authenticate(t),this},_renderImage:function(t,e){if(this._map){var i=new L.ImageOverlay(t,e,{opacity:0,crossOrigin:this.options.useCors,alt:this.options.alt,pane:this.options.pane||this.getPane(),interactive:this.options.interactive}).addTo(this._map);i.once("load",function(t){if(this._map){var i=t.target,s=this._currentImage;i._bounds.equals(e)&&i._bounds.equals(this._map.getBounds())?(this._currentImage=i,"front"===this.options.position?this.bringToFront():this.bringToBack(),this._map&&this._currentImage._map?this._currentImage.setOpacity(this.options.opacity):this._currentImage._map.removeLayer(this._currentImage),s&&this._map&&this._map.removeLayer(s),s&&s._map&&s._map.removeLayer(s)):this._map.removeLayer(i)}this.fire("load",{bounds:e})},this),this.fire("loading",{bounds:e})}},_update:function(){if(this._map){var t=this._map.getZoom(),e=this._map.getBounds();if(!this._animatingZoom&&!(this._map._panTransition&&this._map._panTransition._inProgress||t>this.options.maxZoom||t<this.options.minZoom)){var i=this._buildExportParams();this._requestExport(i,e); | ||
}}},_renderPopup:function(t,e,i,s){if(t=L.latLng(t),this._shouldRenderPopup&&this._lastClick.equals(t)){var r=this._popupFunction(e,i,s);r&&this._popup.setLatLng(t).setContent(r).openOn(this._map)}},_resetPopupState:function(t){this._shouldRenderPopup=!1,this._lastClick=t.latlng}});t.RasterLayer=dt;var mt=dt.extend({options:{updateInterval:150,format:"jpgpng",transparent:!0,f:"json"},query:function(){return this.service.query()},identify:function(){return this.service.identify()},initialize:function(t){t.url=g(t.url),this.service=E(t),this.service.addEventParent(this),L.Util.setOptions(this,t)},setPixelType:function(t){return this.options.pixelType=t,this._update(),this},getPixelType:function(){return this.options.pixelType},setBandIds:function(t){return L.Util.isArray(t)?this.options.bandIds=t.join(","):this.options.bandIds=t.toString(),this._update(),this},getBandIds:function(){return this.options.bandIds},setNoData:function(t,e){return L.Util.isArray(t)?this.options.noData=t.join(","):this.options.noData=t.toString(),e&&(this.options.noDataInterpretation=e),this._update(),this},getNoData:function(){return this.options.noData},getNoDataInterpretation:function(){return this.options.noDataInterpretation},setRenderingRule:function(t){this.options.renderingRule=t,this._update()},getRenderingRule:function(){return this.options.renderingRule},setMosaicRule:function(t){this.options.mosaicRule=t,this._update()},getMosaicRule:function(){return this.options.mosaicRule},_getPopupData:function(t){var e=L.Util.bind(function(e,i,s){e||setTimeout(L.Util.bind(function(){this._renderPopup(t.latlng,e,i,s)},this),300)},this),i=this.identify().at(t.latlng);this.options.mosaicRule&&i.setMosaicRule(this.options.mosaicRule),i.run(e),this._shouldRenderPopup=!0,this._lastClick=t.latlng},_buildExportParams:function(){var t=this._map.getBounds(),e=this._map.getSize(),i=this._map.options.crs.project(t._northEast),s=this._map.options.crs.project(t._southWest),r={bbox:[s.x,s.y,i.x,i.y].join(","),size:e.x+","+e.y,format:this.options.format,transparent:this.options.transparent,bboxSR:this.options.bboxSR,imageSR:this.options.imageSR};return this.options.from&&this.options.to&&(r.time=this.options.from.valueOf()+","+this.options.to.valueOf()),this.options.pixelType&&(r.pixelType=this.options.pixelType),this.options.interpolation&&(r.interpolation=this.options.interpolation),this.options.compressionQuality&&(r.compressionQuality=this.options.compressionQuality),this.options.bandIds&&(r.bandIds=this.options.bandIds),this.options.noData&&(r.noData=this.options.noData),this.options.noDataInterpretation&&(r.noDataInterpretation=this.options.noDataInterpretation),this.service.options.token&&(r.token=this.service.options.token),this.options.renderingRule&&(r.renderingRule=JSON.stringify(this.options.renderingRule)),this.options.mosaicRule&&(r.mosaicRule=JSON.stringify(this.options.mosaicRule)),r},_requestExport:function(t,e){"json"===this.options.f?this.service.get("exportImage",t,function(t,i){t||this._renderImage(i.href,e)},this):(t.f="image",this._renderImage(this.options.url+"exportImage"+L.Util.getParamString(t),e))}});t.ImageMapLayer=mt,t.imageMapLayer=U;var ft=dt.extend({options:{updateInterval:150,layers:!1,layerDefs:!1,timeOptions:!1,format:"png24",transparent:!0,f:"json"},initialize:function(t){t.url=g(t.url),this.service=G(t),this.service.addEventParent(this),(t.proxy||t.token)&&"json"!==t.f&&(t.f="json"),L.Util.setOptions(this,t)},getDynamicLayers:function(){return this.options.dynamicLayers},setDynamicLayers:function(t){return this.options.dynamicLayers=t,this._update(),this},getLayers:function(){return this.options.layers},setLayers:function(t){return this.options.layers=t,this._update(),this},getLayerDefs:function(){return this.options.layerDefs},setLayerDefs:function(t){return this.options.layerDefs=t,this._update(),this},getTimeOptions:function(){return this.options.timeOptions},setTimeOptions:function(t){return this.options.timeOptions=t,this._update(),this},query:function(){return this.service.query()},identify:function(){return this.service.identify()},find:function(){return this.service.find()},_getPopupData:function(t){var e=L.Util.bind(function(e,i,s){e||setTimeout(L.Util.bind(function(){this._renderPopup(t.latlng,e,i,s)},this),300)},this),i=this.identify().on(this._map).at(t.latlng);this.options.layers?i.layers("visible:"+this.options.layers.join(",")):i.layers("visible"),i.run(e),this._shouldRenderPopup=!0,this._lastClick=t.latlng},_buildExportParams:function(){var t=this._map.getBounds(),e=this._map.getSize(),i=this._map.options.crs.project(t._northEast),s=this._map.options.crs.project(t._southWest),r=this._map.latLngToLayerPoint(t._northEast),o=this._map.latLngToLayerPoint(t._southWest);(r.y>0||o.y<e.y)&&(e.y=o.y-r.y);var n={bbox:[s.x,s.y,i.x,i.y].join(","),size:e.x+","+e.y,dpi:96,format:this.options.format,transparent:this.options.transparent,bboxSR:this.options.bboxSR,imageSR:this.options.imageSR};return this.options.dynamicLayers&&(n.dynamicLayers=this.options.dynamicLayers),this.options.layers&&(n.layers="show:"+this.options.layers.join(",")),this.options.layerDefs&&(n.layerDefs=JSON.stringify(this.options.layerDefs)),this.options.timeOptions&&(n.timeOptions=JSON.stringify(this.options.timeOptions)),this.options.from&&this.options.to&&(n.time=this.options.from.valueOf()+","+this.options.to.valueOf()),this.service.options.token&&(n.token=this.service.options.token),n},_requestExport:function(t,e){"json"===this.options.f?this.service.get("export",t,function(t,i){t||this._renderImage(i.href,e)},this):(t.f="image",this._renderImage(this.options.url+"export"+L.Util.getParamString(t),e))}});t.DynamicMapLayer=ft,t.dynamicMapLayer=z;var yt=L.Layer.extend({options:{cellSize:512,updateInterval:150},initialize:function(t){t=L.setOptions(this,t)},onAdd:function(t){this._map=t,this._update=L.Util.throttle(this._update,this.options.updateInterval,this),this._reset(),this._update()},onRemove:function(){this._map.removeEventListener(this.getEvents(),this),this._removeCells()},getEvents:function(){var t={moveend:this._update,zoomend:this._reset};return t},addTo:function(t){return t.addLayer(this),this},removeFrom:function(t){return t.removeLayer(this),this},_reset:function(){this._removeCells(),this._cells={},this._activeCells={},this._cellsToLoad=0,this._cellsTotal=0,this._cellNumBounds=this._getCellNumBounds(),this._resetWrap()},_resetWrap:function(){var t=this._map,e=t.options.crs;if(!e.infinite){var i=this._getCellSize();e.wrapLng&&(this._wrapLng=[Math.floor(t.project([0,e.wrapLng[0]]).x/i),Math.ceil(t.project([0,e.wrapLng[1]]).x/i)]),e.wrapLat&&(this._wrapLat=[Math.floor(t.project([e.wrapLat[0],0]).y/i),Math.ceil(t.project([e.wrapLat[1],0]).y/i)])}},_getCellSize:function(){return this.options.cellSize},_update:function(){if(this._map){var t=this._map.getPixelBounds(),e=this._map.getZoom(),i=this._getCellSize();if(!(e>this.options.maxZoom||e<this.options.minZoom)){var s=L.bounds(t.min.divideBy(i).floor(),t.max.divideBy(i).floor());this._removeOtherCells(s),this._addCells(s)}}},_addCells:function(t){var e,i,s,r=[],o=t.getCenter(),n=this._map.getZoom();for(e=t.min.y;e<=t.max.y;e++)for(i=t.min.x;i<=t.max.x;i++)s=new L.Point(i,e),s.z=n,this._isValidCell(s)&&r.push(s);var a=r.length;if(0!==a)for(this._cellsToLoad+=a,this._cellsTotal+=a,r.sort(function(t,e){return t.distanceTo(o)-e.distanceTo(o)}),i=0;a>i;i++)this._addCell(r[i])},_isValidCell:function(t){var e=this._map.options.crs;if(!e.infinite){var i=this._cellNumBounds;if(!e.wrapLng&&(t.x<i.min.x||t.x>i.max.x)||!e.wrapLat&&(t.y<i.min.y||t.y>i.max.y))return!1}if(!this.options.bounds)return!0;var s=this._cellCoordsToBounds(t);return L.latLngBounds(this.options.bounds).intersects(s)},_cellCoordsToBounds:function(t){var e=this._map,i=this.options.cellSize,s=t.multiplyBy(i),r=s.add([i,i]),o=e.wrapLatLng(e.unproject(s,t.z)),n=e.wrapLatLng(e.unproject(r,t.z));return new L.LatLngBounds(o,n)},_cellCoordsToKey:function(t){return t.x+":"+t.y},_keyToCellCoords:function(t){var e=t.split(":"),i=parseInt(e[0],10),s=parseInt(e[1],10);return new L.Point(i,s)},_removeOtherCells:function(t){for(var e in this._cells)t.contains(this._keyToCellCoords(e))||this._removeCell(e)},_removeCell:function(t){var e=this._activeCells[t];e&&(delete this._activeCells[t],this.cellLeave&&this.cellLeave(e.bounds,e.coords),this.fire("cellleave",{bounds:e.bounds,coords:e.coords}))},_removeCells:function(){for(var t in this._cells){var e=this._cells[t].bounds,i=this._cells[t].coords;this.cellLeave&&this.cellLeave(e,i),this.fire("cellleave",{bounds:e,coords:i})}},_addCell:function(t){this._wrapCoords(t);var e=this._cellCoordsToKey(t),i=this._cells[e];i&&!this._activeCells[e]&&(this.cellEnter&&this.cellEnter(i.bounds,t),this.fire("cellenter",{bounds:i.bounds,coords:t}),this._activeCells[e]=i),i||(i={coords:t,bounds:this._cellCoordsToBounds(t)},this._cells[e]=i,this._activeCells[e]=i,this.createCell&&this.createCell(i.bounds,t),this.fire("cellcreate",{bounds:i.bounds,coords:t}))},_wrapCoords:function(t){t.x=this._wrapLng?L.Util.wrapNum(t.x,this._wrapLng):t.x,t.y=this._wrapLat?L.Util.wrapNum(t.y,this._wrapLat):t.y},_getCellNumBounds:function(){var t=this._map.getPixelWorldBounds(),e=this._getCellSize();return t?L.bounds(t.min.divideBy(e).floor(),t.max.divideBy(e).ceil().subtract([1,1])):null}});t.FeatureGrid=yt;var gt=yt.extend({options:{attribution:null,where:"1=1",fields:["*"],from:!1,to:!1,timeField:!1,timeFilterMode:"server",simplifyFactor:0,precision:6},initialize:function(t){if(yt.prototype.initialize.call(this,t),t.url=g(t.url),t=L.setOptions(this,t),this.service=A(t),this.service.addEventParent(this),"*"!==this.options.fields[0]){for(var e=!1,i=0;i<this.options.fields.length;i++)this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i)&&(e=!0);e===!1&&b("no known esriFieldTypeOID field detected in fields Array. Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.")}this.options.timeField.start&&this.options.timeField.end?(this._startTimeIndex=new Z,this._endTimeIndex=new Z):this.options.timeField&&(this._timeIndex=new Z),this._cache={},this._currentSnapshot=[],this._activeRequests=0},onAdd:function(t){return yt.prototype.onAdd.call(this,t)},onRemove:function(t){return yt.prototype.onRemove.call(this,t)},getAttribution:function(){return this.options.attribution},createCell:function(t,e){this._requestFeatures(t,e)},_requestFeatures:function(t,e,i){return this._activeRequests++,1===this._activeRequests&&this.fire("loading",{bounds:t},!0),this._buildQuery(t).run(function(s,r,o){o&&o.exceededTransferLimit&&this.fire("drawlimitexceeded"),!s&&r&&r.features.length&&L.Util.requestAnimFrame(L.Util.bind(function(){this._addFeatures(r.features,e),this._postProcessFeatures(t)},this)),s||!r||r.features.length||this._postProcessFeatures(t),i&&i.call(this,s,r)},this)},_postProcessFeatures:function(t){this._activeRequests--,this._activeRequests<=0&&this.fire("load",{bounds:t})},_cacheKey:function(t){return t.z+":"+t.x+":"+t.y},_addFeatures:function(t,e){var i=this._cacheKey(e);this._cache[i]=this._cache[i]||[];for(var s=t.length-1;s>=0;s--){var r=t[s].id;this._currentSnapshot.push(r),this._cache[i].push(r)}this.options.timeField&&this._buildTimeIndexes(t);var o=this._map.getZoom();o>this.options.maxZoom||o<this.options.minZoom||this.createLayers(t)},_buildQuery:function(t){var e=this.service.query().intersects(t).where(this.options.where).fields(this.options.fields).precision(this.options.precision);return this.options.simplifyFactor&&e.simplify(this._map,this.options.simplifyFactor),"server"===this.options.timeFilterMode&&this.options.from&&this.options.to&&e.between(this.options.from,this.options.to),e},setWhere:function(t,e,i){this.options.where=t&&t.length?t:"1=1";for(var s=[],r=[],o=0,n=null,a=L.Util.bind(function(t,a){if(t&&(n=t),a)for(var l=a.features.length-1;l>=0;l--)r.push(a.features[l].id);o--,0>=o&&(this._currentSnapshot=r,L.Util.requestAnimFrame(L.Util.bind(function(){this.removeLayers(s),this.addLayers(r),e&&e.call(i,n)},this)))},this),l=this._currentSnapshot.length-1;l>=0;l--)s.push(this._currentSnapshot[l]);for(var u in this._activeCells){o++;var h=this._keyToCellCoords(u),c=this._cellCoordsToBounds(h);this._requestFeatures(c,u,a)}return this},getWhere:function(){return this.options.where},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(t,e,i,s){var r=this.options.from,o=this.options.to,n=0,a=null,l=L.Util.bind(function(l){l&&(a=l),this._filterExistingFeatures(r,o,t,e),n--,i&&0>=n&&i.call(s,a)},this);if(this.options.from=t,this.options.to=e,this._filterExistingFeatures(r,o,t,e),"server"===this.options.timeFilterMode)for(var u in this._activeCells){n++;var h=this._keyToCellCoords(u),c=this._cellCoordsToBounds(h);this._requestFeatures(c,u,l)}return this},refresh:function(){for(var t in this._activeCells){var e=this._keyToCellCoords(t),i=this._cellCoordsToBounds(e);this._requestFeatures(i,t)}this.redraw&&this.once("load",function(){this.eachFeature(function(t){this._redraw(t.feature.id)},this)},this)},_filterExistingFeatures:function(t,e,i,s){var r=t&&e?this._getFeaturesInTimeRange(t,e):this._currentSnapshot,o=this._getFeaturesInTimeRange(i,s);if(o.indexOf)for(var n=0;n<o.length;n++){var a=r.indexOf(o[n]);a>=0&&r.splice(a,1)}L.Util.requestAnimFrame(L.Util.bind(function(){this.removeLayers(r),this.addLayers(o)},this))},_getFeaturesInTimeRange:function(t,e){var i,s=[];if(this.options.timeField.start&&this.options.timeField.end){var r=this._startTimeIndex.between(t,e),o=this._endTimeIndex.between(t,e);i=r.concat(o)}else i=this._timeIndex.between(t,e);for(var n=i.length-1;n>=0;n--)s.push(i[n].id);return s},_buildTimeIndexes:function(t){var e,i;if(this.options.timeField.start&&this.options.timeField.end){var s=[],r=[];for(e=t.length-1;e>=0;e--)i=t[e],s.push({id:i.id,value:new Date(i.properties[this.options.timeField.start])}),r.push({id:i.id,value:new Date(i.properties[this.options.timeField.end])});this._startTimeIndex.bulkAdd(s),this._endTimeIndex.bulkAdd(r)}else{var o=[];for(e=t.length-1;e>=0;e--)i=t[e],o.push({id:i.id,value:new Date(i.properties[this.options.timeField])});this._timeIndex.bulkAdd(o)}},_featureWithinTimeRange:function(t){if(!this.options.from||!this.options.to)return!0;var e=+this.options.from.valueOf(),i=+this.options.to.valueOf();if("string"==typeof this.options.timeField){var s=+t.properties[this.options.timeField];return s>=e&&i>=s}if(this.options.timeField.start&&this.options.timeField.end){var r=+t.properties[this.options.timeField.start],o=+t.properties[this.options.timeField.end];return r>=e&&i>=r||o>=e&&i>=o}},authenticate:function(t){return this.service.authenticate(t),this},metadata:function(t,e){return this.service.metadata(t,e),this},query:function(){return this.service.query()},_getMetadata:function(t){if(this._metadata){var e;t(e,this._metadata)}else this.metadata(L.Util.bind(function(e,i){this._metadata=i,t(e,this._metadata)},this))},addFeature:function(t,e,i){this._getMetadata(L.Util.bind(function(s,r){return s?void(e&&e.call(this,s,null)):void this.service.addFeature(t,L.Util.bind(function(s,o){s||(t.properties[r.objectIdField]=o.objectId,t.id=o.objectId,this.createLayers([t])),e&&e.call(i,s,o)},this))},this))},updateFeature:function(t,e,i){this.service.updateFeature(t,function(s,r){s||(this.removeLayers([t.id],!0),this.createLayers([t])),e&&e.call(i,s,r)},this)},deleteFeature:function(t,e,i){this.service.deleteFeature(t,function(t,s){!t&&s.objectId&&this.removeLayers([s.objectId],!0),e&&e.call(i,t,s)},this)},deleteFeatures:function(t,e,i){return this.service.deleteFeatures(t,function(t,s){if(!t&&s.length>0)for(var r=0;r<s.length;r++)this.removeLayers([s[r].objectId],!0);e&&e.call(i,t,s)},this)}});Z.prototype._query=function(t){for(var e,i,s=0,r=this.values.length-1;r>=s;)if(e=(s+r)/2|0,i=this.values[Math.round(e)],+i.value<+t)s=e+1;else{if(!(+i.value>+t))return e;r=e-1}return~r},Z.prototype.sort=function(){this.values.sort(function(t,e){return+e.value-+t.value}).reverse(),this.dirty=!1},Z.prototype.between=function(t,e){this.dirty&&this.sort();var i=this._query(t),s=this._query(e);return 0===i&&0===s?[]:(i=Math.abs(i),s=0>s?Math.abs(s):s+1,this.values.slice(i,s))},Z.prototype.bulkAdd=function(t){this.dirty=!0,this.values=this.values.concat(t)},t.FeatureManager=gt;var _t=gt.extend({options:{cacheLayers:!0},initialize:function(t){gt.prototype.initialize.call(this,t),this._originalStyle=this.options.style,this._layers={}},onAdd:function(t){return t.on("zoomstart zoomend",function(t){this._zooming="zoomstart"===t.type},this),gt.prototype.onAdd.call(this,t)},onRemove:function(t){for(var e in this._layers)t.removeLayer(this._layers[e]);return gt.prototype.onRemove.call(this,t)},createNewLayer:function(t){var e=L.GeoJSON.geometryToLayer(t,this.options);return e.defaultOptions=e.options,e},_updateLayer:function(t,e){var i=[],s=this.options.coordsToLatLng||L.GeoJSON.coordsToLatLng;switch(e.properties&&(t.feature.properties=e.properties),e.geometry.type){case"Point":i=L.GeoJSON.coordsToLatLng(e.geometry.coordinates),t.setLatLng(i);break;case"LineString":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,0,s),t.setLatLngs(i);break;case"MultiLineString":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,1,s),t.setLatLngs(i);break;case"Polygon":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,1,s),t.setLatLngs(i);break;case"MultiPolygon":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,2,s),t.setLatLngs(i)}},createLayers:function(t){for(var e=t.length-1;e>=0;e--){var i,s=t[e],r=this._layers[s.id];r&&!this._map.hasLayer(r)&&this._map.addLayer(r),r&&(r.setLatLngs||r.setLatLng)&&this._updateLayer(r,s),r||(i=this.createNewLayer(s),i.feature=s,i.addEventParent(this),this.options.onEachFeature&&this.options.onEachFeature(i.feature,i),this._layers[i.feature.id]=i,this.setFeatureStyle(i.feature.id,this.options.style),this.fire("createfeature",{feature:i.feature},!0),(!this.options.timeField||this.options.timeField&&this._featureWithinTimeRange(s))&&this._map.addLayer(i))}},addLayers:function(t){for(var e=t.length-1;e>=0;e--){var i=this._layers[t[e]];i&&(this.fire("addfeature",{feature:i.feature},!0),this._map.addLayer(i))}},removeLayers:function(t,e){for(var i=t.length-1;i>=0;i--){var s=t[i],r=this._layers[s];r&&(this.fire("removefeature",{feature:r.feature,permanent:e},!0),this._map.removeLayer(r)),r&&e&&delete this._layers[s]}},cellEnter:function(t,e){this._zooming||L.Util.requestAnimFrame(L.Util.bind(function(){var t=this._cacheKey(e),i=this._cellCoordsToKey(e),s=this._cache[t];this._activeCells[i]&&s&&this.addLayers(s)},this))},cellLeave:function(t,e){this._zooming||L.Util.requestAnimFrame(L.Util.bind(function(){var t=this._cacheKey(e),i=this._cellCoordsToKey(e),s=this._cache[t],r=this._map.getBounds();if(!this._activeCells[i]&&s){for(var o=!0,n=0;n<s.length;n++){var a=this._layers[s[n]];a&&a.getBounds&&r.intersects(a.getBounds())&&(o=!1)}o&&this.removeLayers(s,!this.options.cacheLayers),!this.options.cacheLayers&&o&&(delete this._cache[t],delete this._cells[i],delete this._activeCells[i])}},this))},resetStyle:function(){return this.options.style=this._originalStyle,this.eachFeature(function(t){this.resetFeatureStyle(t.feature.id)},this),this},setStyle:function(t){return this.options.style=t,this.eachFeature(function(e){this.setFeatureStyle(e.feature.id,t)},this),this},resetFeatureStyle:function(t){var e=this._layers[t],i=this._originalStyle||L.Path.prototype.options;return e&&(L.Util.extend(e.options,e.defaultOptions),this.setFeatureStyle(t,i)),this},setFeatureStyle:function(t,e){var i=this._layers[t];return"function"==typeof e&&(e=e(i.feature)),i.setStyle&&i.setStyle(e),this},eachFeature:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},getFeature:function(t){return this._layers[t]},bringToBack:function(){this.eachFeature(function(t){t.bringToBack&&t.bringToBack()})},bringToFront:function(){this.eachFeature(function(t){t.bringToFront&&t.bringToFront()})},redraw:function(t){return t&&this._redraw(t),this},_redraw:function(t){var e=this._layers[t],i=e.feature;if(e&&e.setIcon&&this.options.pointToLayer&&this.options.pointToLayer){var s=this.options.pointToLayer(i,L.latLng(i.geometry.coordinates[1],i.geometry.coordinates[0])),r=s.options.icon;e.setIcon(r)}if(e&&e.setStyle&&this.options.pointToLayer){var o=this.options.pointToLayer(i,L.latLng(i.geometry.coordinates[1],i.geometry.coordinates[0])),n=o.options;this.setFeatureStyle(i.id,n)}e&&e.setStyle&&this.options.style&&this.resetStyle(i.id)}});t.FeatureLayer=_t,t.featureLayer=N;var vt="2.0.0-beta.2",Lt={Task:$,task:P,Query:Y,query:F,Find:et,find:C,Identify:it,identify:O,IdentifyFeatures:st,identifyFeatures:k,IdentifyImage:rt,identifyImage:M},bt={Service:ot,service:q,MapService:nt,mapService:G,ImageService:at,imageService:E,FeatureLayerService:lt,featureLayerService:A},xt={BasemapLayer:ct,basemapLayer:j,TiledMapLayer:pt,tiledMapLayer:B,RasterLayer:dt,ImageMapLayer:mt,imageMapLayer:U,DynamicMapLayer:ft,dynamicMapLayer:z,FeatureGrid:yt,FeatureManager:gt,FeatureLayer:_t,featureLayer:N},St="undefined"==typeof define?!1:define.amd&&"function"==typeof define,Tt="object"==typeof t&&"undefined"!=typeof module,It=window&&window.System;(St||Tt||It)&&window&&window.L&&(window.L.esri={VERSION:vt,Support:Q,Util:V,get:K,post:T,request:w,Tasks:Lt,Services:bt,Layers:xt,BasemapLayer:ct,basemapLayer:j,TiledMapLayer:pt,tiledMapLayer:B,RasterLayer:dt,ImageMapLayer:mt,imageMapLayer:U,DynamicMapLayer:ft,dynamicMapLayer:z,FeatureGrid:yt,FeatureManager:gt,FeatureLayer:_t,featureLayer:N}),t.VERSION=vt,t.Tasks=Lt,t.Services=bt,t.Layers=xt}); | ||
}}},_renderPopup:function(t,e,i,s){if(t=L.latLng(t),this._shouldRenderPopup&&this._lastClick.equals(t)){var r=this._popupFunction(e,i,s);r&&this._popup.setLatLng(t).setContent(r).openOn(this._map)}},_resetPopupState:function(t){this._shouldRenderPopup=!1,this._lastClick=t.latlng}});t.RasterLayer=dt;var mt=dt.extend({options:{updateInterval:150,format:"jpgpng",transparent:!0,f:"json"},query:function(){return this.service.query()},identify:function(){return this.service.identify()},initialize:function(t){t.url=g(t.url),this.service=E(t),this.service.addEventParent(this),L.Util.setOptions(this,t)},setPixelType:function(t){return this.options.pixelType=t,this._update(),this},getPixelType:function(){return this.options.pixelType},setBandIds:function(t){return L.Util.isArray(t)?this.options.bandIds=t.join(","):this.options.bandIds=t.toString(),this._update(),this},getBandIds:function(){return this.options.bandIds},setNoData:function(t,e){return L.Util.isArray(t)?this.options.noData=t.join(","):this.options.noData=t.toString(),e&&(this.options.noDataInterpretation=e),this._update(),this},getNoData:function(){return this.options.noData},getNoDataInterpretation:function(){return this.options.noDataInterpretation},setRenderingRule:function(t){this.options.renderingRule=t,this._update()},getRenderingRule:function(){return this.options.renderingRule},setMosaicRule:function(t){this.options.mosaicRule=t,this._update()},getMosaicRule:function(){return this.options.mosaicRule},_getPopupData:function(t){var e=L.Util.bind(function(e,i,s){e||setTimeout(L.Util.bind(function(){this._renderPopup(t.latlng,e,i,s)},this),300)},this),i=this.identify().at(t.latlng);this.options.mosaicRule&&i.setMosaicRule(this.options.mosaicRule),i.run(e),this._shouldRenderPopup=!0,this._lastClick=t.latlng},_buildExportParams:function(){var t=this._map.getBounds(),e=this._map.getSize(),i=this._map.options.crs.project(t._northEast),s=this._map.options.crs.project(t._southWest),r={bbox:[s.x,s.y,i.x,i.y].join(","),size:e.x+","+e.y,format:this.options.format,transparent:this.options.transparent,bboxSR:this.options.bboxSR,imageSR:this.options.imageSR};return this.options.from&&this.options.to&&(r.time=this.options.from.valueOf()+","+this.options.to.valueOf()),this.options.pixelType&&(r.pixelType=this.options.pixelType),this.options.interpolation&&(r.interpolation=this.options.interpolation),this.options.compressionQuality&&(r.compressionQuality=this.options.compressionQuality),this.options.bandIds&&(r.bandIds=this.options.bandIds),this.options.noData&&(r.noData=this.options.noData),this.options.noDataInterpretation&&(r.noDataInterpretation=this.options.noDataInterpretation),this.service.options.token&&(r.token=this.service.options.token),this.options.renderingRule&&(r.renderingRule=JSON.stringify(this.options.renderingRule)),this.options.mosaicRule&&(r.mosaicRule=JSON.stringify(this.options.mosaicRule)),r},_requestExport:function(t,e){"json"===this.options.f?this.service.get("exportImage",t,function(t,i){t||this._renderImage(i.href,e)},this):(t.f="image",this._renderImage(this.options.url+"exportImage"+L.Util.getParamString(t),e))}});t.ImageMapLayer=mt,t.imageMapLayer=U;var ft=dt.extend({options:{updateInterval:150,layers:!1,layerDefs:!1,timeOptions:!1,format:"png24",transparent:!0,f:"json"},initialize:function(t){t.url=g(t.url),this.service=G(t),this.service.addEventParent(this),(t.proxy||t.token)&&"json"!==t.f&&(t.f="json"),L.Util.setOptions(this,t)},getDynamicLayers:function(){return this.options.dynamicLayers},setDynamicLayers:function(t){return this.options.dynamicLayers=t,this._update(),this},getLayers:function(){return this.options.layers},setLayers:function(t){return this.options.layers=t,this._update(),this},getLayerDefs:function(){return this.options.layerDefs},setLayerDefs:function(t){return this.options.layerDefs=t,this._update(),this},getTimeOptions:function(){return this.options.timeOptions},setTimeOptions:function(t){return this.options.timeOptions=t,this._update(),this},query:function(){return this.service.query()},identify:function(){return this.service.identify()},find:function(){return this.service.find()},_getPopupData:function(t){var e=L.Util.bind(function(e,i,s){e||setTimeout(L.Util.bind(function(){this._renderPopup(t.latlng,e,i,s)},this),300)},this),i=this.identify().on(this._map).at(t.latlng);this.options.layers?i.layers("visible:"+this.options.layers.join(",")):i.layers("visible"),i.run(e),this._shouldRenderPopup=!0,this._lastClick=t.latlng},_buildExportParams:function(){var t=this._map.getBounds(),e=this._map.getSize(),i=this._map.options.crs.project(t._northEast),s=this._map.options.crs.project(t._southWest),r=this._map.latLngToLayerPoint(t._northEast),o=this._map.latLngToLayerPoint(t._southWest);(r.y>0||o.y<e.y)&&(e.y=o.y-r.y);var n={bbox:[s.x,s.y,i.x,i.y].join(","),size:e.x+","+e.y,dpi:96,format:this.options.format,transparent:this.options.transparent,bboxSR:this.options.bboxSR,imageSR:this.options.imageSR};return this.options.dynamicLayers&&(n.dynamicLayers=this.options.dynamicLayers),this.options.layers&&(n.layers="show:"+this.options.layers.join(",")),this.options.layerDefs&&(n.layerDefs=JSON.stringify(this.options.layerDefs)),this.options.timeOptions&&(n.timeOptions=JSON.stringify(this.options.timeOptions)),this.options.from&&this.options.to&&(n.time=this.options.from.valueOf()+","+this.options.to.valueOf()),this.service.options.token&&(n.token=this.service.options.token),n},_requestExport:function(t,e){"json"===this.options.f?this.service.get("export",t,function(t,i){t||this._renderImage(i.href,e)},this):(t.f="image",this._renderImage(this.options.url+"export"+L.Util.getParamString(t),e))}});t.DynamicMapLayer=ft,t.dynamicMapLayer=z;var yt=L.Layer.extend({options:{cellSize:512,updateInterval:150},initialize:function(t){t=L.setOptions(this,t)},onAdd:function(t){this._map=t,this._update=L.Util.throttle(this._update,this.options.updateInterval,this),this._reset(),this._update()},onRemove:function(){this._map.removeEventListener(this.getEvents(),this),this._removeCells()},getEvents:function(){var t={moveend:this._update,zoomend:this._reset};return t},addTo:function(t){return t.addLayer(this),this},removeFrom:function(t){return t.removeLayer(this),this},_reset:function(){this._removeCells(),this._cells={},this._activeCells={},this._cellsToLoad=0,this._cellsTotal=0,this._cellNumBounds=this._getCellNumBounds(),this._resetWrap()},_resetWrap:function(){var t=this._map,e=t.options.crs;if(!e.infinite){var i=this._getCellSize();e.wrapLng&&(this._wrapLng=[Math.floor(t.project([0,e.wrapLng[0]]).x/i),Math.ceil(t.project([0,e.wrapLng[1]]).x/i)]),e.wrapLat&&(this._wrapLat=[Math.floor(t.project([e.wrapLat[0],0]).y/i),Math.ceil(t.project([e.wrapLat[1],0]).y/i)])}},_getCellSize:function(){return this.options.cellSize},_update:function(){if(this._map){var t=this._map.getPixelBounds(),e=this._map.getZoom(),i=this._getCellSize();if(!(e>this.options.maxZoom||e<this.options.minZoom)){var s=L.bounds(t.min.divideBy(i).floor(),t.max.divideBy(i).floor());this._removeOtherCells(s),this._addCells(s)}}},_addCells:function(t){var e,i,s,r=[],o=t.getCenter(),n=this._map.getZoom();for(e=t.min.y;e<=t.max.y;e++)for(i=t.min.x;i<=t.max.x;i++)s=new L.Point(i,e),s.z=n,this._isValidCell(s)&&r.push(s);var a=r.length;if(0!==a)for(this._cellsToLoad+=a,this._cellsTotal+=a,r.sort(function(t,e){return t.distanceTo(o)-e.distanceTo(o)}),i=0;a>i;i++)this._addCell(r[i])},_isValidCell:function(t){var e=this._map.options.crs;if(!e.infinite){var i=this._cellNumBounds;if(!e.wrapLng&&(t.x<i.min.x||t.x>i.max.x)||!e.wrapLat&&(t.y<i.min.y||t.y>i.max.y))return!1}if(!this.options.bounds)return!0;var s=this._cellCoordsToBounds(t);return L.latLngBounds(this.options.bounds).intersects(s)},_cellCoordsToBounds:function(t){var e=this._map,i=this.options.cellSize,s=t.multiplyBy(i),r=s.add([i,i]),o=e.wrapLatLng(e.unproject(s,t.z)),n=e.wrapLatLng(e.unproject(r,t.z));return new L.LatLngBounds(o,n)},_cellCoordsToKey:function(t){return t.x+":"+t.y},_keyToCellCoords:function(t){var e=t.split(":"),i=parseInt(e[0],10),s=parseInt(e[1],10);return new L.Point(i,s)},_removeOtherCells:function(t){for(var e in this._cells)t.contains(this._keyToCellCoords(e))||this._removeCell(e)},_removeCell:function(t){var e=this._activeCells[t];e&&(delete this._activeCells[t],this.cellLeave&&this.cellLeave(e.bounds,e.coords),this.fire("cellleave",{bounds:e.bounds,coords:e.coords}))},_removeCells:function(){for(var t in this._cells){var e=this._cells[t].bounds,i=this._cells[t].coords;this.cellLeave&&this.cellLeave(e,i),this.fire("cellleave",{bounds:e,coords:i})}},_addCell:function(t){this._wrapCoords(t);var e=this._cellCoordsToKey(t),i=this._cells[e];i&&!this._activeCells[e]&&(this.cellEnter&&this.cellEnter(i.bounds,t),this.fire("cellenter",{bounds:i.bounds,coords:t}),this._activeCells[e]=i),i||(i={coords:t,bounds:this._cellCoordsToBounds(t)},this._cells[e]=i,this._activeCells[e]=i,this.createCell&&this.createCell(i.bounds,t),this.fire("cellcreate",{bounds:i.bounds,coords:t}))},_wrapCoords:function(t){t.x=this._wrapLng?L.Util.wrapNum(t.x,this._wrapLng):t.x,t.y=this._wrapLat?L.Util.wrapNum(t.y,this._wrapLat):t.y},_getCellNumBounds:function(){var t=this._map.getPixelWorldBounds(),e=this._getCellSize();return t?L.bounds(t.min.divideBy(e).floor(),t.max.divideBy(e).ceil().subtract([1,1])):null}});t.FeatureGrid=yt;var gt=yt.extend({options:{attribution:null,where:"1=1",fields:["*"],from:!1,to:!1,timeField:!1,timeFilterMode:"server",simplifyFactor:0,precision:6},initialize:function(t){if(yt.prototype.initialize.call(this,t),t.url=g(t.url),t=L.setOptions(this,t),this.service=A(t),this.service.addEventParent(this),"*"!==this.options.fields[0]){for(var e=!1,i=0;i<this.options.fields.length;i++)this.options.fields[i].match(/^(OBJECTID|FID|OID|ID)$/i)&&(e=!0);e===!1&&b("no known esriFieldTypeOID field detected in fields Array. Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.")}this.options.timeField.start&&this.options.timeField.end?(this._startTimeIndex=new Z,this._endTimeIndex=new Z):this.options.timeField&&(this._timeIndex=new Z),this._cache={},this._currentSnapshot=[],this._activeRequests=0},onAdd:function(t){return yt.prototype.onAdd.call(this,t)},onRemove:function(t){return yt.prototype.onRemove.call(this,t)},getAttribution:function(){return this.options.attribution},createCell:function(t,e){this._requestFeatures(t,e)},_requestFeatures:function(t,e,i){return this._activeRequests++,1===this._activeRequests&&this.fire("loading",{bounds:t},!0),this._buildQuery(t).run(function(s,r,o){o&&o.exceededTransferLimit&&this.fire("drawlimitexceeded"),!s&&r&&r.features.length&&L.Util.requestAnimFrame(L.Util.bind(function(){this._addFeatures(r.features,e),this._postProcessFeatures(t)},this)),s||!r||r.features.length||this._postProcessFeatures(t),i&&i.call(this,s,r)},this)},_postProcessFeatures:function(t){this._activeRequests--,this._activeRequests<=0&&this.fire("load",{bounds:t})},_cacheKey:function(t){return t.z+":"+t.x+":"+t.y},_addFeatures:function(t,e){var i=this._cacheKey(e);this._cache[i]=this._cache[i]||[];for(var s=t.length-1;s>=0;s--){var r=t[s].id;this._currentSnapshot.push(r),this._cache[i].push(r)}this.options.timeField&&this._buildTimeIndexes(t);var o=this._map.getZoom();o>this.options.maxZoom||o<this.options.minZoom||this.createLayers(t)},_buildQuery:function(t){var e=this.service.query().intersects(t).where(this.options.where).fields(this.options.fields).precision(this.options.precision);return this.options.simplifyFactor&&e.simplify(this._map,this.options.simplifyFactor),"server"===this.options.timeFilterMode&&this.options.from&&this.options.to&&e.between(this.options.from,this.options.to),e},setWhere:function(t,e,i){this.options.where=t&&t.length?t:"1=1";for(var s=[],r=[],o=0,n=null,a=L.Util.bind(function(t,a){if(t&&(n=t),a)for(var l=a.features.length-1;l>=0;l--)r.push(a.features[l].id);o--,0>=o&&(this._currentSnapshot=r,L.Util.requestAnimFrame(L.Util.bind(function(){this.removeLayers(s),this.addLayers(r),e&&e.call(i,n)},this)))},this),l=this._currentSnapshot.length-1;l>=0;l--)s.push(this._currentSnapshot[l]);for(var u in this._activeCells){o++;var h=this._keyToCellCoords(u),c=this._cellCoordsToBounds(h);this._requestFeatures(c,u,a)}return this},getWhere:function(){return this.options.where},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(t,e,i,s){var r=this.options.from,o=this.options.to,n=0,a=null,l=L.Util.bind(function(l){l&&(a=l),this._filterExistingFeatures(r,o,t,e),n--,i&&0>=n&&i.call(s,a)},this);if(this.options.from=t,this.options.to=e,this._filterExistingFeatures(r,o,t,e),"server"===this.options.timeFilterMode)for(var u in this._activeCells){n++;var h=this._keyToCellCoords(u),c=this._cellCoordsToBounds(h);this._requestFeatures(c,u,l)}return this},refresh:function(){for(var t in this._activeCells){var e=this._keyToCellCoords(t),i=this._cellCoordsToBounds(e);this._requestFeatures(i,t)}this.redraw&&this.once("load",function(){this.eachFeature(function(t){this._redraw(t.feature.id)},this)},this)},_filterExistingFeatures:function(t,e,i,s){var r=t&&e?this._getFeaturesInTimeRange(t,e):this._currentSnapshot,o=this._getFeaturesInTimeRange(i,s);if(o.indexOf)for(var n=0;n<o.length;n++){var a=r.indexOf(o[n]);a>=0&&r.splice(a,1)}L.Util.requestAnimFrame(L.Util.bind(function(){this.removeLayers(r),this.addLayers(o)},this))},_getFeaturesInTimeRange:function(t,e){var i,s=[];if(this.options.timeField.start&&this.options.timeField.end){var r=this._startTimeIndex.between(t,e),o=this._endTimeIndex.between(t,e);i=r.concat(o)}else i=this._timeIndex.between(t,e);for(var n=i.length-1;n>=0;n--)s.push(i[n].id);return s},_buildTimeIndexes:function(t){var e,i;if(this.options.timeField.start&&this.options.timeField.end){var s=[],r=[];for(e=t.length-1;e>=0;e--)i=t[e],s.push({id:i.id,value:new Date(i.properties[this.options.timeField.start])}),r.push({id:i.id,value:new Date(i.properties[this.options.timeField.end])});this._startTimeIndex.bulkAdd(s),this._endTimeIndex.bulkAdd(r)}else{var o=[];for(e=t.length-1;e>=0;e--)i=t[e],o.push({id:i.id,value:new Date(i.properties[this.options.timeField])});this._timeIndex.bulkAdd(o)}},_featureWithinTimeRange:function(t){if(!this.options.from||!this.options.to)return!0;var e=+this.options.from.valueOf(),i=+this.options.to.valueOf();if("string"==typeof this.options.timeField){var s=+t.properties[this.options.timeField];return s>=e&&i>=s}if(this.options.timeField.start&&this.options.timeField.end){var r=+t.properties[this.options.timeField.start],o=+t.properties[this.options.timeField.end];return r>=e&&i>=r||o>=e&&i>=o}},authenticate:function(t){return this.service.authenticate(t),this},metadata:function(t,e){return this.service.metadata(t,e),this},query:function(){return this.service.query()},_getMetadata:function(t){if(this._metadata){var e;t(e,this._metadata)}else this.metadata(L.Util.bind(function(e,i){this._metadata=i,t(e,this._metadata)},this))},addFeature:function(t,e,i){this._getMetadata(L.Util.bind(function(s,r){return s?void(e&&e.call(this,s,null)):void this.service.addFeature(t,L.Util.bind(function(s,o){s||(t.properties[r.objectIdField]=o.objectId,t.id=o.objectId,this.createLayers([t])),e&&e.call(i,s,o)},this))},this))},updateFeature:function(t,e,i){this.service.updateFeature(t,function(s,r){s||(this.removeLayers([t.id],!0),this.createLayers([t])),e&&e.call(i,s,r)},this)},deleteFeature:function(t,e,i){this.service.deleteFeature(t,function(t,s){!t&&s.objectId&&this.removeLayers([s.objectId],!0),e&&e.call(i,t,s)},this)},deleteFeatures:function(t,e,i){return this.service.deleteFeatures(t,function(t,s){if(!t&&s.length>0)for(var r=0;r<s.length;r++)this.removeLayers([s[r].objectId],!0);e&&e.call(i,t,s)},this)}});Z.prototype._query=function(t){for(var e,i,s=0,r=this.values.length-1;r>=s;)if(e=(s+r)/2|0,i=this.values[Math.round(e)],+i.value<+t)s=e+1;else{if(!(+i.value>+t))return e;r=e-1}return~r},Z.prototype.sort=function(){this.values.sort(function(t,e){return+e.value-+t.value}).reverse(),this.dirty=!1},Z.prototype.between=function(t,e){this.dirty&&this.sort();var i=this._query(t),s=this._query(e);return 0===i&&0===s?[]:(i=Math.abs(i),s=0>s?Math.abs(s):s+1,this.values.slice(i,s))},Z.prototype.bulkAdd=function(t){this.dirty=!0,this.values=this.values.concat(t)},t.FeatureManager=gt;var _t=gt.extend({options:{cacheLayers:!0},initialize:function(t){gt.prototype.initialize.call(this,t),this._originalStyle=this.options.style,this._layers={}},onAdd:function(t){return t.on("zoomstart zoomend",function(t){this._zooming="zoomstart"===t.type},this),gt.prototype.onAdd.call(this,t)},onRemove:function(t){for(var e in this._layers)t.removeLayer(this._layers[e]);return gt.prototype.onRemove.call(this,t)},createNewLayer:function(t){var e=L.GeoJSON.geometryToLayer(t,this.options);return e.defaultOptions=e.options,e},_updateLayer:function(t,e){var i=[],s=this.options.coordsToLatLng||L.GeoJSON.coordsToLatLng;switch(e.properties&&(t.feature.properties=e.properties),e.geometry.type){case"Point":i=L.GeoJSON.coordsToLatLng(e.geometry.coordinates),t.setLatLng(i);break;case"LineString":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,0,s),t.setLatLngs(i);break;case"MultiLineString":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,1,s),t.setLatLngs(i);break;case"Polygon":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,1,s),t.setLatLngs(i);break;case"MultiPolygon":i=L.GeoJSON.coordsToLatLngs(e.geometry.coordinates,2,s),t.setLatLngs(i)}},createLayers:function(t){for(var e=t.length-1;e>=0;e--){var i,s=t[e],r=this._layers[s.id];r&&!this._map.hasLayer(r)&&this._map.addLayer(r),r&&(r.setLatLngs||r.setLatLng)&&this._updateLayer(r,s),r||(i=this.createNewLayer(s),i.feature=s,i.addEventParent(this),this.options.onEachFeature&&this.options.onEachFeature(i.feature,i),this._layers[i.feature.id]=i,this.setFeatureStyle(i.feature.id,this.options.style),this.fire("createfeature",{feature:i.feature},!0),(!this.options.timeField||this.options.timeField&&this._featureWithinTimeRange(s))&&this._map.addLayer(i))}},addLayers:function(t){for(var e=t.length-1;e>=0;e--){var i=this._layers[t[e]];i&&(this.fire("addfeature",{feature:i.feature},!0),this._map.addLayer(i))}},removeLayers:function(t,e){for(var i=t.length-1;i>=0;i--){var s=t[i],r=this._layers[s];r&&(this.fire("removefeature",{feature:r.feature,permanent:e},!0),this._map.removeLayer(r)),r&&e&&delete this._layers[s]}},cellEnter:function(t,e){this._zooming||L.Util.requestAnimFrame(L.Util.bind(function(){var t=this._cacheKey(e),i=this._cellCoordsToKey(e),s=this._cache[t];this._activeCells[i]&&s&&this.addLayers(s)},this))},cellLeave:function(t,e){this._zooming||L.Util.requestAnimFrame(L.Util.bind(function(){var t=this._cacheKey(e),i=this._cellCoordsToKey(e),s=this._cache[t],r=this._map.getBounds();if(!this._activeCells[i]&&s){for(var o=!0,n=0;n<s.length;n++){var a=this._layers[s[n]];a&&a.getBounds&&r.intersects(a.getBounds())&&(o=!1)}o&&this.removeLayers(s,!this.options.cacheLayers),!this.options.cacheLayers&&o&&(delete this._cache[t],delete this._cells[i],delete this._activeCells[i])}},this))},resetStyle:function(){return this.options.style=this._originalStyle,this.eachFeature(function(t){this.resetFeatureStyle(t.feature.id)},this),this},setStyle:function(t){return this.options.style=t,this.eachFeature(function(e){this.setFeatureStyle(e.feature.id,t)},this),this},resetFeatureStyle:function(t){var e=this._layers[t],i=this._originalStyle||L.Path.prototype.options;return e&&(L.Util.extend(e.options,e.defaultOptions),this.setFeatureStyle(t,i)),this},setFeatureStyle:function(t,e){var i=this._layers[t];return"function"==typeof e&&(e=e(i.feature)),i.setStyle&&i.setStyle(e),this},eachFeature:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},getFeature:function(t){return this._layers[t]},bringToBack:function(){this.eachFeature(function(t){t.bringToBack&&t.bringToBack()})},bringToFront:function(){this.eachFeature(function(t){t.bringToFront&&t.bringToFront()})},redraw:function(t){return t&&this._redraw(t),this},_redraw:function(t){var e=this._layers[t],i=e.feature;if(e&&e.setIcon&&this.options.pointToLayer&&this.options.pointToLayer){var s=this.options.pointToLayer(i,L.latLng(i.geometry.coordinates[1],i.geometry.coordinates[0])),r=s.options.icon;e.setIcon(r)}if(e&&e.setStyle&&this.options.pointToLayer){var o=this.options.pointToLayer(i,L.latLng(i.geometry.coordinates[1],i.geometry.coordinates[0])),n=o.options;this.setFeatureStyle(i.id,n)}e&&e.setStyle&&this.options.style&&this.resetStyle(i.id)}});t.FeatureLayer=_t,t.featureLayer=N;var vt="2.0.0-beta.3",Lt={Task:$,task:P,Query:Y,query:F,Find:et,find:C,Identify:it,identify:O,IdentifyFeatures:st,identifyFeatures:k,IdentifyImage:rt,identifyImage:M},bt={Service:ot,service:q,MapService:nt,mapService:G,ImageService:at,imageService:E,FeatureLayerService:lt,featureLayerService:A},xt={BasemapLayer:ct,basemapLayer:j,TiledMapLayer:pt,tiledMapLayer:B,RasterLayer:dt,ImageMapLayer:mt,imageMapLayer:U,DynamicMapLayer:ft,dynamicMapLayer:z,FeatureGrid:yt,FeatureManager:gt,FeatureLayer:_t,featureLayer:N},St="undefined"==typeof define?!1:define.amd&&"function"==typeof define,Tt="object"==typeof t&&"undefined"!=typeof module,It=window&&window.System;(St||Tt||It)&&window&&window.L&&(window.L.esri={VERSION:vt,Support:Q,Util:V,get:K,post:T,request:w,Tasks:Lt,Services:bt,Layers:xt,BasemapLayer:ct,basemapLayer:j,TiledMapLayer:pt,tiledMapLayer:B,RasterLayer:dt,ImageMapLayer:mt,imageMapLayer:U,DynamicMapLayer:ft,dynamicMapLayer:z,FeatureGrid:yt,FeatureManager:gt,FeatureLayer:_t,featureLayer:N}),t.VERSION=vt,t.Tasks=Lt,t.Services=bt,t.Layers=xt}); | ||
//# sourceMappingURL=./esri-leaflet.js.map |
{ | ||
"name": "esri-leaflet", | ||
"description": "Leaflet plugins for consuming ArcGIS Online and ArcGIS Server services.", | ||
"version": "2.0.0-beta.2", | ||
"version": "2.0.0-beta.3", | ||
"author": "Patrick Arlt <parlt@esri.com> (http://patrickarlt.com)", | ||
@@ -11,6 +11,2 @@ "browserify": { | ||
}, | ||
"files": [ | ||
"dist/esri-leaflet.js", | ||
"dist/esri-leaflet.js.map" | ||
], | ||
"bugs": { | ||
@@ -58,2 +54,6 @@ "url": "https://github.com/esri/esri-leaflet/issues" | ||
}, | ||
"files": [ | ||
"dist/esri-leaflet.js", | ||
"dist/esri-leaflet.js.map" | ||
], | ||
"homepage": "http://esri.github.io/esri-leaflet", | ||
@@ -85,10 +85,10 @@ "jsnext:main": "./index.js", | ||
"scripts": { | ||
"lint": "semistandard src/**/*.js", | ||
"posttest": "rm ./dist/esri-leaflet-src.js", | ||
"prepublish": "./scripts/build.js", | ||
"pretest": "npm run lint && esperanto -i src/EsriLeaflet.js -o ./dist/esri-leaflet-src.js --skip=leaflet --t umd --strict --name L.esri --bundle -m inline", | ||
"release": "./scripts/release.sh", | ||
"prepublish": "./scripts/build.js", | ||
"start": "grunt", | ||
"lint": "semistandard src/**/*.js", | ||
"pretest": "npm run lint && esperanto -i src/EsriLeaflet.js -o ./dist/esri-leaflet-src.js --skip=leaflet --t umd --strict --name L.esri --bundle", | ||
"posttest": "rm ./dist/esri-leaflet-src.js", | ||
"test": "karma start" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
362285
0