diff --git a/dist/leaflet-src.js b/dist/leaflet-src.js index 95b4b6ec..536f4135 100644 --- a/dist/leaflet-src.js +++ b/dist/leaflet-src.js @@ -131,6 +131,10 @@ L.Util = { return Math.round(num * pow) / pow; }, + splitWords: function (str) { + return str.replace(/^\s+|\s+$/g, '').split(/\s+/); + }, + setOptions: function (obj, options) { obj.options = L.Util.extend({}, obj.options, options); return obj.options; @@ -228,27 +232,28 @@ L.Class.mergeOptions = function (options) { * L.Mixin.Events adds custom events functionality to Leaflet classes */ +var key = '_leaflet_events'; + L.Mixin = {}; L.Mixin.Events = { addEventListener: function (types, fn, context) { // (String, Function[, Object]) or (Object[, Object]) - var events = this._leaflet_events = this._leaflet_events || {}, + var events = this[key] = this[key] || {}, type, i, len; // Types can be a map of types/handlers if (typeof types === 'object') { for (type in types) { if (types.hasOwnProperty(type)) { - this.addEventListener(type, types[type], fn || this); + this.addEventListener(type, types[type], fn); } } return this; } - // TODO extract trim into util method - types = types.replace(/^\s+|\s+$/g, '').split(/\s+/); + types = L.Util.splitWords(types); for (i = 0, len = types.length; i < len; i++) { events[types[i]] = events[types[i]] || []; @@ -262,25 +267,24 @@ L.Mixin.Events = { }, hasEventListeners: function (type) { // (String) -> Boolean - var k = '_leaflet_events'; - return (k in this) && (type in this[k]) && (this[k][type].length > 0); + return (key in this) && (type in this[key]) && (this[key][type].length > 0); }, removeEventListener: function (types, fn, context) { // (String[, Function, Object]) or (Object[, Object]) - var events = this._leaflet_events, + var events = this[key], type, i, len, listeners, j; if (typeof types === 'object') { for (type in types) { if (types.hasOwnProperty(type)) { - this.removeEventListener(type, types[type], context || this); + this.removeEventListener(type, types[type], context); } } return this; } - types = types.replace(/^\s+|\s+$/g, '').split(/\s+/); + types = L.Util.splitWords(types); for (i = 0, len = types.length; i < len; i++) { @@ -311,7 +315,7 @@ L.Mixin.Events = { target: this }, data); - var listeners = this._leaflet_events[type].slice(); + var listeners = this[key][type].slice(); for (var i = 0, len = listeners.length; i < len; i++) { listeners[i].action.call(listeners[i].context || this, event); @@ -341,7 +345,7 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent; gecko3d = gecko && ('MozPerspective' in doc.style), opera3d = opera && ('OTransition' in doc.style); - var touch = (function () { + var touch = !window.L_NO_TOUCH && (function () { var startName = 'ontouchstart'; // WebKit, etc @@ -663,12 +667,15 @@ L.DomUtil = { }, removeClass: function (el, name) { - el.className = el.className.replace(/(\S+)\s*/g, function (w, match) { + function replaceFn(w, match) { if (match === name) { return ''; } return w; - }).replace(/^\s+/, ''); + } + el.className = el.className + .replace(/(\S+)\s*/g, replaceFn) + .replace(/^\s+/, ''); }, setOpacity: function (el, value) { @@ -1452,10 +1459,12 @@ L.Map = L.Class.extend({ panes.markerPane = this._createPane('leaflet-marker-pane'); panes.popupPane = this._createPane('leaflet-popup-pane'); + var zoomHide = ' leaflet-zoom-hide'; + if (!this.options.markerZoomAnimation) { - panes.markerPane.className += ' leaflet-zoom-hide'; - panes.shadowPane.className += ' leaflet-zoom-hide'; - panes.popupPane.className += ' leaflet-zoom-hide'; + panes.markerPane.className += zoomHide; + panes.shadowPane.className += zoomHide; + panes.popupPane.className += zoomHide; } }, @@ -1981,7 +1990,7 @@ L.TileLayer = L.Class.extend({ this.fire("tileunload", {tile: tile, url: tile.src}); if (this.options.reuseTiles) { - tile.className = tile.className.replace(' leaflet-tile-loaded', ''); + L.DomUtil.removeClass(tile, 'leaflet-tile-loaded'); this._unusedTiles.push(tile); } else if (tile.parentNode === this._container) { this._container.removeChild(tile); @@ -2747,7 +2756,7 @@ L.Popup = L.Class.extend({ onRemove: function (map) { map._panes.popupPane.removeChild(this._container); - L.Util.falseFn(this._container.offsetWidth); + L.Util.falseFn(this._container.offsetWidth); // force reflow map.off({ viewreset: this._updatePosition, @@ -2835,29 +2844,30 @@ L.Popup = L.Class.extend({ }, _updateLayout: function () { - var container = this._contentNode; + var container = this._contentNode, + style = container.style; - container.style.width = ''; - container.style.whiteSpace = 'nowrap'; + style.width = ''; + style.whiteSpace = 'nowrap'; var width = container.offsetWidth; width = Math.min(width, this.options.maxWidth); width = Math.max(width, this.options.minWidth); - container.style.width = (width + 1) + 'px'; - container.style.whiteSpace = ''; + style.width = (width + 1) + 'px'; + style.whiteSpace = ''; - container.style.height = ''; + style.height = ''; var height = container.offsetHeight, maxHeight = this.options.maxHeight, - scrolledClass = ' leaflet-popup-scrolled'; + scrolledClass = 'leaflet-popup-scrolled'; if (maxHeight && height > maxHeight) { - container.style.height = maxHeight + 'px'; - container.className += scrolledClass; + style.height = maxHeight + 'px'; + L.DomUtil.addClass(container, scrolledClass); } else { - container.className = container.className.replace(scrolledClass, ''); + L.DomUtil.removeClass(container, scrolledClass); } this._containerWidth = this._container.offsetWidth; @@ -4884,7 +4894,7 @@ L.Draggable = L.Class.extend({ dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0; if (el.tagName.toLowerCase() === 'a') { - el.className = el.className.replace(' leaflet-active', ''); + L.DomUtil.removeClass(el, 'leaflet-active'); } if (dist < L.Draggable.TAP_TOLERANCE) { @@ -4910,11 +4920,11 @@ L.Draggable = L.Class.extend({ }, _setMovingCursor: function () { - document.body.className += ' leaflet-dragging'; + L.DomUtil.addClass(document.body, 'leaflet-dragging'); }, _restoreCursor: function () { - document.body.className = document.body.className.replace(/ leaflet-dragging/g, ''); + L.DomUtil.removeClass(document.body, 'leaflet-dragging'); }, _simulateEvent: function (type, e) { @@ -4941,17 +4951,15 @@ L.Handler = L.Class.extend({ }, enable: function () { - if (this._enabled) { - return; - } + if (this._enabled) { return; } + this._enabled = true; this.addHooks(); }, disable: function () { - if (!this._enabled) { - return; - } + if (!this._enabled) { return; } + this._enabled = false; this.removeHooks(); }, @@ -5335,7 +5343,7 @@ L.Map.TouchZoom = L.Handler.extend({ var map = this._map; this._zooming = false; - map._mapPane.className = map._mapPane.className.replace(' leaflet-touching', ''); //TODO toggleClass util + L.DomUtil.removeClass(map._mapPane, 'leaflet-touching'); L.DomEvent .off(document, 'touchmove', this._onTouchMove) @@ -6555,7 +6563,7 @@ L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : { }, _onPanTransitionEnd: function () { - this._mapPane.className = this._mapPane.className.replace(/ leaflet-pan-anim/g, ''); + L.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim'); this.fire('moveend'); }, @@ -6737,10 +6745,10 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { _onZoomTransitionEnd: function () { this._restoreTileFront(); - L.Util.falseFn(this._tileBg.offsetWidth); + L.Util.falseFn(this._tileBg.offsetWidth); // force reflow this._resetView(this._animateToCenter, this._animateToZoom, true, true); - this._mapPane.className = this._mapPane.className.replace(' leaflet-zoom-anim', ''); //TODO toggleClass util + L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim'); this._animatingZoom = false; }, diff --git a/dist/leaflet.js b/dist/leaflet.js index dda52fe7..abc1f91d 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(){var e,t;typeof exports!="undefined"?e=exports:(t=window.L,e={},e.noConflict=function(){return window.L=t,this},window.L=e),e.version="0.4",e.Util={extend:function(e){var t=Array.prototype.slice.call(arguments,1);for(var n=0,r=t.length,i;n2?Array.prototype.slice.call(arguments,2):null;return function(){return e.apply(t,n||arguments)}},stamp:function(){var e=0,t="_leaflet_id";return function(n){return n[t]=n[t]||++e,n[t]}}(),requestAnimFrame:function(){function t(e){window.setTimeout(e,1e3/60)}var n=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||t;return function(r,i,s,o){r=i?e.Util.bind(r,i):r;if(!s||n!==t)return n.call(window,r,o);r()}}(),cancelAnimFrame:function(){var e=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout;return function(t){if(!t)return;return e.call(window,t)}}(),limitExecByInterval:function(e,t,n){var r,i;return function s(){var o=arguments;if(r){i=!0;return}r=!0,setTimeout(function(){r=!1,i&&(s.apply(n,o),i=!1)},t),e.apply(n,o)}},falseFn:function(){return!1},formatNum:function(e,t){var n=Math.pow(10,t||5);return Math.round(e*n)/n},setOptions:function(t,n){return t.options=e.Util.extend({},t.options,n),t.options},getParamString:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n+"="+e[n]);return"?"+t.join("&")},template:function(e,t){return e.replace(/\{ *([\w_]+) *\}/g,function(e,n){var r=t[n];if(!t.hasOwnProperty(n))throw Error("No value provided for variable "+e);return r})},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},e.Class=function(){},e.Class.extend=function(t){var n=function(){this.initialize&&this.initialize.apply(this,arguments)},r=function(){};r.prototype=this.prototype;var i=new r;i.constructor=n,n.prototype=i;for(var s in this)this.hasOwnProperty(s)&&s!=="prototype"&&(n[s]=this[s]);return t.statics&&(e.Util.extend(n,t.statics),delete t.statics),t.includes&&(e.Util.extend.apply(null,[i].concat(t.includes)),delete t.includes),t.options&&i.options&&(t.options=e.Util.extend({},i.options,t.options)),e.Util.extend(i,t),n},e.Class.include=function(t){e.Util.extend(this.prototype,t)},e.Class.mergeOptions=function(t){e.Util.extend(this.prototype.options,t)},e.Mixin={},e.Mixin.Events={addEventListener:function(e,t,n){var r=this._leaflet_events=this._leaflet_events||{},i,s,o;if(typeof e=="object"){for(i in e)e.hasOwnProperty(i)&&this.addEventListener(i,e[i],t||this);return this}e=e.replace(/^\s+|\s+$/g,"").split(/\s+/);for(s=0,o=e.length;s0},removeEventListener:function(e,t,n){var r=this._leaflet_events,i,s,o,u,a;if(typeof e=="object"){for(i in e)e.hasOwnProperty(i)&&this.removeEventListener(i,e[i],n||this);return this}e=e.replace(/^\s+|\s+$/g,"").split(/\s+/);for(s=0,o=e.length;s=0;a--)(!t||u[a].action===t)&&(!n||u[a].context===n)&&u.splice(a,1)}return this},fireEvent:function(t,n){if(!this.hasEventListeners(t))return this;var r=e.Util.extend({type:t,target:this},n),i=this._leaflet_events[t].slice();for(var s=0,o=i.length;s=this.min.x&&r.x<=this.max.x&&n.y>=this.min.y&&r.y<=this.max.y},intersects:function(e){var t=this.min,n=this.max,r=e.min,i=e.max,s=i.x>=t.x&&r.x<=n.x,o=i.y>=t.y&&r.y<=n.y;return s&&o}}),e.Transformation=e.Class.extend({initialize:function(e,t,n,r){this._a=e,this._b=t,this._c=n,this._d=r},transform:function(e,t){return this._transform(e.clone(),t)},_transform:function(e,t){return t=t||1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e},untransform:function(t,n){return n=n||1,new e.Point((t.x/n-this._b)/this._a,(t.y/n-this._d)/this._c)}}),e.DomUtil={get:function(e){return typeof e=="string"?document.getElementById(e):e},getStyle:function(e,t){var n=e.style[t];!n&&e.currentStyle&&(n=e.currentStyle[t]);if(!n||n==="auto"){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n==="auto"?null:n},getViewportOffset:function(t){var n=0,r=0,i=t,s=document.body;do{n+=i.offsetTop||0,r+=i.offsetLeft||0;if(i.offsetParent===s&&e.DomUtil.getStyle(i,"position")==="absolute")break;if(e.DomUtil.getStyle(i,"position")==="fixed"){n+=s.scrollTop||0,r+=s.scrollLeft||0;break}i=i.offsetParent}while(i);i=t;do{if(i===s)break;n-=i.scrollTop||0,r-=i.scrollLeft||0,i=i.parentNode}while(i);return new e.Point(r,n)},create:function(e,t,n){var r=document.createElement(e);return r.className=t,n&&n.appendChild(r),r},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=e.Util.falseFn)},enableTextSelection:function(){document.onselectstart=this._onselectstart,this._onselectstart=null},hasClass:function(e,t){return e.className.length>0&&RegExp("(^|\\s)"+t+"(\\s|$)").test(e.className)},addClass:function(t,n){e.DomUtil.hasClass(t,n)||(t.className+=(t.className?" ":"")+n)},removeClass:function(e,t){e.className=e.className.replace(/(\S+)\s*/g,function(e,n){return n===t?"":e}).replace(/^\s+/,"")},setOpacity:function(t,n){e.Browser.ie?t.style.filter+=n!==1?"alpha(opacity="+Math.round(n*100)+")":"":t.style.opacity=n},testProp:function(e){var t=document.documentElement.style;for(var n=0;n=n.lat&&s.lat<=r.lat&&i.lng>=n.lng&&s.lng<=r.lng},intersects:function(e){var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),s=i.lat>=t.lat&&r.lat<=n.lat,o=i.lng>=t.lng&&r.lng<=n.lng;return s&&o},toBBoxString:function(){var e=this._southWest,t=this._northEast;return[e.lng,e.lat,t.lng,t.lat].join(",")},equals:function(e){return e?this._southWest.equals(e.getSouthWest())&&this._northEast.equals(e.getNorthEast()):!1}}),e.Projection={},e.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(t){var n=e.LatLng.DEG_TO_RAD,r=this.MAX_LATITUDE,i=Math.max(Math.min(r,t.lat),-r),s=t.lng*n,o=i*n;return o=Math.log(Math.tan(Math.PI/4+o/2)),new e.Point(s,o)},unproject:function(t){var n=e.LatLng.RAD_TO_DEG,r=t.x*n,i=(2*Math.atan(Math.exp(t.y))-Math.PI/2)*n;return new e.LatLng(i,r,!0)}},e.Projection.LonLat={project:function(t){return new e.Point(t.lng,t.lat)},unproject:function(t){return new e.LatLng(t.y,t.x,!0)}},e.CRS={latLngToPoint:function(e,t){var n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)},pointToLatLng:function(e,t){var n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)},project:function(e){return this.projection.project(e)},scale:function(e){return 256*Math.pow(2,e)}},e.CRS.EPSG3857=e.Util.extend({},e.CRS,{code:"EPSG:3857",projection:e.Projection.SphericalMercator,transformation:new e.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(e){var t=this.projection.project(e),n=6378137;return t.multiplyBy(n)}}),e.CRS.EPSG900913=e.Util.extend({},e.CRS.EPSG3857,{code:"EPSG:900913"}),e.CRS.EPSG4326=e.Util.extend({},e.CRS,{code:"EPSG:4326",projection:e.Projection.LonLat,transformation:new e.Transformation(1/360,.5,-1/360,.5)}),e.Map=e.Class.extend({includes:e.Mixin.Events,options:{crs:e.CRS.EPSG3857,fadeAnimation:e.DomUtil.TRANSITION&&!e.Browser.android,trackResize:!0,markerZoomAnimation:!0},initialize:function(t,n){n=e.Util.setOptions(this,n),this._initContainer(t),this._initLayout(),this._initHooks(),this._initEvents(),n.maxBounds&&this.setMaxBounds(n.maxBounds),n.center&&typeof n.zoom!="undefined"&&this.setView(n.center,n.zoom,!0),this._initLayers(n.layers)},setView:function(e,t){return this._resetView(e,this._limitZoom(t)),this},setZoom:function(e){return this.setView(this.getCenter(),e)},zoomIn:function(){return this.setZoom(this._zoom+1)},zoomOut:function(){return this.setZoom(this._zoom-1)},fitBounds:function(e){var t=this.getBoundsZoom(e);return this.setView(e.getCenter(),t)},fitWorld:function(){var t=new e.LatLng(-60,-170),n=new e.LatLng(85,179);return this.fitBounds(new e.LatLngBounds(t,n))},panTo:function(e){return this.setView(e,this._zoom)},panBy:function(e){return this.fire("movestart"),this._rawPanBy(e),this.fire("move"),this.fire("moveend")},setMaxBounds:function(e){this.options.maxBounds=e;if(!e)return this._boundsMinZoom=null,this;var t=this.getBoundsZoom(e,!0);return this._boundsMinZoom=t,this._loaded&&(this._zoomo.x&&(u=o.x-i.x),r.y>s.y&&(a=s.y-r.y),r.xc&&--h>0)d=u*Math.sin(f),p=Math.PI/2-2*Math.atan(a*Math.pow((1-d)/(1+d),.5*u))-f,f+=p;return new e.LatLng(f*n,s,!0)}},e.CRS.EPSG3395=e.Util.extend({},e.CRS,{code:"EPSG:3395",projection:e.Projection.Mercator,transformation:function(){var t=e.Projection.Mercator,n=t.R_MAJOR,r=t.R_MINOR;return new e.Transformation(.5/(Math.PI*n),.5,-0.5/(Math.PI*r),.5)}()}),e.TileLayer=e.Class.extend({includes:e.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,detectRetina:!1,unloadInvisibleTiles:e.Browser.mobile,updateWhenIdle:e.Browser.mobile,reuseTiles:!1},initialize:function(t,n){n=e.Util.setOptions(this,n),n.detectRetina&&window.devicePixelRatio>1&&n.maxZoom>0&&(n.tileSize=Math.floor(n.tileSize/2),n.zoomOffset++,n.minZoom>0&&n.minZoom--,this.options.maxZoom--),this._url=t;var r=this.options.subdomains;typeof r=="string"&&(this.options.subdomains=r.split(""))},onAdd:function(t,n){this._map=t,this._insertAtTheBottom=n,this._initContainer(),this._createTileProto(),t.on({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||(this._limitedUpdate=e.Util.limitExecByInterval(this._update,150,this),t.on("move",this._limitedUpdate,this)),this._reset(),this._update()},onRemove:function(e){e._panes.tilePane.removeChild(this._container),e.off({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||e.off("move",this._limitedUpdate,this),this._container=null,this._map=null},bringToFront:function(){this._container&&this._map._panes.tilePane.appendChild(this._container)},bringToBack:function(){var e=this._map._panes.tilePane;this._container&&e.insertBefore(this._container,e.firstChild)},getAttribution:function(){return this.options.attribution},setOpacity:function(e){this.options.opacity=e,this._map&&this._updateOpacity()},_updateOpacity:function(){e.DomUtil.setOpacity(this._container,this.options.opacity);var t,n=this._tiles;if(e.Browser.webkit)for(t in n)n.hasOwnProperty(t)&&(n[t].style.webkitTransform+=" translate(0,0)")},_initContainer:function(){var t=this._map._panes.tilePane,n=t.firstChild;if(!this._container||t.empty)this._container=e.DomUtil.create("div","leaflet-layer"),this._insertAtTheBottom&&n?t.insertBefore(this._container,n):t.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()},_resetCallback:function(e){this._reset(e.hard)},_reset:function(e){var t,n=this._tiles;for(t in n)n.hasOwnProperty(t)&&this.fire("tileunload",{tile:n[t]});this._tiles={},this.options.reuseTiles&&(this._unusedTiles=[]),e&&this._container&&(this._container.innerHTML=""),this._initContainer()},_update:function(t){if(this._map._panTransition&&this._map._panTransition._inProgress)return;var n=this._map.getPixelBounds(),r=this._map.getZoom(),i=this.options.tileSize;if(r>this.options.maxZoom||re.max.x||re.max.y)&&this._removeTile(i))},_removeTile:function(t){var n=this._tiles[t];this.fire("tileunload",{tile:n,url:n.src}),this.options.reuseTiles?(n.className=n.className.replace(" leaflet-tile-loaded",""),this._unusedTiles.push(n)):n.parentNode===this._container&&this._container.removeChild(n),n.src=e.Util.emptyImageUrl,delete this._tiles[t]},_addTile:function(t,n){var r=this._getTilePos(t),i=this._map.getZoom(),s=t.x+":"+t.y,o=Math.pow(2,this._getOffsetZoom(i));if(!this.options.continuousWorld){if(!this.options.noWrap)t.x=(t.x%o+o)%o;else if(t.x<0||t.x>=o){this._tilesToLoad--;return}if(t.y<0||t.y>=o){this._tilesToLoad--;return}}var u=this._getTile();e.DomUtil.setPosition(u,r,!0),this._tiles[s]=u,this.options.scheme==="tms"&&(t.y=o-t.y-1),this._loadTile(u,t,i),u.parentNode!==this._container&&n.appendChild(u)},_getOffsetZoom:function(e){var t=this.options;return e=t.zoomReverse?t.maxZoom-e:e,e+t.zoomOffset},_getTilePos:function(e){var t=this._map.getPixelOrigin(),n=this.options.tileSize;return e.multiplyBy(n).subtract(t)},getTileUrl:function(t,n){var r=this.options.subdomains,i=(t.x+t.y)%r.length,s=this.options.subdomains[i];return e.Util.template(this._url,e.Util.extend({s:s,z:this._getOffsetZoom(n),x:t.x,y:t.y},this.options))},_createTileProto:function(){var t=this._tileImg=e.DomUtil.create("img","leaflet-tile");t.galleryimg="no";var n=this.options.tileSize;t.style.width=n+"px",t.style.height=n+"px"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var e=this._unusedTiles.pop();return this._resetTile(e),e}return this._createTile()},_resetTile:function(e){},_createTile:function(){var t=this._tileImg.cloneNode(!1);return t.onselectstart=t.onmousemove=e.Util.falseFn,t},_loadTile:function(e,t,n){e._layer=this,e.onload=this._tileOnLoad,e.onerror=this._tileOnError,e.src=this.getTileUrl(t,n)},_tileLoaded:function(){this._tilesToLoad--,this._tilesToLoad||this.fire("load")},_tileOnLoad:function(t){var n=this._layer;this.src!==e.Util.emptyImageUrl&&(this.className+=" leaflet-tile-loaded",n.fire("tileload",{tile:this,url:this.src})),n._tileLoaded()},_tileOnError:function(e){var t=this._layer;t.fire("tileerror",{tile:this,url:this.src});var n=t.options.errorTileUrl;n&&(this.src=n),t._tileLoaded()}}),e.TileLayer.WMS=e.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(t,n){this._url=t;var r=e.Util.extend({},this.defaultWmsParams);r.width=r.height=this.options.tileSize;for(var i in n)this.options.hasOwnProperty(i)||(r[i]=n[i]);this.wmsParams=r,e.Util.setOptions(this,n)},onAdd:function(t,n){var r=parseFloat(this.wmsParams.version)>=1.3?"crs":"srs";this.wmsParams[r]=t.options.crs.code,e.TileLayer.prototype.onAdd.call(this,t,n)},getTileUrl:function(t,n){var r=this._map,i=r.options.crs,s=this.options.tileSize,o=t.multiplyBy(s),u=o.add(new e.Point(s,s)),a=r.unproject(o,n),f=r.unproject(u,n),l=i.project(a),c=i.project(f),h=[l.x,c.y,c.x,l.y].join(",");return this._url+e.Util.getParamString(this.wmsParams)+"&bbox="+h}}),e.TileLayer.Canvas=e.TileLayer.extend({options:{async:!1},initialize:function(t){e.Util.setOptions(this,t)},redraw:function(){var e,t=this._tiles;for(e in t)t.hasOwnProperty(e)&&this._redrawTile(t[e])},_redrawTile:function(e){this.drawTile(e,e._tilePoint,e._zoom)},_createTileProto:function(){var t=this._canvasProto=e.DomUtil.create("canvas","leaflet-tile"),n=this.options.tileSize;t.width=n,t.height=n},_createTile:function(){var t=this._canvasProto.cloneNode(!1);return t.onselectstart=t.onmousemove=e.Util.falseFn,t},_loadTile:function(e,t,n){e._layer=this,e._tilePoint=t,e._zoom=n,this.drawTile(e,t,n),this.options.async||this.tileDrawn(e)},drawTile:function(e,t,n){},tileDrawn:function(e){this._tileOnLoad.call(e)}}),e.ImageOverlay=e.Class.extend({includes:e.Mixin.Events,options:{opacity:1},initialize:function(t,n,r){this._url=t,this._bounds=n,e.Util.setOptions(this,r)},onAdd:function(e){this._map=e,this._image||this._initImage(),e._panes.overlayPane.appendChild(this._image),e.on("viewreset",this._reset,this),e.options.zoomAnimation&&e.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(e){e.getPanes().overlayPane.removeChild(this._image),e.off("viewreset",this._reset,this),e.options.zoomAnimation&&e.off("zoomanim",this._animateZoom,this)},setOpacity:function(e){this.options.opacity=e,this._updateOpacity()},_initImage:function(){this._image=e.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&(this._image.className+=" leaflet-zoom-animated"),this._updateOpacity(),e.Util.extend(this._image,{galleryimg:"no",onselectstart:e.Util.falseFn,onmousemove:e.Util.falseFn,onload:e.Util.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(t){var n=this._map,r=this._image,i=n.getZoomScale(t.zoom),s=this._bounds.getNorthWest(),o=this._bounds.getSouthEast(),u=n._latLngToNewLayerPoint(s,t.zoom,t.center),a=n._latLngToNewLayerPoint(o,t.zoom,t.center).subtract(u),f=n.latLngToLayerPoint(o).subtract(n.latLngToLayerPoint(s)),l=u.add(a.subtract(f).divideBy(2));r.style[e.DomUtil.TRANSFORM]=e.DomUtil.getTranslateString(l)+" scale("+i+") "},_reset:function(){var t=this._image,n=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),r=this._map.latLngToLayerPoint(this._bounds.getSouthEast()).subtract(n);e.DomUtil.setPosition(t,n),t.style.width=r.x+"px",t.style.height=r.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){e.DomUtil.setOpacity(this._image,this.options.opacity)}}),e.Icon=e.Class.extend({options:{className:""},initialize:function(t){e.Util.setOptions(this,t)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this._createIcon("shadow")},_createIcon:function(e){var t=this._getIconUrl(e);if(!t)return null;var n=this._createImg(t);return this._setIconStyles(n,e),n},_setIconStyles:function(e,t){var n=this.options,r=n[t+"Size"],i=n.iconAnchor;!i&&r&&(i=r.divideBy(2,!0)),t==="shadow"&&i&&n.shadowOffset&&i._add(n.shadowOffset),e.className="leaflet-marker-"+t+" "+n.className+" leaflet-zoom-animated",i&&(e.style.marginLeft=-i.x+"px",e.style.marginTop=-i.y+"px"),r&&(e.style.width=r.x+"px",e.style.height=r.y+"px")},_createImg:function(t){var n;return e.Browser.ie6?(n=document.createElement("div"),n.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+t+'")'):(n=document.createElement("img"),n.src=t),n},_getIconUrl:function(e){return this.options[e+"Url"]}}),e.Icon.Default=e.Icon.extend({options:{iconSize:new e.Point(25,41),iconAnchor:new e.Point(13,41),popupAnchor:new e.Point(0,-33),shadowSize:new e.Point(41,41)},_getIconUrl:function(t){var n=e.Icon.Default.imagePath;if(!n)throw Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");return n+"/marker-"+t+".png"}}),e.Icon.Default.imagePath=function(){var e=document.getElementsByTagName("script"),t=/\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/,n,r,i,s;for(n=0,r=e.length;nr?(e.style.height=r+"px",e.className+=i):e.className=e.className.replace(i,""),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng),n=e.Browser.any3d,r=this.options.offset;n&&e.DomUtil.setPosition(this._container,t),this._containerBottom=-r.y-(n?0:t.y),this._containerLeft=-Math.round(this._containerWidth/2)+r.x+(n?0:t.x),this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_zoomAnimation:function(t){var n=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center)._round();e.DomUtil.setPosition(this._container,n)},_adjustPan:function(){if(!this.options.autoPan)return;var t=this._map,n=this._container.offsetHeight,r=this._containerWidth,i=new e.Point(this._containerLeft,-n-this._containerBottom);e.Browser.any3d&&i._add(e.DomUtil.getPosition(this._container));var s=t.layerPointToContainerPoint(i),o=this.options.autoPanPadding,u=t.getSize(),a=0,f=0;s.x<0&&(a=s.x-o.x),s.x+r>u.x&&(a=s.x+r-u.x+o.x),s.y<0&&(f=s.y-o.y),s.y+n>u.y&&(f=s.y+n-u.y+o.y),(a||f)&&t.panBy(new e.Point(a,f))},_onCloseButtonClick:function(t){this._close(),e.DomEvent.stop(t)}}),e.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(t,n){var r=this.options.icon.options.popupAnchor||new e.Point(0,0);return n&&n.offset&&(r=r.add(n.offset)),n=e.Util.extend({offset:r},n),this._popup||this.on("click",this.openPopup,this),this._popup=(new e.Popup(n,this)).setContent(t),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup)),this}}),e.Map.include({openPopup:function(e){return this.closePopup(),this._popup=e,this.addLayer(e).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&this._popup._close(),this}}),e.LayerGroup=e.Class.extend({initialize:function(e){this._layers={};var t,n;if(e)for(t=0,n=e.length;t';var t=e.firstChild;return t.style.behavior="url(#default#VML)",t&&typeof t.adj=="object"}(),e.Path=e.Browser.svg||!e.Browser.vml?e.Path:e.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(e){return document.createElement("')}}catch(e){return function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var e=this._container=this._createElement("shape");e.className+=" leaflet-vml-shape"+(this.options.clickable?" leaflet-clickable":""),e.coordsize="1 1",this._path=this._createElement("path"),e.appendChild(this._path),this._map._pathRoot.appendChild(e)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var e=this._stroke,t=this._fill,n=this.options,r=this._container;r.stroked=n.stroke,r.filled=n.fill,n.stroke?(e||(e=this._stroke=this._createElement("stroke"),e.endcap="round",r.appendChild(e)),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity):e&&(r.removeChild(e),this._stroke=null),n.fill?(t||(t=this._fill=this._createElement("fill"),r.appendChild(t)),t.color=n.fillColor||n.color,t.opacity=n.fillOpacity):t&&(r.removeChild(t),this._fill=null)},_updatePath:function(){var e=this._container.style;e.display="none",this._path.v=this.getPathString()+" ",e.display=""}}),e.Map.include(e.Browser.svg||!e.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var e=this._pathRoot=document.createElement("div");e.className="leaflet-vml-container",this._panes.overlayPane.appendChild(e),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),e.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),e.Path=e.Path.SVG&&!window.L_PREFER_CANVAS||!e.Browser.canvas?e.Path:e.Path.extend({statics:{CANVAS:!0,SVG:!1},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var e=this.options;e.stroke&&(this._ctx.lineWidth=e.weight,this._ctx.strokeStyle=e.color),e.fill&&(this._ctx.fillStyle=e.fillColor||e.color)},_drawPath:function(){var t,n,r,i,s,o;this._ctx.beginPath();for(t=0,r=this._parts.length;ts&&(o=u,s=a);s>n&&(t[o]=1,this._simplifyDPStep(e,t,n,r,o),this._simplifyDPStep(e,t,n,o,i))},_reducePoints:function(e,t){var n=[e[0]];for(var r=1,i=0,s=e.length;rt&&(n.push(e[r]),i=r);return it.max.x&&(n|=2),e.yt.max.y&&(n|=8),n},_sqDist:function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},_sqClosestPointOnSegment:function(t,n,r,i){var s=n.x,o=n.y,u=r.x-s,a=r.y-o,f=u*u+a*a,l;return f>0&&(l=((t.x-s)*u+(t.y-o)*a)/f,l>1?(s=r.x,o=r.y):l>0&&(s+=u*l,o+=a*l)),u=t.x-s,a=t.y-o,i?u*u+a*a:new e.Point(s,o)}},e.Polyline=e.Path.extend({initialize:function(t,n){e.Path.prototype.initialize.call(this,n),this._latlngs=t,e.Handler.PolyEdit&&(this.editing=new e.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var e=0,t=this._latlngs.length;ee.max.x||n.y-t>e.max.y||n.x+tt.y!=s.y>t.y&&t.x<(s.x-i.x)*(t.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}}:{}),e.Circle.include(e.Path.CANVAS?{_drawPath:function(){var e=this._point;this._ctx.beginPath(),this._ctx.arc(e.x,e.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(e){var t=this._point,n=this.options.stroke?this.options.weight/2:0;return e.distanceTo(t)<=this._radius+n}}:{}),e.GeoJSON=e.FeatureGroup.extend({initialize:function(t,n){e.Util.setOptions(this,n),this._geojson=t,this._layers={},t&&this.addGeoJSON(t)},addGeoJSON:function(t){var n=t.features,r,i;if(n){for(r=0,i=n.length;r1){this._simulateClick=!1;return}var n=t.touches&&t.touches.length===1?t.touches[0]:t,r=n.target;e.DomEvent.preventDefault(t),e.Browser.touch&&r.tagName.toLowerCase()==="a"&&(r.className+=" leaflet-active"),this._moved=!1;if(this._moving)return;e.Browser.touch||(e.DomUtil.disableTextSelection(),this._setMovingCursor()),this._startPos=this._newPos=e.DomUtil.getPosition(this._element),this._startPoint=new e.Point(n.clientX,n.clientY),e.DomEvent.on(document,e.Draggable.MOVE,this._onMove,this),e.DomEvent.on(document,e.Draggable.END,this._onUp,this)},_onMove:function(t){if(t.touches&&t.touches.length>1)return;var n=t.touches&&t.touches.length===1?t.touches[0]:t,r=new e.Point(n.clientX,n.clientY),i=r.subtract(this._startPoint);if(!i.x&&!i.y)return;e.DomEvent.preventDefault(t),this._moved||(this.fire("dragstart"),this._moved=!0),this._newPos=this._startPos.add(i),this._moving=!0,e.Util.cancelAnimFrame(this._animRequest),this._animRequest=e.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),e.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(t){if(this._simulateClick&&t.changedTouches){var n=t.changedTouches[0],r=n.target,i=this._newPos&&this._newPos.distanceTo(this._startPos)||0;r.tagName.toLowerCase()==="a"&&(r.className=r.className.replace(" leaflet-active","")),i200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var t=this._map.getSize().divideBy(2),n=this._map.latLngToLayerPoint(new e.LatLng(0,0));this._initialWorldOffset=n.subtract(t)},_onPreDrag:function(){var e=this._map,t=e.options.crs.scale(e.getZoom()),n=Math.round(t/2),r=this._initialWorldOffset.x,i=this._draggable._newPos.x,s=(i-n+r)%t+n-r,o=(i+n+r)%t-n-r,u=Math.abs(s+r)n.inertiaThreshold||typeof this._positions[0]=="undefined";if(i)t.fire("moveend");else{var s=this._lastPos.subtract(this._positions[0]),o=(this._lastTime+r-this._times[0])/1e3,u=s.multiplyBy(.58/o),a=u.distanceTo(new e.Point(0,0)),f=Math.min(n.inertiaMaxSpeed,a),l=u.multiplyBy(f/a),c=f/n.inertiaDeceleration,h=l.multiplyBy(-c/2).round(),p={duration:c,easing:"ease-out"};e.Util.requestAnimFrame(e.Util.bind(function(){this._map.panBy(h,p)},this))}t.fire("dragend"),n.maxBounds&&e.Util.requestAnimFrame(this._panInsideMaxBounds,t,!0,t._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),e.Map.addInitHook("addHandler","dragging",e.Map.Drag),e.Map.mergeOptions({doubleClickZoom:!0}),e.Map.DoubleClickZoom=e.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(e){this.setView(e.latlng,this._zoom+1)}}),e.Map.addInitHook("addHandler","doubleClickZoom",e.Map.DoubleClickZoom),e.Map.mergeOptions({scrollWheelZoom:!e.Browser.touch}),e.Map.ScrollWheelZoom=e.Handler.extend({addHooks:function(){e.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){e.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(t){var n=e.DomEvent.getWheelDelta(t);this._delta+=n,this._lastMousePos=this._map.mouseEventToContainerPoint(t),clearTimeout(this._timer),this._timer=setTimeout(e.Util.bind(this._performZoom,this),50),e.DomEvent.preventDefault(t)},_performZoom:function(){var e=this._map,t=Math.round(this._delta),n=e.getZoom();t=Math.max(Math.min(t,4),-4),t=e._limitZoom(n+t)-n,this._delta=0;if(!t)return;var r=n+t,i=this._getCenterForScrollWheelZoom(this._lastMousePos,r);e.setView(i,r)},_getCenterForScrollWheelZoom:function(e,t){var n=this._map,r=n.getZoomScale(t),i=n.getSize().divideBy(2),s=e.subtract(i).multiplyBy(1-1/r),o=n._getTopLeftPoint().add(i).add(s);return n.unproject(o)}}),e.Map.addInitHook("addHandler","scrollWheelZoom",e.Map.ScrollWheelZoom),e.Util.extend(e.DomEvent,{addDoubleTapListener:function(e,t,n){function l(e){if(e.touches.length!==1)return;var t=Date.now(),n=t-(r||t);o=e.touches[0],i=n>0&&n<=s,r=t}function c(e){i&&(o.type="dblclick",t(o),r=null)}var r,i=!1,s=250,o,u="_leaflet_",a="touchstart",f="touchend";e[u+a+n]=l,e[u+f+n]=c,e.addEventListener(a,l,!1),e.addEventListener(f,c,!1)},removeDoubleTapListener:function(e,t){var n="_leaflet_";e.removeEventListener(e,e[n+"touchstart"+t],!1),e.removeEventListener(e,e[n+"touchend"+t],!1)}}),e.Map.mergeOptions({touchZoom:e.Browser.touch&&!e.Browser.android}),e.Map.TouchZoom=e.Handler.extend({addHooks:function(){e.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){e.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var n=this._map;if(!t.touches||t.touches.length!==2||n._animatingZoom||this._zooming)return;var r=n.mouseEventToLayerPoint(t.touches[0]),i=n.mouseEventToLayerPoint(t.touches[1]),s=n._getCenterLayerPoint();this._startCenter=r.add(i).divideBy(2,!0),this._startDist=r.distanceTo(i),this._moved=!1,this._zooming=!0,this._centerOffset=s.subtract(this._startCenter),e.DomEvent.on(document,"touchmove",this._onTouchMove,this).on(document,"touchend",this._onTouchEnd,this),e.DomEvent.preventDefault(t)},_onTouchMove:function(t){if(!t.touches||t.touches.length!==2)return;var n=this._map,r=n.mouseEventToLayerPoint(t.touches[0]),i=n.mouseEventToLayerPoint(t.touches[1]);this._scale=r.distanceTo(i)/this._startDist,this._delta=r.add(i).divideBy(2,!0).subtract(this._startCenter);if(this._scale===1)return;this._moved||(n._mapPane.className+=" leaflet-zoom-anim leaflet-touching",n.fire("movestart").fire("zoomstart")._prepareTileBg(),this._moved=!0);var s=this._getScaleOrigin(),o=n.layerPointToLatLng(s);n.fire("zoomanim",{center:o,zoom:n.getScaleZoom(this._scale)}),n._tileBg.style[e.DomUtil.TRANSFORM]=e.DomUtil.getTranslateString(this._delta)+" "+e.DomUtil.getScaleString(this._scale,this._startCenter),e.DomEvent.preventDefault(t)},_onTouchEnd:function(t){if(!this._moved||!this._zooming)return;var n=this._map;this._zooming=!1,n._mapPane.className=n._mapPane.className.replace(" leaflet-touching",""),e.DomEvent.off(document,"touchmove",this._onTouchMove).off(document,"touchend",this._onTouchEnd);var r=this._getScaleOrigin(),i=n.layerPointToLatLng(r),s=n.getZoom(),o=n.getScaleZoom(this._scale)-s,u=o>0?Math.ceil(o):Math.floor(o),a=n._limitZoom(s+u);n.fire("zoomanim",{center:i,zoom:a}),n._runAnimation(i,a,n.getZoomScale(a)/this._scale,r,!0)},_getScaleOrigin:function(){var e=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(e)}}),e.Map.addInitHook("addHandler","touchZoom",e.Map.TouchZoom),e.Map.mergeOptions({boxZoom:!0}),e.Map.BoxZoom=e.Handler.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane},addHooks:function(){e.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){e.DomEvent.off(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(t){if(!t.shiftKey||t.which!==1&&t.button!==1)return!1;e.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(t),this._box=e.DomUtil.create("div","leaflet-zoom-box",this._pane),e.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",e.DomEvent.on(document,"mousemove",this._onMouseMove,this).on(document,"mouseup",this._onMouseUp,this).preventDefault(t),this._map.fire("boxzoomstart")},_onMouseMove:function(t){var n=this._startLayerPoint,r=this._box,i=this._map.mouseEventToLayerPoint(t),s=i.subtract(n),o=new e.Point(Math.min(i.x,n.x),Math.min(i.y,n.y));e.DomUtil.setPosition(r,o),r.style.width=Math.abs(s.x)-4+"px",r.style.height=Math.abs(s.y)-4+"px"},_onMouseUp:function(t){this._pane.removeChild(this._box),this._container.style.cursor="",e.DomUtil.enableTextSelection(),e.DomEvent.off(document,"mousemove",this._onMouseMove).off(document,"mouseup",this._onMouseUp);var n=this._map,r=n.mouseEventToLayerPoint(t),i=new e.LatLngBounds(n.layerPointToLatLng(this._startLayerPoint),n.layerPointToLatLng(r));n.fitBounds(i),n.fire("boxzoomend",{boxZoomBounds:i})}}),e.Map.addInitHook("addHandler","boxZoom",e.Map.BoxZoom),e.Handler.MarkerDrag=e.Handler.extend({initialize:function(e){this._marker=e},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=(new e.Draggable(t,t)).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(e){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(t){var n=e.DomUtil.getPosition(this._marker._icon);this._marker._shadow&&e.DomUtil.setPosition(this._marker._shadow,n),this._marker._latlng=this._marker._map.layerPointToLatLng(n),this._marker.fire("move").fire("drag")},_onDragEnd:function(){this._marker.fire("moveend").fire("dragend")}}),e.Handler.PolyEdit=e.Handler.extend({options:{icon:new e.DivIcon({iconSize:new e.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"})},initialize:function(t,n){this._poly=t,e.Util.setOptions(this,n)},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),delete this._markerGroup,delete this._markers)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup||(this._markerGroup=new e.LayerGroup),this._markers=[];var t=this._poly._latlngs,n,r,i,s;for(n=0,i=t.length;ne&&(n._index+=t)})},_createMiddleMarker:function(e,t){var n=this._getMiddleLatLng(e,t),r=this._createMarker(n),i,s,o;r.setOpacity(.6),e._middleRight=t._middleLeft=r,s=function(){var s=t._index;r._index=s,r.off("click",i).on("click",this._onMarkerClick,this),n.lat=r.getLatLng().lat,n.lng=r.getLatLng().lng,this._poly.spliceLatLngs(s,0,n),this._markers.splice(s,0,r),r.setOpacity(1),this._updateIndexes(s,1),t._index++,this._updatePrevNext(e,r),this._updatePrevNext(r,t)},o=function(){r.off("dragstart",s,this),r.off("dragend",o,this),this._createMiddleMarker(e,r),this._createMiddleMarker(r,t)},i=function(){s.call(this),o.call(this),this._poly.fire("edit")},r.on("click",i,this).on("dragstart",s,this).on("dragend",o,this),this._markerGroup.addLayer(r)},_updatePrevNext:function(e,t){e._next=t,t._prev=e},_getMiddleLatLng:function(e,t){var n=this._poly._map,r=n.latLngToLayerPoint(e.getLatLng()),i=n.latLngToLayerPoint(t.getLatLng());return n.layerPointToLatLng(r._add(i).divideBy(2))}}),e.Control=e.Class.extend({options:{position:"topright"},initialize:function(t){e.Util.setOptions(this,t)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this)},addTo:function(t){this._map=t;var n=this._container=this.onAdd(t),r=this.getPosition(),i=t._controlCorners[r];return e.DomUtil.addClass(n,"leaflet-control"),r.indexOf("bottom")!==-1?i.insertBefore(n,i.firstChild):i.appendChild(n),this},removeFrom:function(e){var t=this.getPosition(),n=e._controlCorners[t];return n.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(e),this}}),e.Map.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.removeFrom(this),this},_initControlPos:function(){function i(i,s){var o=n+i+" "+n+s;t[i+s]=e.DomUtil.create("div",o,r)}var t=this._controlCorners={},n="leaflet-",r=this._controlContainer=e.DomUtil.create("div",n+"control-container",this._container);i("top","left"),i("top","right"),i("bottom","left"),i("bottom","right")}}),e.Control.Zoom=e.Control.extend({options:{position:"topleft"},onAdd:function(t){var n="leaflet-control-zoom",r=e.DomUtil.create("div",n);return this._createButton("Zoom in",n+"-in",r,t.zoomIn,t),this._createButton("Zoom out",n+"-out",r,t.zoomOut,t),r},_createButton:function(t,n,r,i,s){var o=e.DomUtil.create("a",n,r);return o.href="#",o.title=t,e.DomEvent.on(o,"click",e.DomEvent.stopPropagation).on(o,"click",e.DomEvent.preventDefault).on(o,"click",i,s),o}}),e.Map.mergeOptions({zoomControl:!0}),e.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new e.Control.Zoom,this.addControl(this.zoomControl))}),e.Control.Attribution=e.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(t){e.Util.setOptions(this,t),this._attributions={}},onAdd:function(t){return this._container=e.DomUtil.create("div","leaflet-control-attribution"),e.DomEvent.disableClickPropagation(this._container),t.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this),this._update(),this._container},onRemove:function(e){e.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(e){this.options.prefix=e,this._update()},addAttribution:function(e){if(!e)return;this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update()},removeAttribution:function(e){if(!e)return;this._attributions[e]--,this._update()},_update:function(){if(!this._map)return;var e=[];for(var t in this._attributions)this._attributions.hasOwnProperty(t)&&this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(", ")),this._container.innerHTML=n.join(" — ")},_onLayerAdd:function(e){e.layer.getAttribution&&this.addAttribution(e.layer.getAttribution())},_onLayerRemove:function(e){e.layer.getAttribution&&this.removeAttribution(e.layer.getAttribution())}}),e.Map.mergeOptions({attributionControl:!0}),e.Map.addInitHook(function(){this.options.attributionControl&&(this.attributionControl=(new e.Control.Attribution).addTo(this))}),e.Control.Scale=e.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(t){this._map=t;var n="leaflet-control-scale",r=e.DomUtil.create("div",n),i=this.options;return i.metric&&(this._mScale=e.DomUtil.create("div",n+"-line",r)),i.imperial&&(this._iScale=e.DomUtil.create("div",n+"-line",r)),t.on(i.updateWhenIdle?"moveend":"move",this._update,this),this._update(),r},onRemove:function(e){e.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_update:function(){var t=this._map.getBounds(),n=t.getCenter().lat,r=new e.LatLng(n,t.getSouthWest().lng),i=new e.LatLng(n,t.getNorthEast().lng),s=this._map.getSize(),o=this.options,u=0;s.x>0&&(u=r.distanceTo(i)*(o.maxWidth/s.x)),o.metric&&u&&this._updateMetric(u),o.imperial&&u&&this._updateImperial(u)},_updateMetric:function(e){var t=this._getRoundNum(e);this._mScale.style.width=this._getScaleWidth(t/e)+"px",this._mScale.innerHTML=t<1e3?t+" m":t/1e3+" km"},_updateImperial:function(e){var t=e*3.2808399,n=this._iScale,r,i,s;t>5280?(r=t/5280,i=this._getRoundNum(r),n.style.width=this._getScaleWidth(i/r)+"px",n.innerHTML=i+" mi"):(s=this._getRoundNum(t),n.style.width=this._getScaleWidth(s/t)+"px",n.innerHTML=s+" ft")},_getScaleWidth:function(e){return Math.round(this.options.maxWidth*e)-10},_getRoundNum:function(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=2?2:1,t*n}}),e.Control.Layers=e.Control.extend({options:{collapsed:!0,position:"topright"},initialize:function(t,n,r){e.Util.setOptions(this,r),this._layers={};for(var i in t)t.hasOwnProperty(i)&&this._addLayer(t[i],i);for(i in n)n.hasOwnProperty(i)&&this._addLayer(n[i],i,!0)},onAdd:function(e){return this._initLayout(),this._update(),this._container},addBaseLayer:function(e,t){return this._addLayer(e,t),this._update(),this},addOverlay:function(e,t){return this._addLayer(e,t,!0),this._update(),this},removeLayer:function(t){var n=e.Util.stamp(t);return delete this._layers[n],this._update(),this},_initLayout:function(){var t="leaflet-control-layers",n=this._container=e.DomUtil.create("div",t);e.Browser.touch?e.DomEvent.on(n,"click",e.DomEvent.stopPropagation):e.DomEvent.disableClickPropagation(n);var r=this._form=e.DomUtil.create("form",t+"-list");if(this.options.collapsed){e.DomEvent.on(n,"mouseover",this._expand,this).on(n,"mouseout",this._collapse,this);var i=this._layersLink=e.DomUtil.create("a",t+"-toggle",n);i.href="#",i.title="Layers",e.Browser.touch?e.DomEvent.on(i,"click",e.DomEvent.stopPropagation).on(i,"click",e.DomEvent.preventDefault).on(i,"click",this._expand,this):e.DomEvent.on(i,"focus",this._expand,this),this._map.on("movestart",this._collapse,this)}else this._expand();this._baseLayersList=e.DomUtil.create("div",t+"-base",r),this._separator=e.DomUtil.create("div",t+"-separator",r),this._overlaysList=e.DomUtil.create("div",t+"-overlays",r),n.appendChild(r)},_addLayer:function(t,n,r){var i=e.Util.stamp(t);this._layers[i]={layer:t,name:n,overlay:r}},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var e=!1,t=!1;for(var n in this._layers)if(this._layers.hasOwnProperty(n)){var r=this._layers[n];this._addItem(r),t=t||r.overlay,e=e||!r.overlay}this._separator.style.display=t&&e?"":"none"},_addItem:function(t,n){var r=document.createElement("label"),i=document.createElement("input");t.overlay||(i.name="leaflet-base-layers"),i.type=t.overlay?"checkbox":"radio",i.layerId=e.Util.stamp(t.layer),i.defaultChecked=this._map.hasLayer(t.layer),e.DomEvent.on(i,"click",this._onInputClick,this);var s=document.createTextNode(" "+t.name);r.appendChild(i),r.appendChild(s);var o=t.overlay?this._overlaysList:this._baseLayersList;o.appendChild(r)},_onInputClick:function(){var e,t,n,r=this._form.getElementsByTagName("input"),i=r.length;for(e=0;e.5&&this._getLoadedTilesPercentage(t)<.5){t.style.visibility="hidden",t.empty=!0,this._stopLoadingImages(t);return}n||(n=this._tileBg=this._createPane("leaflet-tile-pane",this._mapPane),n.style.zIndex=1),n.style[e.DomUtil.TRANSFORM]="",n.style.visibility="hidden",n.empty=!0,t.empty=!1,this._tilePane=this._panes.tilePane=n;var r=this._tileBg=t;r.transition||(r.transition=new e.Transition(r,{duration:.25,easing:"cubic-bezier(0.25,0.1,0.25,0.75)"}),r.transition.on("end",this._onZoomTransitionEnd,this)),this._stopLoadingImages(r)},_getLoadedTilesPercentage:function(e){var t=e.getElementsByTagName("img"),n,r,i=0;for(n=0,r=t.length;n2?Array.prototype.slice.call(arguments,2):null;return function(){return e.apply(t,n||arguments)}},stamp:function(){var e=0,t="_leaflet_id";return function(n){return n[t]=n[t]||++e,n[t]}}(),requestAnimFrame:function(){function t(e){window.setTimeout(e,1e3/60)}var n=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||t;return function(r,i,s,o){r=i?e.Util.bind(r,i):r;if(!s||n!==t)return n.call(window,r,o);r()}}(),cancelAnimFrame:function(){var e=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout;return function(t){if(!t)return;return e.call(window,t)}}(),limitExecByInterval:function(e,t,n){var r,i;return function s(){var o=arguments;if(r){i=!0;return}r=!0,setTimeout(function(){r=!1,i&&(s.apply(n,o),i=!1)},t),e.apply(n,o)}},falseFn:function(){return!1},formatNum:function(e,t){var n=Math.pow(10,t||5);return Math.round(e*n)/n},splitWords:function(e){return e.replace(/^\s+|\s+$/g,"").split(/\s+/)},setOptions:function(t,n){return t.options=e.Util.extend({},t.options,n),t.options},getParamString:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n+"="+e[n]);return"?"+t.join("&")},template:function(e,t){return e.replace(/\{ *([\w_]+) *\}/g,function(e,n){var r=t[n];if(!t.hasOwnProperty(n))throw Error("No value provided for variable "+e);return r})},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},e.Class=function(){},e.Class.extend=function(t){var n=function(){this.initialize&&this.initialize.apply(this,arguments)},r=function(){};r.prototype=this.prototype;var i=new r;i.constructor=n,n.prototype=i;for(var s in this)this.hasOwnProperty(s)&&s!=="prototype"&&(n[s]=this[s]);return t.statics&&(e.Util.extend(n,t.statics),delete t.statics),t.includes&&(e.Util.extend.apply(null,[i].concat(t.includes)),delete t.includes),t.options&&i.options&&(t.options=e.Util.extend({},i.options,t.options)),e.Util.extend(i,t),n},e.Class.include=function(t){e.Util.extend(this.prototype,t)},e.Class.mergeOptions=function(t){e.Util.extend(this.prototype.options,t)};var n="_leaflet_events";e.Mixin={},e.Mixin.Events={addEventListener:function(t,r,i){var s=this[n]=this[n]||{},o,u,a;if(typeof t=="object"){for(o in t)t.hasOwnProperty(o)&&this.addEventListener(o,t[o],r);return this}t=e.Util.splitWords(t);for(u=0,a=t.length;u0},removeEventListener:function(t,r,i){var s=this[n],o,u,a,f,l;if(typeof t=="object"){for(o in t)t.hasOwnProperty(o)&&this.removeEventListener(o,t[o],i);return this}t=e.Util.splitWords(t);for(u=0,a=t.length;u=0;l--)(!r||f[l].action===r)&&(!i||f[l].context===i)&&f.splice(l,1)}return this},fireEvent:function(t,r){if(!this.hasEventListeners(t))return this;var i=e.Util.extend({type:t,target:this},r),s=this[n][t].slice();for(var o=0,u=s.length;o=this.min.x&&r.x<=this.max.x&&n.y>=this.min.y&&r.y<=this.max.y},intersects:function(e){var t=this.min,n=this.max,r=e.min,i=e.max,s=i.x>=t.x&&r.x<=n.x,o=i.y>=t.y&&r.y<=n.y;return s&&o}}),e.Transformation=e.Class.extend({initialize:function(e,t,n,r){this._a=e,this._b=t,this._c=n,this._d=r},transform:function(e,t){return this._transform(e.clone(),t)},_transform:function(e,t){return t=t||1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e},untransform:function(t,n){return n=n||1,new e.Point((t.x/n-this._b)/this._a,(t.y/n-this._d)/this._c)}}),e.DomUtil={get:function(e){return typeof e=="string"?document.getElementById(e):e},getStyle:function(e,t){var n=e.style[t];!n&&e.currentStyle&&(n=e.currentStyle[t]);if(!n||n==="auto"){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n==="auto"?null:n},getViewportOffset:function(t){var n=0,r=0,i=t,s=document.body;do{n+=i.offsetTop||0,r+=i.offsetLeft||0;if(i.offsetParent===s&&e.DomUtil.getStyle(i,"position")==="absolute")break;if(e.DomUtil.getStyle(i,"position")==="fixed"){n+=s.scrollTop||0,r+=s.scrollLeft||0;break}i=i.offsetParent}while(i);i=t;do{if(i===s)break;n-=i.scrollTop||0,r-=i.scrollLeft||0,i=i.parentNode}while(i);return new e.Point(r,n)},create:function(e,t,n){var r=document.createElement(e);return r.className=t,n&&n.appendChild(r),r},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=e.Util.falseFn)},enableTextSelection:function(){document.onselectstart=this._onselectstart,this._onselectstart=null},hasClass:function(e,t){return e.className.length>0&&RegExp("(^|\\s)"+t+"(\\s|$)").test(e.className)},addClass:function(t,n){e.DomUtil.hasClass(t,n)||(t.className+=(t.className?" ":"")+n)},removeClass:function(e,t){function n(e,n){return n===t?"":e}e.className=e.className.replace(/(\S+)\s*/g,n).replace(/^\s+/,"")},setOpacity:function(t,n){e.Browser.ie?t.style.filter+=n!==1?"alpha(opacity="+Math.round(n*100)+")":"":t.style.opacity=n},testProp:function(e){var t=document.documentElement.style;for(var n=0;n=n.lat&&s.lat<=r.lat&&i.lng>=n.lng&&s.lng<=r.lng},intersects:function(e){var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),s=i.lat>=t.lat&&r.lat<=n.lat,o=i.lng>=t.lng&&r.lng<=n.lng;return s&&o},toBBoxString:function(){var e=this._southWest,t=this._northEast;return[e.lng,e.lat,t.lng,t.lat].join(",")},equals:function(e){return e?this._southWest.equals(e.getSouthWest())&&this._northEast.equals(e.getNorthEast()):!1}}),e.Projection={},e.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(t){var n=e.LatLng.DEG_TO_RAD,r=this.MAX_LATITUDE,i=Math.max(Math.min(r,t.lat),-r),s=t.lng*n,o=i*n;return o=Math.log(Math.tan(Math.PI/4+o/2)),new e.Point(s,o)},unproject:function(t){var n=e.LatLng.RAD_TO_DEG,r=t.x*n,i=(2*Math.atan(Math.exp(t.y))-Math.PI/2)*n;return new e.LatLng(i,r,!0)}},e.Projection.LonLat={project:function(t){return new e.Point(t.lng,t.lat)},unproject:function(t){return new e.LatLng(t.y,t.x,!0)}},e.CRS={latLngToPoint:function(e,t){var n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)},pointToLatLng:function(e,t){var n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)},project:function(e){return this.projection.project(e)},scale:function(e){return 256*Math.pow(2,e)}},e.CRS.EPSG3857=e.Util.extend({},e.CRS,{code:"EPSG:3857",projection:e.Projection.SphericalMercator,transformation:new e.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(e){var t=this.projection.project(e),n=6378137;return t.multiplyBy(n)}}),e.CRS.EPSG900913=e.Util.extend({},e.CRS.EPSG3857,{code:"EPSG:900913"}),e.CRS.EPSG4326=e.Util.extend({},e.CRS,{code:"EPSG:4326",projection:e.Projection.LonLat,transformation:new e.Transformation(1/360,.5,-1/360,.5)}),e.Map=e.Class.extend({includes:e.Mixin.Events,options:{crs:e.CRS.EPSG3857,fadeAnimation:e.DomUtil.TRANSITION&&!e.Browser.android,trackResize:!0,markerZoomAnimation:!0},initialize:function(t,n){n=e.Util.setOptions(this,n),this._initContainer(t),this._initLayout(),this._initHooks(),this._initEvents(),n.maxBounds&&this.setMaxBounds(n.maxBounds),n.center&&typeof n.zoom!="undefined"&&this.setView(n.center,n.zoom,!0),this._initLayers(n.layers)},setView:function(e,t){return this._resetView(e,this._limitZoom(t)),this},setZoom:function(e){return this.setView(this.getCenter(),e)},zoomIn:function(){return this.setZoom(this._zoom+1)},zoomOut:function(){return this.setZoom(this._zoom-1)},fitBounds:function(e){var t=this.getBoundsZoom(e);return this.setView(e.getCenter(),t)},fitWorld:function(){var t=new e.LatLng(-60,-170),n=new e.LatLng(85,179);return this.fitBounds(new e.LatLngBounds(t,n))},panTo:function(e){return this.setView(e,this._zoom)},panBy:function(e){return this.fire("movestart"),this._rawPanBy(e),this.fire("move"),this.fire("moveend")},setMaxBounds:function(e){this.options.maxBounds=e;if(!e)return this._boundsMinZoom=null,this;var t=this.getBoundsZoom(e,!0);return this._boundsMinZoom=t,this._loaded&&(this._zoomo.x&&(u=o.x-i.x),r.y>s.y&&(a=s.y-r.y),r.xc&&--h>0)d=u*Math.sin(f),p=Math.PI/2-2*Math.atan(a*Math.pow((1-d)/(1+d),.5*u))-f,f+=p;return new e.LatLng(f*n,s,!0)}},e.CRS.EPSG3395=e.Util.extend({},e.CRS,{code:"EPSG:3395",projection:e.Projection.Mercator,transformation:function(){var t=e.Projection.Mercator,n=t.R_MAJOR,r=t.R_MINOR;return new e.Transformation(.5/(Math.PI*n),.5,-0.5/(Math.PI*r),.5)}()}),e.TileLayer=e.Class.extend({includes:e.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,detectRetina:!1,unloadInvisibleTiles:e.Browser.mobile,updateWhenIdle:e.Browser.mobile,reuseTiles:!1},initialize:function(t,n){n=e.Util.setOptions(this,n),n.detectRetina&&window.devicePixelRatio>1&&n.maxZoom>0&&(n.tileSize=Math.floor(n.tileSize/2),n.zoomOffset++,n.minZoom>0&&n.minZoom--,this.options.maxZoom--),this._url=t;var r=this.options.subdomains;typeof r=="string"&&(this.options.subdomains=r.split(""))},onAdd:function(t,n){this._map=t,this._insertAtTheBottom=n,this._initContainer(),this._createTileProto(),t.on({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||(this._limitedUpdate=e.Util.limitExecByInterval(this._update,150,this),t.on("move",this._limitedUpdate,this)),this._reset(),this._update()},onRemove:function(e){e._panes.tilePane.removeChild(this._container),e.off({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||e.off("move",this._limitedUpdate,this),this._container=null,this._map=null},bringToFront:function(){this._container&&this._map._panes.tilePane.appendChild(this._container)},bringToBack:function(){var e=this._map._panes.tilePane;this._container&&e.insertBefore(this._container,e.firstChild)},getAttribution:function(){return this.options.attribution},setOpacity:function(e){this.options.opacity=e,this._map&&this._updateOpacity()},_updateOpacity:function(){e.DomUtil.setOpacity(this._container,this.options.opacity);var t,n=this._tiles;if(e.Browser.webkit)for(t in n)n.hasOwnProperty(t)&&(n[t].style.webkitTransform+=" translate(0,0)")},_initContainer:function(){var t=this._map._panes.tilePane,n=t.firstChild;if(!this._container||t.empty)this._container=e.DomUtil.create("div","leaflet-layer"),this._insertAtTheBottom&&n?t.insertBefore(this._container,n):t.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()},_resetCallback:function(e){this._reset(e.hard)},_reset:function(e){var t,n=this._tiles;for(t in n)n.hasOwnProperty(t)&&this.fire("tileunload",{tile:n[t]});this._tiles={},this.options.reuseTiles&&(this._unusedTiles=[]),e&&this._container&&(this._container.innerHTML=""),this._initContainer()},_update:function(t){if(this._map._panTransition&&this._map._panTransition._inProgress)return;var n=this._map.getPixelBounds(),r=this._map.getZoom(),i=this.options.tileSize;if(r>this.options.maxZoom||re.max.x||re.max.y)&&this._removeTile(i))},_removeTile:function(t){var n=this._tiles[t];this.fire("tileunload",{tile:n,url:n.src}),this.options.reuseTiles?(e.DomUtil.removeClass(n,"leaflet-tile-loaded"),this._unusedTiles.push(n)):n.parentNode===this._container&&this._container.removeChild(n),n.src=e.Util.emptyImageUrl,delete this._tiles[t]},_addTile:function(t,n){var r=this._getTilePos(t),i=this._map.getZoom(),s=t.x+":"+t.y,o=Math.pow(2,this._getOffsetZoom(i));if(!this.options.continuousWorld){if(!this.options.noWrap)t.x=(t.x%o+o)%o;else if(t.x<0||t.x>=o){this._tilesToLoad--;return}if(t.y<0||t.y>=o){this._tilesToLoad--;return}}var u=this._getTile();e.DomUtil.setPosition(u,r,!0),this._tiles[s]=u,this.options.scheme==="tms"&&(t.y=o-t.y-1),this._loadTile(u,t,i),u.parentNode!==this._container&&n.appendChild(u)},_getOffsetZoom:function(e){var t=this.options;return e=t.zoomReverse?t.maxZoom-e:e,e+t.zoomOffset},_getTilePos:function(e){var t=this._map.getPixelOrigin(),n=this.options.tileSize;return e.multiplyBy(n).subtract(t)},getTileUrl:function(t,n){var r=this.options.subdomains,i=(t.x+t.y)%r.length,s=this.options.subdomains[i];return e.Util.template(this._url,e.Util.extend({s:s,z:this._getOffsetZoom(n),x:t.x,y:t.y},this.options))},_createTileProto:function(){var t=this._tileImg=e.DomUtil.create("img","leaflet-tile");t.galleryimg="no";var n=this.options.tileSize;t.style.width=n+"px",t.style.height=n+"px"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var e=this._unusedTiles.pop();return this._resetTile(e),e}return this._createTile()},_resetTile:function(e){},_createTile:function(){var t=this._tileImg.cloneNode(!1);return t.onselectstart=t.onmousemove=e.Util.falseFn,t},_loadTile:function(e,t,n){e._layer=this,e.onload=this._tileOnLoad,e.onerror=this._tileOnError,e.src=this.getTileUrl(t,n)},_tileLoaded:function(){this._tilesToLoad--,this._tilesToLoad||this.fire("load")},_tileOnLoad:function(t){var n=this._layer;this.src!==e.Util.emptyImageUrl&&(this.className+=" leaflet-tile-loaded",n.fire("tileload",{tile:this,url:this.src})),n._tileLoaded()},_tileOnError:function(e){var t=this._layer;t.fire("tileerror",{tile:this,url:this.src});var n=t.options.errorTileUrl;n&&(this.src=n),t._tileLoaded()}}),e.TileLayer.WMS=e.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(t,n){this._url=t;var r=e.Util.extend({},this.defaultWmsParams);r.width=r.height=this.options.tileSize;for(var i in n)this.options.hasOwnProperty(i)||(r[i]=n[i]);this.wmsParams=r,e.Util.setOptions(this,n)},onAdd:function(t,n){var r=parseFloat(this.wmsParams.version)>=1.3?"crs":"srs";this.wmsParams[r]=t.options.crs.code,e.TileLayer.prototype.onAdd.call(this,t,n)},getTileUrl:function(t,n){var r=this._map,i=r.options.crs,s=this.options.tileSize,o=t.multiplyBy(s),u=o.add(new e.Point(s,s)),a=r.unproject(o,n),f=r.unproject(u,n),l=i.project(a),c=i.project(f),h=[l.x,c.y,c.x,l.y].join(",");return this._url+e.Util.getParamString(this.wmsParams)+"&bbox="+h}}),e.TileLayer.Canvas=e.TileLayer.extend({options:{async:!1},initialize:function(t){e.Util.setOptions(this,t)},redraw:function(){var e,t=this._tiles;for(e in t)t.hasOwnProperty(e)&&this._redrawTile(t[e])},_redrawTile:function(e){this.drawTile(e,e._tilePoint,e._zoom)},_createTileProto:function(){var t=this._canvasProto=e.DomUtil.create("canvas","leaflet-tile"),n=this.options.tileSize;t.width=n,t.height=n},_createTile:function(){var t=this._canvasProto.cloneNode(!1);return t.onselectstart=t.onmousemove=e.Util.falseFn,t},_loadTile:function(e,t,n){e._layer=this,e._tilePoint=t,e._zoom=n,this.drawTile(e,t,n),this.options.async||this.tileDrawn(e)},drawTile:function(e,t,n){},tileDrawn:function(e){this._tileOnLoad.call(e)}}),e.ImageOverlay=e.Class.extend({includes:e.Mixin.Events,options:{opacity:1},initialize:function(t,n,r){this._url=t,this._bounds=n,e.Util.setOptions(this,r)},onAdd:function(e){this._map=e,this._image||this._initImage(),e._panes.overlayPane.appendChild(this._image),e.on("viewreset",this._reset,this),e.options.zoomAnimation&&e.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(e){e.getPanes().overlayPane.removeChild(this._image),e.off("viewreset",this._reset,this),e.options.zoomAnimation&&e.off("zoomanim",this._animateZoom,this)},setOpacity:function(e){this.options.opacity=e,this._updateOpacity()},_initImage:function(){this._image=e.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&(this._image.className+=" leaflet-zoom-animated"),this._updateOpacity(),e.Util.extend(this._image,{galleryimg:"no",onselectstart:e.Util.falseFn,onmousemove:e.Util.falseFn,onload:e.Util.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(t){var n=this._map,r=this._image,i=n.getZoomScale(t.zoom),s=this._bounds.getNorthWest(),o=this._bounds.getSouthEast(),u=n._latLngToNewLayerPoint(s,t.zoom,t.center),a=n._latLngToNewLayerPoint(o,t.zoom,t.center).subtract(u),f=n.latLngToLayerPoint(o).subtract(n.latLngToLayerPoint(s)),l=u.add(a.subtract(f).divideBy(2));r.style[e.DomUtil.TRANSFORM]=e.DomUtil.getTranslateString(l)+" scale("+i+") "},_reset:function(){var t=this._image,n=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),r=this._map.latLngToLayerPoint(this._bounds.getSouthEast()).subtract(n);e.DomUtil.setPosition(t,n),t.style.width=r.x+"px",t.style.height=r.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){e.DomUtil.setOpacity(this._image,this.options.opacity)}}),e.Icon=e.Class.extend({options:{className:""},initialize:function(t){e.Util.setOptions(this,t)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this._createIcon("shadow")},_createIcon:function(e){var t=this._getIconUrl(e);if(!t)return null;var n=this._createImg(t);return this._setIconStyles(n,e),n},_setIconStyles:function(e,t){var n=this.options,r=n[t+"Size"],i=n.iconAnchor;!i&&r&&(i=r.divideBy(2,!0)),t==="shadow"&&i&&n.shadowOffset&&i._add(n.shadowOffset),e.className="leaflet-marker-"+t+" "+n.className+" leaflet-zoom-animated",i&&(e.style.marginLeft=-i.x+"px",e.style.marginTop=-i.y+"px"),r&&(e.style.width=r.x+"px",e.style.height=r.y+"px")},_createImg:function(t){var n;return e.Browser.ie6?(n=document.createElement("div"),n.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+t+'")'):(n=document.createElement("img"),n.src=t),n},_getIconUrl:function(e){return this.options[e+"Url"]}}),e.Icon.Default=e.Icon.extend({options:{iconSize:new e.Point(25,41),iconAnchor:new e.Point(13,41),popupAnchor:new e.Point(0,-33),shadowSize:new e.Point(41,41)},_getIconUrl:function(t){var n=e.Icon.Default.imagePath;if(!n)throw Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");return n+"/marker-"+t+".png"}}),e.Icon.Default.imagePath=function(){var e=document.getElementsByTagName("script"),t=/\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/,n,r,i,s;for(n=0,r=e.length;ns?(n.height=s+"px",e.DomUtil.addClass(t,o)):e.DomUtil.removeClass(t,o),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){var t=this._map.latLngToLayerPoint(this._latlng),n=e.Browser.any3d,r=this.options.offset;n&&e.DomUtil.setPosition(this._container,t),this._containerBottom=-r.y-(n?0:t.y),this._containerLeft=-Math.round(this._containerWidth/2)+r.x+(n?0:t.x),this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_zoomAnimation:function(t){var n=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center)._round();e.DomUtil.setPosition(this._container,n)},_adjustPan:function(){if(!this.options.autoPan)return;var t=this._map,n=this._container.offsetHeight,r=this._containerWidth,i=new e.Point(this._containerLeft,-n-this._containerBottom);e.Browser.any3d&&i._add(e.DomUtil.getPosition(this._container));var s=t.layerPointToContainerPoint(i),o=this.options.autoPanPadding,u=t.getSize(),a=0,f=0;s.x<0&&(a=s.x-o.x),s.x+r>u.x&&(a=s.x+r-u.x+o.x),s.y<0&&(f=s.y-o.y),s.y+n>u.y&&(f=s.y+n-u.y+o.y),(a||f)&&t.panBy(new e.Point(a,f))},_onCloseButtonClick:function(t){this._close(),e.DomEvent.stop(t)}}),e.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(t,n){var r=this.options.icon.options.popupAnchor||new e.Point(0,0);return n&&n.offset&&(r=r.add(n.offset)),n=e.Util.extend({offset:r},n),this._popup||this.on("click",this.openPopup,this),this._popup=(new e.Popup(n,this)).setContent(t),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup)),this}}),e.Map.include({openPopup:function(e){return this.closePopup(),this._popup=e,this.addLayer(e).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&this._popup._close(),this}}),e.LayerGroup=e.Class.extend({initialize:function(e){this._layers={};var t,n;if(e)for(t=0,n=e.length;t';var t=e.firstChild;return t.style.behavior="url(#default#VML)",t&&typeof t.adj=="object"}(),e.Path=e.Browser.svg||!e.Browser.vml?e.Path:e.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(e){return document.createElement("')}}catch(e){return function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var e=this._container=this._createElement("shape");e.className+=" leaflet-vml-shape"+(this.options.clickable?" leaflet-clickable":""),e.coordsize="1 1",this._path=this._createElement("path"),e.appendChild(this._path),this._map._pathRoot.appendChild(e)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var e=this._stroke,t=this._fill,n=this.options,r=this._container;r.stroked=n.stroke,r.filled=n.fill,n.stroke?(e||(e=this._stroke=this._createElement("stroke"),e.endcap="round",r.appendChild(e)),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity):e&&(r.removeChild(e),this._stroke=null),n.fill?(t||(t=this._fill=this._createElement("fill"),r.appendChild(t)),t.color=n.fillColor||n.color,t.opacity=n.fillOpacity):t&&(r.removeChild(t),this._fill=null)},_updatePath:function(){var e=this._container.style;e.display="none",this._path.v=this.getPathString()+" ",e.display=""}}),e.Map.include(e.Browser.svg||!e.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var e=this._pathRoot=document.createElement("div");e.className="leaflet-vml-container",this._panes.overlayPane.appendChild(e),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),e.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),e.Path=e.Path.SVG&&!window.L_PREFER_CANVAS||!e.Browser.canvas?e.Path:e.Path.extend({statics:{CANVAS:!0,SVG:!1},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var e=this.options;e.stroke&&(this._ctx.lineWidth=e.weight,this._ctx.strokeStyle=e.color),e.fill&&(this._ctx.fillStyle=e.fillColor||e.color)},_drawPath:function(){var t,n,r,i,s,o;this._ctx.beginPath();for(t=0,r=this._parts.length;ts&&(o=u,s=a);s>n&&(t[o]=1,this._simplifyDPStep(e,t,n,r,o),this._simplifyDPStep(e,t,n,o,i))},_reducePoints:function(e,t){var n=[e[0]];for(var r=1,i=0,s=e.length;rt&&(n.push(e[r]),i=r);return it.max.x&&(n|=2),e.yt.max.y&&(n|=8),n},_sqDist:function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},_sqClosestPointOnSegment:function(t,n,r,i){var s=n.x,o=n.y,u=r.x-s,a=r.y-o,f=u*u+a*a,l;return f>0&&(l=((t.x-s)*u+(t.y-o)*a)/f,l>1?(s=r.x,o=r.y):l>0&&(s+=u*l,o+=a*l)),u=t.x-s,a=t.y-o,i?u*u+a*a:new e.Point(s,o)}},e.Polyline=e.Path.extend({initialize:function(t,n){e.Path.prototype.initialize.call(this,n),this._latlngs=t,e.Handler.PolyEdit&&(this.editing=new e.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var e=0,t=this._latlngs.length;ee.max.x||n.y-t>e.max.y||n.x+tt.y!=s.y>t.y&&t.x<(s.x-i.x)*(t.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}}:{}),e.Circle.include(e.Path.CANVAS?{_drawPath:function(){var e=this._point;this._ctx.beginPath(),this._ctx.arc(e.x,e.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(e){var t=this._point,n=this.options.stroke?this.options.weight/2:0;return e.distanceTo(t)<=this._radius+n}}:{}),e.GeoJSON=e.FeatureGroup.extend({initialize:function(t,n){e.Util.setOptions(this,n),this._geojson=t,this._layers={},t&&this.addGeoJSON(t)},addGeoJSON:function(t){var n=t.features,r,i;if(n){for(r=0,i=n.length;r1){this._simulateClick=!1;return}var n=t.touches&&t.touches.length===1?t.touches[0]:t,r=n.target;e.DomEvent.preventDefault(t),e.Browser.touch&&r.tagName.toLowerCase()==="a"&&(r.className+=" leaflet-active"),this._moved=!1;if(this._moving)return;e.Browser.touch||(e.DomUtil.disableTextSelection(),this._setMovingCursor()),this._startPos=this._newPos=e.DomUtil.getPosition(this._element),this._startPoint=new e.Point(n.clientX,n.clientY),e.DomEvent.on(document,e.Draggable.MOVE,this._onMove,this),e.DomEvent.on(document,e.Draggable.END,this._onUp,this)},_onMove:function(t){if(t.touches&&t.touches.length>1)return;var n=t.touches&&t.touches.length===1?t.touches[0]:t,r=new e.Point(n.clientX,n.clientY),i=r.subtract(this._startPoint);if(!i.x&&!i.y)return;e.DomEvent.preventDefault(t),this._moved||(this.fire("dragstart"),this._moved=!0),this._newPos=this._startPos.add(i),this._moving=!0,e.Util.cancelAnimFrame(this._animRequest),this._animRequest=e.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),e.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(t){if(this._simulateClick&&t.changedTouches){var n=t.changedTouches[0],r=n.target,i=this._newPos&&this._newPos.distanceTo(this._startPos)||0;r.tagName.toLowerCase()==="a"&&e.DomUtil.removeClass(r,"leaflet-active"),i200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var t=this._map.getSize().divideBy(2),n=this._map.latLngToLayerPoint(new e.LatLng(0,0));this._initialWorldOffset=n.subtract(t)},_onPreDrag:function(){var e=this._map,t=e.options.crs.scale(e.getZoom()),n=Math.round(t/2),r=this._initialWorldOffset.x,i=this._draggable._newPos.x,s=(i-n+r)%t+n-r,o=(i+n+r)%t-n-r,u=Math.abs(s+r)n.inertiaThreshold||typeof this._positions[0]=="undefined";if(i)t.fire("moveend");else{var s=this._lastPos.subtract(this._positions[0]),o=(this._lastTime+r-this._times[0])/1e3,u=s.multiplyBy(.58/o),a=u.distanceTo(new e.Point(0,0)),f=Math.min(n.inertiaMaxSpeed,a),l=u.multiplyBy(f/a),c=f/n.inertiaDeceleration,h=l.multiplyBy(-c/2).round(),p={duration:c,easing:"ease-out"};e.Util.requestAnimFrame(e.Util.bind(function(){this._map.panBy(h,p)},this))}t.fire("dragend"),n.maxBounds&&e.Util.requestAnimFrame(this._panInsideMaxBounds,t,!0,t._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),e.Map.addInitHook("addHandler","dragging",e.Map.Drag),e.Map.mergeOptions({doubleClickZoom:!0}),e.Map.DoubleClickZoom=e.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(e){this.setView(e.latlng,this._zoom+1)}}),e.Map.addInitHook("addHandler","doubleClickZoom",e.Map.DoubleClickZoom),e.Map.mergeOptions({scrollWheelZoom:!e.Browser.touch}),e.Map.ScrollWheelZoom=e.Handler.extend({addHooks:function(){e.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){e.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(t){var n=e.DomEvent.getWheelDelta(t);this._delta+=n,this._lastMousePos=this._map.mouseEventToContainerPoint(t),clearTimeout(this._timer),this._timer=setTimeout(e.Util.bind(this._performZoom,this),50),e.DomEvent.preventDefault(t)},_performZoom:function(){var e=this._map,t=Math.round(this._delta),n=e.getZoom();t=Math.max(Math.min(t,4),-4),t=e._limitZoom(n+t)-n,this._delta=0;if(!t)return;var r=n+t,i=this._getCenterForScrollWheelZoom(this._lastMousePos,r);e.setView(i,r)},_getCenterForScrollWheelZoom:function(e,t){var n=this._map,r=n.getZoomScale(t),i=n.getSize().divideBy(2),s=e.subtract(i).multiplyBy(1-1/r),o=n._getTopLeftPoint().add(i).add(s);return n.unproject(o)}}),e.Map.addInitHook("addHandler","scrollWheelZoom",e.Map.ScrollWheelZoom),e.Util.extend(e.DomEvent,{addDoubleTapListener:function(e,t,n){function l(e){if(e.touches.length!==1)return;var t=Date.now(),n=t-(r||t);o=e.touches[0],i=n>0&&n<=s,r=t}function c(e){i&&(o.type="dblclick",t(o),r=null)}var r,i=!1,s=250,o,u="_leaflet_",a="touchstart",f="touchend";e[u+a+n]=l,e[u+f+n]=c,e.addEventListener(a,l,!1),e.addEventListener(f,c,!1)},removeDoubleTapListener:function(e,t){var n="_leaflet_";e.removeEventListener(e,e[n+"touchstart"+t],!1),e.removeEventListener(e,e[n+"touchend"+t],!1)}}),e.Map.mergeOptions({touchZoom:e.Browser.touch&&!e.Browser.android}),e.Map.TouchZoom=e.Handler.extend({addHooks:function(){e.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){e.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var n=this._map;if(!t.touches||t.touches.length!==2||n._animatingZoom||this._zooming)return;var r=n.mouseEventToLayerPoint(t.touches[0]),i=n.mouseEventToLayerPoint(t.touches[1]),s=n._getCenterLayerPoint();this._startCenter=r.add(i).divideBy(2,!0),this._startDist=r.distanceTo(i),this._moved=!1,this._zooming=!0,this._centerOffset=s.subtract(this._startCenter),e.DomEvent.on(document,"touchmove",this._onTouchMove,this).on(document,"touchend",this._onTouchEnd,this),e.DomEvent.preventDefault(t)},_onTouchMove:function(t){if(!t.touches||t.touches.length!==2)return;var n=this._map,r=n.mouseEventToLayerPoint(t.touches[0]),i=n.mouseEventToLayerPoint(t.touches[1]);this._scale=r.distanceTo(i)/this._startDist,this._delta=r.add(i).divideBy(2,!0).subtract(this._startCenter);if(this._scale===1)return;this._moved||(n._mapPane.className+=" leaflet-zoom-anim leaflet-touching",n.fire("movestart").fire("zoomstart")._prepareTileBg(),this._moved=!0);var s=this._getScaleOrigin(),o=n.layerPointToLatLng(s);n.fire("zoomanim",{center:o,zoom:n.getScaleZoom(this._scale)}),n._tileBg.style[e.DomUtil.TRANSFORM]=e.DomUtil.getTranslateString(this._delta)+" "+e.DomUtil.getScaleString(this._scale,this._startCenter),e.DomEvent.preventDefault(t)},_onTouchEnd:function(t){if(!this._moved||!this._zooming)return;var n=this._map;this._zooming=!1,e.DomUtil.removeClass(n._mapPane,"leaflet-touching"),e.DomEvent.off(document,"touchmove",this._onTouchMove).off(document,"touchend",this._onTouchEnd);var r=this._getScaleOrigin(),i=n.layerPointToLatLng(r),s=n.getZoom(),o=n.getScaleZoom(this._scale)-s,u=o>0?Math.ceil(o):Math.floor(o),a=n._limitZoom(s+u);n.fire("zoomanim",{center:i,zoom:a}),n._runAnimation(i,a,n.getZoomScale(a)/this._scale,r,!0)},_getScaleOrigin:function(){var e=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(e)}}),e.Map.addInitHook("addHandler","touchZoom",e.Map.TouchZoom),e.Map.mergeOptions({boxZoom:!0}),e.Map.BoxZoom=e.Handler.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane},addHooks:function(){e.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){e.DomEvent.off(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(t){if(!t.shiftKey||t.which!==1&&t.button!==1)return!1;e.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(t),this._box=e.DomUtil.create("div","leaflet-zoom-box",this._pane),e.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",e.DomEvent.on(document,"mousemove",this._onMouseMove,this).on(document,"mouseup",this._onMouseUp,this).preventDefault(t),this._map.fire("boxzoomstart")},_onMouseMove:function(t){var n=this._startLayerPoint,r=this._box,i=this._map.mouseEventToLayerPoint(t),s=i.subtract(n),o=new e.Point(Math.min(i.x,n.x),Math.min(i.y,n.y));e.DomUtil.setPosition(r,o),r.style.width=Math.abs(s.x)-4+"px",r.style.height=Math.abs(s.y)-4+"px"},_onMouseUp:function(t){this._pane.removeChild(this._box),this._container.style.cursor="",e.DomUtil.enableTextSelection(),e.DomEvent.off(document,"mousemove",this._onMouseMove).off(document,"mouseup",this._onMouseUp);var n=this._map,r=n.mouseEventToLayerPoint(t),i=new e.LatLngBounds(n.layerPointToLatLng(this._startLayerPoint),n.layerPointToLatLng(r));n.fitBounds(i),n.fire("boxzoomend",{boxZoomBounds:i})}}),e.Map.addInitHook("addHandler","boxZoom",e.Map.BoxZoom),e.Handler.MarkerDrag=e.Handler.extend({initialize:function(e){this._marker=e},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=(new e.Draggable(t,t)).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(e){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(t){var n=e.DomUtil.getPosition(this._marker._icon);this._marker._shadow&&e.DomUtil.setPosition(this._marker._shadow,n),this._marker._latlng=this._marker._map.layerPointToLatLng(n),this._marker.fire("move").fire("drag")},_onDragEnd:function(){this._marker.fire("moveend").fire("dragend")}}),e.Handler.PolyEdit=e.Handler.extend({options:{icon:new e.DivIcon({iconSize:new e.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"})},initialize:function(t,n){this._poly=t,e.Util.setOptions(this,n)},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),delete this._markerGroup,delete this._markers)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup||(this._markerGroup=new e.LayerGroup),this._markers=[];var t=this._poly._latlngs,n,r,i,s;for(n=0,i=t.length;ne&&(n._index+=t)})},_createMiddleMarker:function(e,t){var n=this._getMiddleLatLng(e,t),r=this._createMarker(n),i,s,o;r.setOpacity(.6),e._middleRight=t._middleLeft=r,s=function(){var s=t._index;r._index=s,r.off("click",i).on("click",this._onMarkerClick,this),n.lat=r.getLatLng().lat,n.lng=r.getLatLng().lng,this._poly.spliceLatLngs(s,0,n),this._markers.splice(s,0,r),r.setOpacity(1),this._updateIndexes(s,1),t._index++,this._updatePrevNext(e,r),this._updatePrevNext(r,t)},o=function(){r.off("dragstart",s,this),r.off("dragend",o,this),this._createMiddleMarker(e,r),this._createMiddleMarker(r,t)},i=function(){s.call(this),o.call(this),this._poly.fire("edit")},r.on("click",i,this).on("dragstart",s,this).on("dragend",o,this),this._markerGroup.addLayer(r)},_updatePrevNext:function(e,t){e._next=t,t._prev=e},_getMiddleLatLng:function(e,t){var n=this._poly._map,r=n.latLngToLayerPoint(e.getLatLng()),i=n.latLngToLayerPoint(t.getLatLng());return n.layerPointToLatLng(r._add(i).divideBy(2))}}),e.Control=e.Class.extend({options:{position:"topright"},initialize:function(t){e.Util.setOptions(this,t)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this)},addTo:function(t){this._map=t;var n=this._container=this.onAdd(t),r=this.getPosition(),i=t._controlCorners[r];return e.DomUtil.addClass(n,"leaflet-control"),r.indexOf("bottom")!==-1?i.insertBefore(n,i.firstChild):i.appendChild(n),this},removeFrom:function(e){var t=this.getPosition(),n=e._controlCorners[t];return n.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(e),this}}),e.Map.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.removeFrom(this),this},_initControlPos:function(){function i(i,s){var o=n+i+" "+n+s;t[i+s]=e.DomUtil.create("div",o,r)}var t=this._controlCorners={},n="leaflet-",r=this._controlContainer=e.DomUtil.create("div",n+"control-container",this._container);i("top","left"),i("top","right"),i("bottom","left"),i("bottom","right")}}),e.Control.Zoom=e.Control.extend({options:{position:"topleft"},onAdd:function(t){var n="leaflet-control-zoom",r=e.DomUtil.create("div",n);return this._createButton("Zoom in",n+"-in",r,t.zoomIn,t),this._createButton("Zoom out",n+"-out",r,t.zoomOut,t),r},_createButton:function(t,n,r,i,s){var o=e.DomUtil.create("a",n,r);return o.href="#",o.title=t,e.DomEvent.on(o,"click",e.DomEvent.stopPropagation).on(o,"click",e.DomEvent.preventDefault).on(o,"click",i,s),o}}),e.Map.mergeOptions({zoomControl:!0}),e.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new e.Control.Zoom,this.addControl(this.zoomControl))}),e.Control.Attribution=e.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(t){e.Util.setOptions(this,t),this._attributions={}},onAdd:function(t){return this._container=e.DomUtil.create("div","leaflet-control-attribution"),e.DomEvent.disableClickPropagation(this._container),t.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this),this._update(),this._container},onRemove:function(e){e.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(e){this.options.prefix=e,this._update()},addAttribution:function(e){if(!e)return;this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update()},removeAttribution:function(e){if(!e)return;this._attributions[e]--,this._update()},_update:function(){if(!this._map)return;var e=[];for(var t in this._attributions)this._attributions.hasOwnProperty(t)&&this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(", ")),this._container.innerHTML=n.join(" — ")},_onLayerAdd:function(e){e.layer.getAttribution&&this.addAttribution(e.layer.getAttribution())},_onLayerRemove:function(e){e.layer.getAttribution&&this.removeAttribution(e.layer.getAttribution())}}),e.Map.mergeOptions({attributionControl:!0}),e.Map.addInitHook(function(){this.options.attributionControl&&(this.attributionControl=(new e.Control.Attribution).addTo(this))}),e.Control.Scale=e.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(t){this._map=t;var n="leaflet-control-scale",r=e.DomUtil.create("div",n),i=this.options;return i.metric&&(this._mScale=e.DomUtil.create("div",n+"-line",r)),i.imperial&&(this._iScale=e.DomUtil.create("div",n+"-line",r)),t.on(i.updateWhenIdle?"moveend":"move",this._update,this),this._update(),r},onRemove:function(e){e.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_update:function(){var t=this._map.getBounds(),n=t.getCenter().lat,r=new e.LatLng(n,t.getSouthWest().lng),i=new e.LatLng(n,t.getNorthEast().lng),s=this._map.getSize(),o=this.options,u=0;s.x>0&&(u=r.distanceTo(i)*(o.maxWidth/s.x)),o.metric&&u&&this._updateMetric(u),o.imperial&&u&&this._updateImperial(u)},_updateMetric:function(e){var t=this._getRoundNum(e);this._mScale.style.width=this._getScaleWidth(t/e)+"px",this._mScale.innerHTML=t<1e3?t+" m":t/1e3+" km"},_updateImperial:function(e){var t=e*3.2808399,n=this._iScale,r,i,s;t>5280?(r=t/5280,i=this._getRoundNum(r),n.style.width=this._getScaleWidth(i/r)+"px",n.innerHTML=i+" mi"):(s=this._getRoundNum(t),n.style.width=this._getScaleWidth(s/t)+"px",n.innerHTML=s+" ft")},_getScaleWidth:function(e){return Math.round(this.options.maxWidth*e)-10},_getRoundNum:function(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=2?2:1,t*n}}),e.Control.Layers=e.Control.extend({options:{collapsed:!0,position:"topright"},initialize:function(t,n,r){e.Util.setOptions(this,r),this._layers={};for(var i in t)t.hasOwnProperty(i)&&this._addLayer(t[i],i);for(i in n)n.hasOwnProperty(i)&&this._addLayer(n[i],i,!0)},onAdd:function(e){return this._initLayout(),this._update(),this._container},addBaseLayer:function(e,t){return this._addLayer(e,t),this._update(),this},addOverlay:function(e,t){return this._addLayer(e,t,!0),this._update(),this},removeLayer:function(t){var n=e.Util.stamp(t);return delete this._layers[n],this._update(),this},_initLayout:function(){var t="leaflet-control-layers",n=this._container=e.DomUtil.create("div",t);e.Browser.touch?e.DomEvent.on(n,"click",e.DomEvent.stopPropagation):e.DomEvent.disableClickPropagation(n);var r=this._form=e.DomUtil.create("form",t+"-list");if(this.options.collapsed){e.DomEvent.on(n,"mouseover",this._expand,this).on(n,"mouseout",this._collapse,this);var i=this._layersLink=e.DomUtil.create("a",t+"-toggle",n);i.href="#",i.title="Layers",e.Browser.touch?e.DomEvent.on(i,"click",e.DomEvent.stopPropagation).on(i,"click",e.DomEvent.preventDefault).on(i,"click",this._expand,this):e.DomEvent.on(i,"focus",this._expand,this),this._map.on("movestart",this._collapse,this)}else this._expand();this._baseLayersList=e.DomUtil.create("div",t+"-base",r),this._separator=e.DomUtil.create("div",t+"-separator",r),this._overlaysList=e.DomUtil.create("div",t+"-overlays",r),n.appendChild(r)},_addLayer:function(t,n,r){var i=e.Util.stamp(t);this._layers[i]={layer:t,name:n,overlay:r}},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var e=!1,t=!1;for(var n in this._layers)if(this._layers.hasOwnProperty(n)){var r=this._layers[n];this._addItem(r),t=t||r.overlay,e=e||!r.overlay}this._separator.style.display=t&&e?"":"none"},_addItem:function(t,n){var r=document.createElement("label"),i=document.createElement("input");t.overlay||(i.name="leaflet-base-layers"),i.type=t.overlay?"checkbox":"radio",i.layerId=e.Util.stamp(t.layer),i.defaultChecked=this._map.hasLayer(t.layer),e.DomEvent.on(i,"click",this._onInputClick,this);var s=document.createTextNode(" "+t.name);r.appendChild(i),r.appendChild(s);var o=t.overlay?this._overlaysList:this._baseLayersList;o.appendChild(r)},_onInputClick:function(){var e,t,n,r=this._form.getElementsByTagName("input"),i=r.length;for(e=0;e.5&&this._getLoadedTilesPercentage(t)<.5){t.style.visibility="hidden",t.empty=!0,this._stopLoadingImages(t);return}n||(n=this._tileBg=this._createPane("leaflet-tile-pane",this._mapPane),n.style.zIndex=1),n.style[e.DomUtil.TRANSFORM]="",n.style.visibility="hidden",n.empty=!0,t.empty=!1,this._tilePane=this._panes.tilePane=n;var r=this._tileBg=t;r.transition||(r.transition=new e.Transition(r,{duration:.25,easing:"cubic-bezier(0.25,0.1,0.25,0.75)"}),r.transition.on("end",this._onZoomTransitionEnd,this)),this._stopLoadingImages(r)},_getLoadedTilesPercentage:function(e){var t=e.getElementsByTagName("img"),n,r,i=0;for(n=0,r=t.length;n Boolean - var k = '_leaflet_events'; - return (k in this) && (type in this[k]) && (this[k][type].length > 0); + return (key in this) && (type in this[key]) && (this[key][type].length > 0); }, removeEventListener: function (types, fn, context) { // (String[, Function, Object]) or (Object[, Object]) - var events = this._leaflet_events, + var events = this[key], type, i, len, listeners, j; if (typeof types === 'object') { for (type in types) { if (types.hasOwnProperty(type)) { - this.removeEventListener(type, types[type], context || this); + this.removeEventListener(type, types[type], context); } } return this; } - types = types.replace(/^\s+|\s+$/g, '').split(/\s+/); + types = L.Util.splitWords(types); for (i = 0, len = types.length; i < len; i++) { @@ -85,7 +85,7 @@ L.Mixin.Events = { target: this }, data); - var listeners = this._leaflet_events[type].slice(); + var listeners = this[key][type].slice(); for (var i = 0, len = listeners.length; i < len; i++) { listeners[i].action.call(listeners[i].context || this, event); diff --git a/src/core/Handler.js b/src/core/Handler.js index 4a7eeecb..96ebf4a9 100644 --- a/src/core/Handler.js +++ b/src/core/Handler.js @@ -8,17 +8,15 @@ L.Handler = L.Class.extend({ }, enable: function () { - if (this._enabled) { - return; - } + if (this._enabled) { return; } + this._enabled = true; this.addHooks(); }, disable: function () { - if (!this._enabled) { - return; - } + if (!this._enabled) { return; } + this._enabled = false; this.removeHooks(); }, diff --git a/src/core/Util.js b/src/core/Util.js index bae1436e..066c09f8 100644 --- a/src/core/Util.js +++ b/src/core/Util.js @@ -105,6 +105,10 @@ L.Util = { return Math.round(num * pow) / pow; }, + splitWords: function (str) { + return str.replace(/^\s+|\s+$/g, '').split(/\s+/); + }, + setOptions: function (obj, options) { obj.options = L.Util.extend({}, obj.options, options); return obj.options; diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index 64402c08..3c2b5c89 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -94,12 +94,15 @@ L.DomUtil = { }, removeClass: function (el, name) { - el.className = el.className.replace(/(\S+)\s*/g, function (w, match) { + function replaceFn(w, match) { if (match === name) { return ''; } return w; - }).replace(/^\s+/, ''); + } + el.className = el.className + .replace(/(\S+)\s*/g, replaceFn) + .replace(/^\s+/, ''); }, setOpacity: function (el, value) { diff --git a/src/dom/Draggable.js b/src/dom/Draggable.js index c8215972..82268bea 100644 --- a/src/dom/Draggable.js +++ b/src/dom/Draggable.js @@ -108,7 +108,7 @@ L.Draggable = L.Class.extend({ dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0; if (el.tagName.toLowerCase() === 'a') { - el.className = el.className.replace(' leaflet-active', ''); + L.DomUtil.removeClass(el, 'leaflet-active'); } if (dist < L.Draggable.TAP_TOLERANCE) { @@ -134,11 +134,11 @@ L.Draggable = L.Class.extend({ }, _setMovingCursor: function () { - document.body.className += ' leaflet-dragging'; + L.DomUtil.addClass(document.body, 'leaflet-dragging'); }, _restoreCursor: function () { - document.body.className = document.body.className.replace(/ leaflet-dragging/g, ''); + L.DomUtil.removeClass(document.body, 'leaflet-dragging'); }, _simulateEvent: function (type, e) { diff --git a/src/layer/Popup.js b/src/layer/Popup.js index 9fb6d1a6..b47a49cc 100644 --- a/src/layer/Popup.js +++ b/src/layer/Popup.js @@ -52,7 +52,7 @@ L.Popup = L.Class.extend({ onRemove: function (map) { map._panes.popupPane.removeChild(this._container); - L.Util.falseFn(this._container.offsetWidth); + L.Util.falseFn(this._container.offsetWidth); // force reflow map.off({ viewreset: this._updatePosition, @@ -140,29 +140,30 @@ L.Popup = L.Class.extend({ }, _updateLayout: function () { - var container = this._contentNode; + var container = this._contentNode, + style = container.style; - container.style.width = ''; - container.style.whiteSpace = 'nowrap'; + style.width = ''; + style.whiteSpace = 'nowrap'; var width = container.offsetWidth; width = Math.min(width, this.options.maxWidth); width = Math.max(width, this.options.minWidth); - container.style.width = (width + 1) + 'px'; - container.style.whiteSpace = ''; + style.width = (width + 1) + 'px'; + style.whiteSpace = ''; - container.style.height = ''; + style.height = ''; var height = container.offsetHeight, maxHeight = this.options.maxHeight, - scrolledClass = ' leaflet-popup-scrolled'; + scrolledClass = 'leaflet-popup-scrolled'; if (maxHeight && height > maxHeight) { - container.style.height = maxHeight + 'px'; - container.className += scrolledClass; + style.height = maxHeight + 'px'; + L.DomUtil.addClass(container, scrolledClass); } else { - container.className = container.className.replace(scrolledClass, ''); + L.DomUtil.removeClass(container, scrolledClass); } this._containerWidth = this._container.offsetWidth; diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js index e9fccec6..ae84e9d3 100644 --- a/src/layer/tile/TileLayer.js +++ b/src/layer/tile/TileLayer.js @@ -258,7 +258,7 @@ L.TileLayer = L.Class.extend({ this.fire("tileunload", {tile: tile, url: tile.src}); if (this.options.reuseTiles) { - tile.className = tile.className.replace(' leaflet-tile-loaded', ''); + L.DomUtil.removeClass(tile, 'leaflet-tile-loaded'); this._unusedTiles.push(tile); } else if (tile.parentNode === this._container) { this._container.removeChild(tile); diff --git a/src/map/Map.js b/src/map/Map.js index 54ac6a57..a33e2a4e 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -442,10 +442,12 @@ L.Map = L.Class.extend({ panes.markerPane = this._createPane('leaflet-marker-pane'); panes.popupPane = this._createPane('leaflet-popup-pane'); + var zoomHide = ' leaflet-zoom-hide'; + if (!this.options.markerZoomAnimation) { - panes.markerPane.className += ' leaflet-zoom-hide'; - panes.shadowPane.className += ' leaflet-zoom-hide'; - panes.popupPane.className += ' leaflet-zoom-hide'; + panes.markerPane.className += zoomHide; + panes.shadowPane.className += zoomHide; + panes.popupPane.className += zoomHide; } }, diff --git a/src/map/anim/Map.PanAnimation.js b/src/map/anim/Map.PanAnimation.js index e196cadc..f1840568 100644 --- a/src/map/anim/Map.PanAnimation.js +++ b/src/map/anim/Map.PanAnimation.js @@ -53,7 +53,7 @@ L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : { }, _onPanTransitionEnd: function () { - this._mapPane.className = this._mapPane.className.replace(/ leaflet-pan-anim/g, ''); + L.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim'); this.fire('moveend'); }, diff --git a/src/map/anim/Map.ZoomAnimation.js b/src/map/anim/Map.ZoomAnimation.js index a50a8383..ca1120cb 100644 --- a/src/map/anim/Map.ZoomAnimation.js +++ b/src/map/anim/Map.ZoomAnimation.js @@ -155,10 +155,10 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { _onZoomTransitionEnd: function () { this._restoreTileFront(); - L.Util.falseFn(this._tileBg.offsetWidth); + L.Util.falseFn(this._tileBg.offsetWidth); // force reflow this._resetView(this._animateToCenter, this._animateToZoom, true, true); - this._mapPane.className = this._mapPane.className.replace(' leaflet-zoom-anim', ''); //TODO toggleClass util + L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim'); this._animatingZoom = false; }, diff --git a/src/map/handler/Map.TouchZoom.js b/src/map/handler/Map.TouchZoom.js index d6b01fcb..b970b7bf 100644 --- a/src/map/handler/Map.TouchZoom.js +++ b/src/map/handler/Map.TouchZoom.js @@ -87,7 +87,7 @@ L.Map.TouchZoom = L.Handler.extend({ var map = this._map; this._zooming = false; - map._mapPane.className = map._mapPane.className.replace(' leaflet-touching', ''); //TODO toggleClass util + L.DomUtil.removeClass(map._mapPane, 'leaflet-touching'); L.DomEvent .off(document, 'touchmove', this._onTouchMove)