diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d39fc93..315e45ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ An in-progress version being developed on the master branch. * Added configurable **panning inertia** - after a quick pan, the map slows down in the same direction. * Added **polyline and polygon editing**. [#174](https://github.com/CloudMade/Leaflet/issues/174) + * Adde an unobtrusive **scale control**. * Added `DivIcon` class that easily allows you to create lightweight div-based markers. * Added `Rectangle` vector layer (by [@JasonSanford](https://github.com/JasonSanford)). [#504](https://github.com/CloudMade/Leaflet/pull/504) @@ -65,14 +66,14 @@ An in-progress version being developed on the master branch. * Fixed a bug where `TileLayer` `setOpacity` wouldn't work when setting it back to 1. * Fixed a bug where vector layer `setStyle({stroke: false})` wouldn't remove stroke and the same for fill. [#441](https://github.com/CloudMade/Leaflet/issues/441) * Fixed a bug where `Marker` `bindPopup` method wouldn't take `offset` option into account. - + #### Browser bugfixes * Fixed inability to use scrolled content inside popup due to mouse wheel propagation. * Fixed a bug that caused jumping/stuttering of panning animation in some cases. * Fixed a bug where popup size was calculated incorrectly in IE. * Fixed a bug where cursor would flicker when dragging a marker. - + #### Mobile browser bugfixes * Fixed a bug with false map click events on pinch-zoom and zoom/layers controls click. [#485](https://github.com/CloudMade/Leaflet/issues/485) diff --git a/build/deps.js b/build/deps.js index 22d86ffc..f89d2766 100644 --- a/build/deps.js +++ b/build/deps.js @@ -114,12 +114,12 @@ var deps = { src: ['layer/vector/MultiPoly.js'], deps: ['FeatureGroup', 'Polyline', 'Polygon'], desc: 'MultiPolygon and MultyPolyline layers.' - }, - - Rectangle: { - src: ['layer/vector/Rectangle.js'], - deps: ['Polygon'], - desc: ['Rectangle overlays.'] + }, + + Rectangle: { + src: ['layer/vector/Rectangle.js'], + deps: ['Polygon'], + desc: ['Rectangle overlays.'] }, Circle: { @@ -208,6 +208,13 @@ var deps = { desc: 'Attribution control.' }, + ControlScale: { + src: ['control/Control.js', + 'map/ext/Map.Control.js', + 'control/Control.Scale.js'], + desc: 'Scale control.' + }, + ControlLayers: { src: ['control/Control.js', 'map/ext/Map.Control.js', diff --git a/debug/control/control-layers.html b/debug/control/control-layers.html index 81d7a0bb..f1a45419 100644 --- a/debug/control/control-layers.html +++ b/debug/control/control-layers.html @@ -43,6 +43,8 @@ map.addControl(layersControl); + map.addControl(new L.Control.Scale()); + diff --git a/debug/leaflet-include.js b/debug/leaflet-include.js index 1ab5a1a8..02ca2f2b 100644 --- a/debug/leaflet-include.js +++ b/debug/leaflet-include.js @@ -89,6 +89,7 @@ 'control/Control.Zoom.js', 'control/Control.Attribution.js', 'control/Control.Layers.js', + 'control/Control.Scale.js' ]; function getSrcUrl() { diff --git a/dist/leaflet-src.js b/dist/leaflet-src.js index bab9d901..97f3c667 100644 --- a/dist/leaflet-src.js +++ b/dist/leaflet-src.js @@ -5506,6 +5506,103 @@ L.Control.Attribution = L.Control.extend({ }); +L.Control.Scale = L.Control.extend({ + options: { + position: 'bottomleft', + maxWidth: 100, + metric: true, + imperial: true, + updateWhenIdle: false + }, + + onAdd: function (map) { + this._map = map; + + var className = 'leaflet-control-scale', + container = L.DomUtil.create('div', className), + options = this.options; + + if (options.metric) { + this._mScale = L.DomUtil.create('div', className + '-line', container); + } + if (options.imperial) { + this._iScale = L.DomUtil.create('div', className + '-line', container); + } + + map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this); + this._update(); + + return container; + }, + + onRemove: function (map) { + map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this); + }, + + _update: function () { + var bounds = this._map.getBounds(), + centerLat = bounds.getCenter().lat, + + left = new L.LatLng(centerLat, bounds.getSouthWest().lng), + right = new L.LatLng(centerLat, bounds.getNorthEast().lng), + + size = this._map.getSize(), + options = this.options, + + maxMeters = left.distanceTo(right) * (options.maxWidth / size.x); + + if (options.metric) { + this._updateMetric(maxMeters); + } + + if (options.imperial) { + this._updateImperial(maxMeters); + } + }, + + _updateMetric: function (maxMeters) { + var meters = this._getRoundNum(maxMeters); + + this._mScale.style.width = this._getScaleWidth(meters / maxMeters) + 'px'; + this._mScale.innerHTML = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km'; + }, + + _updateImperial: function (maxMeters) { + var maxFeet = maxMeters * 3.2808399, + scale = this._iScale, + maxMiles, miles, feet; + + if (maxFeet > 5280) { + maxMiles = maxFeet / 5280; + miles = this._getRoundNum(maxMiles); + + scale.style.width = this._getScaleWidth(miles / maxMiles) + 'px'; + scale.innerHTML = miles + ' mi'; + + } else { + feet = this._getRoundNum(maxFeet); + + scale.style.width = this._getScaleWidth(feet / maxFeet) + 'px'; + scale.innerHTML = feet + ' ft'; + } + }, + + _getScaleWidth: function (ratio) { + return Math.round(this.options.maxWidth * ratio) - 10; + }, + + _getRoundNum: function (num) { + var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1), + d = num / pow10; + + return pow10 * (d >= 10 ? + 10 : + d >= 5 ? + 5 : + d >= 2 ? 2 : 1); + } +}); + L.Control.Layers = L.Control.extend({ options: { @@ -5981,7 +6078,7 @@ L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : { if (!this._panTransition) { this._panTransition = new L.Transition(this._mapPane); - //this._panTransition.on('step', this._onPanTransitionStep, this); + this._panTransition.on('step', this._onPanTransitionStep, this); this._panTransition.on('end', this._onPanTransitionEnd, this); } diff --git a/dist/leaflet.css b/dist/leaflet.css index 06bbf202..08a4d9fb 100644 --- a/dist/leaflet.css +++ b/dist/leaflet.css @@ -162,7 +162,7 @@ a.leaflet-active { } .leaflet-control-layers { - box-shadow: 0 0 7px #999; + box-shadow: 0 1px 7px #999; background: #f8f8f9; -moz-border-radius: 8px; -webkit-border-radius: 8px; @@ -206,23 +206,48 @@ a.leaflet-active { } .leaflet-container .leaflet-control-attribution { - margin: 0; - padding: 0 5px; - - font: 11px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; - color: #333; - background-color: rgba(255, 255, 255, 0.7); - box-shadow: 0 0 5px #bbb; + margin: 0; +} + +.leaflet-control-attribution, +.leaflet-control-scale-line { + padding: 0 5px; + color: #333; + } + +.leaflet-container .leaflet-control-attribution, +.leaflet-container .leaflet-control-scale { + font: 11px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; + } + +.leaflet-left .leaflet-control-scale { + margin-left: 5px; + } +.leaflet-bottom .leaflet-control-scale { + margin-bottom: 5px; + } + +.leaflet-control-scale-line { + border: 2px solid #777; + border-top: none; + color: black; + text-shadow: 1px 1px 1px #fff; + background-color: rgba(255, 255, 255, 0.5); + } +.leaflet-control-scale-line:nth-child(2) { + border-top: 2px solid #777; + border-bottom: none; + margin-top: -2px; } .leaflet-touch .leaflet-control-attribution, .leaflet-touch .leaflet-control-layers { box-shadow: none; -} + } .leaflet-touch .leaflet-control-layers { border: 5px solid #bbb; -} + } /* Fade animations */ diff --git a/dist/leaflet.js b/dist/leaflet.js index fb030fda..6e65eac4 100644 --- a/dist/leaflet.js +++ b/dist/leaflet.js @@ -3,4 +3,4 @@ Leaflet is a modern open-source JavaScript library for interactive maps. http://leaflet.cloudmade.com */ -(function(a){a.L={VERSION:"0.4",ROOT_URL:a.L_ROOT_URL||function(){var a=document.getElementsByTagName("script"),b=/\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/,c,d,e,f;for(c=0,d=a.length;c0},removeEventListener:function(a,b,c){if(!this.hasEventListeners(a))return this;for(var d=0,e=this._leaflet_events,f=e[a].length;d=this.min.x&&c.x<=this.max.x&&b.y>=this.min.y&&c.y<=this.max.y},intersects:function(a){var b=this.min,c=this.max,d=a.min,e=a.max,f=e.x>=b.x&&d.x<=c.x,g=e.y>=b.y&&d.y<=c.y;return f&&g}}),L.Transformation=L.Class.extend({initialize:function(a,b,c,d){this._a=a,this._b=b,this._c=c,this._d=d},transform:function(a,b){return this._transform(a.clone(),b)},_transform:function(a,b){return b=b||1,a.x=b*(this._a*a.x+this._b),a.y=b*(this._c*a.y+this._d),a},untransform:function(a,b){return b=b||1,new L.Point((a.x/b-this._b)/this._a,(a.y/b-this._d)/this._c)}}),L.DomUtil={get:function(a){return typeof a=="string"?document.getElementById(a):a},getStyle:function(a,b){var c=a.style[b];!c&&a.currentStyle&&(c=a.currentStyle[b]);if(!c||c==="auto"){var d=document.defaultView.getComputedStyle(a,null);c=d?d[b]:null}return c==="auto"?null:c},getViewportOffset:function(a){var b=0,c=0,d=a,e=document.body;do{b+=d.offsetTop||0,c+=d.offsetLeft||0;if(d.offsetParent===e&&L.DomUtil.getStyle(d,"position")==="absolute")break;d=d.offsetParent}while(d);d=a;do{if(d===e)break;b-=d.scrollTop||0,c-=d.scrollLeft||0,d=d.parentNode}while(d);return new L.Point(c,b)},create:function(a,b,c){var d=document.createElement(a);return d.className=b,c&&c.appendChild(d),d},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=L.Util.falseFn)},enableTextSelection:function(){document.onselectstart=this._onselectstart,this._onselectstart=null},hasClass:function(a,b){return a.className.length>0&&RegExp("(^|\\s)"+b+"(\\s|$)").test(a.className)},addClass:function(a,b){L.DomUtil.hasClass(a,b)||(a.className+=(a.className?" ":"")+b)},removeClass:function(a,b){a.className=a.className.replace(/(\S+)\s*/g,function(a,c){return c===b?"":a}).replace(/^\s+/,"")},setOpacity:function(a,b){L.Browser.ie?a.style.filter="alpha(opacity="+Math.round(b*100)+")":a.style.opacity=b},testProp:function(a){var b=document.documentElement.style;for(var c=0;c=b.lat&&e.lat<=c.lat&&d.lng>=b.lng&&e.lng<=c.lng},intersects:function(a){var b=this._southWest,c=this._northEast,d=a.getSouthWest(),e=a.getNorthEast(),f=e.lat>=b.lat&&d.lat<=c.lat,g=e.lng>=b.lng&&d.lng<=c.lng;return f&&g},toBBoxString:function(){var a=this._southWest,b=this._northEast;return[a.lng,a.lat,b.lng,b.lat].join(",")},equals:function(a){return a?this._southWest.equals(a.getSouthWest())&&this._northEast.equals(a.getNorthEast()):!1}}),L.Projection={},L.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(a){var b=L.LatLng.DEG_TO_RAD,c=this.MAX_LATITUDE,d=Math.max(Math.min(c,a.lat),-c),e=a.lng*b,f=d*b;return f=Math.log(Math.tan(Math.PI/4+f/2)),new L.Point(e,f)},unproject:function(a,b){var c=L.LatLng.RAD_TO_DEG,d=a.x*c,e=(2*Math.atan(Math.exp(a.y))-Math.PI/2)*c;return new L.LatLng(e,d,b)}},L.Projection.LonLat={project:function(a){return new L.Point(a.lng,a.lat)},unproject:function(a,b){return new L.LatLng(a.y,a.x,b)}},L.CRS={latLngToPoint:function(a,b){var c=this.projection.project(a);return this.transformation._transform(c,b)},pointToLatLng:function(a,b,c){var d=this.transformation.untransform(a,b);return this.projection.unproject(d,c)},project:function(a){return this.projection.project(a)}},L.CRS.EPSG3857=L.Util.extend({},L.CRS,{code:"EPSG:3857",projection:L.Projection.SphericalMercator,transformation:new L.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(a){var b=this.projection.project(a),c=6378137;return b.multiplyBy(c)}}),L.CRS.EPSG900913=L.Util.extend({},L.CRS.EPSG3857,{code:"EPSG:900913"}),L.CRS.EPSG4326=L.Util.extend({},L.CRS,{code:"EPSG:4326",projection:L.Projection.LonLat,transformation:new L.Transformation(1/360,.5,-1/360,.5)}),L.Map=L.Class.extend({includes:L.Mixin.Events,options:{crs:L.CRS.EPSG3857||L.CRS.EPSG4326,scale:function(a){return 256*Math.pow(2,a)},center:null,zoom:null,layers:[],dragging:!0,touchZoom:L.Browser.touch&&!L.Browser.android,scrollWheelZoom:!L.Browser.touch,doubleClickZoom:!0,boxZoom:!0,inertia:!L.Browser.android,inertiaDeceleration:L.Browser.touch?3e3:2e3,inertiaMaxSpeed:L.Browser.touch?1500:1e3,inertiaThreshold:L.Browser.touch?32:16,zoomControl:!0,attributionControl:!0,fadeAnimation:L.DomUtil.TRANSITION&&!L.Browser.android,zoomAnimation:L.DomUtil.TRANSITION&&!L.Browser.android&&!L.Browser.mobileOpera,trackResize:!0,closePopupOnClick:!0,worldCopyJump:!0},initialize:function(a,b){L.Util.setOptions(this,b);var c=this._container=L.DomUtil.get(a);if(c._leaflet)throw Error("Map container is already initialized.");c._leaflet=!0,this._initLayout(),L.DomEvent&&(this._initEvents(),L.Handler&&this._initInteraction(),L.Control&&this._initControls()),b=this.options,b.maxBounds&&this.setMaxBounds(b.maxBounds);var d=b.center,e=b.zoom;d&&typeof e!="undefined"&&this.setView(d,e,!0),this._initLayers(b.layers)},setView:function(a,b){return this._resetView(a,this._limitZoom(b)),this},setZoom:function(a){return this.setView(this.getCenter(),a)},zoomIn:function(){return this.setZoom(this._zoom+1)},zoomOut:function(){return this.setZoom(this._zoom-1)},fitBounds:function(a){var b=this.getBoundsZoom(a);return this.setView(a.getCenter(),b)},fitWorld:function(){var a=new L.LatLng(-60,-170),b=new L.LatLng(85,179);return this.fitBounds(new L.LatLngBounds(a,b))},panTo:function(a){return this.setView(a,this._zoom)},panBy:function(a){return this.fire("movestart"),this._rawPanBy(a),this.fire("move"),this.fire("moveend")},setMaxBounds:function(a){this.options.maxBounds=a;if(!a)return this._boundsMinZoom=null,this;var b=this.getBoundsZoom(a,!0);return this._boundsMinZoom=b,this._loaded&&(this._zoomf.x&&(g=f.x-d.x),c.y>e.y&&(h=e.y-c.y),c.xl&&--m>0)o=h*Math.sin(j),n=Math.PI/2-2*Math.atan(i*Math.pow((1-o)/(1+o),.5*h))-j,j+=n;return new L.LatLng(j*c,f,b)}},L.CRS.EPSG3395=L.Util.extend({},L.CRS,{code:"EPSG:3395",projection:L.Projection.Mercator,transformation:function(){var a=L.Projection.Mercator,b=a.R_MAJOR,c=a.R_MINOR;return new L.Transformation(.5/(Math.PI*b),.5,-0.5/(Math.PI*c),.5)}()}),L.TileLayer=L.Class.extend({includes:L.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",opacity:1,scheme:"xyz",continuousWorld:!1,noWrap:!1,zoomOffset:0,zoomReverse:!1,unloadInvisibleTiles:L.Browser.mobile,updateWhenIdle:L.Browser.mobile,reuseTiles:!1},initialize:function(a,b){L.Util.setOptions(this,b),this._url=a;var c=this.options.subdomains;typeof c=="string"&&(this.options.subdomains=c.split(""))},onAdd:function(a,b){this._map=a,this._insertAtTheBottom=b,this._initContainer(),this._createTileProto(),a.on("viewreset",this._resetCallback,this),a.on("moveend",this._update,this),this.options.updateWhenIdle||(this._limitedUpdate=L.Util.limitExecByInterval(this._update,150,this),a.on("move",this._limitedUpdate,this)),this._reset(),this._update()},onRemove:function(a){a._panes.tilePane.removeChild(this._container),a.off("viewreset",this._resetCallback,this),a.off("moveend",this._update,this),this.options.updateWhenIdle||a.off("move",this._limitedUpdate,this),this._container=null,this._map=null},getAttribution:function(){return this.options.attribution},setOpacity:function(a){this.options.opacity=a,this._map&&this._updateOpacity();var b,c=this._tiles;if(L.Browser.webkit)for(b in c)c.hasOwnProperty(b)&&(c[b].style.webkitTransform+=" translate(0,0)")},_updateOpacity:function(){L.DomUtil.setOpacity(this._container,this.options.opacity)},_initContainer:function(){var a=this._map._panes.tilePane,b=a.firstChild;if(!this._container||a.empty)this._container=L.DomUtil.create("div","leaflet-layer"),this._insertAtTheBottom&&b?a.insertBefore(this._container,b):a.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()},_resetCallback:function(a){this._reset(a.hard)},_reset:function(a){var b,c=this._tiles;for(b in c)c.hasOwnProperty(b)&&this.fire("tileunload",{tile:c[b]});this._tiles={},this.options.reuseTiles&&(this._unusedTiles=[]),a&&this._container&&(this._container.innerHTML=""),this._initContainer()},_update:function(a){if(this._map._panTransition&&this._map._panTransition._inProgress)return;var b=this._map.getPixelBounds(),c=this._map.getZoom(),d=this.options.tileSize;if(c>this.options.maxZoom||ca.max.x||da.max.y)&&this._removeTile(e))},_removeTile:function(a){var b=this._tiles[a];this.fire("tileunload",{tile:b,url:b.src}),b.parentNode===this._container&&this._container.removeChild(b),this.options.reuseTiles&&this._unusedTiles.push(b),b.src=L.Util.emptyImageUrl,delete this._tiles[a]},_addTile:function(a,b){var c=this._getTilePos(a),d=this._map.getZoom(),e=a.x+":"+a.y,f=Math.pow(2,this._getOffsetZoom(d));if(!this.options.continuousWorld){if(!this.options.noWrap)a.x=(a.x%f+f)%f;else if(a.x<0||a.x>=f){this._tilesToLoad--;return}if(a.y<0||a.y>=f){this._tilesToLoad--;return}}var g=this._getTile();L.DomUtil.setPosition(g,c),this._tiles[e]=g,this.options.scheme==="tms"&&(a.y=f-a.y-1),this._loadTile(g,a,d),b.appendChild(g)},_getOffsetZoom:function(a){var b=this.options;return a=b.zoomReverse?b.maxZoom-a:a,a+b.zoomOffset},_getTilePos:function(a){var b=this._map.getPixelOrigin(),c=this.options.tileSize;return a.multiplyBy(c).subtract(b)},getTileUrl:function(a,b){var c=this.options.subdomains,d=(a.x+a.y)%c.length,e=this.options.subdomains[d];return L.Util.template(this._url,L.Util.extend({s:e,z:this._getOffsetZoom(b),x:a.x,y:a.y},this.options))},_createTileProto:function(){var a=this._tileImg=L.DomUtil.create("img","leaflet-tile");a.galleryimg="no";var b=this.options.tileSize;a.style.width=b+"px",a.style.height=b+"px"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var a=this._unusedTiles.pop();return this._resetTile(a),a}return this._createTile()},_resetTile:function(a){},_createTile:function(){var a=this._tileImg.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a.onload=this._tileOnLoad,a.onerror=this._tileOnError,a.src=this.getTileUrl(b,c)},_tileOnLoad:function(a){var b=this._layer;this.className+=" leaflet-tile-loaded",b.fire("tileload",{tile:this,url:this.src}),b._tilesToLoad--,b._tilesToLoad||b.fire("load")},_tileOnError:function(a){var b=this._layer;b.fire("tileerror",{tile:this,url:this.src});var c=b.options.errorTileUrl;c&&(this.src=c)}}),L.TileLayer.WMS=L.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(a,b){this._url=a;var c=L.Util.extend({},this.defaultWmsParams);c.width=c.height=this.options.tileSize;for(var d in b)this.options.hasOwnProperty(d)||(c[d]=b[d]);this.wmsParams=c,L.Util.setOptions(this,b)},onAdd:function(a,b){var c=parseFloat(this.wmsParams.version)<1.3?"srs":"crs";this.wmsParams[c]=a.options.crs.code,L.TileLayer.prototype.onAdd.call(this,a,b)},getTileUrl:function(a,b){var c=this._map,d=c.options.crs,e=this.options.tileSize,f=a.multiplyBy(e),g=f.add(new L.Point(e,e)),h=c.unproject(f,b,!0),i=c.unproject(g,b,!0),j=d.project(h),k=d.project(i),l=[j.x,k.y,k.x,j.y].join(",");return this._url+L.Util.getParamString(this.wmsParams)+"&bbox="+l}}),L.TileLayer.Canvas=L.TileLayer.extend({options:{async:!1},initialize:function(a){L.Util.setOptions(this,a)},redraw:function(){var a,b=this._tiles;for(a in b)b.hasOwnProperty(a)&&this._redrawTile(b[a])},_redrawTile:function(a){this.drawTile(a,a._tilePoint,a._zoom)},_createTileProto:function(){var a=this._canvasProto=L.DomUtil.create("canvas","leaflet-tile"),b=this.options.tileSize;a.width=b,a.height=b},_createTile:function(){var a=this._canvasProto.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a._tilePoint=b,a._zoom=c,this.drawTile(a,b,c),this.options.async||this.tileDrawn(a)},drawTile:function(a,b,c){},tileDrawn:function(a){this._tileOnLoad.call(a)}}),L.ImageOverlay=L.Class.extend({includes:L.Mixin.Events,initialize:function(a,b){this._url=a,this._bounds=b},onAdd:function(a){this._map=a,this._image||this._initImage(),a._panes.overlayPane.appendChild(this._image),a.on("viewreset",this._reset,this),this._reset()},onRemove:function(a){a.getPanes().overlayPane.removeChild(this._image),a.off("viewreset",this._reset,this)},_initImage:function(){this._image=L.DomUtil.create("img","leaflet-image-layer"),this._image.style.visibility="hidden",L.Util.extend(this._image,{galleryimg:"no",onselectstart:L.Util.falseFn,onmousemove:L.Util.falseFn,onload:L.Util.bind(this._onImageLoad,this),src:this._url})},_reset:function(){var a=this._image,b=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),c=this._map.latLngToLayerPoint(this._bounds.getSouthEast()).subtract(b);L.DomUtil.setPosition(a,b),a.style.width=c.x+"px",a.style.height=c.y+"px"},_onImageLoad:function(){this._image.style.visibility="",this.fire("load")}}),L.Icon=L.Class.extend({options:{className:""},initialize:function(a){L.Util.setOptions(this,a)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this.options.shadowUrl?this._createIcon("shadow"):null},_createIcon:function(a){var b=this._createImg(this.options[a+"Url"]);return this._setIconStyles(b,a),b},_setIconStyles:function(a,b){var c=this.options,d=c[b+"Size"],e=c.iconAnchor;!e&&d&&(e=d.divideBy(2,!0)),b==="shadow"&&e&&c.shadowOffset&&e._add(c.shadowOffset),a.className="leaflet-marker-"+b+" "+c.className,e&&(a.style.marginLeft=-e.x+"px",a.style.marginTop=-e.y+"px"),d&&(a.style.width=d.x+"px",a.style.height=d.y+"px")},_createImg:function(a){var b;return L.Browser.ie6?(b=document.createElement("div"),b.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+a+'")'):(b=document.createElement("img"),b.src=a),b}}),L.Icon.Default=L.Icon.extend({options:{iconUrl:L.ROOT_URL+"images/marker.png",iconSize:new L.Point(25,41),iconAnchor:new L.Point(13,41),popupAnchor:new L.Point(0,-33),shadowUrl:L.ROOT_URL+"images/marker-shadow.png",shadowSize:new L.Point(41,41)}}),L.Marker=L.Class.extend({includes:L.Mixin.Events,options:{icon:new L.Icon.Default,title:"",clickable:!0,draggable:!1,zIndexOffset:0,opacity:1},initialize:function(a,b){L.Util.setOptions(this,b),this._latlng=a},onAdd:function(a){this._map=a,a.on("viewreset",this._reset,this),this._initIcon(),this._reset()},onRemove:function(a){this._removeIcon(),this.closePopup&&this.closePopup(),a.off("viewreset",this._reset,this),this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(a){this._latlng=a,this._reset(),this._popup&&this._popup.setLatLng(a)},setZIndexOffset:function(a){this.options.zIndexOffset=a,this._reset()},setIcon:function(a){this._map&&this._removeIcon(),this.options.icon=a,this._map&&(this._initIcon(),this._reset())},_initIcon:function(){var a=this.options;this._icon||(this._icon=a.icon.createIcon(),a.title&&(this._icon.title=a.title),this._initInteraction(),this._updateOpacity()),this._shadow||(this._shadow=a.icon.createShadow());var b=this._map._panes;b.markerPane.appendChild(this._icon),this._shadow&&b.shadowPane.appendChild(this._shadow)},_removeIcon:function(){var a=this._map._panes;a.markerPane.removeChild(this._icon),this._shadow&&a.shadowPane.removeChild(this._shadow),this._icon=this._shadow=null},_reset:function(){var a=this._icon;if(!a)return;var b=this._map.latLngToLayerPoint(this._latlng).round();L.DomUtil.setPosition(a,b),this._shadow&&L.DomUtil.setPosition(this._shadow,b),a.style.zIndex=b.y+this.options.zIndexOffset},_initInteraction:function(){if(!this.options.clickable)return;var a=this._icon,b=["dblclick","mousedown","mouseover","mouseout"];a.className+=" leaflet-clickable",L.DomEvent.addListener(a,"click",this._onMouseClick,this);for(var c=0;cd?(a.style.height=d+"px",a.className+=e):a.className=a.className.replace(e,""),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){var a=this._map.latLngToLayerPoint(this._latlng);this._containerBottom=-a.y-this.options.offset.y,this._containerLeft=a.x-Math.round(this._containerWidth/2)+this.options.offset.x,this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_adjustPan:function(){if(!this.options.autoPan)return;var a=this._map,b=this._container.offsetHeight,c=this._containerWidth,d=new L.Point(this._containerLeft,-b-this._containerBottom),e=a.layerPointToContainerPoint(d),f=new L.Point(0,0),g=this.options.autoPanPadding,h=a.getSize();e.x<0&&(f.x=e.x-g.x),e.x+c>h.x&&(f.x=e.x+c-h.x+g.x),e.y<0&&(f.y=e.y-g.y),e.y+b>h.y&&(f.y=e.y+b-h.y+g.y),(f.x||f.y)&&a.panBy(f)},_onCloseButtonClick:function(a){this._close(),L.DomEvent.stop(a)}}),L.Marker.include({openPopup:function(){return this._popup&&this._map&&(this._popup.setLatLng(this._latlng),this._map.openPopup(this._popup)),this},closePopup:function(){return this._popup&&this._popup._close(),this},bindPopup:function(a,b){var c=this.options.icon.options.popupAnchor||new L.Point(0,0);return b&&b.offset&&(c=c.add(b.offset)),b=L.Util.extend({offset:c},b),this._popup||this.on("click",this.openPopup,this),this._popup=(new L.Popup(b,this)).setContent(a),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup)),this}}),L.Map.include({openPopup:function(a){return this.closePopup(),this._popup=a,this.addLayer(a).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&(this.removeLayer(this._popup).fire("popupclose",{popup:this._popup}),this._popup=null),this}}),L.LayerGroup=L.Class.extend({initialize:function(a){this._layers={};var b,c;if(a)for(b=0,c=a.length;b';var b=a.firstChild;return b.style.behavior="url(#default#VML)",b&&typeof b.adj=="object"}(),L.Path=L.Browser.svg||!L.Browser.vml?L.Path:L.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(a){return document.createElement("')}}catch(a){return function(a){return document.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var a=this._container=this._createElement("shape");a.className+=" leaflet-vml-shape"+(this.options.clickable?" leaflet-clickable":""),a.coordsize="1 1",this._path=this._createElement("path"),a.appendChild(this._path),this._map._pathRoot.appendChild(a)},_initStyle:function(){var a=this._container,b,c;this.options.stroke&&(b=this._stroke=this._createElement("stroke"),b.endcap="round",a.appendChild(b)),this.options.fill&&(c=this._fill=this._createElement("fill"),a.appendChild(c)),this._updateStyle()},_updateStyle:function(){var a=this._stroke,b=this._fill,c=this.options,d=this._container;d.stroked=c.stroke,d.filled=c.fill,c.stroke&&(a.weight=c.weight+"px",a.color=c.color,a.opacity=c.opacity),c.fill&&(b.color=c.fillColor||c.color,b.opacity=c.fillOpacity)},_updatePath:function(){var a=this._container.style;a.display="none",this._path.v=this.getPathString()+" ",a.display=""}}),L.Map.include(L.Browser.svg||!L.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var a=this._pathRoot=document.createElement("div");a.className="leaflet-vml-container",this._panes.overlayPane.appendChild(a),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),L.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),L.Path=L.Path.SVG&&!window.L_PREFER_CANVAS||!L.Browser.canvas?L.Path:L.Path.extend({statics:{CANVAS:!0,SVG:!1},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var a=this.options;a.stroke&&(this._ctx.lineWidth=a.weight,this._ctx.strokeStyle=a.color),a.fill&&(this._ctx.fillStyle=a.fillColor||a.color)},_drawPath:function(){var a,b,c,d,e,f;this._ctx.beginPath();for(a=0,c=this._parts.length;af&&(g=h,f=i);f>c&&(b[g]=1,this._simplifyDPStep(a,b,c,d,g),this._simplifyDPStep(a,b,c,g,e))},_reducePoints:function(a,b){var c=[a[0]];for(var d=1,e=0,f=a.length;db&&(c.push(a[d]),e=d);return eb.max.x&&(c|=2),a.yb.max.y&&(c|=8),c},_sqDist:function(a,b){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d},_sqClosestPointOnSegment:function(a,b,c,d){var e=b.x,f=b.y,g=c.x-e,h=c.y-f,i=g*g+h*h,j;return i>0&&(j=((a.x-e)*g+(a.y-f)*h)/i,j>1?(e=c.x,f=c.y):j>0&&(e+=g*j,f+=h*j)),g=a.x-e,h=a.y-f,d?g*g+h*h:new L.Point(e,f)}},L.Polyline=L.Path.extend({initialize:function(a,b){L.Path.prototype.initialize.call(this,b),this._latlngs=a,L.Handler.PolyEdit&&(this.editing=new L.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var a=0,b=this._latlngs.length;aa.max.x||c.y-b>a.max.y||c.x+ba.y!=e.y>a.y&&a.x<(e.x-d.x)*(a.y-d.y)/(e.y-d.y)+d.x&&(b=!b)}return b}}:{}),L.Circle.include(L.Path.CANVAS?{_drawPath:function(){var a=this._point;this._ctx.beginPath(),this._ctx.arc(a.x,a.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(a){var b=this._point,c=this.options.stroke?this.options.weight/2:0;return a.distanceTo(b)<=this._radius+c}}:{}),L.GeoJSON=L.FeatureGroup.extend({initialize:function(a,b){L.Util.setOptions(this,b),this._geojson=a,this._layers={},a&&this.addGeoJSON(a)},addGeoJSON:function(a){var b=a.features,c,d;if(b){for(c=0,d=b.length;c1){this._simulateClick=!1;return}var b=a.touches&&a.touches.length===1?a.touches[0]:a,c=b.target;L.DomEvent.preventDefault(a),L.Browser.touch&&c.tagName.toLowerCase()==="a"&&(c.className+=" leaflet-active"),this._moved=!1;if(this._moving)return;L.Browser.touch||(L.DomUtil.disableTextSelection(),this._setMovingCursor()),this._startPos=this._newPos=L.DomUtil.getPosition(this._element),this._startPoint=new L.Point(b.clientX,b.clientY),L.DomEvent.addListener(document,L.Draggable.MOVE,this._onMove,this),L.DomEvent.addListener(document,L.Draggable.END,this._onUp,this)},_onMove:function(a){if(a.touches&&a.touches.length>1)return;L.DomEvent.preventDefault(a);var b=a.touches&&a.touches.length===1?a.touches[0]:a;this._moved||(this.fire("dragstart"),this._moved=!0),this._moving=!0;var c=new L.Point(b.clientX,b.clientY);this._newPos=this._startPos.add(c).subtract(this._startPoint),L.Util.cancelAnimFrame(this._animRequest),this._animRequest=L.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),L.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(a){if(this._simulateClick&&a.changedTouches){var b=a.changedTouches[0],c=b.target,d=this._newPos&&this._newPos.distanceTo(this._startPos)||0;c.tagName.toLowerCase()==="a"&&(c.className=c.className.replace(" leaflet-active","")),d200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var a=this._map.getSize().divideBy(2),b=this._map.latLngToLayerPoint(new L.LatLng(0,0));this._initialWorldOffset=b.subtract(a)},_onPreDrag:function(){var a=this._map,b=a.options.scale(a.getZoom()),c=Math.round(b/2),d=this._initialWorldOffset.x,e=this._draggable._newPos.x,f=(e-c+d)%b+c-d,g=(e+c+d)%b-c-d,h=Math.abs(f+d)b.inertiaThreshold||typeof this._positions[0]=="undefined";if(d)a.fire("moveend");else{var e=this._lastPos.subtract(this._positions[0]),f=(this._lastTime+c-this._times[0])/1e3,g=e.multiplyBy(.58/f),h=g.distanceTo(new L.Point(0,0)),i=Math.min(b.inertiaMaxSpeed,h),j=g.multiplyBy(i/h),k=i/b.inertiaDeceleration,l=j.multiplyBy(-k/2).round(),m={duration:k,easing:"ease-out"};L.Util.requestAnimFrame(L.Util.bind(function(){this._map.panBy(l,m)},this))}a.fire("dragend"),b.maxBounds&&L.Util.requestAnimFrame(this._panInsideMaxBounds,a,!0,a._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),L.Map.DoubleClickZoom=L.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(a){this.setView(a.latlng,this._zoom+1)}}),L.Map.ScrollWheelZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(a){var b=L.DomEvent.getWheelDelta(a);this._delta+=b,this._lastMousePos=this._map.mouseEventToContainerPoint(a),clearTimeout(this._timer),this._timer=setTimeout(L.Util.bind(this._performZoom,this),50),L.DomEvent.preventDefault(a)},_performZoom:function(){var a=this._map,b=Math.round(this._delta),c=a.getZoom();b=Math.max(Math.min(b,4),-4),b=a._limitZoom(c+b)-c,this._delta=0;if(!b)return;var d=this._getCenterForScrollWheelZoom(this._lastMousePos,b),e=c+b;a.setView(d,e)},_getCenterForScrollWheelZoom:function(a,b){var c=this._map,d=c.getPixelBounds().getCenter(),e=c.getSize().divideBy(2),f=a.subtract(e).multiplyBy(1-Math.pow(2,-b)),g=d.add(f);return c.unproject(g,c._zoom,!0)}}),L.Util.extend(L.DomEvent,{addDoubleTapListener:function(a,b,c){function k(a){if(a.touches.length!==1)return;var b=Date.now(),c=b-(d||b);g=a.touches[0],e=c>0&&c<=f,d=b}function l(a){e&&(g.type="dblclick",b(g),d=null)}var d,e=!1,f=250,g,h="_leaflet_",i="touchstart",j="touchend";a[h+i+c]=k,a[h+j+c]=l,a.addEventListener(i,k,!1),a.addEventListener(j,l,!1)},removeDoubleTapListener:function(a,b){var c="_leaflet_";a.removeEventListener(a,a[c+"touchstart"+b],!1),a.removeEventListener(a,a[c+"touchend"+b],!1)}}),L.Map.TouchZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(a){var b=this._map;if(!a.touches||a.touches.length!==2||b._animatingZoom||this._zooming)return;var c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]),e=b.containerPointToLayerPoint(b.getSize().divideBy(2));this._startCenter=c.add(d).divideBy(2,!0),this._startDist=c.distanceTo(d),this._moved=!1,this._zooming=!0,this._centerOffset=e.subtract(this._startCenter),L.DomEvent.addListener(document,"touchmove",this._onTouchMove,this).addListener(document,"touchend",this._onTouchEnd,this),L.DomEvent.preventDefault(a)},_onTouchMove:function(a){if(!a.touches||a.touches.length!==2)return;var b=this._map,c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]);this._scale=c.distanceTo(d)/this._startDist,this._delta=c.add(d).divideBy(2,!0).subtract(this._startCenter);if(this._scale===1)return;this._moved||(b._mapPane.className+=" leaflet-zoom-anim",b.fire("zoomstart").fire("movestart")._prepareTileBg(),this._moved=!0),b._tileBg.style.webkitTransform=L.DomUtil.getTranslateString(this._delta)+" "+L.DomUtil.getScaleString(this._scale,this._startCenter),L.DomEvent.preventDefault(a)},_onTouchEnd:function(a){if(!this._moved||!this._zooming)return;this._zooming=!1,L.DomEvent.removeListener(document,"touchmove",this._onTouchMove).removeListener(document,"touchend",this._onTouchEnd);var b=this._centerOffset.subtract(this._delta).divideBy(this._scale),c=this._map.getPixelOrigin().add(this._startCenter).add(b),d=this._map.unproject(c),e=this._map.getZoom(),f=Math.log(this._scale)/Math.LN2,g=f>0?Math.ceil(f):Math.floor(f),h=this._map._limitZoom(e+g),i=Math.pow(2,h-e);this._map._runAnimation(d,h,i/this._scale,this._startCenter.add(b))}}),L.Map.BoxZoom=L.Handler.extend({initialize:function(a){this._map=a,this._container=a._container,this._pane=a._panes.overlayPane},addHooks:function(){L.DomEvent.addListener(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){L.DomEvent.removeListener(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(a){if(!a.shiftKey||a.which!==1&&a.button!==1)return!1;L.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(a),this._box=L.DomUtil.create("div","leaflet-zoom-box",this._pane),L.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",L.DomEvent.addListener(document,"mousemove",this._onMouseMove,this).addListener(document,"mouseup",this._onMouseUp,this).preventDefault(a)},_onMouseMove:function(a){var b=this._startLayerPoint,c=this._box,d=this._map.mouseEventToLayerPoint(a),e=d.subtract(b),f=new L.Point(Math.min(d.x,b.x),Math.min(d.y,b.y));L.DomUtil.setPosition(c,f),c.style.width=Math.abs(e.x)-4+"px",c.style.height=Math.abs(e.y)-4+"px"},_onMouseUp:function(a){this._pane.removeChild(this._box),this._container.style.cursor="",L.DomUtil.enableTextSelection(),L.DomEvent.removeListener(document,"mousemove",this._onMouseMove).removeListener(document,"mouseup",this._onMouseUp);var b=this._map,c=b.mouseEventToLayerPoint(a),d=new L.LatLngBounds(b.layerPointToLatLng(this._startLayerPoint),b.layerPointToLatLng(c));b.fitBounds(d)}}),L.Handler.MarkerDrag=L.Handler.extend({initialize:function(a){this._marker=a},addHooks:function(){var a=this._marker._icon;this._draggable||(this._draggable=(new L.Draggable(a,a)).on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this)),this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(a){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(a){var b=L.DomUtil.getPosition(this._marker._icon);this._marker._shadow&&L.DomUtil.setPosition(this._marker._shadow,b),this._marker._latlng=this._marker._map.layerPointToLatLng(b),this._marker.fire("move").fire("drag")},_onDragEnd:function(){this._marker.fire("moveend").fire("dragend")}}),L.Handler.PolyEdit=L.Handler.extend({options:{icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"})},initialize:function(a,b){this._poly=a,L.Util.setOptions(this,b)},addHooks:function(){this._poly._map&&(this._markerGroup||this._initMarkers(),this._poly._map.addLayer(this._markerGroup))},removeHooks:function(){this._poly._map&&this._poly._map.removeLayer(this._markerGroup)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup=new L.LayerGroup,this._markers=[];var a=this._poly._latlngs,b,c,d,e;for(b=0,d=a.length;ba&&(c._index+=b)})},_createMiddleMarker:function(a,b){function e(){var e=b._index;d._index=e,d.off("click",g).on("click",this._onMarkerClick,this),this._poly.spliceLatLngs(e,0,c),this._markers.splice(e,0,d),d.setOpacity(1),this._updateIndexes(e,1),b._index++,this._updatePrevNext(a,d),this._updatePrevNext(d,b)}function f(){d.off("dragstart",e,this),d.off("dragend",f,this),this._createMiddleMarker(a,d),this._createMiddleMarker(d,b)}function g(){e.call(this),f.call(this),this._poly.fire("edit")}var c=this._getMiddleLatLng(a,b),d=this._createMarker(c);d.setOpacity(.6),a._middleRight=b._middleLeft=d,d.on("click",g,this).on("dragstart",e,this).on("dragend",f,this),this._markerGroup.addLayer(d)},_updatePrevNext:function(a,b){a._next=b,b._prev=a},_getMiddleLatLng:function(a,b){var c=this._poly._map,d=c.latLngToLayerPoint(a.getLatLng()),e=c.latLngToLayerPoint(b.getLatLng());return c.layerPointToLatLng(d._add(e).divideBy(2))}}),L.Control=L.Class.extend({options:{position:"topright"},initialize:function(a){L.Util.setOptions(this,a)},getPosition:function(){return this.options.position},setPosition:function(a){this.options.position=a,this._map&&(this._map.removeControl(this),this._map.addControl(this))}}),L.Map.include({addControl:function(a){var b=a.onAdd(this);a._container=b,a._map=this;var c=a.getPosition(),d=this._controlCorners[c];return L.DomUtil.addClass(b,"leaflet-control"),c.indexOf("bottom")!==-1?d.insertBefore(b,d.firstChild):d.appendChild(b),this},removeControl:function(a){var b=a.getPosition(),c=this._controlCorners[b];return c.removeChild(a._container),a._map=null,a.onRemove&&a.onRemove(this),this},_initControlPos:function(){var a="leaflet-top",b="leaflet-bottom",c="leaflet-left",d="leaflet-right",e="leaflet-corner",f=this._container,g=this._controlCorners={};g.topleft=L.DomUtil.create("div",[e,a,c].join(" "),f),g.topright=L.DomUtil.create("div",[e,a,d].join(" "),f),g.bottomleft=L.DomUtil.create("div",[e,b,c].join(" "),f),g.bottomright=L.DomUtil.create("div",[e,b,d].join(" "),f)}}),L.Control.Zoom=L.Control.extend({options:{position:"topleft"},onAdd:function(a){var b="leaflet-control-zoom",c=L.DomUtil.create("div",b);return this._createButton("Zoom in",b+"-in",c,a.zoomIn,a),this._createButton("Zoom out",b+"-out",c,a.zoomOut,a),c},_createButton:function(a,b,c,d,e){var f=L.DomUtil.create("a",b,c);return f.href="#",f.title=a,L.DomEvent.addListener(f,"click",L.DomEvent.stopPropagation).addListener(f,"click",L.DomEvent.preventDefault).addListener(f,"click",d,e),f}}),L.Control.Attribution=L.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(a){L.Util.setOptions(this,a),this._attributions={}},onAdd:function(a){return this._map=a,this._container=L.DomUtil.create("div","leaflet-control-attribution"),L.DomEvent.disableClickPropagation(this._container),this._update(),this._container},setPrefix:function(a){this.options.prefix=a,this._update()},addAttribution:function(a){if(!a)return;this._attributions[a]||(this._attributions[a]=0),this._attributions[a]++,this._update()},removeAttribution:function(a){if(!a)return;this._attributions[a]--,this._update()},_update:function(){if(!this._map)return;var a=[];for(var b in this._attributions)this._attributions.hasOwnProperty(b)&&this._attributions[b]&&a.push(b);var c=[];this.options.prefix&&c.push(this.options.prefix),a.length&&c.push(a.join(", ")),this._container.innerHTML=c.join(" — ")}}),L.Control.Layers=L.Control.extend({options:{collapsed:!0,position:"topright"},initialize:function(a,b,c){L.Util.setOptions(this,c),this._layers={};for(var d in a)a.hasOwnProperty(d)&&this._addLayer(a[d],d);for(d in b)b.hasOwnProperty(d)&&this._addLayer(b[d],d,!0)},onAdd:function(a){return this._map=a,this._initLayout(),this._update(),this._container},addBaseLayer:function(a,b){return this._addLayer(a,b),this._update(),this},addOverlay:function(a,b){return this._addLayer(a,b,!0),this._update(),this},removeLayer:function(a){var b=L.Util.stamp(a);return delete this._layers[b],this._update(),this},_initLayout:function(){this._container=L.DomUtil.create("div","leaflet-control-layers"),L.Browser.touch?L.DomEvent.addListener(this._container,"click",L.DomEvent.stopPropagation):L.DomEvent.disableClickPropagation(this._container),this._form=L.DomUtil.create("form","leaflet-control-layers-list");if(this.options.collapsed){L.DomEvent.addListener(this._container,"mouseover",this._expand,this),L.DomEvent.addListener(this._container,"mouseout",this._collapse,this);var a=this._layersLink=L.DomUtil.create("a","leaflet-control-layers-toggle");a.href="#",a.title="Layers",L.Browser.touch?L.DomEvent.addListener(a,"click",this._expand,this):L.DomEvent.addListener(a,"focus",this._expand,this),this._map.on("movestart",this._collapse,this),this._container.appendChild(a)}else this._expand();this._baseLayersList=L.DomUtil.create("div","leaflet-control-layers-base",this._form),this._separator=L.DomUtil.create("div","leaflet-control-layers-separator",this._form),this._overlaysList=L.DomUtil.create("div","leaflet-control-layers-overlays",this._form),this._container.appendChild(this._form)},_addLayer:function(a,b,c){var d=L.Util.stamp(a);this._layers[d]={layer:a,name:b,overlay:c}},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var a=!1,b=!1;for(var c in this._layers)if(this._layers.hasOwnProperty(c)){var d=this._layers[c];this._addItem(d),b=b||d.overlay,a=a||!d.overlay}this._separator.style.display=b&&a?"":"none"},_addItem:function(a,b){var c=document.createElement("label"),d=document.createElement("input");a.overlay||(d.name="leaflet-base-layers"),d.type=a.overlay?"checkbox":"radio",d.checked=this._map.hasLayer(a.layer),d.layerId=L.Util.stamp(a.layer),L.DomEvent.addListener(d,"click",this._onInputClick,this);var e=document.createTextNode(" "+a.name);c.appendChild(d),c.appendChild(e);var f=a.overlay?this._overlaysList:this._baseLayersList;f.appendChild(c)},_onInputClick:function(){var a,b,c,d=this._form.getElementsByTagName("input"),e=d.length;for(a=0;a0},removeEventListener:function(a,b,c){if(!this.hasEventListeners(a))return this;for(var d=0,e=this._leaflet_events,f=e[a].length;d=this.min.x&&c.x<=this.max.x&&b.y>=this.min.y&&c.y<=this.max.y},intersects:function(a){var b=this.min,c=this.max,d=a.min,e=a.max,f=e.x>=b.x&&d.x<=c.x,g=e.y>=b.y&&d.y<=c.y;return f&&g}}),L.Transformation=L.Class.extend({initialize:function(a,b,c,d){this._a=a,this._b=b,this._c=c,this._d=d},transform:function(a,b){return this._transform(a.clone(),b)},_transform:function(a,b){return b=b||1,a.x=b*(this._a*a.x+this._b),a.y=b*(this._c*a.y+this._d),a},untransform:function(a,b){return b=b||1,new L.Point((a.x/b-this._b)/this._a,(a.y/b-this._d)/this._c)}}),L.DomUtil={get:function(a){return typeof a=="string"?document.getElementById(a):a},getStyle:function(a,b){var c=a.style[b];!c&&a.currentStyle&&(c=a.currentStyle[b]);if(!c||c==="auto"){var d=document.defaultView.getComputedStyle(a,null);c=d?d[b]:null}return c==="auto"?null:c},getViewportOffset:function(a){var b=0,c=0,d=a,e=document.body;do{b+=d.offsetTop||0,c+=d.offsetLeft||0;if(d.offsetParent===e&&L.DomUtil.getStyle(d,"position")==="absolute")break;d=d.offsetParent}while(d);d=a;do{if(d===e)break;b-=d.scrollTop||0,c-=d.scrollLeft||0,d=d.parentNode}while(d);return new L.Point(c,b)},create:function(a,b,c){var d=document.createElement(a);return d.className=b,c&&c.appendChild(d),d},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=L.Util.falseFn)},enableTextSelection:function(){document.onselectstart=this._onselectstart,this._onselectstart=null},hasClass:function(a,b){return a.className.length>0&&RegExp("(^|\\s)"+b+"(\\s|$)").test(a.className)},addClass:function(a,b){L.DomUtil.hasClass(a,b)||(a.className+=(a.className?" ":"")+b)},removeClass:function(a,b){a.className=a.className.replace(/(\S+)\s*/g,function(a,c){return c===b?"":a}).replace(/^\s+/,"")},setOpacity:function(a,b){L.Browser.ie?a.style.filter="alpha(opacity="+Math.round(b*100)+")":a.style.opacity=b},testProp:function(a){var b=document.documentElement.style;for(var c=0;c=b.lat&&e.lat<=c.lat&&d.lng>=b.lng&&e.lng<=c.lng},intersects:function(a){var b=this._southWest,c=this._northEast,d=a.getSouthWest(),e=a.getNorthEast(),f=e.lat>=b.lat&&d.lat<=c.lat,g=e.lng>=b.lng&&d.lng<=c.lng;return f&&g},toBBoxString:function(){var a=this._southWest,b=this._northEast;return[a.lng,a.lat,b.lng,b.lat].join(",")},equals:function(a){return a?this._southWest.equals(a.getSouthWest())&&this._northEast.equals(a.getNorthEast()):!1}}),L.Projection={},L.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(a){var b=L.LatLng.DEG_TO_RAD,c=this.MAX_LATITUDE,d=Math.max(Math.min(c,a.lat),-c),e=a.lng*b,f=d*b;return f=Math.log(Math.tan(Math.PI/4+f/2)),new L.Point(e,f)},unproject:function(a,b){var c=L.LatLng.RAD_TO_DEG,d=a.x*c,e=(2*Math.atan(Math.exp(a.y))-Math.PI/2)*c;return new L.LatLng(e,d,b)}},L.Projection.LonLat={project:function(a){return new L.Point(a.lng,a.lat)},unproject:function(a,b){return new L.LatLng(a.y,a.x,b)}},L.CRS={latLngToPoint:function(a,b){var c=this.projection.project(a);return this.transformation._transform(c,b)},pointToLatLng:function(a,b,c){var d=this.transformation.untransform(a,b);return this.projection.unproject(d,c)},project:function(a){return this.projection.project(a)}},L.CRS.EPSG3857=L.Util.extend({},L.CRS,{code:"EPSG:3857",projection:L.Projection.SphericalMercator,transformation:new L.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(a){var b=this.projection.project(a),c=6378137;return b.multiplyBy(c)}}),L.CRS.EPSG900913=L.Util.extend({},L.CRS.EPSG3857,{code:"EPSG:900913"}),L.CRS.EPSG4326=L.Util.extend({},L.CRS,{code:"EPSG:4326",projection:L.Projection.LonLat,transformation:new L.Transformation(1/360,.5,-1/360,.5)}),L.Map=L.Class.extend({includes:L.Mixin.Events,options:{crs:L.CRS.EPSG3857||L.CRS.EPSG4326,scale:function(a){return 256*Math.pow(2,a)},center:null,zoom:null,layers:[],dragging:!0,touchZoom:L.Browser.touch&&!L.Browser.android,scrollWheelZoom:!L.Browser.touch,doubleClickZoom:!0,boxZoom:!0,inertia:!L.Browser.android,inertiaDeceleration:L.Browser.touch?3e3:2e3,inertiaMaxSpeed:L.Browser.touch?1500:1e3,inertiaThreshold:L.Browser.touch?32:16,zoomControl:!0,attributionControl:!0,fadeAnimation:L.DomUtil.TRANSITION&&!L.Browser.android,zoomAnimation:L.DomUtil.TRANSITION&&!L.Browser.android&&!L.Browser.mobileOpera,trackResize:!0,closePopupOnClick:!0,worldCopyJump:!0},initialize:function(a,b){L.Util.setOptions(this,b);var c=this._container=L.DomUtil.get(a);if(c._leaflet)throw Error("Map container is already initialized.");c._leaflet=!0,this._initLayout(),L.DomEvent&&(this._initEvents(),L.Handler&&this._initInteraction(),L.Control&&this._initControls()),b=this.options,b.maxBounds&&this.setMaxBounds(b.maxBounds);var d=b.center,e=b.zoom;d&&typeof e!="undefined"&&this.setView(d,e,!0),this._initLayers(b.layers)},setView:function(a,b){return this._resetView(a,this._limitZoom(b)),this},setZoom:function(a){return this.setView(this.getCenter(),a)},zoomIn:function(){return this.setZoom(this._zoom+1)},zoomOut:function(){return this.setZoom(this._zoom-1)},fitBounds:function(a){var b=this.getBoundsZoom(a);return this.setView(a.getCenter(),b)},fitWorld:function(){var a=new L.LatLng(-60,-170),b=new L.LatLng(85,179);return this.fitBounds(new L.LatLngBounds(a,b))},panTo:function(a){return this.setView(a,this._zoom)},panBy:function(a){return this.fire("movestart"),this._rawPanBy(a),this.fire("move"),this.fire("moveend")},setMaxBounds:function(a){this.options.maxBounds=a;if(!a)return this._boundsMinZoom=null,this;var b=this.getBoundsZoom(a,!0);return this._boundsMinZoom=b,this._loaded&&(this._zoomf.x&&(g=f.x-d.x),c.y>e.y&&(h=e.y-c.y),c.xl&&--m>0)o=h*Math.sin(j),n=Math.PI/2-2*Math.atan(i*Math.pow((1-o)/(1+o),.5*h))-j,j+=n;return new L.LatLng(j*c,f,b)}},L.CRS.EPSG3395=L.Util.extend({},L.CRS,{code:"EPSG:3395",projection:L.Projection.Mercator,transformation:function(){var a=L.Projection.Mercator,b=a.R_MAJOR,c=a.R_MINOR;return new L.Transformation(.5/(Math.PI*b),.5,-0.5/(Math.PI*c),.5)}()}),L.TileLayer=L.Class.extend({includes:L.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",opacity:1,scheme:"xyz",continuousWorld:!1,noWrap:!1,zoomOffset:0,zoomReverse:!1,unloadInvisibleTiles:L.Browser.mobile,updateWhenIdle:L.Browser.mobile,reuseTiles:!1},initialize:function(a,b){L.Util.setOptions(this,b),this._url=a;var c=this.options.subdomains;typeof c=="string"&&(this.options.subdomains=c.split(""))},onAdd:function(a,b){this._map=a,this._insertAtTheBottom=b,this._initContainer(),this._createTileProto(),a.on("viewreset",this._resetCallback,this),a.on("moveend",this._update,this),this.options.updateWhenIdle||(this._limitedUpdate=L.Util.limitExecByInterval(this._update,150,this),a.on("move",this._limitedUpdate,this)),this._reset(),this._update()},onRemove:function(a){a._panes.tilePane.removeChild(this._container),a.off("viewreset",this._resetCallback,this),a.off("moveend",this._update,this),this.options.updateWhenIdle||a.off("move",this._limitedUpdate,this),this._container=null,this._map=null},getAttribution:function(){return this.options.attribution},setOpacity:function(a){this.options.opacity=a,this._map&&this._updateOpacity();var b,c=this._tiles;if(L.Browser.webkit)for(b in c)c.hasOwnProperty(b)&&(c[b].style.webkitTransform+=" translate(0,0)")},_updateOpacity:function(){L.DomUtil.setOpacity(this._container,this.options.opacity)},_initContainer:function(){var a=this._map._panes.tilePane,b=a.firstChild;if(!this._container||a.empty)this._container=L.DomUtil.create("div","leaflet-layer"),this._insertAtTheBottom&&b?a.insertBefore(this._container,b):a.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()},_resetCallback:function(a){this._reset(a.hard)},_reset:function(a){var b,c=this._tiles;for(b in c)c.hasOwnProperty(b)&&this.fire("tileunload",{tile:c[b]});this._tiles={},this.options.reuseTiles&&(this._unusedTiles=[]),a&&this._container&&(this._container.innerHTML=""),this._initContainer()},_update:function(a){if(this._map._panTransition&&this._map._panTransition._inProgress)return;var b=this._map.getPixelBounds(),c=this._map.getZoom(),d=this.options.tileSize;if(c>this.options.maxZoom||ca.max.x||da.max.y)&&this._removeTile(e))},_removeTile:function(a){var b=this._tiles[a];this.fire("tileunload",{tile:b,url:b.src}),b.parentNode===this._container&&this._container.removeChild(b),this.options.reuseTiles&&this._unusedTiles.push(b),b.src=L.Util.emptyImageUrl,delete this._tiles[a]},_addTile:function(a,b){var c=this._getTilePos(a),d=this._map.getZoom(),e=a.x+":"+a.y,f=Math.pow(2,this._getOffsetZoom(d));if(!this.options.continuousWorld){if(!this.options.noWrap)a.x=(a.x%f+f)%f;else if(a.x<0||a.x>=f){this._tilesToLoad--;return}if(a.y<0||a.y>=f){this._tilesToLoad--;return}}var g=this._getTile();L.DomUtil.setPosition(g,c),this._tiles[e]=g,this.options.scheme==="tms"&&(a.y=f-a.y-1),this._loadTile(g,a,d),b.appendChild(g)},_getOffsetZoom:function(a){var b=this.options;return a=b.zoomReverse?b.maxZoom-a:a,a+b.zoomOffset},_getTilePos:function(a){var b=this._map.getPixelOrigin(),c=this.options.tileSize;return a.multiplyBy(c).subtract(b)},getTileUrl:function(a,b){var c=this.options.subdomains,d=(a.x+a.y)%c.length,e=this.options.subdomains[d];return L.Util.template(this._url,L.Util.extend({s:e,z:this._getOffsetZoom(b),x:a.x,y:a.y},this.options))},_createTileProto:function(){var a=this._tileImg=L.DomUtil.create("img","leaflet-tile");a.galleryimg="no";var b=this.options.tileSize;a.style.width=b+"px",a.style.height=b+"px"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var a=this._unusedTiles.pop();return this._resetTile(a),a}return this._createTile()},_resetTile:function(a){},_createTile:function(){var a=this._tileImg.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a.onload=this._tileOnLoad,a.onerror=this._tileOnError,a.src=this.getTileUrl(b,c)},_tileOnLoad:function(a){var b=this._layer;this.className+=" leaflet-tile-loaded",b.fire("tileload",{tile:this,url:this.src}),b._tilesToLoad--,b._tilesToLoad||b.fire("load")},_tileOnError:function(a){var b=this._layer;b.fire("tileerror",{tile:this,url:this.src});var c=b.options.errorTileUrl;c&&(this.src=c)}}),L.TileLayer.WMS=L.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(a,b){this._url=a;var c=L.Util.extend({},this.defaultWmsParams);c.width=c.height=this.options.tileSize;for(var d in b)this.options.hasOwnProperty(d)||(c[d]=b[d]);this.wmsParams=c,L.Util.setOptions(this,b)},onAdd:function(a,b){var c=parseFloat(this.wmsParams.version)<1.3?"srs":"crs";this.wmsParams[c]=a.options.crs.code,L.TileLayer.prototype.onAdd.call(this,a,b)},getTileUrl:function(a,b){var c=this._map,d=c.options.crs,e=this.options.tileSize,f=a.multiplyBy(e),g=f.add(new L.Point(e,e)),h=c.unproject(f,b,!0),i=c.unproject(g,b,!0),j=d.project(h),k=d.project(i),l=[j.x,k.y,k.x,j.y].join(",");return this._url+L.Util.getParamString(this.wmsParams)+"&bbox="+l}}),L.TileLayer.Canvas=L.TileLayer.extend({options:{async:!1},initialize:function(a){L.Util.setOptions(this,a)},redraw:function(){var a,b=this._tiles;for(a in b)b.hasOwnProperty(a)&&this._redrawTile(b[a])},_redrawTile:function(a){this.drawTile(a,a._tilePoint,a._zoom)},_createTileProto:function(){var a=this._canvasProto=L.DomUtil.create("canvas","leaflet-tile"),b=this.options.tileSize;a.width=b,a.height=b},_createTile:function(){var a=this._canvasProto.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a._tilePoint=b,a._zoom=c,this.drawTile(a,b,c),this.options.async||this.tileDrawn(a)},drawTile:function(a,b,c){},tileDrawn:function(a){this._tileOnLoad.call(a)}}),L.ImageOverlay=L.Class.extend({includes:L.Mixin.Events,initialize:function(a,b){this._url=a,this._bounds=b},onAdd:function(a){this._map=a,this._image||this._initImage(),a._panes.overlayPane.appendChild(this._image),a.on("viewreset",this._reset,this),this._reset()},onRemove:function(a){a.getPanes().overlayPane.removeChild(this._image),a.off("viewreset",this._reset,this)},_initImage:function(){this._image=L.DomUtil.create("img","leaflet-image-layer"),this._image.style.visibility="hidden",L.Util.extend(this._image,{galleryimg:"no",onselectstart:L.Util.falseFn,onmousemove:L.Util.falseFn,onload:L.Util.bind(this._onImageLoad,this),src:this._url})},_reset:function(){var a=this._image,b=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),c=this._map.latLngToLayerPoint(this._bounds.getSouthEast()).subtract(b);L.DomUtil.setPosition(a,b),a.style.width=c.x+"px",a.style.height=c.y+"px"},_onImageLoad:function(){this._image.style.visibility="",this.fire("load")}}),L.Icon=L.Class.extend({options:{className:""},initialize:function(a){L.Util.setOptions(this,a)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this.options.shadowUrl?this._createIcon("shadow"):null},_createIcon:function(a){var b=this._createImg(this.options[a+"Url"]);return this._setIconStyles(b,a),b},_setIconStyles:function(a,b){var c=this.options,d=c[b+"Size"],e=c.iconAnchor;!e&&d&&(e=d.divideBy(2,!0)),b==="shadow"&&e&&c.shadowOffset&&e._add(c.shadowOffset),a.className="leaflet-marker-"+b+" "+c.className,e&&(a.style.marginLeft=-e.x+"px",a.style.marginTop=-e.y+"px"),d&&(a.style.width=d.x+"px",a.style.height=d.y+"px")},_createImg:function(a){var b;return L.Browser.ie6?(b=document.createElement("div"),b.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+a+'")'):(b=document.createElement("img"),b.src=a),b}}),L.Icon.Default=L.Icon.extend({options:{iconUrl:L.ROOT_URL+"images/marker.png",iconSize:new L.Point(25,41),iconAnchor:new L.Point(13,41),popupAnchor:new L.Point(0,-33),shadowUrl:L.ROOT_URL+"images/marker-shadow.png",shadowSize:new L.Point(41,41)}}),L.Marker=L.Class.extend({includes:L.Mixin.Events,options:{icon:new L.Icon.Default,title:"",clickable:!0,draggable:!1,zIndexOffset:0,opacity:1},initialize:function(a,b){L.Util.setOptions(this,b),this._latlng=a},onAdd:function(a){this._map=a,a.on("viewreset",this._reset,this),this._initIcon(),this._reset()},onRemove:function(a){this._removeIcon(),this.closePopup&&this.closePopup(),a.off("viewreset",this._reset,this),this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(a){this._latlng=a,this._reset(),this._popup&&this._popup.setLatLng(a)},setZIndexOffset:function(a){this.options.zIndexOffset=a,this._reset()},setIcon:function(a){this._map&&this._removeIcon(),this.options.icon=a,this._map&&(this._initIcon(),this._reset())},_initIcon:function(){var a=this.options;this._icon||(this._icon=a.icon.createIcon(),a.title&&(this._icon.title=a.title),this._initInteraction(),this._updateOpacity()),this._shadow||(this._shadow=a.icon.createShadow());var b=this._map._panes;b.markerPane.appendChild(this._icon),this._shadow&&b.shadowPane.appendChild(this._shadow)},_removeIcon:function(){var a=this._map._panes;a.markerPane.removeChild(this._icon),this._shadow&&a.shadowPane.removeChild(this._shadow),this._icon=this._shadow=null},_reset:function(){var a=this._icon;if(!a)return;var b=this._map.latLngToLayerPoint(this._latlng).round();L.DomUtil.setPosition(a,b),this._shadow&&L.DomUtil.setPosition(this._shadow,b),a.style.zIndex=b.y+this.options.zIndexOffset},_initInteraction:function(){if(!this.options.clickable)return;var a=this._icon,b=["dblclick","mousedown","mouseover","mouseout"];a.className+=" leaflet-clickable",L.DomEvent.addListener(a,"click",this._onMouseClick,this);for(var c=0;cd?(a.style.height=d+"px",a.className+=e):a.className=a.className.replace(e,""),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){var a=this._map.latLngToLayerPoint(this._latlng);this._containerBottom=-a.y-this.options.offset.y,this._containerLeft=a.x-Math.round(this._containerWidth/2)+this.options.offset.x,this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_adjustPan:function(){if(!this.options.autoPan)return;var a=this._map,b=this._container.offsetHeight,c=this._containerWidth,d=new L.Point(this._containerLeft,-b-this._containerBottom),e=a.layerPointToContainerPoint(d),f=new L.Point(0,0),g=this.options.autoPanPadding,h=a.getSize();e.x<0&&(f.x=e.x-g.x),e.x+c>h.x&&(f.x=e.x+c-h.x+g.x),e.y<0&&(f.y=e.y-g.y),e.y+b>h.y&&(f.y=e.y+b-h.y+g.y),(f.x||f.y)&&a.panBy(f)},_onCloseButtonClick:function(a){this._close(),L.DomEvent.stop(a)}}),L.Marker.include({openPopup:function(){return this._popup&&this._map&&(this._popup.setLatLng(this._latlng),this._map.openPopup(this._popup)),this},closePopup:function(){return this._popup&&this._popup._close(),this},bindPopup:function(a,b){var c=this.options.icon.options.popupAnchor||new L.Point(0,0);return b&&b.offset&&(c=c.add(b.offset)),b=L.Util.extend({offset:c},b),this._popup||this.on("click",this.openPopup,this),this._popup=(new L.Popup(b,this)).setContent(a),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup)),this}}),L.Map.include({openPopup:function(a){return this.closePopup(),this._popup=a,this.addLayer(a).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&(this.removeLayer(this._popup).fire("popupclose",{popup:this._popup}),this._popup=null),this}}),L.LayerGroup=L.Class.extend({initialize:function(a){this._layers={};var b,c;if(a)for(b=0,c=a.length;b';var b=a.firstChild;return b.style.behavior="url(#default#VML)",b&&typeof b.adj=="object"}(),L.Path=L.Browser.svg||!L.Browser.vml?L.Path:L.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(a){return document.createElement("')}}catch(a){return function(a){return document.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var a=this._container=this._createElement("shape");a.className+=" leaflet-vml-shape"+(this.options.clickable?" leaflet-clickable":""),a.coordsize="1 1",this._path=this._createElement("path"),a.appendChild(this._path),this._map._pathRoot.appendChild(a)},_initStyle:function(){var a=this._container,b,c;this.options.stroke&&(b=this._stroke=this._createElement("stroke"),b.endcap="round",a.appendChild(b)),this.options.fill&&(c=this._fill=this._createElement("fill"),a.appendChild(c)),this._updateStyle()},_updateStyle:function(){var a=this._stroke,b=this._fill,c=this.options,d=this._container;d.stroked=c.stroke,d.filled=c.fill,c.stroke&&(a.weight=c.weight+"px",a.color=c.color,a.opacity=c.opacity),c.fill&&(b.color=c.fillColor||c.color,b.opacity=c.fillOpacity)},_updatePath:function(){var a=this._container.style;a.display="none",this._path.v=this.getPathString()+" ",a.display=""}}),L.Map.include(L.Browser.svg||!L.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var a=this._pathRoot=document.createElement("div");a.className="leaflet-vml-container",this._panes.overlayPane.appendChild(a),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),L.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),L.Path=L.Path.SVG&&!window.L_PREFER_CANVAS||!L.Browser.canvas?L.Path:L.Path.extend({statics:{CANVAS:!0,SVG:!1},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var a=this.options;a.stroke&&(this._ctx.lineWidth=a.weight,this._ctx.strokeStyle=a.color),a.fill&&(this._ctx.fillStyle=a.fillColor||a.color)},_drawPath:function(){var a,b,c,d,e,f;this._ctx.beginPath();for(a=0,c=this._parts.length;af&&(g=h,f=i);f>c&&(b[g]=1,this._simplifyDPStep(a,b,c,d,g),this._simplifyDPStep(a,b,c,g,e))},_reducePoints:function(a,b){var c=[a[0]];for(var d=1,e=0,f=a.length;db&&(c.push(a[d]),e=d);return eb.max.x&&(c|=2),a.yb.max.y&&(c|=8),c},_sqDist:function(a,b){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d},_sqClosestPointOnSegment:function(a,b,c,d){var e=b.x,f=b.y,g=c.x-e,h=c.y-f,i=g*g+h*h,j;return i>0&&(j=((a.x-e)*g+(a.y-f)*h)/i,j>1?(e=c.x,f=c.y):j>0&&(e+=g*j,f+=h*j)),g=a.x-e,h=a.y-f,d?g*g+h*h:new L.Point(e,f)}},L.Polyline=L.Path.extend({initialize:function(a,b){L.Path.prototype.initialize.call(this,b),this._latlngs=a,L.Handler.PolyEdit&&(this.editing=new L.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var a=0,b=this._latlngs.length;aa.max.x||c.y-b>a.max.y||c.x+ba.y!=e.y>a.y&&a.x<(e.x-d.x)*(a.y-d.y)/(e.y-d.y)+d.x&&(b=!b)}return b}}:{}),L.Circle.include(L.Path.CANVAS?{_drawPath:function(){var a=this._point;this._ctx.beginPath(),this._ctx.arc(a.x,a.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(a){var b=this._point,c=this.options.stroke?this.options.weight/2:0;return a.distanceTo(b)<=this._radius+c}}:{}),L.GeoJSON=L.FeatureGroup.extend({initialize:function(a,b){L.Util.setOptions(this,b),this._geojson=a,this._layers={},a&&this.addGeoJSON(a)},addGeoJSON:function(a){var b=a.features,c,d;if(b){for(c=0,d=b.length;c1){this._simulateClick=!1;return}var b=a.touches&&a.touches.length===1?a.touches[0]:a,c=b.target;L.DomEvent.preventDefault(a),L.Browser.touch&&c.tagName.toLowerCase()==="a"&&(c.className+=" leaflet-active"),this._moved=!1;if(this._moving)return;L.Browser.touch||(L.DomUtil.disableTextSelection(),this._setMovingCursor()),this._startPos=this._newPos=L.DomUtil.getPosition(this._element),this._startPoint=new L.Point(b.clientX,b.clientY),L.DomEvent.addListener(document,L.Draggable.MOVE,this._onMove,this),L.DomEvent.addListener(document,L.Draggable.END,this._onUp,this)},_onMove:function(a){if(a.touches&&a.touches.length>1)return;L.DomEvent.preventDefault(a);var b=a.touches&&a.touches.length===1?a.touches[0]:a;this._moved||(this.fire("dragstart"),this._moved=!0),this._moving=!0;var c=new L.Point(b.clientX,b.clientY);this._newPos=this._startPos.add(c).subtract(this._startPoint),L.Util.cancelAnimFrame(this._animRequest),this._animRequest=L.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),L.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(a){if(this._simulateClick&&a.changedTouches){var b=a.changedTouches[0],c=b.target,d=this._newPos&&this._newPos.distanceTo(this._startPos)||0;c.tagName.toLowerCase()==="a"&&(c.className=c.className.replace(" leaflet-active","")),d200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var a=this._map.getSize().divideBy(2),b=this._map.latLngToLayerPoint(new L.LatLng(0,0));this._initialWorldOffset=b.subtract(a)},_onPreDrag:function(){var a=this._map,b=a.options.scale(a.getZoom()),c=Math.round(b/2),d=this._initialWorldOffset.x,e=this._draggable._newPos.x,f=(e-c+d)%b+c-d,g=(e+c+d)%b-c-d,h=Math.abs(f+d)b.inertiaThreshold||typeof this._positions[0]=="undefined";if(d)a.fire("moveend");else{var e=this._lastPos.subtract(this._positions[0]),f=(this._lastTime+c-this._times[0])/1e3,g=e.multiplyBy(.58/f),h=g.distanceTo(new L.Point(0,0)),i=Math.min(b.inertiaMaxSpeed,h),j=g.multiplyBy(i/h),k=i/b.inertiaDeceleration,l=j.multiplyBy(-k/2).round(),m={duration:k,easing:"ease-out"};L.Util.requestAnimFrame(L.Util.bind(function(){this._map.panBy(l,m)},this))}a.fire("dragend"),b.maxBounds&&L.Util.requestAnimFrame(this._panInsideMaxBounds,a,!0,a._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),L.Map.DoubleClickZoom=L.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(a){this.setView(a.latlng,this._zoom+1)}}),L.Map.ScrollWheelZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(a){var b=L.DomEvent.getWheelDelta(a);this._delta+=b,this._lastMousePos=this._map.mouseEventToContainerPoint(a),clearTimeout(this._timer),this._timer=setTimeout(L.Util.bind(this._performZoom,this),50),L.DomEvent.preventDefault(a)},_performZoom:function(){var a=this._map,b=Math.round(this._delta),c=a.getZoom();b=Math.max(Math.min(b,4),-4),b=a._limitZoom(c+b)-c,this._delta=0;if(!b)return;var d=this._getCenterForScrollWheelZoom(this._lastMousePos,b),e=c+b;a.setView(d,e)},_getCenterForScrollWheelZoom:function(a,b){var c=this._map,d=c.getPixelBounds().getCenter(),e=c.getSize().divideBy(2),f=a.subtract(e).multiplyBy(1-Math.pow(2,-b)),g=d.add(f);return c.unproject(g,c._zoom,!0)}}),L.Util.extend(L.DomEvent,{addDoubleTapListener:function(a,b,c){function k(a){if(a.touches.length!==1)return;var b=Date.now(),c=b-(d||b);g=a.touches[0],e=c>0&&c<=f,d=b}function l(a){e&&(g.type="dblclick",b(g),d=null)}var d,e=!1,f=250,g,h="_leaflet_",i="touchstart",j="touchend";a[h+i+c]=k,a[h+j+c]=l,a.addEventListener(i,k,!1),a.addEventListener(j,l,!1)},removeDoubleTapListener:function(a,b){var c="_leaflet_";a.removeEventListener(a,a[c+"touchstart"+b],!1),a.removeEventListener(a,a[c+"touchend"+b],!1)}}),L.Map.TouchZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(a){var b=this._map;if(!a.touches||a.touches.length!==2||b._animatingZoom||this._zooming)return;var c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]),e=b.containerPointToLayerPoint(b.getSize().divideBy(2));this._startCenter=c.add(d).divideBy(2,!0),this._startDist=c.distanceTo(d),this._moved=!1,this._zooming=!0,this._centerOffset=e.subtract(this._startCenter),L.DomEvent.addListener(document,"touchmove",this._onTouchMove,this).addListener(document,"touchend",this._onTouchEnd,this),L.DomEvent.preventDefault(a)},_onTouchMove:function(a){if(!a.touches||a.touches.length!==2)return;var b=this._map,c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]);this._scale=c.distanceTo(d)/this._startDist,this._delta=c.add(d).divideBy(2,!0).subtract(this._startCenter);if(this._scale===1)return;this._moved||(b._mapPane.className+=" leaflet-zoom-anim",b.fire("zoomstart").fire("movestart")._prepareTileBg(),this._moved=!0),b._tileBg.style.webkitTransform=L.DomUtil.getTranslateString(this._delta)+" "+L.DomUtil.getScaleString(this._scale,this._startCenter),L.DomEvent.preventDefault(a)},_onTouchEnd:function(a){if(!this._moved||!this._zooming)return;this._zooming=!1,L.DomEvent.removeListener(document,"touchmove",this._onTouchMove).removeListener(document,"touchend",this._onTouchEnd);var b=this._centerOffset.subtract(this._delta).divideBy(this._scale),c=this._map.getPixelOrigin().add(this._startCenter).add(b),d=this._map.unproject(c),e=this._map.getZoom(),f=Math.log(this._scale)/Math.LN2,g=f>0?Math.ceil(f):Math.floor(f),h=this._map._limitZoom(e+g),i=Math.pow(2,h-e);this._map._runAnimation(d,h,i/this._scale,this._startCenter.add(b))}}),L.Map.BoxZoom=L.Handler.extend({initialize:function(a){this._map=a,this._container=a._container,this._pane=a._panes.overlayPane},addHooks:function(){L.DomEvent.addListener(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){L.DomEvent.removeListener(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(a){if(!a.shiftKey||a.which!==1&&a.button!==1)return!1;L.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(a),this._box=L.DomUtil.create("div","leaflet-zoom-box",this._pane),L.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",L.DomEvent.addListener(document,"mousemove",this._onMouseMove,this).addListener(document,"mouseup",this._onMouseUp,this).preventDefault(a)},_onMouseMove:function(a){var b=this._startLayerPoint,c=this._box,d=this._map.mouseEventToLayerPoint(a),e=d.subtract(b),f=new L.Point(Math.min(d.x,b.x),Math.min(d.y,b.y));L.DomUtil.setPosition(c,f),c.style.width=Math.abs(e.x)-4+"px",c.style.height=Math.abs(e.y)-4+"px"},_onMouseUp:function(a){this._pane.removeChild(this._box),this._container.style.cursor="",L.DomUtil.enableTextSelection(),L.DomEvent.removeListener(document,"mousemove",this._onMouseMove).removeListener(document,"mouseup",this._onMouseUp);var b=this._map,c=b.mouseEventToLayerPoint(a),d=new L.LatLngBounds(b.layerPointToLatLng(this._startLayerPoint),b.layerPointToLatLng(c));b.fitBounds(d)}}),L.Handler.MarkerDrag=L.Handler.extend({initialize:function(a){this._marker=a},addHooks:function(){var a=this._marker._icon;this._draggable||(this._draggable=(new L.Draggable(a,a)).on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this)),this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(a){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(a){var b=L.DomUtil.getPosition(this._marker._icon);this._marker._shadow&&L.DomUtil.setPosition(this._marker._shadow,b),this._marker._latlng=this._marker._map.layerPointToLatLng(b),this._marker.fire("move").fire("drag")},_onDragEnd:function(){this._marker.fire("moveend").fire("dragend")}}),L.Handler.PolyEdit=L.Handler.extend({options:{icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"})},initialize:function(a,b){this._poly=a,L.Util.setOptions(this,b)},addHooks:function(){this._poly._map&&(this._markerGroup||this._initMarkers(),this._poly._map.addLayer(this._markerGroup))},removeHooks:function(){this._poly._map&&this._poly._map.removeLayer(this._markerGroup)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup=new L.LayerGroup,this._markers=[];var a=this._poly._latlngs,b,c,d,e;for(b=0,d=a.length;ba&&(c._index+=b)})},_createMiddleMarker:function(a,b){function e(){var e=b._index;d._index=e,d.off("click",g).on("click",this._onMarkerClick,this),this._poly.spliceLatLngs(e,0,c),this._markers.splice(e,0,d),d.setOpacity(1),this._updateIndexes(e,1),b._index++,this._updatePrevNext(a,d),this._updatePrevNext(d,b)}function f(){d.off("dragstart",e,this),d.off("dragend",f,this),this._createMiddleMarker(a,d),this._createMiddleMarker(d,b)}function g(){e.call(this),f.call(this),this._poly.fire("edit")}var c=this._getMiddleLatLng(a,b),d=this._createMarker(c);d.setOpacity(.6),a._middleRight=b._middleLeft=d,d.on("click",g,this).on("dragstart",e,this).on("dragend",f,this),this._markerGroup.addLayer(d)},_updatePrevNext:function(a,b){a._next=b,b._prev=a},_getMiddleLatLng:function(a,b){var c=this._poly._map,d=c.latLngToLayerPoint(a.getLatLng()),e=c.latLngToLayerPoint(b.getLatLng());return c.layerPointToLatLng(d._add(e).divideBy(2))}}),L.Control=L.Class.extend({options:{position:"topright"},initialize:function(a){L.Util.setOptions(this,a)},getPosition:function(){return this.options.position},setPosition:function(a){this.options.position=a,this._map&&(this._map.removeControl(this),this._map.addControl(this))}}),L.Map.include({addControl:function(a){var b=a.onAdd(this);a._container=b,a._map=this;var c=a.getPosition(),d=this._controlCorners[c];return L.DomUtil.addClass(b,"leaflet-control"),c.indexOf("bottom")!==-1?d.insertBefore(b,d.firstChild):d.appendChild(b),this},removeControl:function(a){var b=a.getPosition(),c=this._controlCorners[b];return c.removeChild(a._container),a._map=null,a.onRemove&&a.onRemove(this),this},_initControlPos:function(){var a="leaflet-top",b="leaflet-bottom",c="leaflet-left",d="leaflet-right",e="leaflet-corner",f=this._container,g=this._controlCorners={};g.topleft=L.DomUtil.create("div",[e,a,c].join(" "),f),g.topright=L.DomUtil.create("div",[e,a,d].join(" "),f),g.bottomleft=L.DomUtil.create("div",[e,b,c].join(" "),f),g.bottomright=L.DomUtil.create("div",[e,b,d].join(" "),f)}}),L.Control.Zoom=L.Control.extend({options:{position:"topleft"},onAdd:function(a){var b="leaflet-control-zoom",c=L.DomUtil.create("div",b);return this._createButton("Zoom in",b+"-in",c,a.zoomIn,a),this._createButton("Zoom out",b+"-out",c,a.zoomOut,a),c},_createButton:function(a,b,c,d,e){var f=L.DomUtil.create("a",b,c);return f.href="#",f.title=a,L.DomEvent.addListener(f,"click",L.DomEvent.stopPropagation).addListener(f,"click",L.DomEvent.preventDefault).addListener(f,"click",d,e),f}}),L.Control.Attribution=L.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(a){L.Util.setOptions(this,a),this._attributions={}},onAdd:function(a){return this._map=a,this._container=L.DomUtil.create("div","leaflet-control-attribution"),L.DomEvent.disableClickPropagation(this._container),this._update(),this._container},setPrefix:function(a){this.options.prefix=a,this._update()},addAttribution:function(a){if(!a)return;this._attributions[a]||(this._attributions[a]=0),this._attributions[a]++,this._update()},removeAttribution:function(a){if(!a)return;this._attributions[a]--,this._update()},_update:function(){if(!this._map)return;var a=[];for(var b in this._attributions)this._attributions.hasOwnProperty(b)&&this._attributions[b]&&a.push(b);var c=[];this.options.prefix&&c.push(this.options.prefix),a.length&&c.push(a.join(", ")),this._container.innerHTML=c.join(" — ")}}),L.Control.Scale=L.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(a){this._map=a;var b="leaflet-control-scale",c=L.DomUtil.create("div",b),d=this.options;return d.metric&&(this._mScale=L.DomUtil.create("div",b+"-line",c)),d.imperial&&(this._iScale=L.DomUtil.create("div",b+"-line",c)),a.on(d.updateWhenIdle?"moveend":"move",this._update,this),this._update(),c},onRemove:function(a){a.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_update:function(){var a=this._map.getBounds(),b=a.getCenter().lat,c=new L.LatLng(b,a.getSouthWest().lng),d=new L.LatLng(b,a.getNorthEast().lng),e=this._map.getSize(),f=this.options,g=c.distanceTo(d)*(f.maxWidth/e.x);f.metric&&this._updateMetric(g),f.imperial&&this._updateImperial(g)},_updateMetric:function(a){var b=this._getRoundNum(a);this._mScale.style.width=this._getScaleWidth(b/a)+"px",this._mScale.innerHTML=b<1e3?b+" m":b/1e3+" km"},_updateImperial:function(a){var b=a*3.2808399,c=this._iScale,d,e,f;b>5280?(d=b/5280,e=this._getRoundNum(d),c.style.width=this._getScaleWidth(e/d)+"px",c.innerHTML=e+" mi"):(f=this._getRoundNum(b),c.style.width=this._getScaleWidth(f/b)+"px",c.innerHTML=f+" ft")},_getScaleWidth:function(a){return Math.round(this.options.maxWidth*a)-10},_getRoundNum:function(a){var b=Math.pow(10,(Math.floor(a)+"").length-1),c=a/b;return b*(c<10?c<5?c<2?1:2:5:10)}}),L.Control.Layers=L.Control.extend({options:{collapsed:!0,position:"topright"},initialize:function(a,b,c){L.Util.setOptions(this,c),this._layers={};for(var d in a)a.hasOwnProperty(d)&&this._addLayer(a[d],d);for(d in b)b.hasOwnProperty(d)&&this._addLayer(b[d],d,!0)},onAdd:function(a){return this._map=a,this._initLayout(),this._update(),this._container},addBaseLayer:function(a,b){return this._addLayer(a,b),this._update(),this},addOverlay:function(a,b){return this._addLayer(a,b,!0),this._update(),this},removeLayer:function(a){var b=L.Util.stamp(a);return delete this._layers[b],this._update(),this},_initLayout:function(){this._container=L.DomUtil.create("div","leaflet-control-layers"),L.Browser.touch?L.DomEvent.addListener(this._container,"click",L.DomEvent.stopPropagation):L.DomEvent.disableClickPropagation(this._container),this._form=L.DomUtil.create("form","leaflet-control-layers-list");if(this.options.collapsed){L.DomEvent.addListener(this._container,"mouseover",this._expand,this),L.DomEvent.addListener(this._container,"mouseout",this._collapse,this);var a=this._layersLink=L.DomUtil.create("a","leaflet-control-layers-toggle");a.href="#",a.title="Layers",L.Browser.touch?L.DomEvent.addListener(a,"click",this._expand,this):L.DomEvent.addListener(a,"focus",this._expand,this),this._map.on("movestart",this._collapse,this),this._container.appendChild(a)}else this._expand();this._baseLayersList=L.DomUtil.create("div","leaflet-control-layers-base",this._form),this._separator=L.DomUtil.create("div","leaflet-control-layers-separator",this._form),this._overlaysList=L.DomUtil.create("div","leaflet-control-layers-overlays",this._form),this._container.appendChild(this._form)},_addLayer:function(a,b,c){var d=L.Util.stamp(a);this._layers[d]={layer:a,name:b,overlay:c}},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var a=!1,b=!1;for(var c in this._layers)if(this._layers.hasOwnProperty(c)){var d=this._layers[c];this._addItem(d),b=b||d.overlay,a=a||!d.overlay}this._separator.style.display=b&&a?"":"none"},_addItem:function(a,b){var c=document.createElement("label"),d=document.createElement("input");a.overlay||(d.name="leaflet-base-layers"),d.type=a.overlay?"checkbox":"radio",d.checked=this._map.hasLayer(a.layer),d.layerId=L.Util.stamp(a.layer),L.DomEvent.addListener(d,"click",this._onInputClick,this);var e=document.createTextNode(" "+a.name);c.appendChild(d),c.appendChild(e);var f=a.overlay?this._overlaysList:this._baseLayersList;f.appendChild(c)},_onInputClick:function(){var a,b,c,d=this._form.getElementsByTagName("input"),e=d.length;for(a=0;a 5280) { + maxMiles = maxFeet / 5280; + miles = this._getRoundNum(maxMiles); + + scale.style.width = this._getScaleWidth(miles / maxMiles) + 'px'; + scale.innerHTML = miles + ' mi'; + + } else { + feet = this._getRoundNum(maxFeet); + + scale.style.width = this._getScaleWidth(feet / maxFeet) + 'px'; + scale.innerHTML = feet + ' ft'; + } + }, + + _getScaleWidth: function (ratio) { + return Math.round(this.options.maxWidth * ratio) - 10; + }, + + _getRoundNum: function (num) { + var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1), + d = num / pow10; + + return pow10 * (d >= 10 ? + 10 : + d >= 5 ? + 5 : + d >= 2 ? 2 : 1); + } +}); \ No newline at end of file