Browse files

small fixes and refactor build process to match leaflet and other plu…

…gins
  • Loading branch information...
1 parent ea412bd commit 483719c45ea23bf2e1355b40964f3cbdab4f9c74 @patrickarlt patrickarlt committed Aug 4, 2013
View
6 .jshintrc
@@ -0,0 +1,6 @@
+{
+ globals: {
+ L: true,
+ Terraformer: true
+ }
+}
View
67 Gruntfile.js
@@ -27,9 +27,13 @@ module.exports = function(grunt) {
},
concat: {
options: {
- separator: '\n'
+ separator: '\n',
+ banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
+ '* Copyright (c) <%= grunt.template.today("yyyy") %> Environmental Systems Research Institute, Inc.\n' +
+ '* Apache License' +
+ '*/\n'
},
- dist: {
+ core: {
src: [
'vendor/terraformer/dist/browser/terraformer.js',
'vendor/terraformer/dist/browser/rtree.js',
@@ -40,7 +44,18 @@ module.exports = function(grunt) {
'src/Layers/TiledMapLayer.js',
'src/Layers/DynamicMapLayer.js'
],
- dest: 'dist/esri-leaflet.js'
+ dest: 'dist/esri-leaflet-src.js'
+ },
+ basemaps: {
+ src: [
+ 'src/esri-leaflet.js',
+ 'src/Layers/BasemapLayer.js'
+ ],
+ dest: 'dist/extras/esri-basemaps-src.js'
+ },
+ cluster: {
+ src: ["src/Layers/ClusteredFeatureLayer.js"],
+ dest: 'dist/extras/clustered-feature-layer-src.js'
}
},
uglify: {
@@ -50,48 +65,22 @@ module.exports = function(grunt) {
except: ['Terraformer']
},
preserveComments: 'some',
- report: 'gzip',
- banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
- '* Copyright (c) <%= grunt.template.today("yyyy") %> Environmental Systems Research Institute, Inc.\n' +
- '* Apache License' +
- '*/\n'
+ report: 'gzip'
},
dist: {
files: {
- 'dist/esri-leaflet.min.js': [
- 'vendor/terraformer/dist/browser/terraformer.js',
- 'vendor/terraformer/dist/browser/rtree.js',
- 'vendor/terraformer/dist/browser/arcgis.js',
- 'src/esri-leaflet.js',
- 'src/Layers/BasemapLayer.js',
- 'src/Layers/FeatureLayer.js',
- 'src/Layers/TiledMapLayer.js',
- 'src/Layers/DynamicMapLayer.js'
+ 'dist/esri-leaflet.js': [
+ "dist/esri-leaflet-src.js"
],
- 'dist/esri-leaflet.unbundled.min.js': [
- 'src/esri-leaflet.js',
- 'src/Layers/BasemapLayer.js',
- 'src/Layers/FeatureLayer.js',
- 'src/Layers/TiledMapLayer.js',
- 'src/Layers/DynamicMapLayer.js'
+ 'dist/extras/clustered-feature-layer.js': [
+ 'dist/extras/clustered-feature-layer-src.js'
+ ],
+ 'dist/extras/esri-basemaps.js': [
+ 'dist/extras/esri-basemaps-src.js'
]
}
}
},
- cssmin: {
- options: {
- banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
- '* Copyright (c) <%= grunt.template.today("yyyy") %> Environmental Systems Research Institute, Inc.\n' +
- '* Apache License' +
- '*/\n',
- report: 'gzip'
- }
- // compress: {
- // files: {
- // 'dist/esri-leaflet.min.css': ['src/esri-leaflet.css']
- // }
- // }
- },
watch: {
src: {
files: ['src/**/*.js'],
@@ -104,13 +93,11 @@ module.exports = function(grunt) {
});
grunt.registerTask('default', ['jshint']);
- grunt.registerTask('build', ['default', 'uglify']);
+ grunt.registerTask('build', ['default', 'concat', 'uglify']);
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
- grunt.loadNpmTasks('grunt-contrib-watch');
};
View
3,412 dist/esri-leaflet-src.js
3,412 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
6 dist/esri-leaflet.min.js → dist/esri-leaflet.js
@@ -1,8 +1,8 @@
-/*! Esri-Leaflet - v0.0.1 - 2013-07-28
+/*! Esri-Leaflet - v0.0.1 - 2013-08-04
* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
* Apache License*/
-!function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"function"==typeof define&&define.amd&&define(b),"object"==typeof window&&(a.Terraformer=b())}(this,function(){function a(){this._thens=[]}function b(){var a=Array.prototype.slice.apply(arguments);void 0!==typeof console&&console.warn&&console.warn.apply(console,a)}function c(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function d(a){switch(a.type){case"Point":return[a.coordinates[0],a.coordinates[1],a.coordinates[0],a.coordinates[1]];case"MultiPoint":return g(a.coordinates);case"LineString":return g(a.coordinates);case"MultiLineString":return e(a.coordinates);case"Polygon":return e(a.coordinates);case"MultiPolygon":return f(a.coordinates);case"Feature":return d(a.geometry);case"FeatureCollection":return h(a);case"GeometryCollection":return i(a);default:throw new Error("Unknown type: "+a.type)}}function e(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++){var i=g[h],j=i[0],k=i[1];null===b?b=j:b>j&&(b=j),null===c?c=j:j>c&&(c=j),null===d?d=k:d>k&&(d=k),null===e?e=k:k>e&&(e=k)}return[b,d,c,e]}function f(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++)for(var i=g[h],j=0;j<i.length;j++){var k=i[j],l=k[0],m=k[1];null===b?b=l:b>l&&(b=l),null===c?c=l:l>c&&(c=l),null===d?d=m:d>m&&(d=m),null===e?e=m:m>e&&(e=m)}return[b,d,c,e]}function g(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++){var g=a[f],h=g[0],i=g[1];null===b?b=h:b>h&&(b=h),null===c?c=h:h>c&&(c=h),null===d?d=i:d>i&&(d=i),null===e?e=i:i>e&&(e=i)}return[b,d,c,e]}function h(a){for(var b,c=[],e=a.features.length-1;e>=0;e--)b=d(a.features[e].geometry),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function i(a){for(var b,c=[],e=a.geometries.length-1;e>=0;e--)b=d(a.geometries[e]),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function j(a){var b=d(a);return{x:b[0],y:b[1],w:Math.abs(b[0]-b[2]),h:Math.abs(b[1]-b[3])}}function k(a){return a*W}function l(a){return a*X}function m(a,b){for(var c=0;c<a.length;c++)"number"==typeof a[c][0]&&(a[c]=b(a[c])),"object"==typeof a[c]&&(a[c]=m(a[c],b));return a}function n(a){var b=a[0],c=a[1];return[k(b/V)-360*Math.floor((k(b/V)+180)/360),k(Math.PI/2-2*Math.atan(Math.exp(-1*c/V)))]}function o(a){var b=a[0],c=Math.max(Math.min(a[1],89.99999),-89.99999);return[l(b)*V,V/2*Math.log((1+Math.sin(l(c)))/(1-Math.sin(l(c))))]}function p(a,b,c){if("Point"===a.type)a.coordinates=b(a.coordinates);else if("Feature"===a.type)a.geometry=p(a.geometry,b,!0);else if("FeatureCollection"===a.type)for(var d=0;d<a.features.length;d++)a.features[d]=p(a.features[d],b,!0);else if("GeometryCollection"===a.type)for(var e=0;e<a.geometries.length;e++)a.geometries[e]=p(a.geometries[e],b,!0);else a.coordinates=m(a.coordinates,b);return c||b===o&&(a.crs=Y),b===n&&delete a.crs,a}function q(a){return p(a,o)}function r(a){return p(a,n)}function s(a,b){return b>a?-1:a>b?1:0}function t(a,b,c){return s((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]),0)}function u(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}function v(a,b){var c=b;for(var d in a){var e=t(b,c,a[d]);(-1===e||0===e&&u(b,a[d])>u(b,c))&&(c=a[d])}return c}function w(a){function b(a,b){return a[0]-b[0]>a[1]-b[1]?1:a[0]-b[0]<a[1]-b[1]?-1:0}if(0===a.length)return[];if(1===a.length)return a;for(var c=[a.sort(b)[0]],d=0;d<c.length;d++){var e=v(a,c[d]);e!==c[0]&&c.push(e)}return c}function x(a,b){for(var c=!1,d=-1,e=a.length,f=e-1;++d<e;f=d)(a[d][1]<=b[1]&&b[1]<a[f][1]||a[f][1]<=b[1]&&b[1]<a[d][1])&&b[0]<(a[f][0]-a[d][0])*(b[1]-a[d][1])/(a[f][1]-a[d][1])+a[d][0]&&(c=!0);return c}function y(a,b){if(a&&a.length){if(1===a.length)return x(a[0],b);if(x(a[0],b)){for(var c=1;c<a.length;c++)if(x(a[c],b))return!1;return!0}return!1}return!1}function z(a,b,c,d){var e=(d[0]-c[0])*(a[1]-c[1])-(d[1]-c[1])*(a[0]-c[0]),f=(b[0]-a[0])*(a[1]-c[1])-(b[1]-a[1])*(a[0]-c[0]),g=(d[1]-c[1])*(b[0]-a[0])-(d[0]-c[0])*(b[1]-a[1]);if(0!==g){var h=e/g,i=f/g;if(h>=0&&1>=h&&i>=0&&1>=i)return!0}return!1}function A(a,b){for(var c=0;c<a.length-1;c++)for(var d=0;d<b.length-1;d++)if(z(a[c],a[c+1],b[d],b[d+1]))return!0;return!1}function B(a,b){for(var c=0;c<b.length;c++)for(var d=b[c],e=0;e<d.length-1;e++)for(var f=0;f<a.length-1;f++)if(z(d[e],d[e+1],a[f],a[f+1]))return!0;return!1}function C(a,b){for(var c=0;c<a.length;c++)if(B(a[c],b))return!0;return!1}function D(a,b){for(var c=0;c<b.length;c++)return B(a,b[c])?!0:!1}function E(a,b){for(var c=0;c<a.length;c++)return D(a[c],b)?!0:!1}function F(a,b){for(var c=0;c<a.length;c++)return E(a[c],b)?!0:!1}function G(a){for(var b=[],c=0;c<a.length;c++){var d=a[c].slice();H(d[0],d[d.length-1])===!1&&d.push(d[0]),b.push(d)}return b}function H(a,b){for(var c=0;c<a.length;c++)for(var d=0;d<b.length;d++)if(a[c]!==b[d])return!1;return!0}function I(a){if(a)switch(a.type){case"Point":return new J(a);case"MultiPoint":return new K(a);case"LineString":return new L(a);case"MultiLineString":return new M(a);case"Polygon":return new N(a);case"MultiPolygon":return new O(a);case"Feature":return new P(a);case"FeatureCollection":return new Q(a);case"GeometryCollection":return new R(a);default:throw new Error("Unknown type: "+a.type)}}function J(a){var b=Array.prototype.slice.call(arguments);if(a&&"Point"===a.type&&a.coordinates)c(this,a);else if(a&&Array.isArray(a))this.coordinates=a;else{if(!(b.length>=2))throw"Terraformer: invalid input for Terraformer.Point";this.coordinates=b}this.type="Point"}function K(a){if(a&&"MultiPoint"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.MultiPoint";this.coordinates=a}this.type="MultiPoint"}function L(a){if(a&&"LineString"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.LineString";this.coordinates=a}this.type="LineString"}function M(a){if(a&&"MultiLineString"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.MultiLineString";this.coordinates=a}this.type="MultiLineString"}function N(a){if(a&&"Polygon"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.Polygon";this.coordinates=a}this.type="Polygon"}function O(a){if(a&&"MultiPolygon"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.MultiPolygon";this.coordinates=a}this.type="MultiPolygon"}function P(a){if(a&&"Feature"===a.type&&a.geometry)c(this,a);else{if(!(a&&a.type&&a.coordinates))throw"Terraformer: invalid input for Terraformer.Feature";this.geometry=a}this.type="Feature"}function Q(a){if(a&&"FeatureCollection"===a.type&&a.features)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.FeatureCollection";this.features=a}this.type="FeatureCollection"}function R(a){if(a&&"GeometryCollection"===a.type&&a.geometries)c(this,a);else if(Array.isArray(a))this.geometries=a;else{if(!a.coordinates||!a.type)throw"Terraformer: invalid input for Terraformer.GeometryCollection";this.type="GeometryCollection",this.geometries=[a]}this.type="GeometryCollection"}function S(a,b,c){for(var d=o(a),e=c||64,f=b||250,g={type:"Polygon",coordinates:[[]]},h=1;e>=h;h++){var i=h*(360/e)*Math.PI/180;g.coordinates[0].push([d[0]+f*Math.cos(i),d[1]+f*Math.sin(i)])}return r(g)}function T(a,b,d){var e=d||64,f=b||250;if(!a||a.length<2||!f||!e)throw new Error("Terraformer: missing parameter for Terraformer.Circle");c(this,new P({type:"Feature",geometry:S(a,f,e),properties:{radius:f,center:a,steps:e}}))}var U={},V=6378137,W=57.29577951308232,X=.017453292519943,Y={type:"link",properties:{href:"http://spatialreference.org/ref/sr-org/6928/ogcwkt/",type:"ogcwkt"}},Z={type:"link",properties:{href:"http://spatialreference.org/ref/epsg/4326/ogcwkt/",type:"ogcwkt"}};a.prototype={then:function(a,b){return this._thens.push({resolve:a,reject:b}),this},resolve:function(a){return this._complete("resolve",a),this},reject:function(a){return this._complete("reject",a),this},_complete:function(a,b){this.then="resolve"===a?function(a){a(b)}:function(a,c){c(b)},this.resolve=this.reject=function(){throw new Error("Deferred already completed.")};for(var c=0;c<this._thens.length;c++){var d=this._thens[c];d[a]&&d[a](b)}delete this._thens}};var $=["length"];return I.prototype={toMercator:function(){return q(this)},toGeographic:function(){return r(this)},envelope:function(){var a=d(this);return{x:a[0],y:a[1],w:Math.abs(a[0]-a[2]),h:Math.abs(a[1]-a[3])}},bbox:function(){return d(this)},convexHull:function(){var a,b,c=[];if("Point"===this.type)return this.coordinates&&this.coordinates.length>0?[this.coordinates]:[];if("LineString"===this.type||"MultiPoint"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return[];c=this.coordinates}else if("Polygon"===this.type||"MultiLineString"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return[];for(a=0;a<this.coordinates.length;a++)c=c.concat(this.coordinates[a])}else{if("MultiPolygon"!==this.type)throw new Error("Unable to get convex hull of "+this.type);if(!(this.coordinates&&this.coordinates.length>0))return[];for(a=0;a<this.coordinates.length;a++)for(b=0;b<this.coordinates[a].length;b++)c=c.concat(this.coordinates[a][b])}return w(c)},toJSON:function(){var a={};for(var b in this)this.hasOwnProperty(b)&&this[b]&&$.indexOf(b)&&(a[b]=this[b]);return a.bbox=d(this),a},intersects:function(a){if("Feature"===a.type&&(a=a.geometry),"LineString"===this.type){if("LineString"===a.type)return A(this.coordinates,a.coordinates);if("MultiLineString"===a.type)return B(this.coordinates,a.coordinates);if("Polygon"===a.type)return B(this.coordinates,G(a.coordinates));if("MultiPolygon"===a.type)return D(this.coordinates,a.coordinates)}else if("MultiLineString"===this.type){if("LineString"===a.type)return B(a.coordinates,this.coordinates);if("Polygon"===a.type||"MultiLineString"===a.type)return C(this.coordinates,a.coordinates);if("MultiPolygon"===a.type)return E(this.coordinates,a.coordinates)}else if("Polygon"===this.type){if("LineString"===a.type)return B(a.coordinates,G(this.coordinates));if("MultiLineString"===a.type)return C(G(this.coordinates),a.coordinates);if("Polygon"===a.type)return C(G(this.coordinates),G(a.coordinates));if("MultiPolygon"===a.type)return E(G(this.coordinates),a.coordinates)}else if("MultiPolygon"===this.type){if("LineString"===a.type)return D(a.coordinates,this.coordinates);if("Polygon"===a.type||"MultiLineString"===a.type)return E(G(a.coordinates),this.coordinates);if("MultiPolygon"===a.type)return F(this.coordinates,a.coordinates)}else if("Feature"===this.type){var c=new I(this.geometry);return c.intersects(a)}return b("Type "+this.type+" to "+a.type+" intersection is not supported by intersects"),!1}},J.prototype=new I,J.prototype.constructor=J,K.prototype=new I,K.prototype.constructor=K,K.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates]);return this},K.prototype.addPoint=function(a){return this.coordinates.push(a),this},K.prototype.insertPoint=function(a,b){return this.coordinates.splice(b,0,a),this},K.prototype.removePoint=function(a){return"number"==typeof a?this.coordinates.splice(a,1):this.coordinates.splice(this.coordinates.indexOf(a),1),this},K.prototype.get=function(a){return new J(this.coordinates[a])},L.prototype=new I,L.prototype.constructor=L,L.prototype.addVertex=function(a){return this.coordinates.push(a),this},L.prototype.insertVertex=function(a,b){return this.coordinates.splice(b,0,a),this},L.prototype.removeVertex=function(a){return this.coordinates.splice(a,1),this},M.prototype=new I,M.prototype.constructor=M,M.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},M.prototype.get=function(a){return new L(this.coordinates[a])},N.prototype=new I,N.prototype.constructor=N,N.prototype.addVertex=function(a){return this.coordinates[0].push(a),this},N.prototype.insertVertex=function(a,b){return this.coordinates[0].splice(b,0,a),this},N.prototype.removeVertex=function(a){return this.coordinates[0].splice(a,1),this},N.prototype.contains=function(a){if("Point"===a.type)return y(this.coordinates,a.coordinates);if("Polygon"===a.type){if(a.coordinates.length>0&&a.coordinates[0].length>0&&y(this.coordinates,a.coordinates[0][0])===!0&&this.intersects(a)===!1)return!0}else if("MultiPolygon"===a.type&&a.coordinates.length>0)for(var b=0;b<a.coordinates.length;b++)if(a.coordinates[b][0].length>0&&y(this.coordinates,a.coordinates[b][0][0])===!0&&this.intersects({type:"Polygon",coordinates:a.coordinates[b]})===!1)return!0;return!1},O.prototype=new I,O.prototype.constructor=O,O.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},O.prototype.contains=function(a){if("Point"!==a.type)throw new Error("Only points are supported");for(var b=0;b<this.coordinates.length;b++)if(y(this.coordinates[b],a.coordinates))return!0;return!1},O.prototype.get=function(a){return new N(this.coordinates[a])},P.prototype=new I,P.prototype.constructor=P,P.prototype.contains=function(a){if("Point"!==a.type)throw new Error("Only points are supported");if(!this.geometry.type.match(/Polygon/))throw new Error("Only features containing Polygons and MultiPolygons are supported");if("MultiPolygon"===this.geometry.type)for(var b=0;b<this.geometry.coordinates.length;b++)if(y(this.geometry.coordinates[b],a.coordinates))return!0;return"Polygon"===this.geometry.type?y(this.geometry.coordinates,a.coordinates):!1},Q.prototype=new I,Q.prototype.constructor=Q,Q.prototype.forEach=function(a){for(var b=0;b<this.features.length;b++)a.apply(this,[this.features[b],b,this.features])},Q.prototype.get=function(a){var b;return this.forEach(function(c){c.id===a&&(b=c)}),new P(b)},R.prototype=new I,R.prototype.constructor=R,R.prototype.forEach=function(a){for(var b=0;b<this.geometries.length;b++)a.apply(this,[this.geometries[b],b,this.geometries])},R.prototype.get=function(a){return new I(this.geometries[a])},T.prototype=new I,T.prototype.constructor=T,T.prototype.recalculate=function(){return this.geometry=S(this.properties.center,this.properties.radius,this.properties.steps),this},T.prototype.center=function(a){return a&&(this.properties.center=a,this.recalculate()),this.properties.center},T.prototype.radius=function(a){return a&&(this.properties.radius=a,this.recalculate()),this.properties.radius},T.prototype.steps=function(a){return a&&(this.properties.steps=a,this.recalculate()),this.properties.steps},T.prototype.contains=function(a){if("Point"!==a.type)throw new Error("Only points are supported");return y(this.geometry.coordinates,a.coordinates)},T.prototype.toJSON=function(){var a=I.prototype.toJSON.call(this);return a},U.Primitive=I,U.Point=J,U.MultiPoint=K,U.LineString=L,U.MultiLineString=M,U.Polygon=N,U.MultiPolygon=O,U.Feature=P,U.FeatureCollection=Q,U.GeometryCollection=R,U.Circle=T,U.toMercator=q,U.toGeographic=r,U.Tools={},U.Tools.positionToMercator=o,U.Tools.positionToGeographic=n,U.Tools.applyConverter=p,U.Tools.toMercator=q,U.Tools.toGeographic=r,U.Tools.createCircle=S,U.Tools.calculateBounds=d,U.Tools.calculateEnvelope=j,U.Tools.coordinatesContainPoint=x,U.Tools.polygonContainsPoint=y,U.Tools.arrayIntersectsArray=A,U.Tools.coordinatesContainPoint=x,U.Tools.convexHull=w,U.MercatorCRS=Y,U.GeographicCRS=Z,U.Deferred=a,U}),function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"function"==typeof define&&define.amd&&define(["terraformer/terraformer"],b),"undefined"==typeof a.Terraformer&&(a.Terraformer={}),a.Terraformer.RTree=b().RTree}(this,function(){function a(a){return"[object Array]"===Object.prototype.toString.call(a)}var Terraformer,b={};"object"==typeof this.navigator&&(Terraformer=this.Terraformer),"object"==typeof module&&"object"==typeof module.exports&&(Terraformer=require("terraformer")),arguments[0]&&"function"==typeof define&&define.amd&&(Terraformer=arguments[0]);var c=function(b){var d=3,e=6;isNaN(b)||(d=Math.floor(b/2),e=b),this.min_width=d,this.max_width=e;var f={x:0,y:0,w:0,h:0,id:"root",nodes:[]};!function(){var a={};return function(b){var c=0;return b in a?c=a[b]++:a[b]=0,b+"_"+c}}(),c.Rectangle.squarified_ratio=function(a,b,c){var d=(a+b)/2,e=a*b,f=e/(d*d);return e*c/f};var g=function(a,b,e){var f=[],g=[],h=[],i=1;if(!a||!c.Rectangle.overlap_rectangle(a,e))return h;var j={x:a.x,y:a.y,w:a.w,h:a.h,target:b};g.push(e.nodes.length),f.push(e);do{var k=f.pop(),l=g.pop()-1;if("target"in j)for(;l>=0;){var o=k.nodes[l];if(c.Rectangle.overlap_rectangle(j,o)){if(j.target&&"leaf"in o&&o.leaf===j.target||!j.target&&("leaf"in o||c.Rectangle.contains_rectangle(o,j))){"nodes"in o?(h=m(o,!0,[],o),k.nodes.splice(l,1)):h=k.nodes.splice(l,1),c.Rectangle.make_MBR(k.nodes,k),delete j.target,k.nodes.length<d&&(j.nodes=m(k,!0,[],k));break}"nodes"in o&&(i+=1,g.push(l),f.push(k),k=o,l=o.nodes.length)}l-=1}else if("nodes"in j){k.nodes.splice(l+1,1),k.nodes.length>0&&c.Rectangle.make_MBR(k.nodes,k);for(var p=0;p<j.nodes.length;p++)n(j.nodes[p],k);j.nodes.length=0,0===f.length&&k.nodes.length<=1?(j.nodes=m(k,!0,j.nodes,k),k.nodes.length=0,f.push(k),g.push(1)):f.length>0&&k.nodes.length<d?(j.nodes=m(k,!0,j.nodes,k),k.nodes.length=0):delete j.nodes}else c.Rectangle.make_MBR(k.nodes,k);i-=1}while(f.length>0);return h},h=function(a,b){var d,e=-1,f=[];f.push(b);var g=b.nodes;do{-1!==e&&(f.push(g[e]),g=g[e].nodes,e=-1);for(var h=g.length-1;h>=0;h--){var i=g[h];if("leaf"in i){e=-1;break}var j=c.Rectangle.squarified_ratio(i.w,i.h,i.nodes.length+1),k=Math.max(i.x+i.w,a.x+a.w)-Math.min(i.x,a.x),l=Math.max(i.y+i.h,a.y+a.h)-Math.min(i.y,a.y),m=c.Rectangle.squarified_ratio(k,l,i.nodes.length+2);(0>e||Math.abs(m-j)<d)&&(d=Math.abs(m-j),e=h)}}while(-1!==e);return f},i=function(a){for(var b=k(a);a.length>0;)j(a,b[0],b[1]);return b},j=function(a,b,e){for(var f,g,h,i=c.Rectangle.squarified_ratio(b.w,b.h,b.nodes.length+1),j=c.Rectangle.squarified_ratio(e.w,e.h,e.nodes.length+1),k=a.length-1;k>=0;k--){var l=a[k],m={};m.x=Math.min(b.x,l.x),m.y=Math.min(b.y,l.y),m.w=Math.max(b.x+b.w,l.x+l.w)-m.x,m.h=Math.max(b.y+b.h,l.y+l.h)-m.y;var n=Math.abs(c.Rectangle.squarified_ratio(m.w,m.h,b.nodes.length+2)-i),o={};o.x=Math.min(e.x,l.x),o.y=Math.min(e.y,l.y),o.w=Math.max(e.x+e.w,l.x+l.w)-o.x,o.h=Math.max(e.y+e.h,l.y+l.h)-o.y;var p=Math.abs(c.Rectangle.squarified_ratio(o.w,o.h,e.nodes.length+2)-j);(!g||!f||Math.abs(p-n)<f)&&(g=k,f=Math.abs(p-n),h=n>p?e:b)}var q=a.splice(g,1)[0];b.nodes.length+a.length+1<=d?(b.nodes.push(q),c.Rectangle.expand_rectangle(b,q)):e.nodes.length+a.length+1<=d?(e.nodes.push(q),c.Rectangle.expand_rectangle(e,q)):(h.nodes.push(q),c.Rectangle.expand_rectangle(h,q))},k=function(a){for(var b,c,d=a.length-1,e=0,f=a.length-1,g=0,h=a.length-2;h>=0;h--){var i=a[h];i.x>a[e].x?e=h:i.x+i.w<a[d].x+a[d].w&&(d=h),i.y>a[g].y?g=h:i.y+i.h<a[f].y+a[f].h&&(f=h)}var j=Math.abs(a[d].x+a[d].w-a[e].x),k=Math.abs(a[f].y+a[f].h-a[g].y);return j>k?d>e?(b=a.splice(d,1)[0],c=a.splice(e,1)[0]):(c=a.splice(e,1)[0],b=a.splice(d,1)[0]):f>g?(b=a.splice(f,1)[0],c=a.splice(g,1)[0]):(c=a.splice(g,1)[0],b=a.splice(f,1)[0]),[{x:b.x,y:b.y,w:b.w,h:b.h,nodes:[b]},{x:c.x,y:c.y,w:c.w,h:c.h,nodes:[c]}]},l=function(a,b){return a.nodes=b.nodes,a.x=b.x,a.y=b.y,a.w=b.w,a.h=b.h,a},m=function(a,b,d,e){var f=[];if(!c.Rectangle.overlap_rectangle(a,e))return d;f.push(e.nodes);do for(var g=f.pop(),h=g.length-1;h>=0;h--){var i=g[h];c.Rectangle.overlap_rectangle(a,i)&&("nodes"in i?f.push(i.nodes):"leaf"in i&&(b?d.push(i):d.push(i.leaf)))}while(f.length>0);return d},n=function(b,d){var f;if(0===d.nodes.length)return d.x=b.x,d.y=b.y,d.w=b.w,d.h=b.h,d.nodes.push(b),void 0;var g=h(b,d),j=b;do{if(f&&"nodes"in f&&0===f.nodes.length){var k=f;f=g.pop();for(var l=0;l<f.nodes.length;l++)if(f.nodes[l]===k||0===f.nodes[l].nodes.length){f.nodes.splice(l,1);break}}else f=g.pop();if("leaf"in j||"nodes"in j||a(j)){if(a(j)){for(var m=0;m<j.length;m++)c.Rectangle.expand_rectangle(f,j[m]);f.nodes=f.nodes.concat(j)}else c.Rectangle.expand_rectangle(f,j),f.nodes.push(j);if(f.nodes.length<=e)j={x:f.x,y:f.y,w:f.w,h:f.h};else{var n=i(f.nodes);j=n,g.length<1&&(f.nodes.push(n[0]),g.push(f),j=n[1])}}else c.Rectangle.expand_rectangle(f,j),j={x:f.x,y:f.y,w:f.w,h:f.h}}while(g.length>0)};this.serialize=function(a){var b=new Terraformer.Deferred;return a&&b.then(function(b){a(null,b)},function(b){a(b,null)}),b.resolve(f),b},this.deserialize=function(a,b,c){var d=Array.prototype.slice.call(arguments),e=new Terraformer.Deferred;switch(d.length){case 1:b=f;break;case 2:"function"==typeof d[1]&&(b=f,c=d[1])}return c&&e.then(function(a){c(null,a)},function(a){c(a,null)}),e.resolve(l(b,a)),e},this.search=function(a,b){var c;if(a.type){var d=Terraformer.Tools.calculateBounds(a);c={x:d[0],y:d[1],w:Math.abs(d[0]-d[2]),h:Math.abs(d[1]-d[3])}}else c=a;var e=new Terraformer.Deferred,g=[c,!1,[],f];if(void 0===c)throw"Wrong number of arguments. RT.Search requires at least a bounding rectangle.";return b&&e.then(function(a){b(null,a)},function(a){b(a,null)}),e.resolve(m.apply(this,g)),e},this.remove=function(a,b,c){var d=Array.prototype.slice.call(arguments),e=new Terraformer.Deferred;if(1===d.length&&d.push(!1),3===d.length&&(c=d.pop(),e.then(function(a){c(null,a)},function(a){c(a,null)})),d[0].type){var h=Terraformer.Tools.calculateBounds(a);d[0]={x:h[0],y:h[1],w:Math.abs(h[0]-h[2]),h:Math.abs(h[1]-h[3])}}if(d.push(f),b===!1){var i=0,j=[];do i=j.length,j=j.concat(g.apply(this,d));while(i!==j.length);return j}return g.apply(this,d)},this.insert=function(a,b,c){var d;if(a.type){var e=Terraformer.Tools.calculateBounds(a);d={x:e[0],y:e[1],w:Math.abs(e[0]-e[2]),h:Math.abs(e[1]-e[3])}}else d=a;var g=new Terraformer.Deferred;if(arguments.length<2)throw"Wrong number of arguments. RT.Insert requires at least a bounding rectangle or GeoJSON and an object.";return c&&g.then(function(a){c(null,a)},function(a){c(a,null)}),g.resolve(n({x:d.x,y:d.y,w:d.w,h:d.h,leaf:b},f)),g}};return c.Rectangle=function(a,b,c,d){var e,f,g,h,i,j;a.x?(e=a.x,g=a.y,0!==a.w&&!a.w&&a.x2?(i=a.x2-a.x,j=a.y2-a.y):(i=a.w,j=a.h),f=e+i,h=g+j):(e=a,g=b,i=c,j=d,f=e+i,h=g+j),this.x1=this.x=function(){return e},this.y1=this.y=function(){return g},this.x2=function(){return f},this.y2=function(){return h},this.w=function(){return i},this.h=function(){return j},this.toJSON=function(){return'{"x":'+e.toString()+', "y":'+g.toString()+', "w":'+i.toString()+', "h":'+j.toString()+"}"},this.overlap=function(a){return this.x()<a.x2()&&this.x2()>a.x()&&this.y()<a.y2()&&this.y2()>a.y()},this.expand=function(a){var b=Math.min(this.x(),a.x()),c=Math.min(this.y(),a.y());return i=Math.max(this.x2(),a.x2())-b,j=Math.max(this.y2(),a.y2())-c,e=b,g=c,this},this.setRect=function(a,b,c,d){var e,f,g,h,i,j;a.x?(e=a.x,g=a.y,0!==a.w&&!a.w&&a.x2?(i=a.x2-a.x,j=a.y2-a.y):(i=a.w,j=a.h),f=e+i,h=g+j):(e=a,g=b,i=c,j=d,f=e+i,h=g+j)}},c.Rectangle.overlap_rectangle=function(a,b){return a.x<b.x+b.w&&a.x+a.w>b.x&&a.y<b.y+b.h&&a.y+a.h>b.y},c.Rectangle.contains_rectangle=function(a,b){return a.x+a.w<=b.x+b.w&&a.x>=b.x&&a.y+a.h<=b.y+b.h&&a.y>=b.y},c.Rectangle.expand_rectangle=function(a,b){var c,d;return c=a.x<b.x?a.x:b.x,d=a.y<b.y?a.y:b.y,a.w=a.x+a.w>b.x+b.w?a.x+a.w-c:b.x+b.w-c,a.h=a.y+a.h>b.y+b.h?a.y+a.h-d:b.y+b.h-d,a.x=c,a.y=d,a},c.Rectangle.make_MBR=function(a,b){if(a.length<1)return{x:0,y:0,w:0,h:0};b?(b.x=a[0].x,b.y=a[0].y,b.w=a[0].w,b.h=a[0].h):b={x:a[0].x,y:a[0].y,w:a[0].w,h:a[0].h};for(var d=a.length-1;d>0;d--)c.Rectangle.expand_rectangle(b,a[d]);return b},b.RTree=c,b}),function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"function"==typeof define&&define.amd&&define(["terraformer/terraformer"],b),"object"==typeof a.navigator&&("undefined"==typeof a.Terraformer&&(a.Terraformer={}),a.Terraformer.ArcGIS=b())}(this,function(){function a(a){var b,c=0,d=0,e=a.length,f=a[d];for(d;e-1>d;d++)b=a[d+1],c+=(b[0]-f[0])*(b[1]+f[1]),f=b;return c>=0}function b(b){var c=[],d=b.shift();a(d)||d.reverse(),c.push(d);for(var e=0;e<b.length;e++){var f=b[e];a(f)&&d.reverse(),c.push(b[e])}return c}function c(a){for(var c=[],d=0;d<a.length;d++){for(var e=b(a[d]),f=e.length-1;f>=0;f--){var g=e[f];c.push(g)}c.push()}return c}function d(a,b){var c=Terraformer.Tools.arrayIntersectsArray(a,b),d=Terraformer.Tools.coordinatesContainPoint(a,b[0]);return!c&&d?!0:!1}function e(b){for(var c=[],e=[],f=0;f<b.length;f++){var g=b[f];if(a(g)){var h=[g];c.push(h)}else e.push(g)}for(;e.length;){for(var i=e.pop(),j=!1,k=c.length-1;k>=0;k--){var l=c[k][0];if(d(l,i)){c[k].push(i),j=!0;break}}j||c.push([i.reverse()])}return 1===c.length?{type:"Polygon",coordinates:c[0]}:{type:"MultiPolygon",coordinates:c}}function f(a){var b=JSON.parse(JSON.stringify(a)),c={};b.x&&b.y&&(c.type="Point",c.coordinates=[b.x,b.y]),b.points&&(c.type="MultiPoint",c.coordinates=b.points),b.paths&&(1===b.paths.length?(c.type="LineString",c.coordinates=b.paths[0]):(c.type="MultiLineString",c.coordinates=b.paths)),b.rings&&(c=e(b.rings)),b.geometry&&(c.type="Feature",c.geometry=f(b.geometry),c.properties=b.attributes||{});var d=b.geometry?b.geometry.spatialReference:b.spatialReference;return d&&102100===d.wkid&&(c=Terraformer.toGeographic(c)),new Terraformer.Primitive(c)}function g(a){var d,e=JSON.parse(JSON.stringify(a)),f={wkid:4326},h={};switch(e.type){case"Point":h.x=e.coordinates[0],h.y=e.coordinates[1],h.spatialReference=f;break;case"MultiPoint":h.points=e.coordinates,h.spatialReference=f;break;case"LineString":h.paths=[e.coordinates],h.spatialReference=f;break;case"MultiLineString":h.paths=e.coordinates,h.spatialReference=f;break;case"Polygon":h.rings=b(e.coordinates),h.spatialReference=f;break;case"MultiPolygon":h.rings=c(e.coordinates),h.spatialReference=f;break;case"Feature":h.geometry=g(e.geometry),h.attributes=e.properties;break;case"FeatureCollection":for(h=[],d=0;d<e.features.length;d++)h.push(g(e.features[d]));break;case"GeometryCollection":for(h=[],d=0;d<e.geometries.length;d++)h.push(g(e.geometries[d]))}return h}var Terraformer,h={};return"object"==typeof this.navigator&&(Terraformer=this.Terraformer),"object"==typeof module&&"object"==typeof module.exports&&(Terraformer=require("terraformer")),arguments[0]&&"function"==typeof define&&define.amd&&(Terraformer=arguments[0]),h.parse=f,h.convert=g,h}),L.esri={AttributionStyles:"line-height:9px; text-overflow:ellipsis; white-space:nowrap;overflow:hidden; display:inline-block;",LogoStyles:"position:absolute; top:-38px; right:2px;",_callback:{}},L.esri.Support={CORS:!!(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest)},L.esri.RequestHandlers={CORS:function(a,b,c,d){var e=new XMLHttpRequest;b.f="json",e.onreadystatechange=function(){var a;if(4===e.readyState){try{a=JSON.parse(e.responseText)}catch(b){a={error:"Could not parse response as JSON."}}d?c.call(d,a):c(a)}},e.open("GET",a+L.esri.Util.serialize(b),!0),e.send(null)},JSONP:function(a,b,c,d){var e="c"+(1e9*Math.random()).toString(36).replace(".","_");b.f="json",b.callback="L.esri._callback."+e;var f=document.createElement("script");f.type="text/javascript",f.src=a+L.esri.Util.serialize(b),f.id=e,L.esri._callback[e]=function(a){d?c.call(d,a):c(a),document.body.removeChild(f),delete L.esri._callback[e]},document.body.appendChild(f)}},L.esri.get=L.esri.Support.CORS?L.esri.RequestHandlers.CORS:L.esri.RequestHandlers.JSONP,L.esri.Util={trim:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},cleanUrl:function(a){return a=L.esri.Util.trim(a),"/"!==a[a.length-1]&&(a+="/"),a.match(/^http:/)&&window.location.protocol.match(/^https:/)&&a.replace("http:","https:"),a},serialize:function(a){var b="?";for(var c in a)if(a.hasOwnProperty(c)){var d=c,e=a[c];b+=encodeURIComponent(d),b+="=",b+=encodeURIComponent(e),b+="&"}return b.substring(0,b.length-1)},indexOf:function(a,b,c){if(c=c||0,a.indexOf)return a.indexOf(b,c);for(var d=c,e=a.length;e>d;d++)if(a[d]===b)return d;return-1},extentToBounds:function(a){var b=new L.LatLng(a.xmin,a.ymin),c=new L.LatLng(a.xmax,a.ymin);return new L.LatLngBounds(b,c)},boundsToExtent:function(a){return{xmin:a.getSouthWest().lng,ymin:a.getSouthWest().lat,xmax:a.getNorthEast().lng,ymax:a.getNorthEast().lat,spatialReference:{wkid:4326}}},boundsToEnvelope:function(a){var b=L.esri.Util.boundsToExtent(a);return{x:b.xmin,y:b.ymin,w:Math.abs(b.xmin-b.ymax),h:Math.abs(b.ymin-b.ymax)}}},L.esri.Mixins={identifiableLayer:{identify:function(a,b,c){var d,e={sr:"4265",mapExtent:JSON.stringify(L.esri.Util.boundsToExtent(this._map.getBounds())),tolerance:3,geometryType:"esriGeometryPoint",imageDisplay:"800,600,96",geometry:JSON.stringify({x:a.lng,y:a.lat,spatialReference:{wkid:4265}})};"function"==typeof b&&"undefined"==typeof c?(c=b,d=e):"object"==typeof b&&(b.layerDefs&&(b.layerDefs=this.parseLayerDefs(b.layerDefs)),d=L.Util.extend(e,b)),L.esri.get(this._url+"/identify",d,c)},parseLayerDefs:function(a){return a instanceof Array?"":"object"==typeof a?JSON.stringify(a):a}}},L.esri.BasemapLayer=L.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Street_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Topographic:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Topo_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Oceans:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/Ocean_Basemap?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},NationalGeographic:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Gray:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Copyright: &copy;2013 Esri, DeLorme, NAVTEQ</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},GrayLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19}},Imagery:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},ImageryLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19}}}},initialize:function(a,b){var c;
-if("object"==typeof a&&a.urlTemplate&&a.options)c=a;else{if("string"!=typeof a||!L.esri.BasemapLayer.TILES[a])throw new Error("L.esri.BasemapLayer: Invalid parameter. Use one of 'Streets', 'Topographic', 'Oceans', 'NationalGeographic', 'Gray', 'GrayLabels', 'Imagery' or 'ImageryLabels'");c=L.esri.BasemapLayer.TILES[a]}var d=L.Util.extend(c.options,b),e=L.esri.Util.cleanUrl(c.urlTemplate);if(L.TileLayer.prototype.initialize.call(this,e,L.Util.setOptions(this,d)),c.attributionUrl){var f=L.esri.Util.cleanUrl(c.attributionUrl);this.dynamicAttribution=!0,this.getAttributionData(f)}},dynamicAttribution:!1,bounds:null,zoom:null,handleTileUpdates:function(a){var b,c;"load"===a.type&&(b=this._map.getBounds(),c=this._map.getZoom()),("viewreset"===a.type||"dragend"===a.type||"zoomend"===a.type)&&(b=a.target.getBounds(),c=a.target.getZoom()),this.attributionBoundingBoxes&&b&&c&&(b.equals(this.bounds)&&c===this.zoom||(this.bounds=b,this.zoom=c,this.updateMapAttribution()))},onAdd:function(a){L.TileLayer.prototype.onAdd.call(this,a),this.dynamicAttribution&&(this.on("load",this.handleTileUpdates,this),this._map.on("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.on("resize",this.resizeAttribution,this)},resizeAttribution:function(){var a=this._map.getSize().x;this.getAttributionLogo().style.display=600>a?"none":"block",this.getAttributionSpan().style.maxWidth=.75*a+"px"},onRemove:function(a){this.dynamicAttribution&&(this.off("load",this.handleTileUpdates,this),this._map.off("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.off("resize",this.resizeAttribution,this),L.TileLayer.prototype.onRemove.call(this,a)},getAttributionData:function(a){this.attributionBoundingBoxes=[],L.esri.get(a,{},L.bind(this.processAttributionData,this))},processAttributionData:function(a){for(var b=0;b<a.contributors.length;b++)for(var c=a.contributors[b],d=0;d<c.coverageAreas.length;d++){var e=c.coverageAreas[d],f=new L.LatLng(e.bbox[0],e.bbox[1]),g=new L.LatLng(e.bbox[2],e.bbox[3]);this.attributionBoundingBoxes.push({attribution:c.attribution,score:e.score,bounds:new L.LatLngBounds(f,g),minZoom:e.zoomMin,maxZoom:e.zoomMax})}this.attributionBoundingBoxes.sort(function(a,b){return a.score<b.score?-1:a.score>b.score?1:0}),this.bounds&&this.updateMapAttribution()},getAttributionSpan:function(){return this._map._container.querySelectorAll(".esri-attributions")[0]},getAttributionLogo:function(){return this._map._container.querySelectorAll(".esri-attribution-logo")[0]},updateMapAttribution:function(){for(var a="",b=0;b<this.attributionBoundingBoxes.length;b++){var c=this.attributionBoundingBoxes[b];if(this.bounds.intersects(c.bounds)&&this.zoom>=c.minZoom&&this.zoom<=c.maxZoom){var d=this.attributionBoundingBoxes[b].attribution;-1===a.indexOf(d)&&(a.length>0&&(a+=", "),a+=d)}}this.getAttributionSpan().innerHTML=a,this.resizeAttribution()}}),L.esri.basemapLayer=function(a,b){return new L.esri.BasemapLayer(a,b)},L.esri.FeatureLayer=L.GeoJSON.extend({options:{cellSize:512,queryWhilePanning:L.Browser.ie||L.Browser.mobile?!1:!0},initialize:function(a,b){this.index=new Terraformer.RTree,this.url=L.esri.Util.cleanUrl(a),L.Util.setOptions(this,b),L.GeoJSON.prototype.initialize.call(this,[],b)},onAdd:function(a){L.LayerGroup.prototype.onAdd.call(this,a),this._initializeVirtualGrid(a)},onRemove:function(a){L.LayerGroup.prototype.onRemove.call(this,a),this._destroyVirtualGrid(a)},update:function(a){var b=L.esri.Util.boundsToEnvelope(a.target.getBounds());this.index.search(b).then(L.Util.bind(function(a){this.eachLayer(L.Util.bind(function(b){var c=b.feature.id;this.setLayerVisibility(b,L.esri.Util.indexOf(a,c)>=0)},this))},this))},render:function(a){if(a.objectIdFieldName&&a.features.length&&!a.error)for(var b=a.objectIdFieldName,c=a.features.length-1;c>=0;c--){var d=a.features[c],e=d.attributes[b];if(!this._layers[e]){var f=Terraformer.ArcGIS.parse(d);f.id=e,this.index.insert(f,e),this.addData(f)}}},setLayerVisibility:function(a,b){var c=b?"block":"none";if(a._icon&&(a._icon.style.display=c),a._shadow&&(a._shadow.style.display=c),a._layers)for(var d in a._layers)a._layers.hasOwnProperty(d)&&(a._layers[d]._container.style.display=c)},_initializeVirtualGrid:function(a){this._map=a;var b=this.options.queryWhilePanning?"move":"moveend";a.on("zoomend",this._zoomHandler,this),a.on("resize",this._resizeHandler,this),a.on(b,this.update,this),a.on(b,this._moveHandler,this),this._resetGrid(a.getBounds())},_destroyVirtualGrid:function(a){a.off("viewreset moveend",this.update,this),a.off("moveend",this._moveHandler,this),a.off("zoomend",this._zoomHandler,this),a.off("resize",this._resizeHandler,this)},_moveHandler:function(a){this._requestFeatures(a.target.getBounds())},_zoomHandler:function(a){this._resetGrid(a.target.getBounds())},_resizeHandler:function(){this._setupSize()},_setupSize:function(){this._rows=Math.ceil(this._map.getSize().x/this._cellSize),this._cols=Math.ceil(this._map.getSize().y/this._cellSize)},_resetGrid:function(a){this._origin=this._map.project(a.getNorthWest()),this._cellSize=this.options.cellSize,this._setupSize(),this._loadedCells=[],this._requestFeatures(a)},_requestFeatures:function(a){for(var b=this._cellsInBounds(a),c=0;c<b.length;c++){var d=b[c];-1===L.esri.Util.indexOf(this._loadedCells,d.id)&&(L.esri.get(this.url+"query",{geometryType:"esriGeometryEnvelope",geometry:JSON.stringify(L.esri.Util.boundsToExtent(d.bounds)),outFields:"*",outSr:4326},this.render,this),this._loadedCells.push(d.id))}},_cellsInBounds:function(a){for(var b=this._map.project(a.getNorthWest()),c=a.getCenter(),d=this._origin.x-b.x,e=this._origin.y-b.y,f=Math.round(d/this._cellSize),g=Math.round(e/this._cellSize),h=[],i=0;i<=this._rows;i++)for(var j=0;j<=this._cols;j++){var k=i-f,l=j-g,m=this._cellExtent(k,l),n=k+":"+l;h.push({id:n,bounds:m,distance:m.getCenter().distanceTo(c)})}return h.sort(function(a,b){return a.distance-b.distance}),h},_cellExtent:function(a,b){var c=this._cellPoint(a,b),d=this._cellPoint(a-1,b-1),e=this._map.unproject(c),f=this._map.unproject(d);return new L.LatLngBounds(f,e)},_cellPoint:function(a,b){var c=this._origin.x+a*this._cellSize,d=this._origin.y+b*this._cellSize;return new L.Point(c,d)}}),L.esri.featureLayer=function(a,b){return new L.esri.FeatureLayer(a,b)},L.esri.TiledMapLayer=L.TileLayer.extend({includes:L.esri.Mixins.identifiableLayer,initialize:function(a,b){b=b||{},this.serviceUrl=L.esri.Util.cleanUrl(a),this.tileUrl=this.serviceUrl+"tile/{z}/{y}/{x}",this.tileUrl.match("://tiles.arcgis.com")&&(this.tileUrl=this.tileUrl.replace("://tiles.arcgis.com","://tiles{s}.arcgis.com"),b.subdomains=["1","2","3","4"]),L.TileLayer.prototype.initialize.call(this,this.tileUrl,b)}}),L.esri.tiledMapLayer=function(a,b){return new L.esri.TiledMapLayer(a,b)},/*!
+!function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"function"==typeof define&&define.amd&&define(b),"object"==typeof window&&(a.Terraformer=b())}(this,function(){function a(){this._thens=[]}function b(){var a=Array.prototype.slice.apply(arguments);void 0!==typeof console&&console.warn&&console.warn.apply(console,a)}function c(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function d(a){switch(a.type){case"Point":return[a.coordinates[0],a.coordinates[1],a.coordinates[0],a.coordinates[1]];case"MultiPoint":return g(a.coordinates);case"LineString":return g(a.coordinates);case"MultiLineString":return e(a.coordinates);case"Polygon":return e(a.coordinates);case"MultiPolygon":return f(a.coordinates);case"Feature":return d(a.geometry);case"FeatureCollection":return h(a);case"GeometryCollection":return i(a);default:throw new Error("Unknown type: "+a.type)}}function e(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++){var i=g[h],j=i[0],k=i[1];null===b?b=j:b>j&&(b=j),null===c?c=j:j>c&&(c=j),null===d?d=k:d>k&&(d=k),null===e?e=k:k>e&&(e=k)}return[b,d,c,e]}function f(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++)for(var g=a[f],h=0;h<g.length;h++)for(var i=g[h],j=0;j<i.length;j++){var k=i[j],l=k[0],m=k[1];null===b?b=l:b>l&&(b=l),null===c?c=l:l>c&&(c=l),null===d?d=m:d>m&&(d=m),null===e?e=m:m>e&&(e=m)}return[b,d,c,e]}function g(a){for(var b=null,c=null,d=null,e=null,f=0;f<a.length;f++){var g=a[f],h=g[0],i=g[1];null===b?b=h:b>h&&(b=h),null===c?c=h:h>c&&(c=h),null===d?d=i:d>i&&(d=i),null===e?e=i:i>e&&(e=i)}return[b,d,c,e]}function h(a){for(var b,c=[],e=a.features.length-1;e>=0;e--)b=d(a.features[e].geometry),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function i(a){for(var b,c=[],e=a.geometries.length-1;e>=0;e--)b=d(a.geometries[e]),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function j(a){var b=d(a);return{x:b[0],y:b[1],w:Math.abs(b[0]-b[2]),h:Math.abs(b[1]-b[3])}}function k(a){return a*W}function l(a){return a*X}function m(a,b){for(var c=0;c<a.length;c++)"number"==typeof a[c][0]&&(a[c]=b(a[c])),"object"==typeof a[c]&&(a[c]=m(a[c],b));return a}function n(a){var b=a[0],c=a[1];return[k(b/V)-360*Math.floor((k(b/V)+180)/360),k(Math.PI/2-2*Math.atan(Math.exp(-1*c/V)))]}function o(a){var b=a[0],c=Math.max(Math.min(a[1],89.99999),-89.99999);return[l(b)*V,V/2*Math.log((1+Math.sin(l(c)))/(1-Math.sin(l(c))))]}function p(a,b,c){if("Point"===a.type)a.coordinates=b(a.coordinates);else if("Feature"===a.type)a.geometry=p(a.geometry,b,!0);else if("FeatureCollection"===a.type)for(var d=0;d<a.features.length;d++)a.features[d]=p(a.features[d],b,!0);else if("GeometryCollection"===a.type)for(var e=0;e<a.geometries.length;e++)a.geometries[e]=p(a.geometries[e],b,!0);else a.coordinates=m(a.coordinates,b);return c||b===o&&(a.crs=Y),b===n&&delete a.crs,a}function q(a){return p(a,o)}function r(a){return p(a,n)}function s(a,b){return b>a?-1:a>b?1:0}function t(a,b,c){return s((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]),0)}function u(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}function v(a,b){var c=b;for(var d in a){var e=t(b,c,a[d]);(-1===e||0===e&&u(b,a[d])>u(b,c))&&(c=a[d])}return c}function w(a){function b(a,b){return a[0]-b[0]>a[1]-b[1]?1:a[0]-b[0]<a[1]-b[1]?-1:0}if(0===a.length)return[];if(1===a.length)return a;for(var c=[a.sort(b)[0]],d=0;d<c.length;d++){var e=v(a,c[d]);e!==c[0]&&c.push(e)}return c}function x(a,b){for(var c=!1,d=-1,e=a.length,f=e-1;++d<e;f=d)(a[d][1]<=b[1]&&b[1]<a[f][1]||a[f][1]<=b[1]&&b[1]<a[d][1])&&b[0]<(a[f][0]-a[d][0])*(b[1]-a[d][1])/(a[f][1]-a[d][1])+a[d][0]&&(c=!0);return c}function y(a,b){if(a&&a.length){if(1===a.length)return x(a[0],b);if(x(a[0],b)){for(var c=1;c<a.length;c++)if(x(a[c],b))return!1;return!0}return!1}return!1}function z(a,b,c,d){var e=(d[0]-c[0])*(a[1]-c[1])-(d[1]-c[1])*(a[0]-c[0]),f=(b[0]-a[0])*(a[1]-c[1])-(b[1]-a[1])*(a[0]-c[0]),g=(d[1]-c[1])*(b[0]-a[0])-(d[0]-c[0])*(b[1]-a[1]);if(0!==g){var h=e/g,i=f/g;if(h>=0&&1>=h&&i>=0&&1>=i)return!0}return!1}function A(a,b){for(var c=0;c<a.length-1;c++)for(var d=0;d<b.length-1;d++)if(z(a[c],a[c+1],b[d],b[d+1]))return!0;return!1}function B(a,b){for(var c=0;c<b.length;c++)for(var d=b[c],e=0;e<d.length-1;e++)for(var f=0;f<a.length-1;f++)if(z(d[e],d[e+1],a[f],a[f+1]))return!0;return!1}function C(a,b){for(var c=0;c<a.length;c++)if(B(a[c],b))return!0;return!1}function D(a,b){for(var c=0;c<b.length;c++)return B(a,b[c])?!0:!1}function E(a,b){for(var c=0;c<a.length;c++)return D(a[c],b)?!0:!1}function F(a,b){for(var c=0;c<a.length;c++)return E(a[c],b)?!0:!1}function G(a){for(var b=[],c=0;c<a.length;c++){var d=a[c].slice();H(d[0],d[d.length-1])===!1&&d.push(d[0]),b.push(d)}return b}function H(a,b){for(var c=0;c<a.length;c++)for(var d=0;d<b.length;d++)if(a[c]!==b[d])return!1;return!0}function I(a){if(a)switch(a.type){case"Point":return new J(a);case"MultiPoint":return new K(a);case"LineString":return new L(a);case"MultiLineString":return new M(a);case"Polygon":return new N(a);case"MultiPolygon":return new O(a);case"Feature":return new P(a);case"FeatureCollection":return new Q(a);case"GeometryCollection":return new R(a);default:throw new Error("Unknown type: "+a.type)}}function J(a){var b=Array.prototype.slice.call(arguments);if(a&&"Point"===a.type&&a.coordinates)c(this,a);else if(a&&Array.isArray(a))this.coordinates=a;else{if(!(b.length>=2))throw"Terraformer: invalid input for Terraformer.Point";this.coordinates=b}this.type="Point"}function K(a){if(a&&"MultiPoint"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.MultiPoint";this.coordinates=a}this.type="MultiPoint"}function L(a){if(a&&"LineString"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.LineString";this.coordinates=a}this.type="LineString"}function M(a){if(a&&"MultiLineString"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.MultiLineString";this.coordinates=a}this.type="MultiLineString"}function N(a){if(a&&"Polygon"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.Polygon";this.coordinates=a}this.type="Polygon"}function O(a){if(a&&"MultiPolygon"===a.type&&a.coordinates)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.MultiPolygon";this.coordinates=a}this.type="MultiPolygon"}function P(a){if(a&&"Feature"===a.type&&a.geometry)c(this,a);else{if(!(a&&a.type&&a.coordinates))throw"Terraformer: invalid input for Terraformer.Feature";this.geometry=a}this.type="Feature"}function Q(a){if(a&&"FeatureCollection"===a.type&&a.features)c(this,a);else{if(!Array.isArray(a))throw"Terraformer: invalid input for Terraformer.FeatureCollection";this.features=a}this.type="FeatureCollection"}function R(a){if(a&&"GeometryCollection"===a.type&&a.geometries)c(this,a);else if(Array.isArray(a))this.geometries=a;else{if(!a.coordinates||!a.type)throw"Terraformer: invalid input for Terraformer.GeometryCollection";this.type="GeometryCollection",this.geometries=[a]}this.type="GeometryCollection"}function S(a,b,c){for(var d=o(a),e=c||64,f=b||250,g={type:"Polygon",coordinates:[[]]},h=1;e>=h;h++){var i=h*(360/e)*Math.PI/180;g.coordinates[0].push([d[0]+f*Math.cos(i),d[1]+f*Math.sin(i)])}return r(g)}function T(a,b,d){var e=d||64,f=b||250;if(!a||a.length<2||!f||!e)throw new Error("Terraformer: missing parameter for Terraformer.Circle");c(this,new P({type:"Feature",geometry:S(a,f,e),properties:{radius:f,center:a,steps:e}}))}var U={},V=6378137,W=57.29577951308232,X=.017453292519943,Y={type:"link",properties:{href:"http://spatialreference.org/ref/sr-org/6928/ogcwkt/",type:"ogcwkt"}},Z={type:"link",properties:{href:"http://spatialreference.org/ref/epsg/4326/ogcwkt/",type:"ogcwkt"}};a.prototype={then:function(a,b){return this._thens.push({resolve:a,reject:b}),this},resolve:function(a){return this._complete("resolve",a),this},reject:function(a){return this._complete("reject",a),this},_complete:function(a,b){this.then="resolve"===a?function(a){a(b)}:function(a,c){c(b)},this.resolve=this.reject=function(){throw new Error("Deferred already completed.")};for(var c=0;c<this._thens.length;c++){var d=this._thens[c];d[a]&&d[a](b)}delete this._thens}};var $=["length"];return I.prototype={toMercator:function(){return q(this)},toGeographic:function(){return r(this)},envelope:function(){var a=d(this);return{x:a[0],y:a[1],w:Math.abs(a[0]-a[2]),h:Math.abs(a[1]-a[3])}},bbox:function(){return d(this)},convexHull:function(){var a,b,c=[];if("Point"===this.type)return this.coordinates&&this.coordinates.length>0?[this.coordinates]:[];if("LineString"===this.type||"MultiPoint"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return[];c=this.coordinates}else if("Polygon"===this.type||"MultiLineString"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return[];for(a=0;a<this.coordinates.length;a++)c=c.concat(this.coordinates[a])}else{if("MultiPolygon"!==this.type)throw new Error("Unable to get convex hull of "+this.type);if(!(this.coordinates&&this.coordinates.length>0))return[];for(a=0;a<this.coordinates.length;a++)for(b=0;b<this.coordinates[a].length;b++)c=c.concat(this.coordinates[a][b])}return w(c)},toJSON:function(){var a={};for(var b in this)this.hasOwnProperty(b)&&this[b]&&$.indexOf(b)&&(a[b]=this[b]);return a.bbox=d(this),a},intersects:function(a){if("Feature"===a.type&&(a=a.geometry),"LineString"===this.type){if("LineString"===a.type)return A(this.coordinates,a.coordinates);if("MultiLineString"===a.type)return B(this.coordinates,a.coordinates);if("Polygon"===a.type)return B(this.coordinates,G(a.coordinates));if("MultiPolygon"===a.type)return D(this.coordinates,a.coordinates)}else if("MultiLineString"===this.type){if("LineString"===a.type)return B(a.coordinates,this.coordinates);if("Polygon"===a.type||"MultiLineString"===a.type)return C(this.coordinates,a.coordinates);if("MultiPolygon"===a.type)return E(this.coordinates,a.coordinates)}else if("Polygon"===this.type){if("LineString"===a.type)return B(a.coordinates,G(this.coordinates));if("MultiLineString"===a.type)return C(G(this.coordinates),a.coordinates);if("Polygon"===a.type)return C(G(this.coordinates),G(a.coordinates));if("MultiPolygon"===a.type)return E(G(this.coordinates),a.coordinates)}else if("MultiPolygon"===this.type){if("LineString"===a.type)return D(a.coordinates,this.coordinates);if("Polygon"===a.type||"MultiLineString"===a.type)return E(G(a.coordinates),this.coordinates);if("MultiPolygon"===a.type)return F(this.coordinates,a.coordinates)}else if("Feature"===this.type){var c=new I(this.geometry);return c.intersects(a)}return b("Type "+this.type+" to "+a.type+" intersection is not supported by intersects"),!1}},J.prototype=new I,J.prototype.constructor=J,K.prototype=new I,K.prototype.constructor=K,K.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates]);return this},K.prototype.addPoint=function(a){return this.coordinates.push(a),this},K.prototype.insertPoint=function(a,b){return this.coordinates.splice(b,0,a),this},K.prototype.removePoint=function(a){return"number"==typeof a?this.coordinates.splice(a,1):this.coordinates.splice(this.coordinates.indexOf(a),1),this},K.prototype.get=function(a){return new J(this.coordinates[a])},L.prototype=new I,L.prototype.constructor=L,L.prototype.addVertex=function(a){return this.coordinates.push(a),this},L.prototype.insertVertex=function(a,b){return this.coordinates.splice(b,0,a),this},L.prototype.removeVertex=function(a){return this.coordinates.splice(a,1),this},M.prototype=new I,M.prototype.constructor=M,M.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},M.prototype.get=function(a){return new L(this.coordinates[a])},N.prototype=new I,N.prototype.constructor=N,N.prototype.addVertex=function(a){return this.coordinates[0].push(a),this},N.prototype.insertVertex=function(a,b){return this.coordinates[0].splice(b,0,a),this},N.prototype.removeVertex=function(a){return this.coordinates[0].splice(a,1),this},N.prototype.contains=function(a){if("Point"===a.type)return y(this.coordinates,a.coordinates);if("Polygon"===a.type){if(a.coordinates.length>0&&a.coordinates[0].length>0&&y(this.coordinates,a.coordinates[0][0])===!0&&this.intersects(a)===!1)return!0}else if("MultiPolygon"===a.type&&a.coordinates.length>0)for(var b=0;b<a.coordinates.length;b++)if(a.coordinates[b][0].length>0&&y(this.coordinates,a.coordinates[b][0][0])===!0&&this.intersects({type:"Polygon",coordinates:a.coordinates[b]})===!1)return!0;return!1},O.prototype=new I,O.prototype.constructor=O,O.prototype.forEach=function(a){for(var b=0;b<this.coordinates.length;b++)a.apply(this,[this.coordinates[b],b,this.coordinates])},O.prototype.contains=function(a){if("Point"!==a.type)throw new Error("Only points are supported");for(var b=0;b<this.coordinates.length;b++)if(y(this.coordinates[b],a.coordinates))return!0;return!1},O.prototype.get=function(a){return new N(this.coordinates[a])},P.prototype=new I,P.prototype.constructor=P,P.prototype.contains=function(a){if("Point"!==a.type)throw new Error("Only points are supported");if(!this.geometry.type.match(/Polygon/))throw new Error("Only features containing Polygons and MultiPolygons are supported");if("MultiPolygon"===this.geometry.type)for(var b=0;b<this.geometry.coordinates.length;b++)if(y(this.geometry.coordinates[b],a.coordinates))return!0;return"Polygon"===this.geometry.type?y(this.geometry.coordinates,a.coordinates):!1},Q.prototype=new I,Q.prototype.constructor=Q,Q.prototype.forEach=function(a){for(var b=0;b<this.features.length;b++)a.apply(this,[this.features[b],b,this.features])},Q.prototype.get=function(a){var b;return this.forEach(function(c){c.id===a&&(b=c)}),new P(b)},R.prototype=new I,R.prototype.constructor=R,R.prototype.forEach=function(a){for(var b=0;b<this.geometries.length;b++)a.apply(this,[this.geometries[b],b,this.geometries])},R.prototype.get=function(a){return new I(this.geometries[a])},T.prototype=new I,T.prototype.constructor=T,T.prototype.recalculate=function(){return this.geometry=S(this.properties.center,this.properties.radius,this.properties.steps),this},T.prototype.center=function(a){return a&&(this.properties.center=a,this.recalculate()),this.properties.center},T.prototype.radius=function(a){return a&&(this.properties.radius=a,this.recalculate()),this.properties.radius},T.prototype.steps=function(a){return a&&(this.properties.steps=a,this.recalculate()),this.properties.steps},T.prototype.contains=function(a){if("Point"!==a.type)throw new Error("Only points are supported");return y(this.geometry.coordinates,a.coordinates)},T.prototype.toJSON=function(){var a=I.prototype.toJSON.call(this);return a},U.Primitive=I,U.Point=J,U.MultiPoint=K,U.LineString=L,U.MultiLineString=M,U.Polygon=N,U.MultiPolygon=O,U.Feature=P,U.FeatureCollection=Q,U.GeometryCollection=R,U.Circle=T,U.toMercator=q,U.toGeographic=r,U.Tools={},U.Tools.positionToMercator=o,U.Tools.positionToGeographic=n,U.Tools.applyConverter=p,U.Tools.toMercator=q,U.Tools.toGeographic=r,U.Tools.createCircle=S,U.Tools.calculateBounds=d,U.Tools.calculateEnvelope=j,U.Tools.coordinatesContainPoint=x,U.Tools.polygonContainsPoint=y,U.Tools.arrayIntersectsArray=A,U.Tools.coordinatesContainPoint=x,U.Tools.convexHull=w,U.MercatorCRS=Y,U.GeographicCRS=Z,U.Deferred=a,U}),function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"function"==typeof define&&define.amd&&define(["terraformer/terraformer"],b),"undefined"==typeof a.Terraformer&&(a.Terraformer={}),a.Terraformer.RTree=b().RTree}(this,function(){function a(a){return"[object Array]"===Object.prototype.toString.call(a)}var Terraformer,b={};"object"==typeof this.navigator&&(Terraformer=this.Terraformer),"object"==typeof module&&"object"==typeof module.exports&&(Terraformer=require("terraformer")),arguments[0]&&"function"==typeof define&&define.amd&&(Terraformer=arguments[0]);var c=function(b){var d=3,e=6;isNaN(b)||(d=Math.floor(b/2),e=b),this.min_width=d,this.max_width=e;var f={x:0,y:0,w:0,h:0,id:"root",nodes:[]};!function(){var a={};return function(b){var c=0;return b in a?c=a[b]++:a[b]=0,b+"_"+c}}(),c.Rectangle.squarified_ratio=function(a,b,c){var d=(a+b)/2,e=a*b,f=e/(d*d);return e*c/f};var g=function(a,b,e){var f=[],g=[],h=[],i=1;if(!a||!c.Rectangle.overlap_rectangle(a,e))return h;var j={x:a.x,y:a.y,w:a.w,h:a.h,target:b};g.push(e.nodes.length),f.push(e);do{var k=f.pop(),l=g.pop()-1;if("target"in j)for(;l>=0;){var o=k.nodes[l];if(c.Rectangle.overlap_rectangle(j,o)){if(j.target&&"leaf"in o&&o.leaf===j.target||!j.target&&("leaf"in o||c.Rectangle.contains_rectangle(o,j))){"nodes"in o?(h=m(o,!0,[],o),k.nodes.splice(l,1)):h=k.nodes.splice(l,1),c.Rectangle.make_MBR(k.nodes,k),delete j.target,k.nodes.length<d&&(j.nodes=m(k,!0,[],k));break}"nodes"in o&&(i+=1,g.push(l),f.push(k),k=o,l=o.nodes.length)}l-=1}else if("nodes"in j){k.nodes.splice(l+1,1),k.nodes.length>0&&c.Rectangle.make_MBR(k.nodes,k);for(var p=0;p<j.nodes.length;p++)n(j.nodes[p],k);j.nodes.length=0,0===f.length&&k.nodes.length<=1?(j.nodes=m(k,!0,j.nodes,k),k.nodes.length=0,f.push(k),g.push(1)):f.length>0&&k.nodes.length<d?(j.nodes=m(k,!0,j.nodes,k),k.nodes.length=0):delete j.nodes}else c.Rectangle.make_MBR(k.nodes,k);i-=1}while(f.length>0);return h},h=function(a,b){var d,e=-1,f=[];f.push(b);var g=b.nodes;do{-1!==e&&(f.push(g[e]),g=g[e].nodes,e=-1);for(var h=g.length-1;h>=0;h--){var i=g[h];if("leaf"in i){e=-1;break}var j=c.Rectangle.squarified_ratio(i.w,i.h,i.nodes.length+1),k=Math.max(i.x+i.w,a.x+a.w)-Math.min(i.x,a.x),l=Math.max(i.y+i.h,a.y+a.h)-Math.min(i.y,a.y),m=c.Rectangle.squarified_ratio(k,l,i.nodes.length+2);(0>e||Math.abs(m-j)<d)&&(d=Math.abs(m-j),e=h)}}while(-1!==e);return f},i=function(a){for(var b=k(a);a.length>0;)j(a,b[0],b[1]);return b},j=function(a,b,e){for(var f,g,h,i=c.Rectangle.squarified_ratio(b.w,b.h,b.nodes.length+1),j=c.Rectangle.squarified_ratio(e.w,e.h,e.nodes.length+1),k=a.length-1;k>=0;k--){var l=a[k],m={};m.x=Math.min(b.x,l.x),m.y=Math.min(b.y,l.y),m.w=Math.max(b.x+b.w,l.x+l.w)-m.x,m.h=Math.max(b.y+b.h,l.y+l.h)-m.y;var n=Math.abs(c.Rectangle.squarified_ratio(m.w,m.h,b.nodes.length+2)-i),o={};o.x=Math.min(e.x,l.x),o.y=Math.min(e.y,l.y),o.w=Math.max(e.x+e.w,l.x+l.w)-o.x,o.h=Math.max(e.y+e.h,l.y+l.h)-o.y;var p=Math.abs(c.Rectangle.squarified_ratio(o.w,o.h,e.nodes.length+2)-j);(!g||!f||Math.abs(p-n)<f)&&(g=k,f=Math.abs(p-n),h=n>p?e:b)}var q=a.splice(g,1)[0];b.nodes.length+a.length+1<=d?(b.nodes.push(q),c.Rectangle.expand_rectangle(b,q)):e.nodes.length+a.length+1<=d?(e.nodes.push(q),c.Rectangle.expand_rectangle(e,q)):(h.nodes.push(q),c.Rectangle.expand_rectangle(h,q))},k=function(a){for(var b,c,d=a.length-1,e=0,f=a.length-1,g=0,h=a.length-2;h>=0;h--){var i=a[h];i.x>a[e].x?e=h:i.x+i.w<a[d].x+a[d].w&&(d=h),i.y>a[g].y?g=h:i.y+i.h<a[f].y+a[f].h&&(f=h)}var j=Math.abs(a[d].x+a[d].w-a[e].x),k=Math.abs(a[f].y+a[f].h-a[g].y);return j>k?d>e?(b=a.splice(d,1)[0],c=a.splice(e,1)[0]):(c=a.splice(e,1)[0],b=a.splice(d,1)[0]):f>g?(b=a.splice(f,1)[0],c=a.splice(g,1)[0]):(c=a.splice(g,1)[0],b=a.splice(f,1)[0]),[{x:b.x,y:b.y,w:b.w,h:b.h,nodes:[b]},{x:c.x,y:c.y,w:c.w,h:c.h,nodes:[c]}]},l=function(a,b){return a.nodes=b.nodes,a.x=b.x,a.y=b.y,a.w=b.w,a.h=b.h,a},m=function(a,b,d,e){var f=[];if(!c.Rectangle.overlap_rectangle(a,e))return d;f.push(e.nodes);do for(var g=f.pop(),h=g.length-1;h>=0;h--){var i=g[h];c.Rectangle.overlap_rectangle(a,i)&&("nodes"in i?f.push(i.nodes):"leaf"in i&&(b?d.push(i):d.push(i.leaf)))}while(f.length>0);return d},n=function(b,d){var f;if(0===d.nodes.length)return d.x=b.x,d.y=b.y,d.w=b.w,d.h=b.h,d.nodes.push(b),void 0;var g=h(b,d),j=b;do{if(f&&"nodes"in f&&0===f.nodes.length){var k=f;f=g.pop();for(var l=0;l<f.nodes.length;l++)if(f.nodes[l]===k||0===f.nodes[l].nodes.length){f.nodes.splice(l,1);break}}else f=g.pop();if("leaf"in j||"nodes"in j||a(j)){if(a(j)){for(var m=0;m<j.length;m++)c.Rectangle.expand_rectangle(f,j[m]);f.nodes=f.nodes.concat(j)}else c.Rectangle.expand_rectangle(f,j),f.nodes.push(j);if(f.nodes.length<=e)j={x:f.x,y:f.y,w:f.w,h:f.h};else{var n=i(f.nodes);j=n,g.length<1&&(f.nodes.push(n[0]),g.push(f),j=n[1])}}else c.Rectangle.expand_rectangle(f,j),j={x:f.x,y:f.y,w:f.w,h:f.h}}while(g.length>0)};this.serialize=function(a){var b=new Terraformer.Deferred;return a&&b.then(function(b){a(null,b)},function(b){a(b,null)}),b.resolve(f),b},this.deserialize=function(a,b,c){var d=Array.prototype.slice.call(arguments),e=new Terraformer.Deferred;switch(d.length){case 1:b=f;break;case 2:"function"==typeof d[1]&&(b=f,c=d[1])}return c&&e.then(function(a){c(null,a)},function(a){c(a,null)}),e.resolve(l(b,a)),e},this.search=function(a,b){var c;if(a.type){var d=Terraformer.Tools.calculateBounds(a);c={x:d[0],y:d[1],w:Math.abs(d[0]-d[2]),h:Math.abs(d[1]-d[3])}}else c=a;var e=new Terraformer.Deferred,g=[c,!1,[],f];if(void 0===c)throw"Wrong number of arguments. RT.Search requires at least a bounding rectangle.";return b&&e.then(function(a){b(null,a)},function(a){b(a,null)}),e.resolve(m.apply(this,g)),e},this.remove=function(a,b,c){var d=Array.prototype.slice.call(arguments),e=new Terraformer.Deferred;if(1===d.length&&d.push(!1),3===d.length&&(c=d.pop(),e.then(function(a){c(null,a)},function(a){c(a,null)})),d[0].type){var h=Terraformer.Tools.calculateBounds(a);d[0]={x:h[0],y:h[1],w:Math.abs(h[0]-h[2]),h:Math.abs(h[1]-h[3])}}if(d.push(f),b===!1){var i=0,j=[];do i=j.length,j=j.concat(g.apply(this,d));while(i!==j.length);return j}return g.apply(this,d)},this.insert=function(a,b,c){var d;if(a.type){var e=Terraformer.Tools.calculateBounds(a);d={x:e[0],y:e[1],w:Math.abs(e[0]-e[2]),h:Math.abs(e[1]-e[3])}}else d=a;var g=new Terraformer.Deferred;if(arguments.length<2)throw"Wrong number of arguments. RT.Insert requires at least a bounding rectangle or GeoJSON and an object.";return c&&g.then(function(a){c(null,a)},function(a){c(a,null)}),g.resolve(n({x:d.x,y:d.y,w:d.w,h:d.h,leaf:b},f)),g}};return c.Rectangle=function(a,b,c,d){var e,f,g,h,i,j;a.x?(e=a.x,g=a.y,0!==a.w&&!a.w&&a.x2?(i=a.x2-a.x,j=a.y2-a.y):(i=a.w,j=a.h),f=e+i,h=g+j):(e=a,g=b,i=c,j=d,f=e+i,h=g+j),this.x1=this.x=function(){return e},this.y1=this.y=function(){return g},this.x2=function(){return f},this.y2=function(){return h},this.w=function(){return i},this.h=function(){return j},this.toJSON=function(){return'{"x":'+e.toString()+', "y":'+g.toString()+', "w":'+i.toString()+', "h":'+j.toString()+"}"},this.overlap=function(a){return this.x()<a.x2()&&this.x2()>a.x()&&this.y()<a.y2()&&this.y2()>a.y()},this.expand=function(a){var b=Math.min(this.x(),a.x()),c=Math.min(this.y(),a.y());return i=Math.max(this.x2(),a.x2())-b,j=Math.max(this.y2(),a.y2())-c,e=b,g=c,this},this.setRect=function(a,b,c,d){var e,f,g,h,i,j;a.x?(e=a.x,g=a.y,0!==a.w&&!a.w&&a.x2?(i=a.x2-a.x,j=a.y2-a.y):(i=a.w,j=a.h),f=e+i,h=g+j):(e=a,g=b,i=c,j=d,f=e+i,h=g+j)}},c.Rectangle.overlap_rectangle=function(a,b){return a.x<b.x+b.w&&a.x+a.w>b.x&&a.y<b.y+b.h&&a.y+a.h>b.y},c.Rectangle.contains_rectangle=function(a,b){return a.x+a.w<=b.x+b.w&&a.x>=b.x&&a.y+a.h<=b.y+b.h&&a.y>=b.y},c.Rectangle.expand_rectangle=function(a,b){var c,d;return c=a.x<b.x?a.x:b.x,d=a.y<b.y?a.y:b.y,a.w=a.x+a.w>b.x+b.w?a.x+a.w-c:b.x+b.w-c,a.h=a.y+a.h>b.y+b.h?a.y+a.h-d:b.y+b.h-d,a.x=c,a.y=d,a},c.Rectangle.make_MBR=function(a,b){if(a.length<1)return{x:0,y:0,w:0,h:0};b?(b.x=a[0].x,b.y=a[0].y,b.w=a[0].w,b.h=a[0].h):b={x:a[0].x,y:a[0].y,w:a[0].w,h:a[0].h};for(var d=a.length-1;d>0;d--)c.Rectangle.expand_rectangle(b,a[d]);return b},b.RTree=c,b}),function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"function"==typeof define&&define.amd&&define(["terraformer/terraformer"],b),"object"==typeof a.navigator&&("undefined"==typeof a.Terraformer&&(a.Terraformer={}),a.Terraformer.ArcGIS=b())}(this,function(){function a(a){var b,c=0,d=0,e=a.length,f=a[d];for(d;e-1>d;d++)b=a[d+1],c+=(b[0]-f[0])*(b[1]+f[1]),f=b;return c>=0}function b(b){var c=[],d=b.shift();a(d)||d.reverse(),c.push(d);for(var e=0;e<b.length;e++){var f=b[e];a(f)&&d.reverse(),c.push(b[e])}return c}function c(a){for(var c=[],d=0;d<a.length;d++){for(var e=b(a[d]),f=e.length-1;f>=0;f--){var g=e[f];c.push(g)}c.push()}return c}function d(a,b){var c=Terraformer.Tools.arrayIntersectsArray(a,b),d=Terraformer.Tools.coordinatesContainPoint(a,b[0]);return!c&&d?!0:!1}function e(b){for(var c=[],e=[],f=0;f<b.length;f++){var g=b[f];if(a(g)){var h=[g];c.push(h)}else e.push(g)}for(;e.length;){for(var i=e.pop(),j=!1,k=c.length-1;k>=0;k--){var l=c[k][0];if(d(l,i)){c[k].push(i),j=!0;break}}j||c.push([i.reverse()])}return 1===c.length?{type:"Polygon",coordinates:c[0]}:{type:"MultiPolygon",coordinates:c}}function f(a){var b=JSON.parse(JSON.stringify(a)),c={};b.x&&b.y&&(c.type="Point",c.coordinates=[b.x,b.y]),b.points&&(c.type="MultiPoint",c.coordinates=b.points),b.paths&&(1===b.paths.length?(c.type="LineString",c.coordinates=b.paths[0]):(c.type="MultiLineString",c.coordinates=b.paths)),b.rings&&(c=e(b.rings)),b.geometry&&(c.type="Feature",c.geometry=f(b.geometry),c.properties=b.attributes||{});var d=b.geometry?b.geometry.spatialReference:b.spatialReference;return d&&102100===d.wkid&&(c=Terraformer.toGeographic(c)),new Terraformer.Primitive(c)}function g(a){var d,e=JSON.parse(JSON.stringify(a)),f={wkid:4326},h={};switch(e.type){case"Point":h.x=e.coordinates[0],h.y=e.coordinates[1],h.spatialReference=f;break;case"MultiPoint":h.points=e.coordinates,h.spatialReference=f;break;case"LineString":h.paths=[e.coordinates],h.spatialReference=f;break;case"MultiLineString":h.paths=e.coordinates,h.spatialReference=f;break;case"Polygon":h.rings=b(e.coordinates),h.spatialReference=f;break;case"MultiPolygon":h.rings=c(e.coordinates),h.spatialReference=f;break;case"Feature":h.geometry=g(e.geometry),h.attributes=e.properties;break;case"FeatureCollection":for(h=[],d=0;d<e.features.length;d++)h.push(g(e.features[d]));break;case"GeometryCollection":for(h=[],d=0;d<e.geometries.length;d++)h.push(g(e.geometries[d]))}return h}var Terraformer,h={};return"object"==typeof this.navigator&&(Terraformer=this.Terraformer),"object"==typeof module&&"object"==typeof module.exports&&(Terraformer=require("terraformer")),arguments[0]&&"function"==typeof define&&define.amd&&(Terraformer=arguments[0]),h.parse=f,h.convert=g,h}),L.esri={AttributionStyles:"line-height:9px; text-overflow:ellipsis; white-space:nowrap;overflow:hidden; display:inline-block;",LogoStyles:"position:absolute; top:-38px; right:2px;",_callback:{}},L.esri.Support={CORS:!!(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest)},L.esri.RequestHandlers={CORS:function(a,b,c,d){var e=new XMLHttpRequest;b.f="json",e.onreadystatechange=function(){var a;if(4===e.readyState){try{a=JSON.parse(e.responseText)}catch(b){a={error:"Could not parse response as JSON."}}d?c.call(d,a):c(a)}},e.open("GET",a+L.esri.Util.serialize(b),!0),e.send(null)},JSONP:function(a,b,c,d){var e="c"+(1e9*Math.random()).toString(36).replace(".","_");b.f="json",b.callback="L.esri._callback."+e;var f=document.createElement("script");f.type="text/javascript",f.src=a+L.esri.Util.serialize(b),f.id=e,L.esri._callback[e]=function(a){d?c.call(d,a):c(a),document.body.removeChild(f),delete L.esri._callback[e]},document.body.appendChild(f)}},L.esri.get=L.esri.Support.CORS?L.esri.RequestHandlers.CORS:L.esri.RequestHandlers.JSONP,L.esri.Util={debounce:function(a,b){var c=null;return function(){var d=this||d,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,e)},b)}},roundAwayFromZero:function(a){return a>0?Math.ceil(a):Math.floor(a)},trim:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},cleanUrl:function(a){return a=L.esri.Util.trim(a),"/"!==a[a.length-1]&&(a+="/"),a},serialize:function(a){var b="?";for(var c in a)if(a.hasOwnProperty(c)){var d=c,e=a[c];b+=encodeURIComponent(d),b+="=",b+=encodeURIComponent(e),b+="&"}return b.substring(0,b.length-1)},indexOf:function(a,b,c){if(c=c||0,a.indexOf)return a.indexOf(b,c);for(var d=c,e=a.length;e>d;d++)if(a[d]===b)return d;return-1},extentToBounds:function(a){var b=new L.LatLng(a.xmin,a.ymin),c=new L.LatLng(a.xmax,a.ymin);return new L.LatLngBounds(b,c)},boundsToExtent:function(a){return{xmin:a.getSouthWest().lng,ymin:a.getSouthWest().lat,xmax:a.getNorthEast().lng,ymax:a.getNorthEast().lat,spatialReference:{wkid:4326}}},boundsToEnvelope:function(a){var b=L.esri.Util.boundsToExtent(a);return{x:b.xmin,y:b.ymin,w:Math.abs(b.xmin-b.ymax),h:Math.abs(b.ymin-b.ymax)}}},L.esri.Mixins={},L.esri.Mixins.featureGrid={_initializeFeatureGrid:function(a){this._map=a,this._previousCells=[],this.center=this._map.getCenter(),this.origin=this._map.project(this.center),this._moveHandler=L.esri.Util.debounce(function(a){"zoomend"===a.type&&(this.origin=this._map.project(this.center),this._previousCells=[]),this._requestFeatures(a.target.getBounds())},this.options.debounce,this),a.on("zoomend resize move",this._moveHandler,this),this._requestFeatures(a.getBounds())},_destroyFeatureGrid:function(a){a.on("zoomend resize move",this._moveHandler,this)},_requestFeatures:function(a){for(var b=this._cellsWithin(a),c=0;c<b.length;c++){var d=b[c];L.esri.get(this.url+"query",{geometryType:"esriGeometryEnvelope",geometry:JSON.stringify(L.esri.Util.boundsToExtent(d.bounds)),outFields:"*",outSr:4326},this._render,this)}},_cellsWithin:function(a){for(var b=this._map.getSize(),c=this._map.project(this._map.getCenter()),d=a.pad(Math.min(this.options.cellSize/b.x,this.options.cellSize/b.y)),e=[],f=this._map.project(d.getNorthWest()),g=this._map.project(d.getSouthEast()),h=f.subtract(c).divideBy(this.options.cellSize),i=g.subtract(c).divideBy(this.options.cellSize),j=Math.round((this.origin.x-c.x)/this.options.cellSize),k=Math.round((this.origin.y-c.y)/this.options.cellSize),l=L.esri.Util.roundAwayFromZero(h.x)-j,m=L.esri.Util.roundAwayFromZero(i.x)-j,n=L.esri.Util.roundAwayFromZero(h.y)-k,o=L.esri.Util.roundAwayFromZero(i.y)-k,p=l;m>p;p++)for(var q=n;o>q;q++){var r="cell:"+p+":"+q,s=this._previousCells.indexOf(r)>=0;if(!s||!this.options.deduplicate){var t=this._cellExtent(p,q),u=t.getCenter(),v=u.distanceTo(t.getNorthWest()),w=u.distanceTo(this.center),x={row:p,col:q,id:r,center:u,bounds:t,distance:w,radius:v};e.push(x),this._previousCells.push(r)}}return e.sort(function(a,b){return a.distance-b.distance}),e},_cellExtent:function(a,b){var c=this._cellPoint(a,b),d=this._cellPoint(a+1,b+1),e=this._map.unproject(c),f=this._map.unproject(d);return L.latLngBounds(e,f)},_cellPoint:function(a,b){var c=this.origin.x+a*this.options.cellSize,d=this.origin.y+b*this.options.cellSize;return[c,d]}},L.esri.Mixins.identifiableLayer={identify:function(a,b,c){var d,e={sr:"4265",mapExtent:JSON.stringify(L.esri.Util.boundsToExtent(this._map.getBounds())),tolerance:3,geometryType:"esriGeometryPoint",imageDisplay:"800,600,96",geometry:JSON.stringify({x:a.lng,y:a.lat,spatialReference:{wkid:4265}})};"function"==typeof b&&"undefined"==typeof c?(c=b,d=e):"object"==typeof b&&(b.layerDefs&&(b.layerDefs=this.parseLayerDefs(b.layerDefs)),d=L.Util.extend(e,b)),L.esri.get(this._url+"/identify",d,c)},parseLayerDefs:function(a){return a instanceof Array?"":"object"==typeof a?JSON.stringify(a):a}},L.esri.BasemapLayer=L.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Street_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Topographic:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Topo_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Oceans:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/Ocean_Basemap?f=json",options:{minZoom:1,maxZoom:16,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},NationalGeographic:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Gray:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Copyright: &copy;2013 Esri, DeLorme, NAVTEQ</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},GrayLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16}},Imagery:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},ImageryLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19}}}},initialize:function(a,b){var c;
+if("object"==typeof a&&a.urlTemplate&&a.options)c=a;else{if("string"!=typeof a||!L.esri.BasemapLayer.TILES[a])throw new Error("L.esri.BasemapLayer: Invalid parameter. Use one of 'Streets', 'Topographic', 'Oceans', 'NationalGeographic', 'Gray', 'GrayLabels', 'Imagery' or 'ImageryLabels'");c=L.esri.BasemapLayer.TILES[a]}var d=L.Util.extend(c.options,b),e=L.esri.Util.cleanUrl(c.urlTemplate);if(L.TileLayer.prototype.initialize.call(this,e,L.Util.setOptions(this,d)),c.attributionUrl){var f=L.esri.Util.cleanUrl(c.attributionUrl);this.dynamicAttribution=!0,this.getAttributionData(f)}},dynamicAttribution:!1,bounds:null,zoom:null,handleTileUpdates:function(a){var b,c;"load"===a.type&&(b=this._map.getBounds(),c=this._map.getZoom()),("viewreset"===a.type||"dragend"===a.type||"zoomend"===a.type)&&(b=a.target.getBounds(),c=a.target.getZoom()),this.attributionBoundingBoxes&&b&&c&&(b.equals(this.bounds)&&c===this.zoom||(this.bounds=b,this.zoom=c,this.updateMapAttribution()))},onAdd:function(a){L.TileLayer.prototype.onAdd.call(this,a),this.dynamicAttribution&&(this.on("load",this.handleTileUpdates,this),this._map.on("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.on("resize",this.resizeAttribution,this)},resizeAttribution:function(){var a=this._map.getSize().x;this.getAttributionLogo().style.display=600>a?"none":"block",this.getAttributionSpan().style.maxWidth=.75*a+"px"},onRemove:function(a){this.dynamicAttribution&&(this.off("load",this.handleTileUpdates,this),this._map.off("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.off("resize",this.resizeAttribution,this),L.TileLayer.prototype.onRemove.call(this,a)},getAttributionData:function(a){this.attributionBoundingBoxes=[],L.esri.get(a,{},L.bind(this.processAttributionData,this))},processAttributionData:function(a){for(var b=0;b<a.contributors.length;b++)for(var c=a.contributors[b],d=0;d<c.coverageAreas.length;d++){var e=c.coverageAreas[d],f=new L.LatLng(e.bbox[0],e.bbox[1]),g=new L.LatLng(e.bbox[2],e.bbox[3]);this.attributionBoundingBoxes.push({attribution:c.attribution,score:e.score,bounds:new L.LatLngBounds(f,g),minZoom:e.zoomMin,maxZoom:e.zoomMax})}this.attributionBoundingBoxes.sort(function(a,b){return a.score<b.score?-1:a.score>b.score?1:0}),this.bounds&&this.updateMapAttribution()},getAttributionSpan:function(){return this._map._container.querySelectorAll(".esri-attributions")[0]},getAttributionLogo:function(){return this._map._container.querySelectorAll(".esri-attribution-logo")[0]},updateMapAttribution:function(){for(var a="",b=0;b<this.attributionBoundingBoxes.length;b++){var c=this.attributionBoundingBoxes[b];if(this.bounds.intersects(c.bounds)&&this.zoom>=c.minZoom&&this.zoom<=c.maxZoom){var d=this.attributionBoundingBoxes[b].attribution;-1===a.indexOf(d)&&(a.length>0&&(a+=", "),a+=d)}}this.getAttributionSpan().innerHTML=a,this.resizeAttribution()}}),L.esri.basemapLayer=function(a,b){return new L.esri.BasemapLayer(a,b)},function(a){function b(a,b){var c=b?"block":"none";if(a._icon&&(a._icon.style.display=c),a._shadow&&(a._shadow.style.display=c),a._layers)for(var d in a._layers)a._layers.hasOwnProperty(d)&&(a._layers[d]._container.style.display=c)}a.esri.FeatureLayer=a.GeoJSON.extend({includes:a.esri.Mixins.featureGrid,options:{cellSize:512,debounce:100,deduplicate:!0},initialize:function(b,c){this.index=new Terraformer.RTree,this.url=a.esri.Util.cleanUrl(b),a.Util.setOptions(this,c),a.GeoJSON.prototype.initialize.call(this,[],c)},onAdd:function(b){a.LayerGroup.prototype.onAdd.call(this,b),b.on("zoomend resize move",this._update,this),this._initializeFeatureGrid(b)},onRemove:function(b){b.off("zoomend resize move",this._update,this),a.LayerGroup.prototype.onRemove.call(this,b),this._destroyFeatureGrid(b)},_update:function(c){var d=a.esri.Util.boundsToEnvelope(c.target.getBounds());this.index.search(d).then(a.Util.bind(function(c){this.eachLayer(a.Util.bind(function(d){var e=d.feature.id;b(d,a.esri.Util.indexOf(c,e)>=0)},this))},this))},_render:function(a){if(a.objectIdFieldName&&a.features.length&&!a.error)for(var b=a.objectIdFieldName,c=a.features.length-1;c>=0;c--){var d=a.features[c],e=d.attributes[b];if(!this._layers[e]){var f=Terraformer.ArcGIS.parse(d);f.id=e,this.index.insert(f,e),this.addData(f)}}}}),a.esri.featureLayer=function(b,c){return new a.esri.FeatureLayer(b,c)}}(L),L.esri.TiledMapLayer=L.TileLayer.extend({includes:L.esri.Mixins.identifiableLayer,initialize:function(a,b){b=b||{},this.serviceUrl=L.esri.Util.cleanUrl(a),this.tileUrl=this.serviceUrl+"tile/{z}/{y}/{x}",this.tileUrl.match("://tiles.arcgis.com")&&(this.tileUrl=this.tileUrl.replace("://tiles.arcgis.com","://tiles{s}.arcgis.com"),b.subdomains=["1","2","3","4"]),L.TileLayer.prototype.initialize.call(this,this.tileUrl,b)}}),L.esri.tiledMapLayer=function(a,b){return new L.esri.TiledMapLayer(a,b)},/*!
* The MIT License (MIT)
*
* Copyright (c) 2013 Sanborn Map Company, Inc.
View
27 dist/esri-leaflet.unbundled.min.js
@@ -1,27 +0,0 @@
-/*! Esri-Leaflet - v0.0.1 - 2013-07-28
-* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
-* Apache License*/
-L.esri={AttributionStyles:"line-height:9px; text-overflow:ellipsis; white-space:nowrap;overflow:hidden; display:inline-block;",LogoStyles:"position:absolute; top:-38px; right:2px;",_callback:{}},L.esri.Support={CORS:!!(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest)},L.esri.RequestHandlers={CORS:function(a,b,c,d){var e=new XMLHttpRequest;b.f="json",e.onreadystatechange=function(){var a;if(4===e.readyState){try{a=JSON.parse(e.responseText)}catch(b){a={error:"Could not parse response as JSON."}}d?c.call(d,a):c(a)}},e.open("GET",a+L.esri.Util.serialize(b),!0),e.send(null)},JSONP:function(a,b,c,d){var e="c"+(1e9*Math.random()).toString(36).replace(".","_");b.f="json",b.callback="L.esri._callback."+e;var f=document.createElement("script");f.type="text/javascript",f.src=a+L.esri.Util.serialize(b),f.id=e,L.esri._callback[e]=function(a){d?c.call(d,a):c(a),document.body.removeChild(f),delete L.esri._callback[e]},document.body.appendChild(f)}},L.esri.get=L.esri.Support.CORS?L.esri.RequestHandlers.CORS:L.esri.RequestHandlers.JSONP,L.esri.Util={trim:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},cleanUrl:function(a){return a=L.esri.Util.trim(a),"/"!==a[a.length-1]&&(a+="/"),a.match(/^http:/)&&window.location.protocol.match(/^https:/)&&a.replace("http:","https:"),a},serialize:function(a){var b="?";for(var c in a)if(a.hasOwnProperty(c)){var d=c,e=a[c];b+=encodeURIComponent(d),b+="=",b+=encodeURIComponent(e),b+="&"}return b.substring(0,b.length-1)},indexOf:function(a,b,c){if(c=c||0,a.indexOf)return a.indexOf(b,c);for(var d=c,e=a.length;e>d;d++)if(a[d]===b)return d;return-1},extentToBounds:function(a){var b=new L.LatLng(a.xmin,a.ymin),c=new L.LatLng(a.xmax,a.ymin);return new L.LatLngBounds(b,c)},boundsToExtent:function(a){return{xmin:a.getSouthWest().lng,ymin:a.getSouthWest().lat,xmax:a.getNorthEast().lng,ymax:a.getNorthEast().lat,spatialReference:{wkid:4326}}},boundsToEnvelope:function(a){var b=L.esri.Util.boundsToExtent(a);return{x:b.xmin,y:b.ymin,w:Math.abs(b.xmin-b.ymax),h:Math.abs(b.ymin-b.ymax)}}},L.esri.Mixins={identifiableLayer:{identify:function(a,b,c){var d,e={sr:"4265",mapExtent:JSON.stringify(L.esri.Util.boundsToExtent(this._map.getBounds())),tolerance:3,geometryType:"esriGeometryPoint",imageDisplay:"800,600,96",geometry:JSON.stringify({x:a.lng,y:a.lat,spatialReference:{wkid:4265}})};"function"==typeof b&&"undefined"==typeof c?(c=b,d=e):"object"==typeof b&&(b.layerDefs&&(b.layerDefs=this.parseLayerDefs(b.layerDefs)),d=L.Util.extend(e,b)),L.esri.get(this._url+"/identify",d,c)},parseLayerDefs:function(a){return a instanceof Array?"":"object"==typeof a?JSON.stringify(a):a}}},L.esri.BasemapLayer=L.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Street_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Topographic:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Topo_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Oceans:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/Ocean_Basemap?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},NationalGeographic:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Gray:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Copyright: &copy;2013 Esri, DeLorme, NAVTEQ</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},GrayLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19}},Imagery:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},ImageryLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19}}}},initialize:function(a,b){var c;if("object"==typeof a&&a.urlTemplate&&a.options)c=a;else{if("string"!=typeof a||!L.esri.BasemapLayer.TILES[a])throw new Error("L.esri.BasemapLayer: Invalid parameter. Use one of 'Streets', 'Topographic', 'Oceans', 'NationalGeographic', 'Gray', 'GrayLabels', 'Imagery' or 'ImageryLabels'");c=L.esri.BasemapLayer.TILES[a]}var d=L.Util.extend(c.options,b),e=L.esri.Util.cleanUrl(c.urlTemplate);if(L.TileLayer.prototype.initialize.call(this,e,L.Util.setOptions(this,d)),c.attributionUrl){var f=L.esri.Util.cleanUrl(c.attributionUrl);this.dynamicAttribution=!0,this.getAttributionData(f)}},dynamicAttribution:!1,bounds:null,zoom:null,handleTileUpdates:function(a){var b,c;"load"===a.type&&(b=this._map.getBounds(),c=this._map.getZoom()),("viewreset"===a.type||"dragend"===a.type||"zoomend"===a.type)&&(b=a.target.getBounds(),c=a.target.getZoom()),this.attributionBoundingBoxes&&b&&c&&(b.equals(this.bounds)&&c===this.zoom||(this.bounds=b,this.zoom=c,this.updateMapAttribution()))},onAdd:function(a){L.TileLayer.prototype.onAdd.call(this,a),this.dynamicAttribution&&(this.on("load",this.handleTileUpdates,this),this._map.on("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.on("resize",this.resizeAttribution,this)},resizeAttribution:function(){var a=this._map.getSize().x;this.getAttributionLogo().style.display=600>a?"none":"block",this.getAttributionSpan().style.maxWidth=.75*a+"px"},onRemove:function(a){this.dynamicAttribution&&(this.off("load",this.handleTileUpdates,this),this._map.off("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.off("resize",this.resizeAttribution,this),L.TileLayer.prototype.onRemove.call(this,a)},getAttributionData:function(a){this.attributionBoundingBoxes=[],L.esri.get(a,{},L.bind(this.processAttributionData,this))},processAttributionData:function(a){for(var b=0;b<a.contributors.length;b++)for(var c=a.contributors[b],d=0;d<c.coverageAreas.length;d++){var e=c.coverageAreas[d],f=new L.LatLng(e.bbox[0],e.bbox[1]),g=new L.LatLng(e.bbox[2],e.bbox[3]);this.attributionBoundingBoxes.push({attribution:c.attribution,score:e.score,bounds:new L.LatLngBounds(f,g),minZoom:e.zoomMin,maxZoom:e.zoomMax})}this.attributionBoundingBoxes.sort(function(a,b){return a.score<b.score?-1:a.score>b.score?1:0}),this.bounds&&this.updateMapAttribution()},getAttributionSpan:function(){return this._map._container.querySelectorAll(".esri-attributions")[0]},getAttributionLogo:function(){return this._map._container.querySelectorAll(".esri-attribution-logo")[0]},updateMapAttribution:function(){for(var a="",b=0;b<this.attributionBoundingBoxes.length;b++){var c=this.attributionBoundingBoxes[b];if(this.bounds.intersects(c.bounds)&&this.zoom>=c.minZoom&&this.zoom<=c.maxZoom){var d=this.attributionBoundingBoxes[b].attribution;-1===a.indexOf(d)&&(a.length>0&&(a+=", "),a+=d)}}this.getAttributionSpan().innerHTML=a,this.resizeAttribution()}}),L.esri.basemapLayer=function(a,b){return new L.esri.BasemapLayer(a,b)},L.esri.FeatureLayer=L.GeoJSON.extend({options:{cellSize:512,queryWhilePanning:L.Browser.ie||L.Browser.mobile?!1:!0},initialize:function(a,b){this.index=new Terraformer.RTree,this.url=L.esri.Util.cleanUrl(a),L.Util.setOptions(this,b),L.GeoJSON.prototype.initialize.call(this,[],b)},onAdd:function(a){L.LayerGroup.prototype.onAdd.call(this,a),this._initializeVirtualGrid(a)},onRemove:function(a){L.LayerGroup.prototype.onRemove.call(this,a),this._destroyVirtualGrid(a)},update:function(a){var b=L.esri.Util.boundsToEnvelope(a.target.getBounds());this.index.search(b).then(L.Util.bind(function(a){this.eachLayer(L.Util.bind(function(b){var c=b.feature.id;this.setLayerVisibility(b,L.esri.Util.indexOf(a,c)>=0)},this))},this))},render:function(a){if(a.objectIdFieldName&&a.features.length&&!a.error)for(var b=a.objectIdFieldName,c=a.features.length-1;c>=0;c--){var d=a.features[c],e=d.attributes[b];if(!this._layers[e]){var f=Terraformer.ArcGIS.parse(d);f.id=e,this.index.insert(f,e),this.addData(f)}}},setLayerVisibility:function(a,b){var c=b?"block":"none";if(a._icon&&(a._icon.style.display=c),a._shadow&&(a._shadow.style.display=c),a._layers)for(var d in a._layers)a._layers.hasOwnProperty(d)&&(a._layers[d]._container.style.display=c)},_initializeVirtualGrid:function(a){this._map=a;var b=this.options.queryWhilePanning?"move":"moveend";a.on("zoomend",this._zoomHandler,this),a.on("resize",this._resizeHandler,this),a.on(b,this.update,this),a.on(b,this._moveHandler,this),this._resetGrid(a.getBounds())},_destroyVirtualGrid:function(a){a.off("viewreset moveend",this.update,this),a.off("moveend",this._moveHandler,this),a.off("zoomend",this._zoomHandler,this),a.off("resize",this._resizeHandler,this)},_moveHandler:function(a){this._requestFeatures(a.target.getBounds())},_zoomHandler:function(a){this._resetGrid(a.target.getBounds())},_resizeHandler:function(){this._setupSize()},_setupSize:function(){this._rows=Math.ceil(this._map.getSize().x/this._cellSize),this._cols=Math.ceil(this._map.getSize().y/this._cellSize)},_resetGrid:function(a){this._origin=this._map.project(a.getNorthWest()),this._cellSize=this.options.cellSize,this._setupSize(),this._loadedCells=[],this._requestFeatures(a)},_requestFeatures:function(a){for(var b=this._cellsInBounds(a),c=0;c<b.length;c++){var d=b[c];-1===L.esri.Util.indexOf(this._loadedCells,d.id)&&(L.esri.get(this.url+"query",{geometryType:"esriGeometryEnvelope",geometry:JSON.stringify(L.esri.Util.boundsToExtent(d.bounds)),outFields:"*",outSr:4326},this.render,this),this._loadedCells.push(d.id))}},_cellsInBounds:function(a){for(var b=this._map.project(a.getNorthWest()),c=a.getCenter(),d=this._origin.x-b.x,e=this._origin.y-b.y,f=Math.round(d/this._cellSize),g=Math.round(e/this._cellSize),h=[],i=0;i<=this._rows;i++)for(var j=0;j<=this._cols;j++){var k=i-f,l=j-g,m=this._cellExtent(k,l),n=k+":"+l;h.push({id:n,bounds:m,distance:m.getCenter().distanceTo(c)})}return h.sort(function(a,b){return a.distance-b.distance}),h},_cellExtent:function(a,b){var c=this._cellPoint(a,b),d=this._cellPoint(a-1,b-1),e=this._map.unproject(c),f=this._map.unproject(d);return new L.LatLngBounds(f,e)},_cellPoint:function(a,b){var c=this._origin.x+a*this._cellSize,d=this._origin.y+b*this._cellSize;return new L.Point(c,d)}}),L.esri.featureLayer=function(a,b){return new L.esri.FeatureLayer(a,b)},L.esri.TiledMapLayer=L.TileLayer.extend({includes:L.esri.Mixins.identifiableLayer,initialize:function(a,b){b=b||{},this.serviceUrl=L.esri.Util.cleanUrl(a),this.tileUrl=this.serviceUrl+"tile/{z}/{y}/{x}",this.tileUrl.match("://tiles.arcgis.com")&&(this.tileUrl=this.tileUrl.replace("://tiles.arcgis.com","://tiles{s}.arcgis.com"),b.subdomains=["1","2","3","4"]),L.TileLayer.prototype.initialize.call(this,this.tileUrl,b)}}),L.esri.tiledMapLayer=function(a,b){return new L.esri.TiledMapLayer(a,b)},/*!
- * The MIT License (MIT)
- *
- * Copyright (c) 2013 Sanborn Map Company, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-L.esri.DynamicMapLayer=L.ImageOverlay.extend({includes:L.esri.Mixins.identifiableLayer,defaultParams:{format:"png8",transparent:!0,f:"image",bboxSR:102100,imageSR:102100,layers:"",opacity:1},initialize:function(a,b){this._url=L.esri.Util.cleanUrl(a),this._layerParams=L.Util.extend({},this.defaultParams);for(var c in b)this.options.hasOwnProperty(c)||(this._layerParams[c]=b[c]);delete this._layerParams.token,this._parseLayers(),this._parseLayerDefs(),L.Util.setOptions(this,b)},onAdd:function(a){if(this._map=a,this._image||this._initImage(),a._panes.overlayPane.appendChild(this._image),a.on({viewreset:this._reset,moveend:this._update,zoomend:this._zoomUpdate},this),a.options.zoomAnimation&&L.Browser.any3d&&a.on("zoomanim",this._animateZoom,this),a.options.crs&&a.options.crs.code){var b=a.options.crs.code.split(":")[1];this._layerParams.bboxSR=b,this._layerParams.imageSR=b}this._reset()},onRemove:function(a){a.getPanes().overlayPane.removeChild(this._image),a.off({viewreset:this._reset,moveend:this._update},this),a.options.zoomAnimation&&a.off("zoomanim",this._animateZoom,this)},_animateZoom:function(a){var b=this._map,c=this._image,d=b.getZoomScale(a.zoom),e=this._map.getBounds().getNorthWest(),f=this._map.getBounds().getSouthEast(),g=b._latLngToNewLayerPoint(e,a.zoom,a.center),h=b._latLngToNewLayerPoint(f,a.zoom,a.center)._subtract(g),i=g._add(h._multiplyBy(.5*(1-1/d)));c.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(i)+" scale("+d+") "},_parseLayers:function(){if("undefined"==typeof this._layerParams.layers)return delete this._layerParams.layerOption,void 0;var a=this._layerParams.layerOption||null,b=this._layerParams.layers||null,c="show",d=["show","hide","include","exclude"];if(delete this._layerParams.layerOption,a)-1!==d.indexOf(a)&&(c=a),this._layerParams.layers=c+":"+b;else if(b instanceof Array)this._layerParams.layers=c+":"+b.join(",");else if("string"==typeof b){var e=b.match(":");e&&(b=b.split(e[0]),Number(b[1].split(",")[0])&&(-1!==d.indexOf(b[0])&&(c=b[0]),b=b[1])),this._layerParams.layers=c+":"+b}},_parseLayerDefs:function(){if("undefined"!=typeof this._layerParams.layerDefs){var a=this._layerParams.layerDefs,b=[];if(a instanceof Array)for(var c=a.length,d=0;c>d;d++)a[d]&&b.push(d+":"+a[d]);else{if("object"!=typeof a)return delete this._layerParams.layerDefs,void 0;for(var e in a)a.hasOwnProperty(e)&&b.push(e+":"+a[e])}this._layerParams.layerDefs=b.join(";")}},_initImage:function(){this._image=L.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&L.Browser.any3d?L.DomUtil.addClass(this._image,"leaflet-zoom-animated"):L.DomUtil.addClass(this._image,"leaflet-zoom-hide"),this._updateOpacity(),L.Util.extend(this._image,{galleryimg:"no",onselectstart:L.Util.falseFn,onmousemove:L.Util.falseFn,onload:L.Util.bind(this._onImageLoad,this),src:this._getImageUrl()})},_getImageUrl:function(){var a=this._map.getBounds(),b=this._map.getSize(),c=this._map.options.crs.project(a._northEast),d=this._map.options.crs.project(a._southWest);this._layerParams.bbox=[d.x,d.y,c.x,c.y].join(","),this._layerParams.size=b.x+","+b.y;var e=this._url+"export"+L.Util.getParamString(this._layerParams);return"undefined"!=typeof this.options.token&&(e=e+"&token="+this.options.token),e},_update:function(){if(!this._map._panTransition||!this._map._panTransition._inProgress){var a=this._map.getZoom();a>this.options.maxZoom||a<this.options.minZoom||(this._newImage=L.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&L.Browser.any3d?L.DomUtil.addClass(this._newImage,"leaflet-zoom-animated"):L.DomUtil.addClass(this._newImage,"leaflet-zoom-hide"),this._updateOpacity(),L.Util.extend(this._newImage,{galleryimg:"no",onselectstart:L.Util.falseFn,onmousemove:L.Util.falseFn,onload:L.Util.bind(this._onNewImageLoad,this),src:this._getImageUrl()}))}},_updateOpacity:function(){L.DomUtil.setOpacity(this._image,this.options.opacity),this._newImage&&L.DomUtil.setOpacity(this._newImage,this.options.opacity)},_zoomUpdate:function(){},_onNewImageLoad:function(){var a=this._map.getBounds(),b=L.latLng(a._northEast.lat,a._southWest.lng),c=L.latLng(a._southWest.lat,a._northEast.lng),d=this._map.latLngToLayerPoint(b),e=this._map.latLngToLayerPoint(c)._subtract(d);L.DomUtil.setPosition(this._newImage,d),this._newImage.style.width=e.x+"px",this._newImage.style.height=e.y+"px",this._map._panes.overlayPane.appendChild(this._newImage),this._map._panes.overlayPane.removeChild(this._image),this._image=this._newImage,this._newImage=null},_onImageLoad:function(){this.fire("load")},_reset:function(){}}),L.esri.dynamicMapLayer=function(a,b){return new L.esri.DynamicMapLayer(a,b)};
View
61 dist/extras/clustered-feature-layer-src.js
@@ -0,0 +1,61 @@
+/*! Esri-Leaflet - v0.0.1 - 2013-08-04
+* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
+* Apache License*/
+/* globals Terraformer, L */
+(function(L, Terraformer){
+ L.esri.ClusteredFeatureLayer = L.Class.extend({
+ includes: L.esri.Mixins.featureGrid,
+ options: {
+ cellSize: 512,
+ debounce: 100,
+ deduplicate: true,
+ marker: function (geojson, latlng) {
+ return new L.marker(latlng);
+ },
+ eachMarker: undefined
+ },
+ initialize: function(url, options){
+ L.Util.setOptions(this, options);
+ this.url = L.esri.Util.cleanUrl(url);
+ this._loaded = [];
+ this.cluster = this.options.cluster || new L.MarkerClusterGroup();
+ },
+ onAdd: function(map){
+ this.options.cluster.addTo(map);
+ this._initializeFeatureGrid(map);
+ },
+ onRemove: function(map){
+ this._destroyFeatureGrid(map);
+ },
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ _render: function(response){
+ if(response.objectIdFieldName && response.features.length && !response.error){
+ var idKey = response.objectIdFieldName;
+ for (var i = response.features.length - 1; i >= 0; i--) {
+ var feature = response.features[i];
+ var id = feature.attributes[idKey];
+ if(L.esri.Util.indexOf(this._loaded, id) < 0){
+ var geojson = Terraformer.ArcGIS.parse(feature);
+ geojson.id = id;
+ var marker = this.options.marker(geojson, [geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]]);
+
+ if(this.options.eachMarker){
+ this.options.eachMarker(geojson, marker);
+ }
+
+ this.cluster.addLayer(marker);
+ this._loaded.push(id);
+ }
+ }
+ }
+ }
+ });
+
+ L.esri.clusteredFeatureLayer = function(url, options){
+ return new L.esri.ClusteredFeatureLayer(url, options);
+ };
+})(L, Terraformer);
View
4 dist/extras/clustered-feature-layer.js
@@ -0,0 +1,4 @@
+/*! Esri-Leaflet - v0.0.1 - 2013-08-04
+* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
+* Apache License*/
+!function(a,Terraformer){a.esri.ClusteredFeatureLayer=a.Class.extend({includes:a.esri.Mixins.featureGrid,options:{cellSize:512,debounce:100,deduplicate:!0,marker:function(b,c){return new a.marker(c)},eachMarker:void 0},initialize:function(b,c){a.Util.setOptions(this,c),this.url=a.esri.Util.cleanUrl(b),this._loaded=[],this.cluster=this.options.cluster||new a.MarkerClusterGroup},onAdd:function(a){this.options.cluster.addTo(a),this._initializeFeatureGrid(a)},onRemove:function(a){this._destroyFeatureGrid(a)},addTo:function(a){return a.addLayer(this),this},_render:function(b){if(b.objectIdFieldName&&b.features.length&&!b.error)for(var c=b.objectIdFieldName,d=b.features.length-1;d>=0;d--){var e=b.features[d],f=e.attributes[c];if(a.esri.Util.indexOf(this._loaded,f)<0){var g=Terraformer.ArcGIS.parse(e);g.id=f;var h=this.options.marker(g,[g.geometry.coordinates[1],g.geometry.coordinates[0]]);this.options.eachMarker&&this.options.eachMarker(g,h),this.cluster.addLayer(h),this._loaded.push(f)}}}}),a.esri.clusteredFeatureLayer=function(b,c){return new a.esri.ClusteredFeatureLayer(b,c)}}(L,Terraformer);
View
517 dist/extras/esri-basemaps-src.js
@@ -0,0 +1,517 @@
+/*! Esri-Leaflet - v0.0.1 - 2013-08-04
+* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
+* Apache License*/
+/* globals L */
+
+L.esri = {
+ AttributionStyles:"line-height:9px; text-overflow:ellipsis; white-space:nowrap;overflow:hidden; display:inline-block;",
+ LogoStyles:"position:absolute; top:-38px; right:2px;",
+ _callback: {}
+};
+
+// Namespace for various support variables we need to track
+L.esri.Support = {
+ // from: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js#L20
+ CORS: !!(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest())
+};
+
+// AJAX handlers for CORS (modern browsers) or JSONP (older browsers)
+L.esri.RequestHandlers = {
+ CORS: function(url, params, callback, context){
+ var httpRequest = new XMLHttpRequest();
+
+ params.f="json";
+
+ httpRequest.onreadystatechange = function(){
+ var response;
+ if (httpRequest.readyState === 4) {
+ try {
+ response = JSON.parse(httpRequest.responseText);
+ } catch(e) {
+ response = {
+ error: "Could not parse response as JSON."
+ };
+ }
+ if(context){
+ callback.call(context, response);
+ } else {
+ callback(response);
+ }
+ }
+ };
+
+ httpRequest.open('GET', url + L.esri.Util.serialize(params), true);
+ httpRequest.send(null);
+ },
+ JSONP: function(url, params, callback, context){
+ var callbackId = "c"+(Math.random() * 1e9).toString(36).replace(".", "_");
+
+ params.f="json";
+ params.callback="L.esri._callback."+callbackId;
+
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = url + L.esri.Util.serialize(params);
+ script.id = callbackId;
+
+ L.esri._callback[callbackId] = function(response){
+ if(context){
+ callback.call(context, response);
+ } else {
+ callback(response);
+ }
+ document.body.removeChild(script);
+ delete L.esri._callback[callbackId];
+ };
+
+ document.body.appendChild(script);
+ }
+};
+
+// Choose the correct AJAX handler depending on CORS support
+L.esri.get = (L.esri.Support.CORS) ? L.esri.RequestHandlers.CORS : L.esri.RequestHandlers.JSONP;
+
+// General utility namespace
+L.esri.Util = {
+ // make it so that passed `function` never gets called
+ // twice within `delay` milliseconds. Used to throttle
+ // `move` events on the layer.
+ // http://remysharp.com/2010/07/21/throttling-function-calls/
+ debounce: function (fn, delay, context) {
+ var timer = null;
+ return function() {
+ var context = this||context, args = arguments;
+ clearTimeout(timer);
+ timer = setTimeout(function () {
+ fn.apply(context, args);
+ }, delay);
+ };
+ },
+ // round a number away from zero used to snap
+ // row/columns away from the origin of the grid
+ roundAwayFromZero: function (num){
+ return (num > 0) ? Math.ceil(num) : Math.floor(num);
+ },
+ trim: function(str) {
+ return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
+ },
+ cleanUrl: function(url){
+ url = L.esri.Util.trim(url);
+
+ //add a trailing slash to the url if the user omitted it
+ if(url[url.length-1] !== "/"){
+ url += "/";
+ }
+
+ return url;
+ },
+ // quick and dirty serialization
+ serialize: function(params){
+ var qs="?";
+
+ for(var param in params){
+ if(params.hasOwnProperty(param)){
+ var key = param;
+ var value = params[param];
+ qs+=encodeURIComponent(key);
+ qs+="=";
+ qs+=encodeURIComponent(value);
+ qs+="&";
+ }
+ }
+
+ return qs.substring(0, qs.length - 1);
+ },
+
+ // index of polyfill, needed for IE 8
+ indexOf: function(arr, obj, start){
+ start = start || 0;
+ if(arr.indexOf){
+ return arr.indexOf(obj, start);
+ }
+ for (var i = start, j = arr.length; i < j; i++) {
+ if (arr[i] === obj) { return i; }
+ }
+ return -1;
+ },
+
+ // convert an extent (ArcGIS) to LatLngBounds (Leaflet)
+ extentToBounds: function(extent){
+ var southWest = new L.LatLng(extent.xmin, extent.ymin);
+ var northEast = new L.LatLng(extent.xmax, extent.ymin);
+ return new L.LatLngBounds(southWest, northEast);
+ },
+
+ // convert an LatLngBounds (Leaflet) to extent (ArcGIS)
+ boundsToExtent: function(bounds) {
+ return {
+ "xmin": bounds.getSouthWest().lng,
+ "ymin": bounds.getSouthWest().lat,
+ "xmax": bounds.getNorthEast().lng,
+ "ymax": bounds.getNorthEast().lat,
+ "spatialReference": {
+ "wkid" : 4326
+ }
+ };
+ },
+
+ // convert a LatLngBounds (Leaflet) to a Envelope (Terraformer.Rtree)
+ boundsToEnvelope: function(bounds){
+ var extent = L.esri.Util.boundsToExtent(bounds);
+ return {
+ x: extent.xmin,
+ y: extent.ymin,
+ w: Math.abs(extent.xmin - extent.ymax),
+ h: Math.abs(extent.ymin - extent.ymax)
+ };
+ }
+};
+
+L.esri.Mixins = {};
+
+L.esri.Mixins.featureGrid = {
+ _initializeFeatureGrid: function(map){
+ this._map = map;
+ this._previousCells = [];
+ this.center = this._map.getCenter();
+ this.origin = this._map.project(this.center);
+
+ this._moveHandler = L.esri.Util.debounce(function(e){
+ if(e.type === "zoomend"){
+ this.origin = this._map.project(this.center);
+ this._previousCells = [];
+ }
+ this._requestFeatures(e.target.getBounds());
+ }, this.options.debounce, this);
+
+ map.on("zoomend resize move", this._moveHandler, this);
+
+ this._requestFeatures(map.getBounds());
+ },
+ _destroyFeatureGrid: function(map){
+ map.on("zoomend resize move", this._moveHandler, this);
+ },
+ _requestFeatures: function(bounds){
+ var cells = this._cellsWithin(bounds);
+ for (var i = 0; i < cells.length; i++) {
+ var cell = cells[i];
+ L.esri.get(this.url+"query", {
+ geometryType: "esriGeometryEnvelope",
+ geometry: JSON.stringify(L.esri.Util.boundsToExtent(cell.bounds)),
+ outFields:"*",
+ outSr: 4326
+ }, this._render, this);
+ }
+ },
+ _cellsWithin: function(mapBounds){
+ var size = this._map.getSize();
+ var offset = this._map.project(this._map.getCenter());
+ var bounds = mapBounds.pad(Math.min(this.options.cellSize/size.x, this.options.cellSize/size.y));
+ var cells = [];
+
+ var topLeftPoint = this._map.project(bounds.getNorthWest());
+ var bottomRightPoint = this._map.project(bounds.getSouthEast());
+
+ var topLeft = topLeftPoint.subtract(offset).divideBy(this.options.cellSize);
+ var bottomRight = bottomRightPoint.subtract(offset).divideBy(this.options.cellSize);
+
+ var offsetRows = Math.round((this.origin.x - offset.x) / this.options.cellSize);
+ var offsetCols = Math.round((this.origin.y - offset.y) / this.options.cellSize);
+
+ var minRow = L.esri.Util.roundAwayFromZero(topLeft.x)-offsetRows;
+ var maxRow = L.esri.Util.roundAwayFromZero(bottomRight.x)-offsetRows;
+ var minCol = L.esri.Util.roundAwayFromZero(topLeft.y)-offsetCols;
+ var maxCol = L.esri.Util.roundAwayFromZero(bottomRight.y)-offsetCols;
+
+ for (var row = minRow; row < maxRow; row++) {
+ for (var col = minCol; col < maxCol; col++) {
+ var cellId = "cell:"+row+":"+col;
+ var duplicate = this._previousCells.indexOf(cellId) >= 0;
+
+ if(!duplicate || !this.options.deduplicate){
+ var cellBounds = this._cellExtent(row, col);
+ var cellCenter = cellBounds.getCenter();
+ var radius = cellCenter.distanceTo(cellBounds.getNorthWest());
+ var distance = cellCenter.distanceTo(this.center);
+ var cell = {
+ row: row,
+ col: col,
+ id: cellId,
+ center: cellCenter,
+ bounds: cellBounds,
+ distance:distance,
+ radius: radius
+ };
+ cells.push(cell);
+ this._previousCells.push(cellId);
+ }
+ }
+ }
+
+ cells.sort(function (a, b) {
+ return a.distance - b.distance;
+ });
+
+ return cells;
+ },
+ _cellExtent: function(row, col){
+ var swPoint = this._cellPoint(row, col);
+ var nePoint = this._cellPoint(row+1, col+1);
+ var sw = this._map.unproject(swPoint);
+ var ne = this._map.unproject(nePoint);
+ return L.latLngBounds(sw, ne);
+ },
+ _cellPoint:function(row, col){
+ var x = this.origin.x + (row*this.options.cellSize);
+ var y = this.origin.y + (col*this.options.cellSize);
+ return [x, y];
+ }
+};
+
+L.esri.Mixins.identifiableLayer = {
+ identify:function(latLng, options, callback){
+ var defaults = {
+ sr: '4265',
+ mapExtent: JSON.stringify(L.esri.Util.boundsToExtent(this._map.getBounds())),
+ tolerance: 3,
+ geometryType: 'esriGeometryPoint',
+ imageDisplay: '800,600,96',
+ geometry: JSON.stringify({
+ x: latLng.lng,
+ y: latLng.lat,
+ spatialReference: {
+ wkid: 4265
+ }
+ })
+ };
+
+ var params;
+
+ if (typeof options === 'function' && typeof callback === 'undefined') {
+ callback = options;
+ params = defaults;
+ } else if (typeof options === 'object') {
+ if (options.layerDefs) {
+ options.layerDefs = this.parseLayerDefs(options.layerDefs);
+ }
+
+ params = L.Util.extend(defaults, options);
+ }
+
+ L.esri.get(this._url + '/identify', params, callback);
+ },
+ parseLayerDefs: function (layerDefs) {
+ if (layerDefs instanceof Array) {
+ //throw 'must be object or string';
+ return '';
+ }
+
+ if (typeof layerDefs === 'object') {
+ return JSON.stringify(layerDefs);
+ }
+
+ return layerDefs;
+ }
+};
+
+L.esri.BasemapLayer = L.TileLayer.extend({
+ statics: {
+ TILES: {
+ Streets: {
+ urlTemplate: "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",
+ attributionUrl: "http://static.arcgis.com/attribution/World_Street_Map?f=json",
+ options: {
+ minZoom: 1,
+ maxZoom: 19,
+ attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
+ }
+ },
+ Topographic: {
+ urlTemplate: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",
+ attributionUrl: "http://static.arcgis.com/attribution/World_Topo_Map?f=json",
+ options: {
+ minZoom: 1,
+ maxZoom: 19,
+ attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
+ }
+ },
+ Oceans: {
+ urlTemplate: "http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}",
+ attributionUrl: "http://static.arcgis.com/attribution/Ocean_Basemap?f=json",
+ options: {
+ minZoom: 1,
+ maxZoom: 16,
+ attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
+ }
+ },
+ NationalGeographic: {
+ urlTemplate: "http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",
+ options: {
+ minZoom: 1,
+ maxZoom: 16,
+ attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
+ }
+ },
+ Gray: {
+ urlTemplate: "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",
+ options: {
+ minZoom: 1,
+ maxZoom: 16,
+ attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Copyright: &copy;2013 Esri, DeLorme, NAVTEQ</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
+ }
+ },
+ GrayLabels: {
+ urlTemplate: "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",
+ options: {
+ minZoom: 1,
+ maxZoom: 16
+ }
+ },
+ Imagery: {
+ urlTemplate: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
+ options: {
+ minZoom: 1,
+ maxZoom: 19,
+ attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
+ }
+ },
+ ImageryLabels: {
+ urlTemplate: "http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",
+ options: {
+ minZoom: 1,
+ maxZoom: 19
+ }
+ }
+ }
+ },
+ initialize: function(key, options){
+ var config;
+
+ // set the config variable with the appropriate config object
+ if (typeof key === "object" && key.urlTemplate && key.options){
+ config = key;
+ } else if(typeof key === "string" && L.esri.BasemapLayer.TILES[key]){
+ config = L.esri.BasemapLayer.TILES[key];
+ } else {
+ throw new Error("L.esri.BasemapLayer: Invalid parameter. Use one of 'Streets', 'Topographic', 'Oceans', 'NationalGeographic', 'Gray', 'GrayLabels', 'Imagery' or 'ImageryLabels'");
+ }
+
+ // merge passed options into the config options
+ var mergedOptions = L.Util.extend(config.options, options);
+
+ // clean up our input url
+ var url = L.esri.Util.cleanUrl(config.urlTemplate);
+
+ // call the initialize method on L.TileLayer to set everything up
+ L.TileLayer.prototype.initialize.call(this, url, L.Util.setOptions(this, mergedOptions));
+
+ // if this basemap requires dynamic attribution set it up
+ if(config.attributionUrl){
+ var attributionUrl =L.esri.Util.cleanUrl(config.attributionUrl);
+ this.dynamicAttribution = true;
+ this.getAttributionData(attributionUrl);
+ }
+ },
+ dynamicAttribution: false,
+ bounds: null,
+ zoom: null,
+ handleTileUpdates: function(e){
+ var newBounds;
+ var newZoom;
+
+ if(e.type === "load"){
+ newBounds = this._map.getBounds();
+ newZoom = this._map.getZoom();
+ }
+
+ if(e.type === "viewreset" || e.type === "dragend" || e.type ==="zoomend"){
+ newBounds = e.target.getBounds();
+ newZoom = e.target.getZoom();
+ }
+
+ if(this.attributionBoundingBoxes && newBounds && newZoom){
+ if(!newBounds.equals(this.bounds) || newZoom !== this.zoom){
+ this.bounds = newBounds;
+ this.zoom = newZoom;
+ this.updateMapAttribution();
+ }
+ }
+ },
+ onAdd: function(map){
+ L.TileLayer.prototype.onAdd.call(this, map);
+ if(this.dynamicAttribution){
+ this.on("load", this.handleTileUpdates, this);
+ this._map.on("viewreset zoomend dragend", this.handleTileUpdates, this);
+ }
+ this._map.on("resize", this.resizeAttribution, this);
+ },
+ resizeAttribution: function(){
+ var mapWidth = this._map.getSize().x;
+ this.getAttributionLogo().style.display = (mapWidth < 600) ? "none":"block";
+ this.getAttributionSpan().style.maxWidth = (mapWidth* 0.75) + "px";
+ },
+ onRemove: function(map){
+ if(this.dynamicAttribution){
+ this.off("load", this.handleTileUpdates, this);
+ this._map.off("viewreset zoomend dragend", this.handleTileUpdates, this);
+ }
+ this._map.off("resize", this.resizeAttribution, this);
+ L.TileLayer.prototype.onRemove.call(this, map);
+ },
+ getAttributionData: function(url){
+ this.attributionBoundingBoxes = [];
+ L.esri.get(url, {}, L.bind(this.processAttributionData, this));
+ },
+ processAttributionData: function(attributionData){
+ for (var c = 0; c < attributionData.contributors.length; c++) {
+ var contributor = attributionData.contributors[c];
+ for (var i = 0; i < contributor.coverageAreas.length; i++) {
+ var coverageArea = contributor.coverageAreas[i];
+ var southWest = new L.LatLng(coverageArea.bbox[0], coverageArea.bbox[1]);
+ var northEast = new L.LatLng(coverageArea.bbox[2], coverageArea.bbox[3]);
+ this.attributionBoundingBoxes.push({
+ attribution: contributor.attribution,
+ score: coverageArea.score,
+ bounds: new L.LatLngBounds(southWest, northEast),
+ minZoom: coverageArea.zoomMin,
+ maxZoom: coverageArea.zoomMax
+ });
+ }
+ }
+ this.attributionBoundingBoxes.sort(function(a,b){
+ if (a.score < b.score){ return -1; }
+ if (a.score > b.score){ return 1; }
+ return 0;
+ });
+ if(this.bounds){
+ this.updateMapAttribution();
+ }
+ },
+ getAttributionSpan:function(){
+ return this._map._container.querySelectorAll('.esri-attributions')[0];
+ },
+ getAttributionLogo:function(){
+ return this._map._container.querySelectorAll('.esri-attribution-logo')[0];
+ },
+ updateMapAttribution: function(){
+ var newAttributions = '';
+ for (var i = 0; i < this.attributionBoundingBoxes.length; i++) {
+ var attr = this.attributionBoundingBoxes[i];
+ if(this.bounds.intersects(attr.bounds) && this.zoom >= attr.minZoom && this.zoom <= attr.maxZoom) {
+ var attribution = this.attributionBoundingBoxes[i].attribution;
+ if(newAttributions.indexOf(attribution) === -1){
+ if(newAttributions.length > 0){
+ newAttributions += ', ';
+ }
+ newAttributions += attribution;
+ }
+ }
+ }
+ this.getAttributionSpan().innerHTML = newAttributions;
+ this.resizeAttribution();
+ }
+});
+
+L.esri.basemapLayer = function(key, options){
+ return new L.esri.BasemapLayer(key, options);
+};
View
4 dist/extras/esri-basemaps.js
@@ -0,0 +1,4 @@
+/*! Esri-Leaflet - v0.0.1 - 2013-08-04
+* Copyright (c) 2013 Environmental Systems Research Institute, Inc.
+* Apache License*/
+L.esri={AttributionStyles:"line-height:9px; text-overflow:ellipsis; white-space:nowrap;overflow:hidden; display:inline-block;",LogoStyles:"position:absolute; top:-38px; right:2px;",_callback:{}},L.esri.Support={CORS:!!(window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest)},L.esri.RequestHandlers={CORS:function(a,b,c,d){var e=new XMLHttpRequest;b.f="json",e.onreadystatechange=function(){var a;if(4===e.readyState){try{a=JSON.parse(e.responseText)}catch(b){a={error:"Could not parse response as JSON."}}d?c.call(d,a):c(a)}},e.open("GET",a+L.esri.Util.serialize(b),!0),e.send(null)},JSONP:function(a,b,c,d){var e="c"+(1e9*Math.random()).toString(36).replace(".","_");b.f="json",b.callback="L.esri._callback."+e;var f=document.createElement("script");f.type="text/javascript",f.src=a+L.esri.Util.serialize(b),f.id=e,L.esri._callback[e]=function(a){d?c.call(d,a):c(a),document.body.removeChild(f),delete L.esri._callback[e]},document.body.appendChild(f)}},L.esri.get=L.esri.Support.CORS?L.esri.RequestHandlers.CORS:L.esri.RequestHandlers.JSONP,L.esri.Util={debounce:function(a,b){var c=null;return function(){var d=this||d,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,e)},b)}},roundAwayFromZero:function(a){return a>0?Math.ceil(a):Math.floor(a)},trim:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},cleanUrl:function(a){return a=L.esri.Util.trim(a),"/"!==a[a.length-1]&&(a+="/"),a},serialize:function(a){var b="?";for(var c in a)if(a.hasOwnProperty(c)){var d=c,e=a[c];b+=encodeURIComponent(d),b+="=",b+=encodeURIComponent(e),b+="&"}return b.substring(0,b.length-1)},indexOf:function(a,b,c){if(c=c||0,a.indexOf)return a.indexOf(b,c);for(var d=c,e=a.length;e>d;d++)if(a[d]===b)return d;return-1},extentToBounds:function(a){var b=new L.LatLng(a.xmin,a.ymin),c=new L.LatLng(a.xmax,a.ymin);return new L.LatLngBounds(b,c)},boundsToExtent:function(a){return{xmin:a.getSouthWest().lng,ymin:a.getSouthWest().lat,xmax:a.getNorthEast().lng,ymax:a.getNorthEast().lat,spatialReference:{wkid:4326}}},boundsToEnvelope:function(a){var b=L.esri.Util.boundsToExtent(a);return{x:b.xmin,y:b.ymin,w:Math.abs(b.xmin-b.ymax),h:Math.abs(b.ymin-b.ymax)}}},L.esri.Mixins={},L.esri.Mixins.featureGrid={_initializeFeatureGrid:function(a){this._map=a,this._previousCells=[],this.center=this._map.getCenter(),this.origin=this._map.project(this.center),this._moveHandler=L.esri.Util.debounce(function(a){"zoomend"===a.type&&(this.origin=this._map.project(this.center),this._previousCells=[]),this._requestFeatures(a.target.getBounds())},this.options.debounce,this),a.on("zoomend resize move",this._moveHandler,this),this._requestFeatures(a.getBounds())},_destroyFeatureGrid:function(a){a.on("zoomend resize move",this._moveHandler,this)},_requestFeatures:function(a){for(var b=this._cellsWithin(a),c=0;c<b.length;c++){var d=b[c];L.esri.get(this.url+"query",{geometryType:"esriGeometryEnvelope",geometry:JSON.stringify(L.esri.Util.boundsToExtent(d.bounds)),outFields:"*",outSr:4326},this._render,this)}},_cellsWithin:function(a){for(var b=this._map.getSize(),c=this._map.project(this._map.getCenter()),d=a.pad(Math.min(this.options.cellSize/b.x,this.options.cellSize/b.y)),e=[],f=this._map.project(d.getNorthWest()),g=this._map.project(d.getSouthEast()),h=f.subtract(c).divideBy(this.options.cellSize),i=g.subtract(c).divideBy(this.options.cellSize),j=Math.round((this.origin.x-c.x)/this.options.cellSize),k=Math.round((this.origin.y-c.y)/this.options.cellSize),l=L.esri.Util.roundAwayFromZero(h.x)-j,m=L.esri.Util.roundAwayFromZero(i.x)-j,n=L.esri.Util.roundAwayFromZero(h.y)-k,o=L.esri.Util.roundAwayFromZero(i.y)-k,p=l;m>p;p++)for(var q=n;o>q;q++){var r="cell:"+p+":"+q,s=this._previousCells.indexOf(r)>=0;if(!s||!this.options.deduplicate){var t=this._cellExtent(p,q),u=t.getCenter(),v=u.distanceTo(t.getNorthWest()),w=u.distanceTo(this.center),x={row:p,col:q,id:r,center:u,bounds:t,distance:w,radius:v};e.push(x),this._previousCells.push(r)}}return e.sort(function(a,b){return a.distance-b.distance}),e},_cellExtent:function(a,b){var c=this._cellPoint(a,b),d=this._cellPoint(a+1,b+1),e=this._map.unproject(c),f=this._map.unproject(d);return L.latLngBounds(e,f)},_cellPoint:function(a,b){var c=this.origin.x+a*this.options.cellSize,d=this.origin.y+b*this.options.cellSize;return[c,d]}},L.esri.Mixins.identifiableLayer={identify:function(a,b,c){var d,e={sr:"4265",mapExtent:JSON.stringify(L.esri.Util.boundsToExtent(this._map.getBounds())),tolerance:3,geometryType:"esriGeometryPoint",imageDisplay:"800,600,96",geometry:JSON.stringify({x:a.lng,y:a.lat,spatialReference:{wkid:4265}})};"function"==typeof b&&"undefined"==typeof c?(c=b,d=e):"object"==typeof b&&(b.layerDefs&&(b.layerDefs=this.parseLayerDefs(b.layerDefs)),d=L.Util.extend(e,b)),L.esri.get(this._url+"/identify",d,c)},parseLayerDefs:function(a){return a instanceof Array?"":"object"==typeof a?JSON.stringify(a):a}},L.esri.BasemapLayer=L.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Street_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Topographic:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/World_Topo_Map?f=json",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Oceans:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}",attributionUrl:"http://static.arcgis.com/attribution/Ocean_Basemap?f=json",options:{minZoom:1,maxZoom:16,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},NationalGeographic:{urlTemplate:"http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},Gray:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Copyright: &copy;2013 Esri, DeLorme, NAVTEQ</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},GrayLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16}},Imagery:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,attribution:"<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"}},ImageryLabels:{urlTemplate:"http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19}}}},initialize:function(a,b){var c;if("object"==typeof a&&a.urlTemplate&&a.options)c=a;else{if("string"!=typeof a||!L.esri.BasemapLayer.TILES[a])throw new Error("L.esri.BasemapLayer: Invalid parameter. Use one of 'Streets', 'Topographic', 'Oceans', 'NationalGeographic', 'Gray', 'GrayLabels', 'Imagery' or 'ImageryLabels'");c=L.esri.BasemapLayer.TILES[a]}var d=L.Util.extend(c.options,b),e=L.esri.Util.cleanUrl(c.urlTemplate);if(L.TileLayer.prototype.initialize.call(this,e,L.Util.setOptions(this,d)),c.attributionUrl){var f=L.esri.Util.cleanUrl(c.attributionUrl);this.dynamicAttribution=!0,this.getAttributionData(f)}},dynamicAttribution:!1,bounds:null,zoom:null,handleTileUpdates:function(a){var b,c;"load"===a.type&&(b=this._map.getBounds(),c=this._map.getZoom()),("viewreset"===a.type||"dragend"===a.type||"zoomend"===a.type)&&(b=a.target.getBounds(),c=a.target.getZoom()),this.attributionBoundingBoxes&&b&&c&&(b.equals(this.bounds)&&c===this.zoom||(this.bounds=b,this.zoom=c,this.updateMapAttribution()))},onAdd:function(a){L.TileLayer.prototype.onAdd.call(this,a),this.dynamicAttribution&&(this.on("load",this.handleTileUpdates,this),this._map.on("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.on("resize",this.resizeAttribution,this)},resizeAttribution:function(){var a=this._map.getSize().x;this.getAttributionLogo().style.display=600>a?"none":"block",this.getAttributionSpan().style.maxWidth=.75*a+"px"},onRemove:function(a){this.dynamicAttribution&&(this.off("load",this.handleTileUpdates,this),this._map.off("viewreset zoomend dragend",this.handleTileUpdates,this)),this._map.off("resize",this.resizeAttribution,this),L.TileLayer.prototype.onRemove.call(this,a)},getAttributionData:function(a){this.attributionBoundingBoxes=[],L.esri.get(a,{},L.bind(this.processAttributionData,this))},processAttributionData:function(a){for(var b=0;b<a.contributors.length;b++)for(var c=a.contributors[b],d=0;d<c.coverageAreas.length;d++){var e=c.coverageAreas[d],f=new L.LatLng(e.bbox[0],e.bbox[1]),g=new L.LatLng(e.bbox[2],e.bbox[3]);this.attributionBoundingBoxes.push({attribution:c.attribution,score:e.score,bounds:new L.LatLngBounds(f,g),minZoom:e.zoomMin,maxZoom:e.zoomMax})}this.attributionBoundingBoxes.sort(function(a,b){return a.score<b.score?-1:a.score>b.score?1:0}),this.bounds&&this.updateMapAttribution()},getAttributionSpan:function(){return this._map._container.querySelectorAll(".esri-attributions")[0]},getAttributionLogo:function(){return this._map._container.querySelectorAll(".esri-attribution-logo")[0]},updateMapAttribution:function(){for(var a="",b=0;b<this.attributionBoundingBoxes.length;b++){var c=this.attributionBoundingBoxes[b];if(this.bounds.intersects(c.bounds)&&this.zoom>=c.minZoom&&this.zoom<=c.maxZoom){var d=this.attributionBoundingBoxes[b].attribution;-1===a.indexOf(d)&&(a.length>0&&(a+=", "),a+=d)}}this.getAttributionSpan().innerHTML=a,this.resizeAttribution()}}),L.esri.basemapLayer=function(a,b){return new L.esri.BasemapLayer(a,b)};
View
10 src/Layers/BasemapLayer.js
@@ -1,5 +1,3 @@
-/* globals L */
-
L.esri.BasemapLayer = L.TileLayer.extend({
statics: {
TILES: {
@@ -26,31 +24,31 @@ L.esri.BasemapLayer = L.TileLayer.extend({
attributionUrl: "http://static.arcgis.com/attribution/Ocean_Basemap?f=json",
options: {
minZoom: 1,
- maxZoom: 19,
+ maxZoom: 16,
attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
}
},
NationalGeographic: {
urlTemplate: "http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}",
options: {
minZoom: 1,
- maxZoom: 19,
+ maxZoom: 16,
attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Esri</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
}
},
Gray: {
urlTemplate: "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",
options: {
minZoom: 1,
- maxZoom: 19,
+ maxZoom: 16,
attribution: "<span class='esri-attributions' style='"+L.esri.AttributionStyles+"'>Copyright: &copy;2013 Esri, DeLorme, NAVTEQ</span><img src='https://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/images/map/logo-med.png' alt='Powered by Esri' class='esri-attribution-logo' style='"+L.esri.LogoStyles+"'>"
}
},
GrayLabels: {
urlTemplate: "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}",
options: {
minZoom: 1,
- maxZoom: 19
+ maxZoom: 16
}
},
Imagery: {
View
58 src/Layers/ClusteredFeatureLayer.js
@@ -0,0 +1,58 @@
+/* globals Terraformer, L */
+(function(L, Terraformer){
+ L.esri.ClusteredFeatureLayer = L.Class.extend({
+ includes: L.esri.Mixins.featureGrid,
+ options: {
+ cellSize: 512,
+ debounce: 100,
+ deduplicate: true,
+ marker: function (geojson, latlng) {
+ return new L.marker(latlng);
+ },
+ eachMarker: undefined
+ },
+ initialize: function(url, options){
+ L.Util.setOptions(this, options);
+ this.url = L.esri.Util.cleanUrl(url);
+ this._loaded = [];
+ this.cluster = this.options.cluster || new L.MarkerClusterGroup();
+ },
+ onAdd: function(map){
+ this.options.cluster.addTo(map);
+ this._initializeFeatureGrid(map);
+ },
+ onRemove: function(map){
+ this._destroyFeatureGrid(map);
+ },
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ _render: function(response){
+ if(response.objectIdFieldName && response.features.length && !response.error){
+ var idKey = response.objectIdFieldName;
+ for (var i = response.features.length - 1; i >= 0; i--) {
+ var feature = response.features[i];
+ var id = feature.attributes[idKey];
+ if(L.esri.Util.indexOf(this._loaded, id) < 0){
+ var geojson = Terraformer.ArcGIS.parse(feature);
+ geojson.id = id;
+ var marker = this.options.marker(geojson, [geojson.geometry.coordinates[1], geojson.geometry.coordinates[0]]);
+
+ if(this.options.eachMarker){
+ this.options.eachMarker(geojson, marker);
+ }
+
+ this.cluster.addLayer(marker);
+ this._loaded.push(id);
+ }
+ }
+ }
+ }
+ });
+
+ L.esri.clusteredFeatureLayer = function(url, options){
+ return new L.esri.ClusteredFeatureLayer(url, options);
+ };
+})(L, Terraformer);
View
4 src/esri-leaflet.js
@@ -164,7 +164,7 @@ L.esri.Util = {
}
};
-L.esri.Mixins = {}
+L.esri.Mixins = {};
L.esri.Mixins.featureGrid = {
_initializeFeatureGrid: function(map){
@@ -263,7 +263,7 @@ L.esri.Mixins.featureGrid = {
var y = this.origin.y + (col*this.options.cellSize);
return [x, y];
}
-}
+};
L.esri.Mixins.identifiableLayer = {
identify:function(latLng, options, callback){

0 comments on commit 483719c

Please sign in to comment.