text: /*! esri-leaflet - v1.0.0-rc.6 - 2015-03-05
  *   Copyright (c) 2015 Environmental Systems Research Institute, Inc.
  *   Apache License*/
  (function (factory) {
    //define an AMD module that relies on 'leaflet'
    if (typeof define === 'function' && define.amd) {
      define(['leaflet'], function (L) {
        return factory(L);
      });
    //define a common js module that relies on 'leaflet'
    } else if (typeof module === 'object' && typeof module.exports === 'object') {
      module.exports = factory(require('leaflet'));
    }
  
    if(typeof window !== 'undefined' && window.L){
      factory(window.L);
    }
  }(function (L) {
  var EsriLeaflet = { //jshint ignore:line
    VERSION: '1.0.0-rc.5',
    Layers: {},
    Services: {},
    Controls: {},
    Tasks: {},
    Util: {},
    Support: {
      CORS: !!(window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()),
      pointerEvents: document.documentElement.style.pointerEvents === ''
    }
  };
  
  if(typeof window !== 'undefined' && window.L){
    window.L.esri = EsriLeaflet;
  }
  
  
  (function(EsriLeaflet){
  
    var callbacks = 0;
  
    window._EsriLeafletCallbacks = {};
  
    function serialize(params){
      var data = '';
  
      params.f = params.f || 'json';
  
      for (var key in params){
        if(params.hasOwnProperty(key)){
          var param = params[key];
          var type = Object.prototype.toString.call(param);
          var value;
  
          if(data.length){
            data += '&';
          }
  
          if (type === '[object Array]'){
            value = (Object.prototype.toString.call(param[0]) === '[object Object]') ? JSON.stringify(param) : param.join(',');
          } else if (type === '[object Object]') {
            value = JSON.stringify(param);
          } else if (type === '[object Date]'){
            value = param.valueOf();
          } else {
            value = param;
          }
  
          data += encodeURIComponent(key) + '=' + encodeURIComponent(value);
        }
      }
  
      return data;
    }
  
    function createRequest(callback, context){
      var httpRequest = new XMLHttpRequest();
  
      httpRequest.onerror = function(e) {
        httpRequest.onreadystatechange = L.Util.falseFn;
  
        callback.call(context, {
          error: {
            code: 500,
            message: 'XMLHttpRequest error'
          }
        }, null);
      };
  
      httpRequest.onreadystatechange = function(){
        var response;
        var error;
  
        if (httpRequest.readyState === 4) {
          try {
            response = JSON.parse(httpRequest.responseText);
          } catch(e) {
            response = null;
            error = {
              code: 500,
              message: 'Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error.'
            };
          }
  
          if (!error && response.error) {
            error = response.error;
            response = null;
          }
  
          httpRequest.onerror = L.Util.falseFn;
  
          callback.call(context, error, response);
        }
      };
  
      return httpRequest;
    }
  
    // AJAX handlers for CORS (modern browsers) or JSONP (older browsers)
    EsriLeaflet.Request = {
      request: function(url, params, callback, context){
        var paramString = serialize(params);
        var httpRequest = createRequest(callback, context);
        var requestLength = (url + '?' + paramString).length;
  
        // request is less then 2000 characters and the browser supports CORS, make GET request with XMLHttpRequest
        if(requestLength <= 2000 && L.esri.Support.CORS){
          httpRequest.open('GET', url + '?' + paramString);
          httpRequest.send(null);
  
        // request is less more then 2000 characters and the browser supports CORS, make POST request with XMLHttpRequest
        } else if (requestLength > 2000 && L.esri.Support.CORS){
          httpRequest.open('POST', url);
          httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          httpRequest.send(paramString);
  
        // request is less more then 2000 characters and the browser does not support CORS, make a JSONP request
        } else if(requestLength <= 2000 && !L.esri.Support.CORS){
          return L.esri.Request.get.JSONP(url, params, callback, context);
  
        // request is longer then 2000 characters and the browser does not support CORS, log a warning
        } else {
          if(console && console.warn){
            console.warn('a request to ' + url + ' was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html');
            return;
          }
        }
  
        return httpRequest;
      },
      post: {
        XMLHTTP: function (url, params, callback, context) {
          var httpRequest = createRequest(callback, context);
          httpRequest.open('POST', url);
          httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
          httpRequest.send(serialize(params));
  
          return httpRequest;
        }
      },
  
      get: {
        CORS: function (url, params, callback, context) {
          var httpRequest = createRequest(callback, context);
  
          httpRequest.open('GET', url + '?' + serialize(params), true);
          httpRequest.send(null);
  
          return httpRequest;
        },
        JSONP: function(url, params, callback, context){
          var callbackId = 'c' + callbacks;
  
          params.callback = 'window._EsriLeafletCallbacks.' + callbackId;
  
          var script = L.DomUtil.create('script', null, document.body);
          script.type = 'text/javascript';
          script.src = url + '?' +  serialize(params);
          script.id = callbackId;
  
          window._EsriLeafletCallbacks[callbackId] = function(response){
            if(window._EsriLeafletCallbacks[callbackId] !== true){
              var error;
              var responseType = Object.prototype.toString.call(response);
  
              if(!(responseType === '[object Object]' || responseType === '[object Array]')){
                error = {
                  error: {
                    code: 500,
                    message: 'Expected array or object as JSONP response'
                  }
                };
                response = null;
              }
  
              if (!error && response.error) {
                error = response;
                response = null;
              }
  
              callback.call(context, error, response);
              window._EsriLeafletCallbacks[callbackId] = true;
            }
          };
  
          callbacks++;
  
          return {
            id: callbackId,
            url: script.src,
            abort: function(){
              window._EsriLeafletCallbacks._callback[callbackId]({
                code: 0,
                message: 'Request aborted.'
              });
            }
          };
        }
      }
    };
  
    // choose the correct AJAX handler depending on CORS support
    EsriLeaflet.get = (EsriLeaflet.Support.CORS) ? EsriLeaflet.Request.get.CORS : EsriLeaflet.Request.get.JSONP;
  
    // always use XMLHttpRequest for posts
    EsriLeaflet.post = EsriLeaflet.Request.post.XMLHTTP;
  
    // expose a common request method the uses GET\POST based on request length
    EsriLeaflet.request = EsriLeaflet.Request.request;
  
  })(EsriLeaflet);
  
  (function(EsriLeaflet){
  
    var tileProtocol = (window.location.protocol !== 'https:') ? 'http:' : 'https:';
  
    EsriLeaflet.Layers.BasemapLayer = L.TileLayer.extend({
      statics: {
        TILES: {
          Streets: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
            attributionUrl: 'https://static.arcgis.com/attribution/World_Street_Map',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 19,
              subdomains: ['server', 'services'],
              attribution: 'Esri'
            }
          },
          Topographic: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
            attributionUrl: 'https://static.arcgis.com/attribution/World_Topo_Map',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 19,
              subdomains: ['server', 'services'],
              attribution: 'Esri'
            }
          },
          Oceans: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}',
            attributionUrl: 'https://static.arcgis.com/attribution/Ocean_Basemap',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 16,
              subdomains: ['server', 'services'],
              attribution: 'Esri'
            }
          },
          OceansLabels: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: true,
              logoPosition: 'bottomright',
              //pane: 'esri-label',
              minZoom: 1,
              maxZoom: 16,
              subdomains: ['server', 'services']
            }
          },
          NationalGeographic: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 16,
              subdomains: ['server', 'services'],
              attribution: 'Esri'
            }
          },
          DarkGray: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 16,
              subdomains: ['server', 'services'],
              attribution: 'Esri, DeLorme, HERE'
            }
          },
          DarkGrayLabels: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: true,
              logoPosition: 'bottomright',
              //pane: 'esri-label',
              minZoom: 1,
              maxZoom: 16,
              subdomains: ['server', 'services']
            }
          },
          Gray: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 16,
              subdomains: ['server', 'services'],
              attribution: 'Esri, NAVTEQ, DeLorme'
            }
          },
          GrayLabels: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: true,
              logoPosition: 'bottomright',
              //pane: 'esri-label',
              minZoom: 1,
              maxZoom: 16,
              subdomains: ['server', 'services']
            }
          },
          Imagery: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 19,
              subdomains: ['server', 'services'],
              attribution: 'Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community'
            }
          },
          ImageryLabels: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: true,
              logoPosition: 'bottomright',
              //pane: 'esri-label',
              minZoom: 1,
              maxZoom: 19,
              subdomains: ['server', 'services']
            }
          },
          ImageryTransportation: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}',
            //pane: 'esri-label',
            options: {
              hideLogo: true,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 19,
              subdomains: ['server', 'services']
            }
          },
          ShadedRelief: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 13,
              subdomains: ['server', 'services'],
              attribution: 'ESRI, NAVTEQ, DeLorme'
            }
          },
          ShadedReliefLabels: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: true,
              logoPosition: 'bottomright',
              //pane: 'esri-label',
              minZoom: 1,
              maxZoom: 12,
              subdomains: ['server', 'services']
            }
          },
          Terrain: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: false,
              logoPosition: 'bottomright',
              minZoom: 1,
              maxZoom: 13,
              subdomains: ['server', 'services'],
              attribution: 'Esri, USGS, NOAA'
            }
          },
          TerrainLabels: {
            urlTemplate: tileProtocol + '//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}',
            options: {
              hideLogo: true,
              logoPosition: 'bottomright',
              //pane: 'esri-label',
              minZoom: 1,
              maxZoom: 13,
              subdomains: ['server', 'services']
            }
          }
        }
      },
      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' && EsriLeaflet.BasemapLayer.TILES[key]){
          config = EsriLeaflet.BasemapLayer.TILES[key];
        } else {
          throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of "Streets", "Topographic", "Oceans", "OceansLabels", "NationalGeographic", "Gray", "GrayLabels", "DarkGray", "DarkGrayLabels", "Imagery", "ImageryLabels", "ImageryTransportation", "ShadedRelief", "ShadedReliefLabels", "Terrain" or "TerrainLabels"');
        }
  
        // merge passed options into the config options
        var tileOptions = L.Util.extend(config.options, options);
  
        // call the initialize method on L.TileLayer to set everything up
        L.TileLayer.prototype.initialize.call(this, config.urlTemplate, L.Util.setOptions(this, tileOptions));
  
        // if this basemap requires dynamic attribution set it up
        if(config.attributionUrl){
          this._getAttributionData(config.attributionUrl);
        }
        this._logo = new EsriLeaflet.Controls.Logo({
          position: this.options.logoPosition
        });
      },
      onAdd: function(map){
        if(!this.options.hideLogo && !map._hasEsriLogo){
          this._logo.addTo(map);
          map._hasEsriLogo = true;
        }
  
        // if(this.options.pane && EsriLeaflet.Support.pointerEvents){
        //   this._initPane();
        // }
  
        L.TileLayer.prototype.onAdd.call(this, map);
  
        map.on('moveend', this._updateMapAttribution, this);
      },
      onRemove: function(map){
        // check to make sure the logo hasn't already been removed
        if(this._logo && this._logo._container){
          map.removeControl(this._logo);
          map._hasEsriLogo = false;
        }
  
        L.TileLayer.prototype.onRemove.call(this, map);
  
        map.off('moveend', this._updateMapAttribution, this);
      },
      getAttribution:function(){
        var attribution = '<span class="esri-attributions" style="line-height:14px; vertical-align: -3px; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; display:inline-block;">' + this.options.attribution + '</span>'/* + logo*/;
        return attribution;
      },
      // _initPane: function(){
      //   if(!this._map.getPane(this.options.pane)){
      //     var pane = this._map.createPane(this.options.pane);
      //     pane.style.pointerEvents = 'none';
      //     pane.style.zIndex = 5;
      //   }
      // },
      _getAttributionData: function(url){
        EsriLeaflet.get(url, {}, function(error, attributions){
          this._attributions = [];
          for (var c = 0; c < attributions.contributors.length; c++) {
            var contributor = attributions.contributors[c];
            for (var i = 0; i < contributor.coverageAreas.length; i++) {
              var coverageArea = contributor.coverageAreas[i];
              var southWest = new L.LatLng(coverageArea.bbox[0], coverageArea.bbox[1]);
              var northEast = new L.LatLng(coverageArea.bbox[2], coverageArea.bbox[3]);
              this._attributions.push({
                attribution: contributor.attribution,
                score: coverageArea.score,
                bounds: new L.LatLngBounds(southWest, northEast),
                minZoom: coverageArea.zoomMin,
                maxZoom: coverageArea.zoomMax
              });
            }
          }
  
          this._attributions.sort(function(a, b){
            return b.score - a.score;
          });
  
          this._updateMapAttribution();
        }, this);
      },
      _updateMapAttribution: function(){
        if(this._map && this._map.attributionControl && this._attributions){
          var newAttributions = '';
          var bounds = this._map.getBounds();
          var zoom = this._map.getZoom();
  
          for (var i = 0; i < this._attributions.length; i++) {
            var attribution = this._attributions[i];
            var text = attribution.attribution;
            if(!newAttributions.match(text) && bounds.intersects(attribution.bounds) && zoom >= attribution.minZoom && zoom <= attribution.maxZoom) {
              newAttributions += (', ' + text);
            }
          }
          newAttributions = newAttributions.substr(2);
          var attributionElement = this._map.attributionControl._container.querySelector('.esri-attributions');
          attributionElement.innerHTML = newAttributions;
          attributionElement.style.maxWidth =  (this._map.getSize().x * 0.65) + 'px';
          this.fire('attributionupdated', {
            attribution: newAttributions
          });
        }
      }
    });
  
    EsriLeaflet.BasemapLayer = EsriLeaflet.Layers.BasemapLayer;
  
    EsriLeaflet.Layers.basemapLayer = function(key, options){
      return new EsriLeaflet.Layers.BasemapLayer(key, options);
    };
  
    EsriLeaflet.basemapLayer = function(key, options){
      return new EsriLeaflet.Layers.BasemapLayer(key, options);
    };
  
  })(EsriLeaflet);
  
  EsriLeaflet.Controls.Logo = L.Control.extend({
    options: {
      position: 'bottomright',
      marginTop: 0,
      marginLeft: 0,
      marginBottom: 0,
      marginRight: 0
    },
    onAdd: function () {
      var div = L.DomUtil.create('div', 'esri-leaflet-logo');
      div.style.marginTop = this.options.marginTop;
      div.style.marginLeft = this.options.marginLeft;
      div.style.marginBottom = this.options.marginBottom;
      div.style.marginRight = this.options.marginRight;
      div.innerHTML = '<a href="https://developers.arcgis.com" style="border: none;"><img src="https://js.arcgis.com/3.11/esri/images/map/logo-med.png" style="border: none;"></a>';
      return div;
    }
  });
  
  EsriLeaflet.Controls.logo = function(options){
    return new L.esri.Controls.Logo(options);
  };
  
  
    return EsriLeaflet;
  }));
  //# sourceMappingURL=esri-leaflet-basemaps-src.js.map