diff --git a/debug/map/controls.html b/debug/map/controls.html index f1a45419..ce04dd95 100644 --- a/debug/map/controls.html +++ b/debug/map/controls.html @@ -42,7 +42,6 @@ }); map.addControl(layersControl); - map.addControl(new L.Control.Scale()); diff --git a/dist/leaflet-src.js b/dist/leaflet-src.js index f136eb4b..dc65fe9e 100644 --- a/dist/leaflet-src.js +++ b/dist/leaflet-src.js @@ -186,20 +186,15 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ { // instantiate class without calling constructor var F = function () {}; F.prototype = this.prototype; + var proto = new F(); - proto.constructor = NewClass; + NewClass.prototype = proto; - // add superclass access - NewClass.superclass = this.prototype; - - // add class name - //proto.className = props; - //inherit parent's statics for (var i in this) { - if (this.hasOwnProperty(i) && i !== 'prototype' && i !== 'superclass') { + if (this.hasOwnProperty(i) && i !== 'prototype') { NewClass[i] = this[i]; } } @@ -224,18 +219,19 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ { // mix given properties into the prototype L.Util.extend(proto, props); - // allow inheriting further - NewClass.extend = L.Class.extend; - - // method for adding properties to prototype - NewClass.include = function (props) { - L.Util.extend(this.prototype, props); - }; - return NewClass; }; +// method for adding properties to prototype +L.Class.include = function (props) { + L.Util.extend(this.prototype, props); +}; + +L.Class.mergeOptions = function (options) { + L.Util.extend(this.prototype.options, options); +}; + /* * L.Mixin.Events adds custom events functionality to Leaflet classes */ @@ -957,18 +953,6 @@ L.Map = L.Class.extend({ zoom: null, layers: [], - // interaction - dragging: true, - touchZoom: L.Browser.touch && !L.Browser.android, - scrollWheelZoom: !L.Browser.touch, - doubleClickZoom: true, - boxZoom: true, - - inertia: !L.Browser.android, - inertiaDeceleration: L.Browser.touch ? 3000 : 2000, // px/s^2 - inertiaMaxSpeed: L.Browser.touch ? 1500 : 1000, // px/s - inertiaThreshold: L.Browser.touch ? 32 : 16, // ms - // controls zoomControl: true, attributionControl: true, @@ -979,7 +963,6 @@ L.Map = L.Class.extend({ // misc trackResize: true, - closePopupOnClick: true, worldCopyJump: true }, @@ -2503,6 +2486,10 @@ L.DivIcon = L.Icon.extend({ +L.Map.mergeOptions({ + closePopupOnClick: true +}); + L.Popup = L.Class.extend({ includes: L.Mixin.Events, @@ -2778,7 +2765,6 @@ L.Map.include({ } }); - /* * L.LayerGroup is a class to combine several layers so you can manipulate the group (e.g. add/remove it) as one layer. */ @@ -4660,6 +4646,14 @@ L.Handler = L.Class.extend({ * L.Handler.MapDrag is used internally by L.Map to make the map draggable. */ +L.Map.mergeOptions({ + dragging: true, + inertia: !L.Browser.android, + inertiaDeceleration: L.Browser.touch ? 3000 : 2000, // px/s^2 + inertiaMaxSpeed: L.Browser.touch ? 1500 : 1000, // px/s + inertiaThreshold: L.Browser.touch ? 32 : 16 // ms +}); + L.Map.Drag = L.Handler.extend({ addHooks: function () { if (!this._draggable) { @@ -4748,7 +4742,7 @@ L.Map.Drag = L.Handler.extend({ var map = this._map, options = map.options, delay = +new Date() - this._lastTime, - + noInertia = !options.inertia || delay > options.inertiaThreshold || typeof this._positions[0] === 'undefined'; @@ -4798,6 +4792,10 @@ L.Map.Drag = L.Handler.extend({ * L.Handler.DoubleClickZoom is used internally by L.Map to add double-click zooming. */ +L.Map.mergeOptions({ + doubleClickZoom: true +}); + L.Map.DoubleClickZoom = L.Handler.extend({ addHooks: function () { this._map.on('dblclick', this._onDoubleClick); @@ -4817,6 +4815,10 @@ L.Map.DoubleClickZoom = L.Handler.extend({ * L.Handler.ScrollWheelZoom is used internally by L.Map to enable mouse scroll wheel zooming on the map. */ +L.Map.mergeOptions({ + scrollWheelZoom: !L.Browser.touch +}); + L.Map.ScrollWheelZoom = L.Handler.extend({ addHooks: function () { L.DomEvent.addListener(this._map._container, 'mousewheel', this._onWheelScroll, this); @@ -4918,6 +4920,10 @@ L.Util.extend(L.DomEvent, { * L.Handler.TouchZoom is used internally by L.Map to add touch-zooming on Webkit-powered mobile browsers. */ +L.Map.mergeOptions({ + touchZoom: L.Browser.touch && !L.Browser.android +}); + L.Map.TouchZoom = L.Handler.extend({ addHooks: function () { L.DomEvent.addListener(this._map._container, 'touchstart', this._onTouchStart, this); @@ -5013,6 +5019,10 @@ L.Map.TouchZoom = L.Handler.extend({ * L.Handler.ShiftDragZoom is used internally by L.Map to add shift-drag zoom (zoom to a selected bounding box). */ +L.Map.mergeOptions({ + boxZoom: true +}); + L.Map.BoxZoom = L.Handler.extend({ initialize: function (map) { this._map = map; @@ -5245,17 +5255,29 @@ L.Handler.PolyEdit = L.Handler.extend({ }, _onMarkerClick: function (e) { + // Default action on marker click is to remove that marker, but if we remove the marker when latlng count < 3, we don't have a valid polyline anymore + if (this._poly._latlngs.length < 3) { + return; + } + var marker = e.target, i = marker._index; + + // Check existence of previous and next markers since they wouldn't exist for edge points on the polyline + if (marker._prev && marker._next) { + this._createMiddleMarker(marker._prev, marker._next); + this._updatePrevNext(marker._prev, marker._next); + } - this._createMiddleMarker(marker._prev, marker._next); - this._updatePrevNext(marker._prev, marker._next); - - this._markerGroup - .removeLayer(marker._middleLeft) - .removeLayer(marker._middleRight) - .removeLayer(marker); - + // The marker itself is guaranteed to exist and present in the layer, since we managed to click on it + this._markerGroup.removeLayer(marker); + // Check for the existence of middle left or middle right + if (marker._middleLeft) { + this._markerGroup.removeLayer(marker._middleLeft); + } + if (marker._middleRight) { + this._markerGroup.removeLayer(marker._middleRight); + } this._poly.spliceLatLngs(i, 1); this._updateIndexes(i, -1); this._poly.fire('edit'); @@ -5355,20 +5377,14 @@ L.Control = L.Class.extend({ this._map.removeControl(this); this._map.addControl(this); } - } -}); + }, + addTo: function (map) { + this._map = map; - -L.Map.include({ - addControl: function (control) { - var container = control.onAdd(this); - - control._container = container; - control._map = this; - - var pos = control.getPosition(), - corner = this._controlCorners[pos]; + var container = this._container = this.onAdd(map), + pos = this.getPosition(), + corner = map._controlCorners[pos]; L.DomUtil.addClass(container, 'leaflet-control'); @@ -5377,35 +5393,55 @@ L.Map.include({ } else { corner.appendChild(container); } + + return this; + }, + + removeFrom: function (map) { + var pos = this.getPosition(), + corner = map._controlCorners[pos]; + + corner.removeChild(this._container); + this._map = null; + + if (this.onRemove) { + this.onRemove(map); + } + + return this; + } +}); + + + +L.Map.include({ + addControl: function (control) { + control.addTo(this); return this; }, removeControl: function (control) { - var pos = control.getPosition(), - corner = this._controlCorners[pos]; - - corner.removeChild(control._container); - control._map = null; - - if (control.onRemove) { - control.onRemove(this); - } + control.removeFrom(this); return this; }, _initControlPos: function () { - var top = 'leaflet-top', - bottom = 'leaflet-bottom', - left = 'leaflet-left', - right = 'leaflet-right', - corner = 'leaflet-corner', - container = this._container, - corners = this._controlCorners = {}; + var corners = this._controlCorners = {}, + l = 'leaflet-', + container = this._controlContainer = + L.DomUtil.create('div', l + 'control-container', this._container); - corners.topleft = L.DomUtil.create('div', [corner, top, left].join(' '), container); - corners.topright = L.DomUtil.create('div', [corner, top, right].join(' '), container); - corners.bottomleft = L.DomUtil.create('div', [corner, bottom, left].join(' '), container); - corners.bottomright = L.DomUtil.create('div', [corner, bottom, right].join(' '), container); + function createCorner(vSide, hSide) { + var className = l + vSide + ' ' + l + hSide; + + corners[vSide + hSide] = + L.DomUtil.create('div', className, container); + } + + createCorner('top', 'left'); + createCorner('top', 'right'); + createCorner('bottom', 'left'); + createCorner('bottom', 'right'); } }); @@ -5498,7 +5534,7 @@ L.Control.Attribution = L.Control.extend({ } var prefixAndAttribs = []; - + if (this.options.prefix) { prefixAndAttribs.push(this.options.prefix); } @@ -5632,8 +5668,6 @@ L.Control.Layers = L.Control.extend({ }, onAdd: function (map) { - this._map = map; - this._initLayout(); this._update(); @@ -5660,43 +5694,39 @@ L.Control.Layers = L.Control.extend({ }, _initLayout: function () { - this._container = L.DomUtil.create('div', 'leaflet-control-layers'); + var className = 'leaflet-control-layers', + container = this._container = L.DomUtil.create('div', className); if (!L.Browser.touch) { - L.DomEvent.disableClickPropagation(this._container); + L.DomEvent.disableClickPropagation(container); } else { - L.DomEvent.addListener(this._container, 'click', L.DomEvent.stopPropagation); + L.DomEvent.addListener(container, 'click', L.DomEvent.stopPropagation); } - this._form = L.DomUtil.create('form', 'leaflet-control-layers-list'); + var form = this._form = L.DomUtil.create('form', className + '-list'); if (this.options.collapsed) { - L.DomEvent.addListener(this._container, 'mouseover', this._expand, this); - L.DomEvent.addListener(this._container, 'mouseout', this._collapse, this); + L.DomEvent + .addListener(container, 'mouseover', this._expand, this) + .addListener(container, 'mouseout', this._collapse, this); - var link = this._layersLink = L.DomUtil.create('a', 'leaflet-control-layers-toggle'); + var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container); link.href = '#'; link.title = 'Layers'; - if (L.Browser.touch) { - L.DomEvent.addListener(link, 'click', this._expand, this); - //L.DomEvent.disableClickPropagation(link); - } else { - L.DomEvent.addListener(link, 'focus', this._expand, this); - } + L.DomEvent.addListener(link, L.Browser.touch ? 'click' : 'focus', this._expand, this); + this._map.on('movestart', this._collapse, this); // TODO keyboard accessibility - - this._container.appendChild(link); } else { this._expand(); } - this._baseLayersList = L.DomUtil.create('div', 'leaflet-control-layers-base', this._form); - this._separator = L.DomUtil.create('div', 'leaflet-control-layers-separator', this._form); - this._overlaysList = L.DomUtil.create('div', 'leaflet-control-layers-overlays', this._form); + this._baseLayersList = L.DomUtil.create('div', className + '-base', form); + this._separator = L.DomUtil.create('div', className + '-separator', form); + this._overlaysList = L.DomUtil.create('div', className + '-overlays', form); - this._container.appendChild(this._form); + container.appendChild(form); }, _addLayer: function (layer, name, overlay) { diff --git a/dist/leaflet.js b/dist/leaflet.js index 57043743..ad0da04b 100644 --- a/dist/leaflet.js +++ b/dist/leaflet.js @@ -3,4 +3,4 @@ Leaflet is a modern open-source JavaScript library for interactive maps. http://leaflet.cloudmade.com */ -(function(a){a.L={VERSION:"0.4",ROOT_URL:a.L_ROOT_URL||function(){var a=document.getElementsByTagName("script"),b=/\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/,c,d,e,f;for(c=0,d=a.length;c0},removeEventListener:function(a,b,c){if(!this.hasEventListeners(a))return this;for(var d=0,e=this._leaflet_events,f=e[a].length;d=this.min.x&&c.x<=this.max.x&&b.y>=this.min.y&&c.y<=this.max.y},intersects:function(a){var b=this.min,c=this.max,d=a.min,e=a.max,f=e.x>=b.x&&d.x<=c.x,g=e.y>=b.y&&d.y<=c.y;return f&&g}}),L.Transformation=L.Class.extend({initialize:function(a,b,c,d){this._a=a,this._b=b,this._c=c,this._d=d},transform:function(a,b){return this._transform(a.clone(),b)},_transform:function(a,b){return b=b||1,a.x=b*(this._a*a.x+this._b),a.y=b*(this._c*a.y+this._d),a},untransform:function(a,b){return b=b||1,new L.Point((a.x/b-this._b)/this._a,(a.y/b-this._d)/this._c)}}),L.DomUtil={get:function(a){return typeof a=="string"?document.getElementById(a):a},getStyle:function(a,b){var c=a.style[b];!c&&a.currentStyle&&(c=a.currentStyle[b]);if(!c||c==="auto"){var d=document.defaultView.getComputedStyle(a,null);c=d?d[b]:null}return c==="auto"?null:c},getViewportOffset:function(a){var b=0,c=0,d=a,e=document.body;do{b+=d.offsetTop||0,c+=d.offsetLeft||0;if(d.offsetParent===e&&L.DomUtil.getStyle(d,"position")==="absolute")break;d=d.offsetParent}while(d);d=a;do{if(d===e)break;b-=d.scrollTop||0,c-=d.scrollLeft||0,d=d.parentNode}while(d);return new L.Point(c,b)},create:function(a,b,c){var d=document.createElement(a);return d.className=b,c&&c.appendChild(d),d},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=L.Util.falseFn)},enableTextSelection:function(){document.onselectstart=this._onselectstart,this._onselectstart=null},hasClass:function(a,b){return a.className.length>0&&RegExp("(^|\\s)"+b+"(\\s|$)").test(a.className)},addClass:function(a,b){L.DomUtil.hasClass(a,b)||(a.className+=(a.className?" ":"")+b)},removeClass:function(a,b){a.className=a.className.replace(/(\S+)\s*/g,function(a,c){return c===b?"":a}).replace(/^\s+/,"")},setOpacity:function(a,b){L.Browser.ie?a.style.filter="alpha(opacity="+Math.round(b*100)+")":a.style.opacity=b},testProp:function(a){var b=document.documentElement.style;for(var c=0;c=b.lat&&e.lat<=c.lat&&d.lng>=b.lng&&e.lng<=c.lng},intersects:function(a){var b=this._southWest,c=this._northEast,d=a.getSouthWest(),e=a.getNorthEast(),f=e.lat>=b.lat&&d.lat<=c.lat,g=e.lng>=b.lng&&d.lng<=c.lng;return f&&g},toBBoxString:function(){var a=this._southWest,b=this._northEast;return[a.lng,a.lat,b.lng,b.lat].join(",")},equals:function(a){return a?this._southWest.equals(a.getSouthWest())&&this._northEast.equals(a.getNorthEast()):!1}}),L.Projection={},L.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(a){var b=L.LatLng.DEG_TO_RAD,c=this.MAX_LATITUDE,d=Math.max(Math.min(c,a.lat),-c),e=a.lng*b,f=d*b;return f=Math.log(Math.tan(Math.PI/4+f/2)),new L.Point(e,f)},unproject:function(a,b){var c=L.LatLng.RAD_TO_DEG,d=a.x*c,e=(2*Math.atan(Math.exp(a.y))-Math.PI/2)*c;return new L.LatLng(e,d,b)}},L.Projection.LonLat={project:function(a){return new L.Point(a.lng,a.lat)},unproject:function(a,b){return new L.LatLng(a.y,a.x,b)}},L.CRS={latLngToPoint:function(a,b){var c=this.projection.project(a);return this.transformation._transform(c,b)},pointToLatLng:function(a,b,c){var d=this.transformation.untransform(a,b);return this.projection.unproject(d,c)},project:function(a){return this.projection.project(a)}},L.CRS.EPSG3857=L.Util.extend({},L.CRS,{code:"EPSG:3857",projection:L.Projection.SphericalMercator,transformation:new L.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(a){var b=this.projection.project(a),c=6378137;return b.multiplyBy(c)}}),L.CRS.EPSG900913=L.Util.extend({},L.CRS.EPSG3857,{code:"EPSG:900913"}),L.CRS.EPSG4326=L.Util.extend({},L.CRS,{code:"EPSG:4326",projection:L.Projection.LonLat,transformation:new L.Transformation(1/360,.5,-1/360,.5)}),L.Map=L.Class.extend({includes:L.Mixin.Events,options:{crs:L.CRS.EPSG3857||L.CRS.EPSG4326,scale:function(a){return 256*Math.pow(2,a)},center:null,zoom:null,layers:[],dragging:!0,touchZoom:L.Browser.touch&&!L.Browser.android,scrollWheelZoom:!L.Browser.touch,doubleClickZoom:!0,boxZoom:!0,inertia:!L.Browser.android,inertiaDeceleration:L.Browser.touch?3e3:2e3,inertiaMaxSpeed:L.Browser.touch?1500:1e3,inertiaThreshold:L.Browser.touch?32:16,zoomControl:!0,attributionControl:!0,fadeAnimation:L.DomUtil.TRANSITION&&!L.Browser.android,zoomAnimation:L.DomUtil.TRANSITION&&!L.Browser.android&&!L.Browser.mobileOpera,trackResize:!0,closePopupOnClick:!0,worldCopyJump:!0},initialize:function(a,b){L.Util.setOptions(this,b);var c=this._container=L.DomUtil.get(a);if(c._leaflet)throw Error("Map container is already initialized.");c._leaflet=!0,this._initLayout(),L.DomEvent&&(this._initEvents(),L.Handler&&this._initInteraction(),L.Control&&this._initControls()),b=this.options,b.maxBounds&&this.setMaxBounds(b.maxBounds);var d=b.center,e=b.zoom;d&&typeof e!="undefined"&&this.setView(d,e,!0),this._initLayers(b.layers)},setView:function(a,b){return this._resetView(a,this._limitZoom(b)),this},setZoom:function(a){return this.setView(this.getCenter(),a)},zoomIn:function(){return this.setZoom(this._zoom+1)},zoomOut:function(){return this.setZoom(this._zoom-1)},fitBounds:function(a){var b=this.getBoundsZoom(a);return this.setView(a.getCenter(),b)},fitWorld:function(){var a=new L.LatLng(-60,-170),b=new L.LatLng(85,179);return this.fitBounds(new L.LatLngBounds(a,b))},panTo:function(a){return this.setView(a,this._zoom)},panBy:function(a){return this.fire("movestart"),this._rawPanBy(a),this.fire("move"),this.fire("moveend")},setMaxBounds:function(a){this.options.maxBounds=a;if(!a)return this._boundsMinZoom=null,this;var b=this.getBoundsZoom(a,!0);return this._boundsMinZoom=b,this._loaded&&(this._zoomf.x&&(g=f.x-d.x),c.y>e.y&&(h=e.y-c.y),c.xl&&--m>0)o=h*Math.sin(j),n=Math.PI/2-2*Math.atan(i*Math.pow((1-o)/(1+o),.5*h))-j,j+=n;return new L.LatLng(j*c,f,b)}},L.CRS.EPSG3395=L.Util.extend({},L.CRS,{code:"EPSG:3395",projection:L.Projection.Mercator,transformation:function(){var a=L.Projection.Mercator,b=a.R_MAJOR,c=a.R_MINOR;return new L.Transformation(.5/(Math.PI*b),.5,-0.5/(Math.PI*c),.5)}()}),L.TileLayer=L.Class.extend({includes:L.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",opacity:1,scheme:"xyz",continuousWorld:!1,noWrap:!1,zoomOffset:0,zoomReverse:!1,unloadInvisibleTiles:L.Browser.mobile,updateWhenIdle:L.Browser.mobile,reuseTiles:!1},initialize:function(a,b){L.Util.setOptions(this,b),this._url=a;var c=this.options.subdomains;typeof c=="string"&&(this.options.subdomains=c.split(""))},onAdd:function(a,b){this._map=a,this._insertAtTheBottom=b,this._initContainer(),this._createTileProto(),a.on("viewreset",this._resetCallback,this),a.on("moveend",this._update,this),this.options.updateWhenIdle||(this._limitedUpdate=L.Util.limitExecByInterval(this._update,150,this),a.on("move",this._limitedUpdate,this)),this._reset(),this._update()},onRemove:function(a){a._panes.tilePane.removeChild(this._container),a.off("viewreset",this._resetCallback,this),a.off("moveend",this._update,this),this.options.updateWhenIdle||a.off("move",this._limitedUpdate,this),this._container=null,this._map=null},getAttribution:function(){return this.options.attribution},setOpacity:function(a){this.options.opacity=a,this._map&&this._updateOpacity();var b,c=this._tiles;if(L.Browser.webkit)for(b in c)c.hasOwnProperty(b)&&(c[b].style.webkitTransform+=" translate(0,0)")},_updateOpacity:function(){L.DomUtil.setOpacity(this._container,this.options.opacity)},_initContainer:function(){var a=this._map._panes.tilePane,b=a.firstChild;if(!this._container||a.empty)this._container=L.DomUtil.create("div","leaflet-layer"),this._insertAtTheBottom&&b?a.insertBefore(this._container,b):a.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()},_resetCallback:function(a){this._reset(a.hard)},_reset:function(a){var b,c=this._tiles;for(b in c)c.hasOwnProperty(b)&&this.fire("tileunload",{tile:c[b]});this._tiles={},this.options.reuseTiles&&(this._unusedTiles=[]),a&&this._container&&(this._container.innerHTML=""),this._initContainer()},_update:function(a){if(this._map._panTransition&&this._map._panTransition._inProgress)return;var b=this._map.getPixelBounds(),c=this._map.getZoom(),d=this.options.tileSize;if(c>this.options.maxZoom||ca.max.x||da.max.y)&&this._removeTile(e))},_removeTile:function(a){var b=this._tiles[a];this.fire("tileunload",{tile:b,url:b.src}),b.parentNode===this._container&&this._container.removeChild(b),this.options.reuseTiles&&this._unusedTiles.push(b),b.src=L.Util.emptyImageUrl,delete this._tiles[a]},_addTile:function(a,b){var c=this._getTilePos(a),d=this._map.getZoom(),e=a.x+":"+a.y,f=Math.pow(2,this._getOffsetZoom(d));if(!this.options.continuousWorld){if(!this.options.noWrap)a.x=(a.x%f+f)%f;else if(a.x<0||a.x>=f){this._tilesToLoad--;return}if(a.y<0||a.y>=f){this._tilesToLoad--;return}}var g=this._getTile();L.DomUtil.setPosition(g,c),this._tiles[e]=g,this.options.scheme==="tms"&&(a.y=f-a.y-1),this._loadTile(g,a,d),b.appendChild(g)},_getOffsetZoom:function(a){var b=this.options;return a=b.zoomReverse?b.maxZoom-a:a,a+b.zoomOffset},_getTilePos:function(a){var b=this._map.getPixelOrigin(),c=this.options.tileSize;return a.multiplyBy(c).subtract(b)},getTileUrl:function(a,b){var c=this.options.subdomains,d=(a.x+a.y)%c.length,e=this.options.subdomains[d];return L.Util.template(this._url,L.Util.extend({s:e,z:this._getOffsetZoom(b),x:a.x,y:a.y},this.options))},_createTileProto:function(){var a=this._tileImg=L.DomUtil.create("img","leaflet-tile");a.galleryimg="no";var b=this.options.tileSize;a.style.width=b+"px",a.style.height=b+"px"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var a=this._unusedTiles.pop();return this._resetTile(a),a}return this._createTile()},_resetTile:function(a){},_createTile:function(){var a=this._tileImg.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a.onload=this._tileOnLoad,a.onerror=this._tileOnError,a.src=this.getTileUrl(b,c)},_tileOnLoad:function(a){var b=this._layer;this.className+=" leaflet-tile-loaded",b.fire("tileload",{tile:this,url:this.src}),b._tilesToLoad--,b._tilesToLoad||b.fire("load")},_tileOnError:function(a){var b=this._layer;b.fire("tileerror",{tile:this,url:this.src});var c=b.options.errorTileUrl;c&&(this.src=c)}}),L.TileLayer.WMS=L.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(a,b){this._url=a;var c=L.Util.extend({},this.defaultWmsParams);c.width=c.height=this.options.tileSize;for(var d in b)this.options.hasOwnProperty(d)||(c[d]=b[d]);this.wmsParams=c,L.Util.setOptions(this,b)},onAdd:function(a,b){var c=parseFloat(this.wmsParams.version)<1.3?"srs":"crs";this.wmsParams[c]=a.options.crs.code,L.TileLayer.prototype.onAdd.call(this,a,b)},getTileUrl:function(a,b){var c=this._map,d=c.options.crs,e=this.options.tileSize,f=a.multiplyBy(e),g=f.add(new L.Point(e,e)),h=c.unproject(f,b,!0),i=c.unproject(g,b,!0),j=d.project(h),k=d.project(i),l=[j.x,k.y,k.x,j.y].join(",");return this._url+L.Util.getParamString(this.wmsParams)+"&bbox="+l}}),L.TileLayer.Canvas=L.TileLayer.extend({options:{async:!1},initialize:function(a){L.Util.setOptions(this,a)},redraw:function(){var a,b=this._tiles;for(a in b)b.hasOwnProperty(a)&&this._redrawTile(b[a])},_redrawTile:function(a){this.drawTile(a,a._tilePoint,a._zoom)},_createTileProto:function(){var a=this._canvasProto=L.DomUtil.create("canvas","leaflet-tile"),b=this.options.tileSize;a.width=b,a.height=b},_createTile:function(){var a=this._canvasProto.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a._tilePoint=b,a._zoom=c,this.drawTile(a,b,c),this.options.async||this.tileDrawn(a)},drawTile:function(a,b,c){},tileDrawn:function(a){this._tileOnLoad.call(a)}}),L.ImageOverlay=L.Class.extend({includes:L.Mixin.Events,initialize:function(a,b){this._url=a,this._bounds=b},onAdd:function(a){this._map=a,this._image||this._initImage(),a._panes.overlayPane.appendChild(this._image),a.on("viewreset",this._reset,this),this._reset()},onRemove:function(a){a.getPanes().overlayPane.removeChild(this._image),a.off("viewreset",this._reset,this)},_initImage:function(){this._image=L.DomUtil.create("img","leaflet-image-layer"),this._image.style.visibility="hidden",L.Util.extend(this._image,{galleryimg:"no",onselectstart:L.Util.falseFn,onmousemove:L.Util.falseFn,onload:L.Util.bind(this._onImageLoad,this),src:this._url})},_reset:function(){var a=this._image,b=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),c=this._map.latLngToLayerPoint(this._bounds.getSouthEast()).subtract(b);L.DomUtil.setPosition(a,b),a.style.width=c.x+"px",a.style.height=c.y+"px"},_onImageLoad:function(){this._image.style.visibility="",this.fire("load")}}),L.Icon=L.Class.extend({options:{className:""},initialize:function(a){L.Util.setOptions(this,a)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this.options.shadowUrl?this._createIcon("shadow"):null},_createIcon:function(a){var b=this._createImg(this.options[a+"Url"]);return this._setIconStyles(b,a),b},_setIconStyles:function(a,b){var c=this.options,d=c[b+"Size"],e=c.iconAnchor;!e&&d&&(e=d.divideBy(2,!0)),b==="shadow"&&e&&c.shadowOffset&&e._add(c.shadowOffset),a.className="leaflet-marker-"+b+" "+c.className,e&&(a.style.marginLeft=-e.x+"px",a.style.marginTop=-e.y+"px"),d&&(a.style.width=d.x+"px",a.style.height=d.y+"px")},_createImg:function(a){var b;return L.Browser.ie6?(b=document.createElement("div"),b.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+a+'")'):(b=document.createElement("img"),b.src=a),b}}),L.Icon.Default=L.Icon.extend({options:{iconUrl:L.ROOT_URL+"images/marker.png",iconSize:new L.Point(25,41),iconAnchor:new L.Point(13,41),popupAnchor:new L.Point(0,-33),shadowUrl:L.ROOT_URL+"images/marker-shadow.png",shadowSize:new L.Point(41,41)}}),L.Marker=L.Class.extend({includes:L.Mixin.Events,options:{icon:new L.Icon.Default,title:"",clickable:!0,draggable:!1,zIndexOffset:0,opacity:1},initialize:function(a,b){L.Util.setOptions(this,b),this._latlng=a},onAdd:function(a){this._map=a,a.on("viewreset",this._reset,this),this._initIcon(),this._reset()},onRemove:function(a){this._removeIcon(),this.closePopup&&this.closePopup(),a.off("viewreset",this._reset,this),this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(a){this._latlng=a,this._reset(),this._popup&&this._popup.setLatLng(a)},setZIndexOffset:function(a){this.options.zIndexOffset=a,this._reset()},setIcon:function(a){this._map&&this._removeIcon(),this.options.icon=a,this._map&&(this._initIcon(),this._reset())},_initIcon:function(){var a=this.options;this._icon||(this._icon=a.icon.createIcon(),a.title&&(this._icon.title=a.title),this._initInteraction(),this._updateOpacity()),this._shadow||(this._shadow=a.icon.createShadow());var b=this._map._panes;b.markerPane.appendChild(this._icon),this._shadow&&b.shadowPane.appendChild(this._shadow)},_removeIcon:function(){var a=this._map._panes;a.markerPane.removeChild(this._icon),this._shadow&&a.shadowPane.removeChild(this._shadow),this._icon=this._shadow=null},_reset:function(){var a=this._icon;if(!a)return;var b=this._map.latLngToLayerPoint(this._latlng).round();L.DomUtil.setPosition(a,b),this._shadow&&L.DomUtil.setPosition(this._shadow,b),a.style.zIndex=b.y+this.options.zIndexOffset},_initInteraction:function(){if(!this.options.clickable)return;var a=this._icon,b=["dblclick","mousedown","mouseover","mouseout"];a.className+=" leaflet-clickable",L.DomEvent.addListener(a,"click",this._onMouseClick,this);for(var c=0;cd?(a.style.height=d+"px",a.className+=e):a.className=a.className.replace(e,""),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){var a=this._map.latLngToLayerPoint(this._latlng);this._containerBottom=-a.y-this.options.offset.y,this._containerLeft=a.x-Math.round(this._containerWidth/2)+this.options.offset.x,this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_adjustPan:function(){if(!this.options.autoPan)return;var a=this._map,b=this._container.offsetHeight,c=this._containerWidth,d=new L.Point(this._containerLeft,-b-this._containerBottom),e=a.layerPointToContainerPoint(d),f=new L.Point(0,0),g=this.options.autoPanPadding,h=a.getSize();e.x<0&&(f.x=e.x-g.x),e.x+c>h.x&&(f.x=e.x+c-h.x+g.x),e.y<0&&(f.y=e.y-g.y),e.y+b>h.y&&(f.y=e.y+b-h.y+g.y),(f.x||f.y)&&a.panBy(f)},_onCloseButtonClick:function(a){this._close(),L.DomEvent.stop(a)}}),L.Marker.include({openPopup:function(){return this._popup&&this._map&&(this._popup.setLatLng(this._latlng),this._map.openPopup(this._popup)),this},closePopup:function(){return this._popup&&this._popup._close(),this},bindPopup:function(a,b){var c=this.options.icon.options.popupAnchor||new L.Point(0,0);return b&&b.offset&&(c=c.add(b.offset)),b=L.Util.extend({offset:c},b),this._popup||this.on("click",this.openPopup,this),this._popup=(new L.Popup(b,this)).setContent(a),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup)),this}}),L.Map.include({openPopup:function(a){return this.closePopup(),this._popup=a,this.addLayer(a).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&(this.removeLayer(this._popup).fire("popupclose",{popup:this._popup}),this._popup=null),this}}),L.LayerGroup=L.Class.extend({initialize:function(a){this._layers={};var b,c;if(a)for(b=0,c=a.length;b';var b=a.firstChild;return b.style.behavior="url(#default#VML)",b&&typeof b.adj=="object"}(),L.Path=L.Browser.svg||!L.Browser.vml?L.Path:L.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(a){return document.createElement("')}}catch(a){return function(a){return document.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var a=this._container=this._createElement("shape");a.className+=" leaflet-vml-shape"+(this.options.clickable?" leaflet-clickable":""),a.coordsize="1 1",this._path=this._createElement("path"),a.appendChild(this._path),this._map._pathRoot.appendChild(a)},_initStyle:function(){var a=this._container,b,c;this.options.stroke&&(b=this._stroke=this._createElement("stroke"),b.endcap="round",a.appendChild(b)),this.options.fill&&(c=this._fill=this._createElement("fill"),a.appendChild(c)),this._updateStyle()},_updateStyle:function(){var a=this._stroke,b=this._fill,c=this.options,d=this._container;d.stroked=c.stroke,d.filled=c.fill,c.stroke&&(a.weight=c.weight+"px",a.color=c.color,a.opacity=c.opacity),c.fill&&(b.color=c.fillColor||c.color,b.opacity=c.fillOpacity)},_updatePath:function(){var a=this._container.style;a.display="none",this._path.v=this.getPathString()+" ",a.display=""}}),L.Map.include(L.Browser.svg||!L.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var a=this._pathRoot=document.createElement("div");a.className="leaflet-vml-container",this._panes.overlayPane.appendChild(a),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),L.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),L.Path=L.Path.SVG&&!window.L_PREFER_CANVAS||!L.Browser.canvas?L.Path:L.Path.extend({statics:{CANVAS:!0,SVG:!1},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var a=this.options;a.stroke&&(this._ctx.lineWidth=a.weight,this._ctx.strokeStyle=a.color),a.fill&&(this._ctx.fillStyle=a.fillColor||a.color)},_drawPath:function(){var a,b,c,d,e,f;this._ctx.beginPath();for(a=0,c=this._parts.length;af&&(g=h,f=i);f>c&&(b[g]=1,this._simplifyDPStep(a,b,c,d,g),this._simplifyDPStep(a,b,c,g,e))},_reducePoints:function(a,b){var c=[a[0]];for(var d=1,e=0,f=a.length;db&&(c.push(a[d]),e=d);return eb.max.x&&(c|=2),a.yb.max.y&&(c|=8),c},_sqDist:function(a,b){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d},_sqClosestPointOnSegment:function(a,b,c,d){var e=b.x,f=b.y,g=c.x-e,h=c.y-f,i=g*g+h*h,j;return i>0&&(j=((a.x-e)*g+(a.y-f)*h)/i,j>1?(e=c.x,f=c.y):j>0&&(e+=g*j,f+=h*j)),g=a.x-e,h=a.y-f,d?g*g+h*h:new L.Point(e,f)}},L.Polyline=L.Path.extend({initialize:function(a,b){L.Path.prototype.initialize.call(this,b),this._latlngs=a,L.Handler.PolyEdit&&(this.editing=new L.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var a=0,b=this._latlngs.length;aa.max.x||c.y-b>a.max.y||c.x+ba.y!=e.y>a.y&&a.x<(e.x-d.x)*(a.y-d.y)/(e.y-d.y)+d.x&&(b=!b)}return b}}:{}),L.Circle.include(L.Path.CANVAS?{_drawPath:function(){var a=this._point;this._ctx.beginPath(),this._ctx.arc(a.x,a.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(a){var b=this._point,c=this.options.stroke?this.options.weight/2:0;return a.distanceTo(b)<=this._radius+c}}:{}),L.GeoJSON=L.FeatureGroup.extend({initialize:function(a,b){L.Util.setOptions(this,b),this._geojson=a,this._layers={},a&&this.addGeoJSON(a)},addGeoJSON:function(a){var b=a.features,c,d;if(b){for(c=0,d=b.length;c1){this._simulateClick=!1;return}var b=a.touches&&a.touches.length===1?a.touches[0]:a,c=b.target;L.DomEvent.preventDefault(a),L.Browser.touch&&c.tagName.toLowerCase()==="a"&&(c.className+=" leaflet-active"),this._moved=!1;if(this._moving)return;L.Browser.touch||(L.DomUtil.disableTextSelection(),this._setMovingCursor()),this._startPos=this._newPos=L.DomUtil.getPosition(this._element),this._startPoint=new L.Point(b.clientX,b.clientY),L.DomEvent.addListener(document,L.Draggable.MOVE,this._onMove,this),L.DomEvent.addListener(document,L.Draggable.END,this._onUp,this)},_onMove:function(a){if(a.touches&&a.touches.length>1)return;L.DomEvent.preventDefault(a);var b=a.touches&&a.touches.length===1?a.touches[0]:a;this._moved||(this.fire("dragstart"),this._moved=!0),this._moving=!0;var c=new L.Point(b.clientX,b.clientY);this._newPos=this._startPos.add(c).subtract(this._startPoint),L.Util.cancelAnimFrame(this._animRequest),this._animRequest=L.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),L.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(a){if(this._simulateClick&&a.changedTouches){var b=a.changedTouches[0],c=b.target,d=this._newPos&&this._newPos.distanceTo(this._startPos)||0;c.tagName.toLowerCase()==="a"&&(c.className=c.className.replace(" leaflet-active","")),d200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var a=this._map.getSize().divideBy(2),b=this._map.latLngToLayerPoint(new L.LatLng(0,0));this._initialWorldOffset=b.subtract(a)},_onPreDrag:function(){var a=this._map,b=a.options.scale(a.getZoom()),c=Math.round(b/2),d=this._initialWorldOffset.x,e=this._draggable._newPos.x,f=(e-c+d)%b+c-d,g=(e+c+d)%b-c-d,h=Math.abs(f+d)b.inertiaThreshold||typeof this._positions[0]=="undefined";if(d)a.fire("moveend");else{var e=this._lastPos.subtract(this._positions[0]),f=(this._lastTime+c-this._times[0])/1e3,g=e.multiplyBy(.58/f),h=g.distanceTo(new L.Point(0,0)),i=Math.min(b.inertiaMaxSpeed,h),j=g.multiplyBy(i/h),k=i/b.inertiaDeceleration,l=j.multiplyBy(-k/2).round(),m={duration:k,easing:"ease-out"};L.Util.requestAnimFrame(L.Util.bind(function(){this._map.panBy(l,m)},this))}a.fire("dragend"),b.maxBounds&&L.Util.requestAnimFrame(this._panInsideMaxBounds,a,!0,a._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),L.Map.DoubleClickZoom=L.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(a){this.setView(a.latlng,this._zoom+1)}}),L.Map.ScrollWheelZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(a){var b=L.DomEvent.getWheelDelta(a);this._delta+=b,this._lastMousePos=this._map.mouseEventToContainerPoint(a),clearTimeout(this._timer),this._timer=setTimeout(L.Util.bind(this._performZoom,this),50),L.DomEvent.preventDefault(a)},_performZoom:function(){var a=this._map,b=Math.round(this._delta),c=a.getZoom();b=Math.max(Math.min(b,4),-4),b=a._limitZoom(c+b)-c,this._delta=0;if(!b)return;var d=this._getCenterForScrollWheelZoom(this._lastMousePos,b),e=c+b;a.setView(d,e)},_getCenterForScrollWheelZoom:function(a,b){var c=this._map,d=c.getPixelBounds().getCenter(),e=c.getSize().divideBy(2),f=a.subtract(e).multiplyBy(1-Math.pow(2,-b)),g=d.add(f);return c.unproject(g,c._zoom,!0)}}),L.Util.extend(L.DomEvent,{addDoubleTapListener:function(a,b,c){function k(a){if(a.touches.length!==1)return;var b=Date.now(),c=b-(d||b);g=a.touches[0],e=c>0&&c<=f,d=b}function l(a){e&&(g.type="dblclick",b(g),d=null)}var d,e=!1,f=250,g,h="_leaflet_",i="touchstart",j="touchend";a[h+i+c]=k,a[h+j+c]=l,a.addEventListener(i,k,!1),a.addEventListener(j,l,!1)},removeDoubleTapListener:function(a,b){var c="_leaflet_";a.removeEventListener(a,a[c+"touchstart"+b],!1),a.removeEventListener(a,a[c+"touchend"+b],!1)}}),L.Map.TouchZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(a){var b=this._map;if(!a.touches||a.touches.length!==2||b._animatingZoom||this._zooming)return;var c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]),e=b.containerPointToLayerPoint(b.getSize().divideBy(2));this._startCenter=c.add(d).divideBy(2,!0),this._startDist=c.distanceTo(d),this._moved=!1,this._zooming=!0,this._centerOffset=e.subtract(this._startCenter),L.DomEvent.addListener(document,"touchmove",this._onTouchMove,this).addListener(document,"touchend",this._onTouchEnd,this),L.DomEvent.preventDefault(a)},_onTouchMove:function(a){if(!a.touches||a.touches.length!==2)return;var b=this._map,c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]);this._scale=c.distanceTo(d)/this._startDist,this._delta=c.add(d).divideBy(2,!0).subtract(this._startCenter);if(this._scale===1)return;this._moved||(b._mapPane.className+=" leaflet-zoom-anim",b.fire("zoomstart").fire("movestart")._prepareTileBg(),this._moved=!0),b._tileBg.style.webkitTransform=L.DomUtil.getTranslateString(this._delta)+" "+L.DomUtil.getScaleString(this._scale,this._startCenter),L.DomEvent.preventDefault(a)},_onTouchEnd:function(a){if(!this._moved||!this._zooming)return;this._zooming=!1,L.DomEvent.removeListener(document,"touchmove",this._onTouchMove).removeListener(document,"touchend",this._onTouchEnd);var b=this._centerOffset.subtract(this._delta).divideBy(this._scale),c=this._map.getPixelOrigin().add(this._startCenter).add(b),d=this._map.unproject(c),e=this._map.getZoom(),f=Math.log(this._scale)/Math.LN2,g=f>0?Math.ceil(f):Math.floor(f),h=this._map._limitZoom(e+g),i=Math.pow(2,h-e);this._map._runAnimation(d,h,i/this._scale,this._startCenter.add(b))}}),L.Map.BoxZoom=L.Handler.extend({initialize:function(a){this._map=a,this._container=a._container,this._pane=a._panes.overlayPane},addHooks:function(){L.DomEvent.addListener(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){L.DomEvent.removeListener(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(a){if(!a.shiftKey||a.which!==1&&a.button!==1)return!1;L.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(a),this._box=L.DomUtil.create("div","leaflet-zoom-box",this._pane),L.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",L.DomEvent.addListener(document,"mousemove",this._onMouseMove,this).addListener(document,"mouseup",this._onMouseUp,this).preventDefault(a)},_onMouseMove:function(a){var b=this._startLayerPoint,c=this._box,d=this._map.mouseEventToLayerPoint(a),e=d.subtract(b),f=new L.Point(Math.min(d.x,b.x),Math.min(d.y,b.y));L.DomUtil.setPosition(c,f),c.style.width=Math.abs(e.x)-4+"px",c.style.height=Math.abs(e.y)-4+"px"},_onMouseUp:function(a){this._pane.removeChild(this._box),this._container.style.cursor="",L.DomUtil.enableTextSelection(),L.DomEvent.removeListener(document,"mousemove",this._onMouseMove).removeListener(document,"mouseup",this._onMouseUp);var b=this._map,c=b.mouseEventToLayerPoint(a),d=new L.LatLngBounds(b.layerPointToLatLng(this._startLayerPoint),b.layerPointToLatLng(c));b.fitBounds(d)}}),L.Handler.MarkerDrag=L.Handler.extend({initialize:function(a){this._marker=a},addHooks:function(){var a=this._marker._icon;this._draggable||(this._draggable=(new L.Draggable(a,a)).on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this)),this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(a){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(a){var b=L.DomUtil.getPosition(this._marker._icon);this._marker._shadow&&L.DomUtil.setPosition(this._marker._shadow,b),this._marker._latlng=this._marker._map.layerPointToLatLng(b),this._marker.fire("move").fire("drag")},_onDragEnd:function(){this._marker.fire("moveend").fire("dragend")}}),L.Handler.PolyEdit=L.Handler.extend({options:{icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"})},initialize:function(a,b){this._poly=a,L.Util.setOptions(this,b)},addHooks:function(){this._poly._map&&(this._markerGroup||this._initMarkers(),this._poly._map.addLayer(this._markerGroup))},removeHooks:function(){this._poly._map&&this._poly._map.removeLayer(this._markerGroup)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup=new L.LayerGroup,this._markers=[];var a=this._poly._latlngs,b,c,d,e;for(b=0,d=a.length;ba&&(c._index+=b)})},_createMiddleMarker:function(a,b){function e(){var e=b._index;d._index=e,d.off("click",g).on("click",this._onMarkerClick,this),this._poly.spliceLatLngs(e,0,c),this._markers.splice(e,0,d),d.setOpacity(1),this._updateIndexes(e,1),b._index++,this._updatePrevNext(a,d),this._updatePrevNext(d,b)}function f(){d.off("dragstart",e,this),d.off("dragend",f,this),this._createMiddleMarker(a,d),this._createMiddleMarker(d,b)}function g(){e.call(this),f.call(this),this._poly.fire("edit")}var c=this._getMiddleLatLng(a,b),d=this._createMarker(c);d.setOpacity(.6),a._middleRight=b._middleLeft=d,d.on("click",g,this).on("dragstart",e,this).on("dragend",f,this),this._markerGroup.addLayer(d)},_updatePrevNext:function(a,b){a._next=b,b._prev=a},_getMiddleLatLng:function(a,b){var c=this._poly._map,d=c.latLngToLayerPoint(a.getLatLng()),e=c.latLngToLayerPoint(b.getLatLng());return c.layerPointToLatLng(d._add(e).divideBy(2))}}),L.Control=L.Class.extend({options:{position:"topright"},initialize:function(a){L.Util.setOptions(this,a)},getPosition:function(){return this.options.position},setPosition:function(a){this.options.position=a,this._map&&(this._map.removeControl(this),this._map.addControl(this))}}),L.Map.include({addControl:function(a){var b=a.onAdd(this);a._container=b,a._map=this;var c=a.getPosition(),d=this._controlCorners[c];return L.DomUtil.addClass(b,"leaflet-control"),c.indexOf("bottom")!==-1?d.insertBefore(b,d.firstChild):d.appendChild(b),this},removeControl:function(a){var b=a.getPosition(),c=this._controlCorners[b];return c.removeChild(a._container),a._map=null,a.onRemove&&a.onRemove(this),this},_initControlPos:function(){var a="leaflet-top",b="leaflet-bottom",c="leaflet-left",d="leaflet-right",e="leaflet-corner",f=this._container,g=this._controlCorners={};g.topleft=L.DomUtil.create("div",[e,a,c].join(" "),f),g.topright=L.DomUtil.create("div",[e,a,d].join(" "),f),g.bottomleft=L.DomUtil.create("div",[e,b,c].join(" "),f),g.bottomright=L.DomUtil.create("div",[e,b,d].join(" "),f)}}),L.Control.Zoom=L.Control.extend({options:{position:"topleft"},onAdd:function(a){var b="leaflet-control-zoom",c=L.DomUtil.create("div",b);return this._createButton("Zoom in",b+"-in",c,a.zoomIn,a),this._createButton("Zoom out",b+"-out",c,a.zoomOut,a),c},_createButton:function(a,b,c,d,e){var f=L.DomUtil.create("a",b,c);return f.href="#",f.title=a,L.DomEvent.addListener(f,"click",L.DomEvent.stopPropagation).addListener(f,"click",L.DomEvent.preventDefault).addListener(f,"click",d,e),f}}),L.Control.Attribution=L.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(a){L.Util.setOptions(this,a),this._attributions={}},onAdd:function(a){return this._map=a,this._container=L.DomUtil.create("div","leaflet-control-attribution"),L.DomEvent.disableClickPropagation(this._container),this._update(),this._container},setPrefix:function(a){this.options.prefix=a,this._update()},addAttribution:function(a){if(!a)return;this._attributions[a]||(this._attributions[a]=0),this._attributions[a]++,this._update()},removeAttribution:function(a){if(!a)return;this._attributions[a]--,this._update()},_update:function(){if(!this._map)return;var a=[];for(var b in this._attributions)this._attributions.hasOwnProperty(b)&&this._attributions[b]&&a.push(b);var c=[];this.options.prefix&&c.push(this.options.prefix),a.length&&c.push(a.join(", ")),this._container.innerHTML=c.join(" — ")}}),L.Control.Scale=L.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(a){this._map=a;var b="leaflet-control-scale",c=L.DomUtil.create("div",b),d=this.options;return d.metric&&(this._mScale=L.DomUtil.create("div",b+"-line",c)),d.imperial&&(this._iScale=L.DomUtil.create("div",b+"-line",c)),a.on(d.updateWhenIdle?"moveend":"move",this._update,this),this._update(),c},onRemove:function(a){a.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_update:function(){var a=this._map.getBounds(),b=a.getCenter().lat,c=new L.LatLng(b,a.getSouthWest().lng),d=new L.LatLng(b,a.getNorthEast().lng),e=this._map.getSize(),f=this.options,g=c.distanceTo(d)*(f.maxWidth/e.x);f.metric&&this._updateMetric(g),f.imperial&&this._updateImperial(g)},_updateMetric:function(a){var b=this._getRoundNum(a);this._mScale.style.width=this._getScaleWidth(b/a)+"px",this._mScale.innerHTML=b<1e3?b+" m":b/1e3+" km"},_updateImperial:function(a){var b=a*3.2808399,c=this._iScale,d,e,f;b>5280?(d=b/5280,e=this._getRoundNum(d),c.style.width=this._getScaleWidth(e/d)+"px",c.innerHTML=e+" mi"):(f=this._getRoundNum(b),c.style.width=this._getScaleWidth(f/b)+"px",c.innerHTML=f+" ft")},_getScaleWidth:function(a){return Math.round(this.options.maxWidth*a)-10},_getRoundNum:function(a){var b=Math.pow(10,(Math.floor(a)+"").length-1),c=a/b;return c=c<10?c<5?c<2?1:2:5:10,b*c}}),L.Control.Layers=L.Control.extend({options:{collapsed:!0,position:"topright"},initialize:function(a,b,c){L.Util.setOptions(this,c),this._layers={};for(var d in a)a.hasOwnProperty(d)&&this._addLayer(a[d],d);for(d in b)b.hasOwnProperty(d)&&this._addLayer(b[d],d,!0)},onAdd:function(a){return this._map=a,this._initLayout(),this._update(),this._container},addBaseLayer:function(a,b){return this._addLayer(a,b),this._update(),this},addOverlay:function(a,b){return this._addLayer(a,b,!0),this._update(),this},removeLayer:function(a){var b=L.Util.stamp(a);return delete this._layers[b],this._update(),this},_initLayout:function(){this._container=L.DomUtil.create("div","leaflet-control-layers"),L.Browser.touch?L.DomEvent.addListener(this._container,"click",L.DomEvent.stopPropagation):L.DomEvent.disableClickPropagation(this._container),this._form=L.DomUtil.create("form","leaflet-control-layers-list");if(this.options.collapsed){L.DomEvent.addListener(this._container,"mouseover",this._expand,this),L.DomEvent.addListener(this._container,"mouseout",this._collapse,this);var a=this._layersLink=L.DomUtil.create("a","leaflet-control-layers-toggle");a.href="#",a.title="Layers",L.Browser.touch?L.DomEvent.addListener(a,"click",this._expand,this):L.DomEvent.addListener(a,"focus",this._expand,this),this._map.on("movestart",this._collapse,this),this._container.appendChild(a)}else this._expand();this._baseLayersList=L.DomUtil.create("div","leaflet-control-layers-base",this._form),this._separator=L.DomUtil.create("div","leaflet-control-layers-separator",this._form),this._overlaysList=L.DomUtil.create("div","leaflet-control-layers-overlays",this._form),this._container.appendChild(this._form)},_addLayer:function(a,b,c){var d=L.Util.stamp(a);this._layers[d]={layer:a,name:b,overlay:c}},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var a=!1,b=!1;for(var c in this._layers)if(this._layers.hasOwnProperty(c)){var d=this._layers[c];this._addItem(d),b=b||d.overlay,a=a||!d.overlay}this._separator.style.display=b&&a?"":"none"},_addItem:function(a,b){var c=document.createElement("label"),d=document.createElement("input");a.overlay||(d.name="leaflet-base-layers"),d.type=a.overlay?"checkbox":"radio",d.checked=this._map.hasLayer(a.layer),d.layerId=L.Util.stamp(a.layer),L.DomEvent.addListener(d,"click",this._onInputClick,this);var e=document.createTextNode(" "+a.name);c.appendChild(d),c.appendChild(e);var f=a.overlay?this._overlaysList:this._baseLayersList;f.appendChild(c)},_onInputClick:function(){var a,b,c,d=this._form.getElementsByTagName("input"),e=d.length;for(a=0;a0},removeEventListener:function(a,b,c){if(!this.hasEventListeners(a))return this;for(var d=0,e=this._leaflet_events,f=e[a].length;d=this.min.x&&c.x<=this.max.x&&b.y>=this.min.y&&c.y<=this.max.y},intersects:function(a){var b=this.min,c=this.max,d=a.min,e=a.max,f=e.x>=b.x&&d.x<=c.x,g=e.y>=b.y&&d.y<=c.y;return f&&g}}),L.Transformation=L.Class.extend({initialize:function(a,b,c,d){this._a=a,this._b=b,this._c=c,this._d=d},transform:function(a,b){return this._transform(a.clone(),b)},_transform:function(a,b){return b=b||1,a.x=b*(this._a*a.x+this._b),a.y=b*(this._c*a.y+this._d),a},untransform:function(a,b){return b=b||1,new L.Point((a.x/b-this._b)/this._a,(a.y/b-this._d)/this._c)}}),L.DomUtil={get:function(a){return typeof a=="string"?document.getElementById(a):a},getStyle:function(a,b){var c=a.style[b];!c&&a.currentStyle&&(c=a.currentStyle[b]);if(!c||c==="auto"){var d=document.defaultView.getComputedStyle(a,null);c=d?d[b]:null}return c==="auto"?null:c},getViewportOffset:function(a){var b=0,c=0,d=a,e=document.body;do{b+=d.offsetTop||0,c+=d.offsetLeft||0;if(d.offsetParent===e&&L.DomUtil.getStyle(d,"position")==="absolute")break;d=d.offsetParent}while(d);d=a;do{if(d===e)break;b-=d.scrollTop||0,c-=d.scrollLeft||0,d=d.parentNode}while(d);return new L.Point(c,b)},create:function(a,b,c){var d=document.createElement(a);return d.className=b,c&&c.appendChild(d),d},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=L.Util.falseFn)},enableTextSelection:function(){document.onselectstart=this._onselectstart,this._onselectstart=null},hasClass:function(a,b){return a.className.length>0&&RegExp("(^|\\s)"+b+"(\\s|$)").test(a.className)},addClass:function(a,b){L.DomUtil.hasClass(a,b)||(a.className+=(a.className?" ":"")+b)},removeClass:function(a,b){a.className=a.className.replace(/(\S+)\s*/g,function(a,c){return c===b?"":a}).replace(/^\s+/,"")},setOpacity:function(a,b){L.Browser.ie?a.style.filter="alpha(opacity="+Math.round(b*100)+")":a.style.opacity=b},testProp:function(a){var b=document.documentElement.style;for(var c=0;c=b.lat&&e.lat<=c.lat&&d.lng>=b.lng&&e.lng<=c.lng},intersects:function(a){var b=this._southWest,c=this._northEast,d=a.getSouthWest(),e=a.getNorthEast(),f=e.lat>=b.lat&&d.lat<=c.lat,g=e.lng>=b.lng&&d.lng<=c.lng;return f&&g},toBBoxString:function(){var a=this._southWest,b=this._northEast;return[a.lng,a.lat,b.lng,b.lat].join(",")},equals:function(a){return a?this._southWest.equals(a.getSouthWest())&&this._northEast.equals(a.getNorthEast()):!1}}),L.Projection={},L.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(a){var b=L.LatLng.DEG_TO_RAD,c=this.MAX_LATITUDE,d=Math.max(Math.min(c,a.lat),-c),e=a.lng*b,f=d*b;return f=Math.log(Math.tan(Math.PI/4+f/2)),new L.Point(e,f)},unproject:function(a,b){var c=L.LatLng.RAD_TO_DEG,d=a.x*c,e=(2*Math.atan(Math.exp(a.y))-Math.PI/2)*c;return new L.LatLng(e,d,b)}},L.Projection.LonLat={project:function(a){return new L.Point(a.lng,a.lat)},unproject:function(a,b){return new L.LatLng(a.y,a.x,b)}},L.CRS={latLngToPoint:function(a,b){var c=this.projection.project(a);return this.transformation._transform(c,b)},pointToLatLng:function(a,b,c){var d=this.transformation.untransform(a,b);return this.projection.unproject(d,c)},project:function(a){return this.projection.project(a)}},L.CRS.EPSG3857=L.Util.extend({},L.CRS,{code:"EPSG:3857",projection:L.Projection.SphericalMercator,transformation:new L.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(a){var b=this.projection.project(a),c=6378137;return b.multiplyBy(c)}}),L.CRS.EPSG900913=L.Util.extend({},L.CRS.EPSG3857,{code:"EPSG:900913"}),L.CRS.EPSG4326=L.Util.extend({},L.CRS,{code:"EPSG:4326",projection:L.Projection.LonLat,transformation:new L.Transformation(1/360,.5,-1/360,.5)}),L.Map=L.Class.extend({includes:L.Mixin.Events,options:{crs:L.CRS.EPSG3857||L.CRS.EPSG4326,scale:function(a){return 256*Math.pow(2,a)},center:null,zoom:null,layers:[],zoomControl:!0,attributionControl:!0,fadeAnimation:L.DomUtil.TRANSITION&&!L.Browser.android,zoomAnimation:L.DomUtil.TRANSITION&&!L.Browser.android&&!L.Browser.mobileOpera,trackResize:!0,worldCopyJump:!0},initialize:function(a,b){L.Util.setOptions(this,b);var c=this._container=L.DomUtil.get(a);if(c._leaflet)throw Error("Map container is already initialized.");c._leaflet=!0,this._initLayout(),L.DomEvent&&(this._initEvents(),L.Handler&&this._initInteraction(),L.Control&&this._initControls()),b=this.options,b.maxBounds&&this.setMaxBounds(b.maxBounds);var d=b.center,e=b.zoom;d&&typeof e!="undefined"&&this.setView(d,e,!0),this._initLayers(b.layers)},setView:function(a,b){return this._resetView(a,this._limitZoom(b)),this},setZoom:function(a){return this.setView(this.getCenter(),a)},zoomIn:function(){return this.setZoom(this._zoom+1)},zoomOut:function(){return this.setZoom(this._zoom-1)},fitBounds:function(a){var b=this.getBoundsZoom(a);return this.setView(a.getCenter(),b)},fitWorld:function(){var a=new L.LatLng(-60,-170),b=new L.LatLng(85,179);return this.fitBounds(new L.LatLngBounds(a,b))},panTo:function(a){return this.setView(a,this._zoom)},panBy:function(a){return this.fire("movestart"),this._rawPanBy(a),this.fire("move"),this.fire("moveend")},setMaxBounds:function(a){this.options.maxBounds=a;if(!a)return this._boundsMinZoom=null,this;var b=this.getBoundsZoom(a,!0);return this._boundsMinZoom=b,this._loaded&&(this._zoomf.x&&(g=f.x-d.x),c.y>e.y&&(h=e.y-c.y),c.xl&&--m>0)o=h*Math.sin(j),n=Math.PI/2-2*Math.atan(i*Math.pow((1-o)/(1+o),.5*h))-j,j+=n;return new L.LatLng(j*c,f,b)}},L.CRS.EPSG3395=L.Util.extend({},L.CRS,{code:"EPSG:3395",projection:L.Projection.Mercator,transformation:function(){var a=L.Projection.Mercator,b=a.R_MAJOR,c=a.R_MINOR;return new L.Transformation(.5/(Math.PI*b),.5,-0.5/(Math.PI*c),.5)}()}),L.TileLayer=L.Class.extend({includes:L.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",opacity:1,scheme:"xyz",continuousWorld:!1,noWrap:!1,zoomOffset:0,zoomReverse:!1,unloadInvisibleTiles:L.Browser.mobile,updateWhenIdle:L.Browser.mobile,reuseTiles:!1},initialize:function(a,b){L.Util.setOptions(this,b),this._url=a;var c=this.options.subdomains;typeof c=="string"&&(this.options.subdomains=c.split(""))},onAdd:function(a,b){this._map=a,this._insertAtTheBottom=b,this._initContainer(),this._createTileProto(),a.on("viewreset",this._resetCallback,this),a.on("moveend",this._update,this),this.options.updateWhenIdle||(this._limitedUpdate=L.Util.limitExecByInterval(this._update,150,this),a.on("move",this._limitedUpdate,this)),this._reset(),this._update()},onRemove:function(a){a._panes.tilePane.removeChild(this._container),a.off("viewreset",this._resetCallback,this),a.off("moveend",this._update,this),this.options.updateWhenIdle||a.off("move",this._limitedUpdate,this),this._container=null,this._map=null},getAttribution:function(){return this.options.attribution},setOpacity:function(a){this.options.opacity=a,this._map&&this._updateOpacity();var b,c=this._tiles;if(L.Browser.webkit)for(b in c)c.hasOwnProperty(b)&&(c[b].style.webkitTransform+=" translate(0,0)")},_updateOpacity:function(){L.DomUtil.setOpacity(this._container,this.options.opacity)},_initContainer:function(){var a=this._map._panes.tilePane,b=a.firstChild;if(!this._container||a.empty)this._container=L.DomUtil.create("div","leaflet-layer"),this._insertAtTheBottom&&b?a.insertBefore(this._container,b):a.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()},_resetCallback:function(a){this._reset(a.hard)},_reset:function(a){var b,c=this._tiles;for(b in c)c.hasOwnProperty(b)&&this.fire("tileunload",{tile:c[b]});this._tiles={},this.options.reuseTiles&&(this._unusedTiles=[]),a&&this._container&&(this._container.innerHTML=""),this._initContainer()},_update:function(a){if(this._map._panTransition&&this._map._panTransition._inProgress)return;var b=this._map.getPixelBounds(),c=this._map.getZoom(),d=this.options.tileSize;if(c>this.options.maxZoom||ca.max.x||da.max.y)&&this._removeTile(e))},_removeTile:function(a){var b=this._tiles[a];this.fire("tileunload",{tile:b,url:b.src}),b.parentNode===this._container&&this._container.removeChild(b),this.options.reuseTiles&&this._unusedTiles.push(b),b.src=L.Util.emptyImageUrl,delete this._tiles[a]},_addTile:function(a,b){var c=this._getTilePos(a),d=this._map.getZoom(),e=a.x+":"+a.y,f=Math.pow(2,this._getOffsetZoom(d));if(!this.options.continuousWorld){if(!this.options.noWrap)a.x=(a.x%f+f)%f;else if(a.x<0||a.x>=f){this._tilesToLoad--;return}if(a.y<0||a.y>=f){this._tilesToLoad--;return}}var g=this._getTile();L.DomUtil.setPosition(g,c),this._tiles[e]=g,this.options.scheme==="tms"&&(a.y=f-a.y-1),this._loadTile(g,a,d),b.appendChild(g)},_getOffsetZoom:function(a){var b=this.options;return a=b.zoomReverse?b.maxZoom-a:a,a+b.zoomOffset},_getTilePos:function(a){var b=this._map.getPixelOrigin(),c=this.options.tileSize;return a.multiplyBy(c).subtract(b)},getTileUrl:function(a,b){var c=this.options.subdomains,d=(a.x+a.y)%c.length,e=this.options.subdomains[d];return L.Util.template(this._url,L.Util.extend({s:e,z:this._getOffsetZoom(b),x:a.x,y:a.y},this.options))},_createTileProto:function(){var a=this._tileImg=L.DomUtil.create("img","leaflet-tile");a.galleryimg="no";var b=this.options.tileSize;a.style.width=b+"px",a.style.height=b+"px"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var a=this._unusedTiles.pop();return this._resetTile(a),a}return this._createTile()},_resetTile:function(a){},_createTile:function(){var a=this._tileImg.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a.onload=this._tileOnLoad,a.onerror=this._tileOnError,a.src=this.getTileUrl(b,c)},_tileOnLoad:function(a){var b=this._layer;this.className+=" leaflet-tile-loaded",b.fire("tileload",{tile:this,url:this.src}),b._tilesToLoad--,b._tilesToLoad||b.fire("load")},_tileOnError:function(a){var b=this._layer;b.fire("tileerror",{tile:this,url:this.src});var c=b.options.errorTileUrl;c&&(this.src=c)}}),L.TileLayer.WMS=L.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(a,b){this._url=a;var c=L.Util.extend({},this.defaultWmsParams);c.width=c.height=this.options.tileSize;for(var d in b)this.options.hasOwnProperty(d)||(c[d]=b[d]);this.wmsParams=c,L.Util.setOptions(this,b)},onAdd:function(a,b){var c=parseFloat(this.wmsParams.version)<1.3?"srs":"crs";this.wmsParams[c]=a.options.crs.code,L.TileLayer.prototype.onAdd.call(this,a,b)},getTileUrl:function(a,b){var c=this._map,d=c.options.crs,e=this.options.tileSize,f=a.multiplyBy(e),g=f.add(new L.Point(e,e)),h=c.unproject(f,b,!0),i=c.unproject(g,b,!0),j=d.project(h),k=d.project(i),l=[j.x,k.y,k.x,j.y].join(",");return this._url+L.Util.getParamString(this.wmsParams)+"&bbox="+l}}),L.TileLayer.Canvas=L.TileLayer.extend({options:{async:!1},initialize:function(a){L.Util.setOptions(this,a)},redraw:function(){var a,b=this._tiles;for(a in b)b.hasOwnProperty(a)&&this._redrawTile(b[a])},_redrawTile:function(a){this.drawTile(a,a._tilePoint,a._zoom)},_createTileProto:function(){var a=this._canvasProto=L.DomUtil.create("canvas","leaflet-tile"),b=this.options.tileSize;a.width=b,a.height=b},_createTile:function(){var a=this._canvasProto.cloneNode(!1);return a.onselectstart=a.onmousemove=L.Util.falseFn,a},_loadTile:function(a,b,c){a._layer=this,a._tilePoint=b,a._zoom=c,this.drawTile(a,b,c),this.options.async||this.tileDrawn(a)},drawTile:function(a,b,c){},tileDrawn:function(a){this._tileOnLoad.call(a)}}),L.ImageOverlay=L.Class.extend({includes:L.Mixin.Events,initialize:function(a,b){this._url=a,this._bounds=b},onAdd:function(a){this._map=a,this._image||this._initImage(),a._panes.overlayPane.appendChild(this._image),a.on("viewreset",this._reset,this),this._reset()},onRemove:function(a){a.getPanes().overlayPane.removeChild(this._image),a.off("viewreset",this._reset,this)},_initImage:function(){this._image=L.DomUtil.create("img","leaflet-image-layer"),this._image.style.visibility="hidden",L.Util.extend(this._image,{galleryimg:"no",onselectstart:L.Util.falseFn,onmousemove:L.Util.falseFn,onload:L.Util.bind(this._onImageLoad,this),src:this._url})},_reset:function(){var a=this._image,b=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),c=this._map.latLngToLayerPoint(this._bounds.getSouthEast()).subtract(b);L.DomUtil.setPosition(a,b),a.style.width=c.x+"px",a.style.height=c.y+"px"},_onImageLoad:function(){this._image.style.visibility="",this.fire("load")}}),L.Icon=L.Class.extend({options:{className:""},initialize:function(a){L.Util.setOptions(this,a)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this.options.shadowUrl?this._createIcon("shadow"):null},_createIcon:function(a){var b=this._createImg(this.options[a+"Url"]);return this._setIconStyles(b,a),b},_setIconStyles:function(a,b){var c=this.options,d=c[b+"Size"],e=c.iconAnchor;!e&&d&&(e=d.divideBy(2,!0)),b==="shadow"&&e&&c.shadowOffset&&e._add(c.shadowOffset),a.className="leaflet-marker-"+b+" "+c.className,e&&(a.style.marginLeft=-e.x+"px",a.style.marginTop=-e.y+"px"),d&&(a.style.width=d.x+"px",a.style.height=d.y+"px")},_createImg:function(a){var b;return L.Browser.ie6?(b=document.createElement("div"),b.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+a+'")'):(b=document.createElement("img"),b.src=a),b}}),L.Icon.Default=L.Icon.extend({options:{iconUrl:L.ROOT_URL+"images/marker.png",iconSize:new L.Point(25,41),iconAnchor:new L.Point(13,41),popupAnchor:new L.Point(0,-33),shadowUrl:L.ROOT_URL+"images/marker-shadow.png",shadowSize:new L.Point(41,41)}}),L.Marker=L.Class.extend({includes:L.Mixin.Events,options:{icon:new L.Icon.Default,title:"",clickable:!0,draggable:!1,zIndexOffset:0,opacity:1},initialize:function(a,b){L.Util.setOptions(this,b),this._latlng=a},onAdd:function(a){this._map=a,a.on("viewreset",this._reset,this),this._initIcon(),this._reset()},onRemove:function(a){this._removeIcon(),this.closePopup&&this.closePopup(),a.off("viewreset",this._reset,this),this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(a){this._latlng=a,this._reset(),this._popup&&this._popup.setLatLng(a)},setZIndexOffset:function(a){this.options.zIndexOffset=a,this._reset()},setIcon:function(a){this._map&&this._removeIcon(),this.options.icon=a,this._map&&(this._initIcon(),this._reset())},_initIcon:function(){var a=this.options;this._icon||(this._icon=a.icon.createIcon(),a.title&&(this._icon.title=a.title),this._initInteraction(),this._updateOpacity()),this._shadow||(this._shadow=a.icon.createShadow());var b=this._map._panes;b.markerPane.appendChild(this._icon),this._shadow&&b.shadowPane.appendChild(this._shadow)},_removeIcon:function(){var a=this._map._panes;a.markerPane.removeChild(this._icon),this._shadow&&a.shadowPane.removeChild(this._shadow),this._icon=this._shadow=null},_reset:function(){var a=this._icon;if(!a)return;var b=this._map.latLngToLayerPoint(this._latlng).round();L.DomUtil.setPosition(a,b),this._shadow&&L.DomUtil.setPosition(this._shadow,b),a.style.zIndex=b.y+this.options.zIndexOffset},_initInteraction:function(){if(!this.options.clickable)return;var a=this._icon,b=["dblclick","mousedown","mouseover","mouseout"];a.className+=" leaflet-clickable",L.DomEvent.addListener(a,"click",this._onMouseClick,this);for(var c=0;cd?(a.style.height=d+"px",a.className+=e):a.className=a.className.replace(e,""),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){var a=this._map.latLngToLayerPoint(this._latlng);this._containerBottom=-a.y-this.options.offset.y,this._containerLeft=a.x-Math.round(this._containerWidth/2)+this.options.offset.x,this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_adjustPan:function(){if(!this.options.autoPan)return;var a=this._map,b=this._container.offsetHeight,c=this._containerWidth,d=new L.Point(this._containerLeft,-b-this._containerBottom),e=a.layerPointToContainerPoint(d),f=new L.Point(0,0),g=this.options.autoPanPadding,h=a.getSize();e.x<0&&(f.x=e.x-g.x),e.x+c>h.x&&(f.x=e.x+c-h.x+g.x),e.y<0&&(f.y=e.y-g.y),e.y+b>h.y&&(f.y=e.y+b-h.y+g.y),(f.x||f.y)&&a.panBy(f)},_onCloseButtonClick:function(a){this._close(),L.DomEvent.stop(a)}}),L.Marker.include({openPopup:function(){return this._popup&&this._map&&(this._popup.setLatLng(this._latlng),this._map.openPopup(this._popup)),this},closePopup:function(){return this._popup&&this._popup._close(),this},bindPopup:function(a,b){var c=this.options.icon.options.popupAnchor||new L.Point(0,0);return b&&b.offset&&(c=c.add(b.offset)),b=L.Util.extend({offset:c},b),this._popup||this.on("click",this.openPopup,this),this._popup=(new L.Popup(b,this)).setContent(a),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup)),this}}),L.Map.include({openPopup:function(a){return this.closePopup(),this._popup=a,this.addLayer(a).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&(this.removeLayer(this._popup).fire("popupclose",{popup:this._popup}),this._popup=null),this}}),L.LayerGroup=L.Class.extend({initialize:function(a){this._layers={};var b,c;if(a)for(b=0,c=a.length;b';var b=a.firstChild;return b.style.behavior="url(#default#VML)",b&&typeof b.adj=="object"}(),L.Path=L.Browser.svg||!L.Browser.vml?L.Path:L.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(a){return document.createElement("')}}catch(a){return function(a){return document.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var a=this._container=this._createElement("shape");a.className+=" leaflet-vml-shape"+(this.options.clickable?" leaflet-clickable":""),a.coordsize="1 1",this._path=this._createElement("path"),a.appendChild(this._path),this._map._pathRoot.appendChild(a)},_initStyle:function(){var a=this._container,b,c;this.options.stroke&&(b=this._stroke=this._createElement("stroke"),b.endcap="round",a.appendChild(b)),this.options.fill&&(c=this._fill=this._createElement("fill"),a.appendChild(c)),this._updateStyle()},_updateStyle:function(){var a=this._stroke,b=this._fill,c=this.options,d=this._container;d.stroked=c.stroke,d.filled=c.fill,c.stroke&&(a.weight=c.weight+"px",a.color=c.color,a.opacity=c.opacity),c.fill&&(b.color=c.fillColor||c.color,b.opacity=c.fillOpacity)},_updatePath:function(){var a=this._container.style;a.display="none",this._path.v=this.getPathString()+" ",a.display=""}}),L.Map.include(L.Browser.svg||!L.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var a=this._pathRoot=document.createElement("div");a.className="leaflet-vml-container",this._panes.overlayPane.appendChild(a),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),L.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),L.Path=L.Path.SVG&&!window.L_PREFER_CANVAS||!L.Browser.canvas?L.Path:L.Path.extend({statics:{CANVAS:!0,SVG:!1},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var a=this.options;a.stroke&&(this._ctx.lineWidth=a.weight,this._ctx.strokeStyle=a.color),a.fill&&(this._ctx.fillStyle=a.fillColor||a.color)},_drawPath:function(){var a,b,c,d,e,f;this._ctx.beginPath();for(a=0,c=this._parts.length;af&&(g=h,f=i);f>c&&(b[g]=1,this._simplifyDPStep(a,b,c,d,g),this._simplifyDPStep(a,b,c,g,e))},_reducePoints:function(a,b){var c=[a[0]];for(var d=1,e=0,f=a.length;db&&(c.push(a[d]),e=d);return eb.max.x&&(c|=2),a.yb.max.y&&(c|=8),c},_sqDist:function(a,b){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d},_sqClosestPointOnSegment:function(a,b,c,d){var e=b.x,f=b.y,g=c.x-e,h=c.y-f,i=g*g+h*h,j;return i>0&&(j=((a.x-e)*g+(a.y-f)*h)/i,j>1?(e=c.x,f=c.y):j>0&&(e+=g*j,f+=h*j)),g=a.x-e,h=a.y-f,d?g*g+h*h:new L.Point(e,f)}},L.Polyline=L.Path.extend({initialize:function(a,b){L.Path.prototype.initialize.call(this,b),this._latlngs=a,L.Handler.PolyEdit&&(this.editing=new L.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var a=0,b=this._latlngs.length;aa.max.x||c.y-b>a.max.y||c.x+ba.y!=e.y>a.y&&a.x<(e.x-d.x)*(a.y-d.y)/(e.y-d.y)+d.x&&(b=!b)}return b}}:{}),L.Circle.include(L.Path.CANVAS?{_drawPath:function(){var a=this._point;this._ctx.beginPath(),this._ctx.arc(a.x,a.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(a){var b=this._point,c=this.options.stroke?this.options.weight/2:0;return a.distanceTo(b)<=this._radius+c}}:{}),L.GeoJSON=L.FeatureGroup.extend({initialize:function(a,b){L.Util.setOptions(this,b),this._geojson=a,this._layers={},a&&this.addGeoJSON(a)},addGeoJSON:function(a){var b=a.features,c,d;if(b){for(c=0,d=b.length;c1){this._simulateClick=!1;return}var b=a.touches&&a.touches.length===1?a.touches[0]:a,c=b.target;L.DomEvent.preventDefault(a),L.Browser.touch&&c.tagName.toLowerCase()==="a"&&(c.className+=" leaflet-active"),this._moved=!1;if(this._moving)return;L.Browser.touch||(L.DomUtil.disableTextSelection(),this._setMovingCursor()),this._startPos=this._newPos=L.DomUtil.getPosition(this._element),this._startPoint=new L.Point(b.clientX,b.clientY),L.DomEvent.addListener(document,L.Draggable.MOVE,this._onMove,this),L.DomEvent.addListener(document,L.Draggable.END,this._onUp,this)},_onMove:function(a){if(a.touches&&a.touches.length>1)return;L.DomEvent.preventDefault(a);var b=a.touches&&a.touches.length===1?a.touches[0]:a;this._moved||(this.fire("dragstart"),this._moved=!0),this._moving=!0;var c=new L.Point(b.clientX,b.clientY);this._newPos=this._startPos.add(c).subtract(this._startPoint),L.Util.cancelAnimFrame(this._animRequest),this._animRequest=L.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),L.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(a){if(this._simulateClick&&a.changedTouches){var b=a.changedTouches[0],c=b.target,d=this._newPos&&this._newPos.distanceTo(this._startPos)||0;c.tagName.toLowerCase()==="a"&&(c.className=c.className.replace(" leaflet-active","")),d200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var a=this._map.getSize().divideBy(2),b=this._map.latLngToLayerPoint(new L.LatLng(0,0));this._initialWorldOffset=b.subtract(a)},_onPreDrag:function(){var a=this._map,b=a.options.scale(a.getZoom()),c=Math.round(b/2),d=this._initialWorldOffset.x,e=this._draggable._newPos.x,f=(e-c+d)%b+c-d,g=(e+c+d)%b-c-d,h=Math.abs(f+d)b.inertiaThreshold||typeof this._positions[0]=="undefined";if(d)a.fire("moveend");else{var e=this._lastPos.subtract(this._positions[0]),f=(this._lastTime+c-this._times[0])/1e3,g=e.multiplyBy(.58/f),h=g.distanceTo(new L.Point(0,0)),i=Math.min(b.inertiaMaxSpeed,h),j=g.multiplyBy(i/h),k=i/b.inertiaDeceleration,l=j.multiplyBy(-k/2).round(),m={duration:k,easing:"ease-out"};L.Util.requestAnimFrame(L.Util.bind(function(){this._map.panBy(l,m)},this))}a.fire("dragend"),b.maxBounds&&L.Util.requestAnimFrame(this._panInsideMaxBounds,a,!0,a._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),L.Map.mergeOptions({doubleClickZoom:!0}),L.Map.DoubleClickZoom=L.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(a){this.setView(a.latlng,this._zoom+1)}}),L.Map.mergeOptions({scrollWheelZoom:!L.Browser.touch}),L.Map.ScrollWheelZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(a){var b=L.DomEvent.getWheelDelta(a);this._delta+=b,this._lastMousePos=this._map.mouseEventToContainerPoint(a),clearTimeout(this._timer),this._timer=setTimeout(L.Util.bind(this._performZoom,this),50),L.DomEvent.preventDefault(a)},_performZoom:function(){var a=this._map,b=Math.round(this._delta),c=a.getZoom();b=Math.max(Math.min(b,4),-4),b=a._limitZoom(c+b)-c,this._delta=0;if(!b)return;var d=this._getCenterForScrollWheelZoom(this._lastMousePos,b),e=c+b;a.setView(d,e)},_getCenterForScrollWheelZoom:function(a,b){var c=this._map,d=c.getPixelBounds().getCenter(),e=c.getSize().divideBy(2),f=a.subtract(e).multiplyBy(1-Math.pow(2,-b)),g=d.add(f);return c.unproject(g,c._zoom,!0)}}),L.Util.extend(L.DomEvent,{addDoubleTapListener:function(a,b,c){function k(a){if(a.touches.length!==1)return;var b=Date.now(),c=b-(d||b);g=a.touches[0],e=c>0&&c<=f,d=b}function l(a){e&&(g.type="dblclick",b(g),d=null)}var d,e=!1,f=250,g,h="_leaflet_",i="touchstart",j="touchend";a[h+i+c]=k,a[h+j+c]=l,a.addEventListener(i,k,!1),a.addEventListener(j,l,!1)},removeDoubleTapListener:function(a,b){var c="_leaflet_";a.removeEventListener(a,a[c+"touchstart"+b],!1),a.removeEventListener(a,a[c+"touchend"+b],!1)}}),L.Map.mergeOptions({touchZoom:L.Browser.touch&&!L.Browser.android}),L.Map.TouchZoom=L.Handler.extend({addHooks:function(){L.DomEvent.addListener(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){L.DomEvent.removeListener(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(a){var b=this._map;if(!a.touches||a.touches.length!==2||b._animatingZoom||this._zooming)return;var c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]),e=b.containerPointToLayerPoint(b.getSize().divideBy(2));this._startCenter=c.add(d).divideBy(2,!0),this._startDist=c.distanceTo(d),this._moved=!1,this._zooming=!0,this._centerOffset=e.subtract(this._startCenter),L.DomEvent.addListener(document,"touchmove",this._onTouchMove,this).addListener(document,"touchend",this._onTouchEnd,this),L.DomEvent.preventDefault(a)},_onTouchMove:function(a){if(!a.touches||a.touches.length!==2)return;var b=this._map,c=b.mouseEventToLayerPoint(a.touches[0]),d=b.mouseEventToLayerPoint(a.touches[1]);this._scale=c.distanceTo(d)/this._startDist,this._delta=c.add(d).divideBy(2,!0).subtract(this._startCenter);if(this._scale===1)return;this._moved||(b._mapPane.className+=" leaflet-zoom-anim",b.fire("zoomstart").fire("movestart")._prepareTileBg(),this._moved=!0),b._tileBg.style.webkitTransform=L.DomUtil.getTranslateString(this._delta)+" "+L.DomUtil.getScaleString(this._scale,this._startCenter),L.DomEvent.preventDefault(a)},_onTouchEnd:function(a){if(!this._moved||!this._zooming)return;this._zooming=!1,L.DomEvent.removeListener(document,"touchmove",this._onTouchMove).removeListener(document,"touchend",this._onTouchEnd);var b=this._centerOffset.subtract(this._delta).divideBy(this._scale),c=this._map.getPixelOrigin().add(this._startCenter).add(b),d=this._map.unproject(c),e=this._map.getZoom(),f=Math.log(this._scale)/Math.LN2,g=f>0?Math.ceil(f):Math.floor(f),h=this._map._limitZoom(e+g),i=Math.pow(2,h-e);this._map._runAnimation(d,h,i/this._scale,this._startCenter.add(b))}}),L.Map.mergeOptions({boxZoom:!0}),L.Map.BoxZoom=L.Handler.extend({initialize:function(a){this._map=a,this._container=a._container,this._pane=a._panes.overlayPane},addHooks:function(){L.DomEvent.addListener(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){L.DomEvent.removeListener(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(a){if(!a.shiftKey||a.which!==1&&a.button!==1)return!1;L.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(a),this._box=L.DomUtil.create("div","leaflet-zoom-box",this._pane),L.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",L.DomEvent.addListener(document,"mousemove",this._onMouseMove,this).addListener(document,"mouseup",this._onMouseUp,this).preventDefault(a)},_onMouseMove:function(a){var b=this._startLayerPoint,c=this._box,d=this._map.mouseEventToLayerPoint(a),e=d.subtract(b),f=new L.Point(Math.min(d.x,b.x),Math.min(d.y,b.y));L.DomUtil.setPosition(c,f),c.style.width=Math.abs(e.x)-4+"px",c.style.height=Math.abs(e.y)-4+"px"},_onMouseUp:function(a){this._pane.removeChild(this._box),this._container.style.cursor="",L.DomUtil.enableTextSelection(),L.DomEvent.removeListener(document,"mousemove",this._onMouseMove).removeListener(document,"mouseup",this._onMouseUp);var b=this._map,c=b.mouseEventToLayerPoint(a),d=new L.LatLngBounds(b.layerPointToLatLng(this._startLayerPoint),b.layerPointToLatLng(c));b.fitBounds(d)}}),L.Handler.MarkerDrag=L.Handler.extend({initialize:function(a){this._marker=a},addHooks:function(){var a=this._marker._icon;this._draggable||(this._draggable=(new L.Draggable(a,a)).on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this)),this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(a){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(a){var b=L.DomUtil.getPosition(this._marker._icon);this._marker._shadow&&L.DomUtil.setPosition(this._marker._shadow,b),this._marker._latlng=this._marker._map.layerPointToLatLng(b),this._marker.fire("move").fire("drag")},_onDragEnd:function(){this._marker.fire("moveend").fire("dragend")}}),L.Handler.PolyEdit=L.Handler.extend({options:{icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"})},initialize:function(a,b){this._poly=a,L.Util.setOptions(this,b)},addHooks:function(){this._poly._map&&(this._markerGroup||this._initMarkers(),this._poly._map.addLayer(this._markerGroup))},removeHooks:function(){this._poly._map&&this._poly._map.removeLayer(this._markerGroup)},updateMarkers:function(){this._markerGroup.clearLayers(),this._initMarkers()},_initMarkers:function(){this._markerGroup=new L.LayerGroup,this._markers=[];var a=this._poly._latlngs,b,c,d,e;for(b=0,d=a.length;ba&&(c._index+=b)})},_createMiddleMarker:function(a,b){function e(){var e=b._index;d._index=e,d.off("click",g).on("click",this._onMarkerClick,this),this._poly.spliceLatLngs(e,0,c),this._markers.splice(e,0,d),d.setOpacity(1),this._updateIndexes(e,1),b._index++,this._updatePrevNext(a,d),this._updatePrevNext(d,b)}function f(){d.off("dragstart",e,this),d.off("dragend",f,this),this._createMiddleMarker(a,d),this._createMiddleMarker(d,b)}function g(){e.call(this),f.call(this),this._poly.fire("edit")}var c=this._getMiddleLatLng(a,b),d=this._createMarker(c);d.setOpacity(.6),a._middleRight=b._middleLeft=d,d.on("click",g,this).on("dragstart",e,this).on("dragend",f,this),this._markerGroup.addLayer(d)},_updatePrevNext:function(a,b){a._next=b,b._prev=a},_getMiddleLatLng:function(a,b){var c=this._poly._map,d=c.latLngToLayerPoint(a.getLatLng()),e=c.latLngToLayerPoint(b.getLatLng());return c.layerPointToLatLng(d._add(e).divideBy(2))}}),L.Control=L.Class.extend({options:{position:"topright"},initialize:function(a){L.Util.setOptions(this,a)},getPosition:function(){return this.options.position},setPosition:function(a){this.options.position=a,this._map&&(this._map.removeControl(this),this._map.addControl(this))},addTo:function(a){this._map=a;var b=this._container=this.onAdd(a),c=this.getPosition(),d=a._controlCorners[c];return L.DomUtil.addClass(b,"leaflet-control"),c.indexOf("bottom")!==-1?d.insertBefore(b,d.firstChild):d.appendChild(b),this},removeFrom:function(a){var b=this.getPosition(),c=a._controlCorners[b];return c.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(a),this}}),L.Map.include({addControl:function(a){return a.addTo(this),this},removeControl:function(a){return a.removeFrom(this),this},_initControlPos:function(){function d(d,e){var f=b+d+" "+b+e;a[d+e]=L.DomUtil.create("div",f,c)}var a=this._controlCorners={},b="leaflet-",c=this._controlContainer=L.DomUtil.create("div",b+"control-container",this._container);d("top","left"),d("top","right"),d("bottom","left"),d("bottom","right")}}),L.Control.Zoom=L.Control.extend({options:{position:"topleft"},onAdd:function(a){var b="leaflet-control-zoom",c=L.DomUtil.create("div",b);return this._createButton("Zoom in",b+"-in",c,a.zoomIn,a),this._createButton("Zoom out",b+"-out",c,a.zoomOut,a),c},_createButton:function(a,b,c,d,e){var f=L.DomUtil.create("a",b,c);return f.href="#",f.title=a,L.DomEvent.addListener(f,"click",L.DomEvent.stopPropagation).addListener(f,"click",L.DomEvent.preventDefault).addListener(f,"click",d,e),f}}),L.Control.Attribution=L.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(a){L.Util.setOptions(this,a),this._attributions={}},onAdd:function(a){return this._map=a,this._container=L.DomUtil.create("div","leaflet-control-attribution"),L.DomEvent.disableClickPropagation(this._container),this._update(),this._container},setPrefix:function(a){this.options.prefix=a,this._update()},addAttribution:function(a){if(!a)return;this._attributions[a]||(this._attributions[a]=0),this._attributions[a]++,this._update()},removeAttribution:function(a){if(!a)return;this._attributions[a]--,this._update()},_update:function(){if(!this._map)return;var a=[];for(var b in this._attributions)this._attributions.hasOwnProperty(b)&&this._attributions[b]&&a.push(b);var c=[];this.options.prefix&&c.push(this.options.prefix),a.length&&c.push(a.join(", ")),this._container.innerHTML=c.join(" — ")}}),L.Control.Scale=L.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(a){this._map=a;var b="leaflet-control-scale",c=L.DomUtil.create("div",b),d=this.options;return d.metric&&(this._mScale=L.DomUtil.create("div",b+"-line",c)),d.imperial&&(this._iScale=L.DomUtil.create("div",b+"-line",c)),a.on(d.updateWhenIdle?"moveend":"move",this._update,this),this._update(),c},onRemove:function(a){a.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_update:function(){var a=this._map.getBounds(),b=a.getCenter().lat,c=new L.LatLng(b,a.getSouthWest().lng),d=new L.LatLng(b,a.getNorthEast().lng),e=this._map.getSize(),f=this.options,g=c.distanceTo(d)*(f.maxWidth/e.x);f.metric&&this._updateMetric(g),f.imperial&&this._updateImperial(g)},_updateMetric:function(a){var b=this._getRoundNum(a);this._mScale.style.width=this._getScaleWidth(b/a)+"px",this._mScale.innerHTML=b<1e3?b+" m":b/1e3+" km"},_updateImperial:function(a){var b=a*3.2808399,c=this._iScale,d,e,f;b>5280?(d=b/5280,e=this._getRoundNum(d),c.style.width=this._getScaleWidth(e/d)+"px",c.innerHTML=e+" mi"):(f=this._getRoundNum(b),c.style.width=this._getScaleWidth(f/b)+"px",c.innerHTML=f+" ft")},_getScaleWidth:function(a){return Math.round(this.options.maxWidth*a)-10},_getRoundNum:function(a){var b=Math.pow(10,(Math.floor(a)+"").length-1),c=a/b;return c=c<10?c<5?c<2?1:2:5:10,b*c}}),L.Control.Layers=L.Control.extend({options:{collapsed:!0,position:"topright"},initialize:function(a,b,c){L.Util.setOptions(this,c),this._layers={};for(var d in a)a.hasOwnProperty(d)&&this._addLayer(a[d],d);for(d in b)b.hasOwnProperty(d)&&this._addLayer(b[d],d,!0)},onAdd:function(a){return this._initLayout(),this._update(),this._container},addBaseLayer:function(a,b){return this._addLayer(a,b),this._update(),this},addOverlay:function(a,b){return this._addLayer(a,b,!0),this._update(),this},removeLayer:function(a){var b=L.Util.stamp(a);return delete this._layers[b],this._update(),this},_initLayout:function(){var a="leaflet-control-layers",b=this._container=L.DomUtil.create("div",a);L.Browser.touch?L.DomEvent.addListener(b,"click",L.DomEvent.stopPropagation):L.DomEvent.disableClickPropagation(b);var c=this._form=L.DomUtil.create("form",a+"-list");if(this.options.collapsed){L.DomEvent.addListener(b,"mouseover",this._expand,this).addListener(b,"mouseout",this._collapse,this);var d=this._layersLink=L.DomUtil.create("a",a+"-toggle",b);d.href="#",d.title="Layers",L.DomEvent.addListener(d,L.Browser.touch?"click":"focus",this._expand,this),this._map.on("movestart",this._collapse,this)}else this._expand();this._baseLayersList=L.DomUtil.create("div",a+"-base",c),this._separator=L.DomUtil.create("div",a+"-separator",c),this._overlaysList=L.DomUtil.create("div",a+"-overlays",c),b.appendChild(c)},_addLayer:function(a,b,c){var d=L.Util.stamp(a);this._layers[d]={layer:a,name:b,overlay:c}},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var a=!1,b=!1;for(var c in this._layers)if(this._layers.hasOwnProperty(c)){var d=this._layers[c];this._addItem(d),b=b||d.overlay,a=a||!d.overlay}this._separator.style.display=b&&a?"":"none"},_addItem:function(a,b){var c=document.createElement("label"),d=document.createElement("input");a.overlay||(d.name="leaflet-base-layers"),d.type=a.overlay?"checkbox":"radio",d.checked=this._map.hasLayer(a.layer),d.layerId=L.Util.stamp(a.layer),L.DomEvent.addListener(d,"click",this._onInputClick,this);var e=document.createTextNode(" "+a.name);c.appendChild(d),c.appendChild(e);var f=a.overlay?this._overlaysList:this._baseLayersList;f.appendChild(c)},_onInputClick:function(){var a,b,c,d=this._form.getElementsByTagName("input"),e=d.length;for(a=0;a Class*/ { // instantiate class without calling constructor var F = function () {}; F.prototype = this.prototype; + var proto = new F(); - proto.constructor = NewClass; + NewClass.prototype = proto; - // add superclass access - NewClass.superclass = this.prototype; - - // add class name - //proto.className = props; - //inherit parent's statics for (var i in this) { - if (this.hasOwnProperty(i) && i !== 'prototype' && i !== 'superclass') { + if (this.hasOwnProperty(i) && i !== 'prototype') { NewClass[i] = this[i]; } } @@ -54,13 +49,15 @@ L.Class.extend = function (/*Object*/ props) /*-> Class*/ { // mix given properties into the prototype L.Util.extend(proto, props); - // allow inheriting further - NewClass.extend = L.Class.extend; - - // method for adding properties to prototype - NewClass.include = function (props) { - L.Util.extend(this.prototype, props); - }; - return NewClass; }; + + +// method for adding properties to prototype +L.Class.include = function (props) { + L.Util.extend(this.prototype, props); +}; + +L.Class.mergeOptions = function (options) { + L.Util.extend(this.prototype.options, options); +}; \ No newline at end of file diff --git a/src/layer/Popup.js b/src/layer/Popup.js index 9adea46a..ee7d5194 100644 --- a/src/layer/Popup.js +++ b/src/layer/Popup.js @@ -1,4 +1,8 @@ +L.Map.mergeOptions({ + closePopupOnClick: true +}); + L.Popup = L.Class.extend({ includes: L.Mixin.Events, diff --git a/src/map/Map.js b/src/map/Map.js index 7983e0d1..20b192f8 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -17,18 +17,6 @@ L.Map = L.Class.extend({ zoom: null, layers: [], - // interaction - dragging: true, - touchZoom: L.Browser.touch && !L.Browser.android, - scrollWheelZoom: !L.Browser.touch, - doubleClickZoom: true, - boxZoom: true, - - inertia: !L.Browser.android, - inertiaDeceleration: L.Browser.touch ? 3000 : 2000, // px/s^2 - inertiaMaxSpeed: L.Browser.touch ? 1500 : 1000, // px/s - inertiaThreshold: L.Browser.touch ? 32 : 16, // ms - // controls zoomControl: true, attributionControl: true, @@ -39,7 +27,6 @@ L.Map = L.Class.extend({ // misc trackResize: true, - closePopupOnClick: true, worldCopyJump: true }, diff --git a/src/map/ext/Map.Control.js b/src/map/ext/Map.Control.js index 6f5f95a1..c0d6f178 100644 --- a/src/map/ext/Map.Control.js +++ b/src/map/ext/Map.Control.js @@ -1,48 +1,30 @@ L.Map.include({ addControl: function (control) { - var container = control.onAdd(this); - - control._container = container; - control._map = this; - - var pos = control.getPosition(), - corner = this._controlCorners[pos]; - - L.DomUtil.addClass(container, 'leaflet-control'); - - if (pos.indexOf('bottom') !== -1) { - corner.insertBefore(container, corner.firstChild); - } else { - corner.appendChild(container); - } + control.addTo(this); return this; }, removeControl: function (control) { - var pos = control.getPosition(), - corner = this._controlCorners[pos]; - - corner.removeChild(control._container); - control._map = null; - - if (control.onRemove) { - control.onRemove(this); - } + control.removeFrom(this); return this; }, _initControlPos: function () { - var top = 'leaflet-top', - bottom = 'leaflet-bottom', - left = 'leaflet-left', - right = 'leaflet-right', - corner = 'leaflet-corner', - container = this._container, - corners = this._controlCorners = {}; + var corners = this._controlCorners = {}, + l = 'leaflet-', + container = this._controlContainer = + L.DomUtil.create('div', l + 'control-container', this._container); - corners.topleft = L.DomUtil.create('div', [corner, top, left].join(' '), container); - corners.topright = L.DomUtil.create('div', [corner, top, right].join(' '), container); - corners.bottomleft = L.DomUtil.create('div', [corner, bottom, left].join(' '), container); - corners.bottomright = L.DomUtil.create('div', [corner, bottom, right].join(' '), container); + function createCorner(vSide, hSide) { + var className = l + vSide + ' ' + l + hSide; + + corners[vSide + hSide] = + L.DomUtil.create('div', className, container); + } + + createCorner('top', 'left'); + createCorner('top', 'right'); + createCorner('bottom', 'left'); + createCorner('bottom', 'right'); } }); diff --git a/src/map/ext/Map.Popup.js b/src/map/ext/Map.Popup.js index 2890c69f..78335c25 100644 --- a/src/map/ext/Map.Popup.js +++ b/src/map/ext/Map.Popup.js @@ -20,4 +20,4 @@ L.Map.include({ } return this; } -}); +}); \ No newline at end of file diff --git a/src/map/handler/Map.BoxZoom.js b/src/map/handler/Map.BoxZoom.js index cb20e6a0..758b54d2 100644 --- a/src/map/handler/Map.BoxZoom.js +++ b/src/map/handler/Map.BoxZoom.js @@ -2,6 +2,10 @@ * L.Handler.ShiftDragZoom is used internally by L.Map to add shift-drag zoom (zoom to a selected bounding box). */ +L.Map.mergeOptions({ + boxZoom: true +}); + L.Map.BoxZoom = L.Handler.extend({ initialize: function (map) { this._map = map; diff --git a/src/map/handler/Map.DoubleClickZoom.js b/src/map/handler/Map.DoubleClickZoom.js index b009ac43..db22f20c 100644 --- a/src/map/handler/Map.DoubleClickZoom.js +++ b/src/map/handler/Map.DoubleClickZoom.js @@ -2,6 +2,10 @@ * L.Handler.DoubleClickZoom is used internally by L.Map to add double-click zooming. */ +L.Map.mergeOptions({ + doubleClickZoom: true +}); + L.Map.DoubleClickZoom = L.Handler.extend({ addHooks: function () { this._map.on('dblclick', this._onDoubleClick); diff --git a/src/map/handler/Map.Drag.js b/src/map/handler/Map.Drag.js index d4d7ae9f..d973f598 100644 --- a/src/map/handler/Map.Drag.js +++ b/src/map/handler/Map.Drag.js @@ -2,6 +2,14 @@ * L.Handler.MapDrag is used internally by L.Map to make the map draggable. */ +L.Map.mergeOptions({ + dragging: true, + inertia: !L.Browser.android, + inertiaDeceleration: L.Browser.touch ? 3000 : 2000, // px/s^2 + inertiaMaxSpeed: L.Browser.touch ? 1500 : 1000, // px/s + inertiaThreshold: L.Browser.touch ? 32 : 16 // ms +}); + L.Map.Drag = L.Handler.extend({ addHooks: function () { if (!this._draggable) { @@ -90,7 +98,7 @@ L.Map.Drag = L.Handler.extend({ var map = this._map, options = map.options, delay = +new Date() - this._lastTime, - + noInertia = !options.inertia || delay > options.inertiaThreshold || typeof this._positions[0] === 'undefined'; diff --git a/src/map/handler/Map.ScrollWheelZoom.js b/src/map/handler/Map.ScrollWheelZoom.js index ce0b2a07..05bd55bc 100644 --- a/src/map/handler/Map.ScrollWheelZoom.js +++ b/src/map/handler/Map.ScrollWheelZoom.js @@ -2,6 +2,10 @@ * L.Handler.ScrollWheelZoom is used internally by L.Map to enable mouse scroll wheel zooming on the map. */ +L.Map.mergeOptions({ + scrollWheelZoom: !L.Browser.touch +}); + L.Map.ScrollWheelZoom = L.Handler.extend({ addHooks: function () { L.DomEvent.addListener(this._map._container, 'mousewheel', this._onWheelScroll, this); diff --git a/src/map/handler/Map.TouchZoom.js b/src/map/handler/Map.TouchZoom.js index 3647d8c7..e896604c 100644 --- a/src/map/handler/Map.TouchZoom.js +++ b/src/map/handler/Map.TouchZoom.js @@ -2,6 +2,10 @@ * L.Handler.TouchZoom is used internally by L.Map to add touch-zooming on Webkit-powered mobile browsers. */ +L.Map.mergeOptions({ + touchZoom: L.Browser.touch && !L.Browser.android +}); + L.Map.TouchZoom = L.Handler.extend({ addHooks: function () { L.DomEvent.addListener(this._map._container, 'touchstart', this._onTouchStart, this);