!function(t){var e={};function i(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e){L.BingLayer=L.TileLayer.extend({options:{subdomains:[0,1,2,3],type:"Aerial",attribution:"Bing",culture:""},initialize:function(t,e){L.Util.setOptions(this,e),this._key=t,this._url=null,this._providers=[],this.metaRequested=!1},tile2quad:function(t,e,i){for(var o="",r=i;r>0;r--){var a=0,n=1<<r-1;0!=(t&n)&&(a+=1),0!=(e&n)&&(a+=2),o+=a}return o},getTileUrl:function(t){var e=this._getZoomForUrl(),i=this.options.subdomains,o=this.options.subdomains[Math.abs((t.x+t.y)%i.length)];return this._url.replace("{subdomain}",o).replace("{quadkey}",this.tile2quad(t.x,t.y,e)).replace("{culture}",this.options.culture)},loadMetadata:function(){if(!this.metaRequested){this.metaRequested=!0;var t=this,e="_bing_metadata_"+L.Util.stamp(this);window[e]=function(i){window[e]=void 0;var o=document.getElementById(e);if(o.parentNode.removeChild(o),i.errorDetails)throw new Error(i.errorDetails);t.initMetadata(i)};var i="file:"===document.location.protocol?"http":document.location.protocol.slice(0,-1),o=i+"://dev.virtualearth.net/REST/v1/Imagery/Metadata/"+this.options.type+"?include=ImageryProviders&jsonp="+e+"&key="+this._key+"&UriScheme="+i,r=document.createElement("script");r.type="text/javascript",r.src=o,r.id=e,document.getElementsByTagName("head")[0].appendChild(r)}},initMetadata:function(t){var e=t.resourceSets[0].resources[0];if(this.options.subdomains=e.imageUrlSubdomains,this._url=e.imageUrl,e.imageryProviders)for(var i=0;i<e.imageryProviders.length;i++)for(var o=e.imageryProviders[i],r=0;r<o.coverageAreas.length;r++){var a=o.coverageAreas[r],n={zoomMin:a.zoomMin,zoomMax:a.zoomMax,active:!1},s=new L.LatLngBounds(new L.LatLng(a.bbox[0]+.01,a.bbox[1]+.01),new L.LatLng(a.bbox[2]-.01,a.bbox[3]-.01));n.bounds=s,n.attrib=o.attribution,this._providers.push(n)}this._update()},_update:function(){null!==this._url&&this._map&&(this._update_attribution(),L.TileLayer.prototype._update.apply(this,[]))},_update_attribution:function(){for(var t=L.latLngBounds(this._map.getBounds().getSouthWest().wrap(),this._map.getBounds().getNorthEast().wrap()),e=this._map.getZoom(),i=0;i<this._providers.length;i++){var o=this._providers[i];e<=o.zoomMax&&e>=o.zoomMin&&t.intersects(o.bounds)?(!o.active&&this._map.attributionControl&&this._map.attributionControl.addAttribution(o.attrib),o.active=!0):(o.active&&this._map.attributionControl&&this._map.attributionControl.removeAttribution(o.attrib),o.active=!1)}},onAdd:function(t){this.loadMetadata(),L.TileLayer.prototype.onAdd.apply(this,[t])},onRemove:function(t){for(var e=0;e<this._providers.length;e++){var i=this._providers[e];i.active&&this._map.attributionControl&&(this._map.attributionControl.removeAttribution(i.attrib),i.active=!1)}L.TileLayer.prototype.onRemove.apply(this,[t])}}),L.bingLayer=function(t,e){return new L.BingLayer(t,e)}}]);
//# sourceMappingURL=tile-bing-prod.js.map