From 7517cbcd5358c5771da39f5cb41388a0a3617b58 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 7 Nov 2012 19:21:21 +0200 Subject: [PATCH] fix typos and regression in #1122 --- dist/leaflet-src.js | 1216 ++++++++++++++++++----------------- dist/leaflet.js | 2 +- src/core/Browser.js | 2 +- src/dom/DomEvent.MsTouch.js | 2 +- src/layer/FeatureGroup.js | 9 +- src/layer/LayerGroup.js | 4 - src/layer/vector/Polygon.js | 4 +- 7 files changed, 632 insertions(+), 607 deletions(-) diff --git a/dist/leaflet-src.js b/dist/leaflet-src.js index 52f365df..3f03b7be 100644 --- a/dist/leaflet-src.js +++ b/dist/leaflet-src.js @@ -29,11 +29,13 @@ L.version = '0.4.4'; */ L.Util = { - extend: function (/*Object*/ dest) /*-> Object*/ { // merge src properties into dest - var sources = Array.prototype.slice.call(arguments, 1); - for (var j = 0, len = sources.length, src; j < len; j++) { + extend: function (dest) { // (Object[, Object, ...]) -> + var sources = Array.prototype.slice.call(arguments, 1), + i, j, len, src; + + for (j = 0, len = sources.length; j < len; j++) { src = sources[j] || {}; - for (var i in src) { + for (i in src) { if (src.hasOwnProperty(i)) { dest[i] = src[i]; } @@ -130,7 +132,7 @@ L.Util = { function getPrefixed(name) { var i, fn, - prefixes = ['webkit', 'moz', 'o', 'ms']; + prefixes = ['webkit', 'moz', 'o', 'ms']; for (i = 0; i < prefixes.length && !fn; i++) { fn = window[prefixes[i] + name]; @@ -143,21 +145,19 @@ L.Util = { function timeoutDefer(fn) { var time = +new Date(), - timeToCall = Math.max(0, 16 - (time - lastTime)); + timeToCall = Math.max(0, 16 - (time - lastTime)); lastTime = time + timeToCall; return window.setTimeout(fn, timeToCall); } var requestFn = window.requestAnimationFrame || - getPrefixed('RequestAnimationFrame') || timeoutDefer; + getPrefixed('RequestAnimationFrame') || timeoutDefer; var cancelFn = window.cancelAnimationFrame || - getPrefixed('CancelAnimationFrame') || - getPrefixed('CancelRequestAnimationFrame') || - function (id) { - window.clearTimeout(id); - }; + getPrefixed('CancelAnimationFrame') || + getPrefixed('CancelRequestAnimationFrame') || + function (id) { window.clearTimeout(id); }; L.Util.requestAnimFrame = function (fn, context, immediate, element) { @@ -252,11 +252,11 @@ var key = '_leaflet_events'; L.Mixin = {}; L.Mixin.Events = { - + addEventListener: function (types, fn, context) { // (String, Function[, Object]) or (Object[, Object]) var events = this[key] = this[key] || {}, type, i, len; - + // Types can be a map of types/handlers if (typeof types === 'object') { for (type in types) { @@ -264,12 +264,12 @@ L.Mixin.Events = { this.addEventListener(type, types[type], fn); } } - + return this; } - + types = L.Util.splitWords(types); - + for (i = 0, len = types.length; i < len; i++) { events[types[i]] = events[types[i]] || []; events[types[i]].push({ @@ -277,7 +277,7 @@ L.Mixin.Events = { context: context || this }); } - + return this; }, @@ -288,24 +288,24 @@ L.Mixin.Events = { removeEventListener: function (types, fn, context) { // (String[, Function, Object]) or (Object[, Object]) var events = this[key], type, i, len, listeners, j; - + if (typeof types === 'object') { for (type in types) { if (types.hasOwnProperty(type)) { this.removeEventListener(type, types[type], fn); } } - + return this; } - + types = L.Util.splitWords(types); for (i = 0, len = types.length; i < len; i++) { if (this.hasEventListeners(types[i])) { listeners = events[types[i]]; - + for (j = listeners.length - 1; j >= 0; j--) { if ( (!fn || listeners[j].action === fn) && @@ -316,7 +316,7 @@ L.Mixin.Events = { } } } - + return this; }, @@ -348,30 +348,30 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent; (function () { var ie = !!window.ActiveXObject, - // http://tanalin.com/en/articles/ie-version-js/ - ie6 = ie && !window.XMLHttpRequest, - ie7 = ie && !document.querySelector, + // http://tanalin.com/en/articles/ie-version-js/ + ie6 = ie && !window.XMLHttpRequest, + ie7 = ie && !document.querySelector, - // terrible browser detection to work around Safari / iOS / Android browser bugs - // see TileLayer._addTile and debug/hacks/jitter.html + // terrible browser detection to work around Safari / iOS / Android browser bugs + // see TileLayer._addTile and debug/hacks/jitter.html - ua = navigator.userAgent.toLowerCase(), - webkit = ua.indexOf("webkit") !== -1, - chrome = ua.indexOf("chrome") !== -1, - android = ua.indexOf("android") !== -1, - android23 = ua.search("android [23]") !== -1, + ua = navigator.userAgent.toLowerCase(), + webkit = ua.indexOf("webkit") !== -1, + chrome = ua.indexOf("chrome") !== -1, + android = ua.indexOf("android") !== -1, + android23 = ua.search("android [23]") !== -1, - mobile = typeof orientation !== undefined + '', - msTouch = (window.navigator && window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints), - retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) || - ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches)), + mobile = typeof orientation !== undefined + '', + msTouch = (window.navigator && window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints), + retina = (('devicePixelRatio' in window && window.devicePixelRatio > 1) || + ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches)), - doc = document.documentElement, - ie3d = ie && ('transition' in doc.style), - webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()), - gecko3d = 'MozPerspective' in doc.style, - opera3d = 'OTransition' in doc.style, - any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d); + doc = document.documentElement, + ie3d = ie && ('transition' in doc.style), + webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()), + gecko3d = 'MozPerspective' in doc.style, + opera3d = 'OTransition' in doc.style, + any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d); var touch = !window.L_NO_TOUCH && (function () { @@ -385,7 +385,7 @@ L.Mixin.Events.fire = L.Mixin.Events.fireEvent; // Firefox/Gecko var div = document.createElement('div'), - supported = false; + supported = false; if (!div.setAttribute) { return false; @@ -514,15 +514,15 @@ L.Point.prototype = { point = L.point(point); var x = point.x - this.x, - y = point.y - this.y; + y = point.y - this.y; return Math.sqrt(x * x + y * y); }, toString: function () { return 'Point(' + - L.Util.formatNum(this.x) + ', ' + - L.Util.formatNum(this.y) + ')'; + L.Util.formatNum(this.x) + ', ' + + L.Util.formatNum(this.y) + ')'; } }; @@ -574,8 +574,8 @@ L.Bounds = L.Class.extend({ getCenter: function (round) { // (Boolean) -> Point return new L.Point( - (this.min.x + this.max.x) / 2, - (this.min.y + this.max.y) / 2, round); + (this.min.x + this.max.x) / 2, + (this.min.y + this.max.y) / 2, round); }, getBottomLeft: function () { // -> Point @@ -603,21 +603,20 @@ L.Bounds = L.Class.extend({ } return (min.x >= this.min.x) && - (max.x <= this.max.x) && - (min.y >= this.min.y) && - (max.y <= this.max.y); + (max.x <= this.max.x) && + (min.y >= this.min.y) && + (max.y <= this.max.y); }, intersects: function (bounds) { // (Bounds) -> Boolean bounds = L.bounds(bounds); var min = this.min, - max = this.max, - min2 = bounds.min, - max2 = bounds.max; - - var xIntersects = (max2.x >= min.x) && (min2.x <= max.x), - yIntersects = (max2.y >= min.y) && (min2.y <= max.y); + max = this.max, + min2 = bounds.min, + max2 = bounds.max, + xIntersects = (max2.x >= min.x) && (min2.x <= max.x), + yIntersects = (max2.y >= min.y) && (min2.y <= max.y); return xIntersects && yIntersects; }, @@ -662,8 +661,8 @@ L.Transformation = L.Class.extend({ untransform: function (/*Point*/ point, /*Number*/ scale) /*-> Point*/ { scale = scale || 1; return new L.Point( - (point.x / scale - this._b) / this._a, - (point.y / scale - this._d) / this._c); + (point.x / scale - this._b) / this._a, + (point.y / scale - this._d) / this._c); } }); @@ -696,11 +695,11 @@ L.DomUtil = { getViewportOffset: function (element) { var top = 0, - left = 0, - el = element, - docBody = document.body, - pos, - ie7 = L.Browser.ie7; + left = 0, + el = element, + docBody = document.body, + pos, + ie7 = L.Browser.ie7; do { top += el.offsetTop || 0; @@ -726,14 +725,15 @@ L.DomUtil = { top -= el.scrollTop || 0; left -= el.scrollLeft || 0; - //Webkit (and ie <= 7) handles RTL scrollLeft different to everyone else + // webkit (and ie <= 7) handles RTL scrollLeft different to everyone else // https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) { left += el.scrollWidth - el.clientWidth; - //ie7 shows the scrollbar by default and provides clientWidth counting it, so we need to add it back in if it is visible - // Scrollbar is on the left as we are RTL - if (ie7 && L.DomUtil.getStyle(el, 'overflow-y') !== 'hidden' && L.DomUtil.getStyle(el, 'overflow') !== 'hidden') { + // ie7 shows the scrollbar by default and provides clientWidth counting it, so we + // need to add it back in if it is visible; scrollbar is on the left as we are RTL + if (ie7 && L.DomUtil.getStyle(el, 'overflow-y') !== 'hidden' && + L.DomUtil.getStyle(el, 'overflow') !== 'hidden') { left += 17; } } @@ -783,7 +783,7 @@ L.DomUtil = { hasClass: function (el, name) { return (el.className.length > 0) && - new RegExp("(^|\\s)" + name + "(\\s|$)").test(el.className); + new RegExp("(^|\\s)" + name + "(\\s|$)").test(el.className); }, addClass: function (el, name) { @@ -800,8 +800,8 @@ L.DomUtil = { } el.className = el.className - .replace(/(\S+)\s*/g, replaceFn) - .replace(/(^\s+|\s+$)/, ''); + .replace(/(\S+)\s*/g, replaceFn) + .replace(/(^\s+|\s+$)/, ''); }, setOpacity: function (el, value) { @@ -812,7 +812,7 @@ L.DomUtil = { } else if ('filter' in el.style) { var filter = false, - filterName = 'DXImageTransform.Microsoft.Alpha'; + filterName = 'DXImageTransform.Microsoft.Alpha'; // filters collection throws an error if we try to retrieve a filter that doesn't exist try { filter = el.filters.item(filterName); } catch (e) {} @@ -846,8 +846,8 @@ L.DomUtil = { // (same speed either way), Opera 12 doesn't support translate3d var is3d = L.Browser.webkit3d, - open = 'translate' + (is3d ? '3d' : '') + '(', - close = (is3d ? ',0' : '') + ')'; + open = 'translate' + (is3d ? '3d' : '') + '(', + close = (is3d ? ',0' : '') + ')'; return open + point.x + 'px,' + point.y + 'px' + close; }, @@ -888,14 +888,14 @@ L.DomUtil = { // prefix style property names L.DomUtil.TRANSFORM = L.DomUtil.testProp( - ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']); + ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']); L.DomUtil.TRANSITION = L.DomUtil.testProp( - ['transition', 'webkitTransition', 'OTransition', 'MozTransition', 'msTransition']); + ['transition', 'webkitTransition', 'OTransition', 'MozTransition', 'msTransition']); L.DomUtil.TRANSITION_END = - L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ? - L.DomUtil.TRANSITION + 'End' : 'transitionend'; + L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ? + L.DomUtil.TRANSITION + 'End' : 'transitionend'; /* @@ -904,7 +904,7 @@ L.DomUtil.TRANSITION_END = L.LatLng = function (rawLat, rawLng, noWrap) { // (Number, Number[, Boolean]) var lat = parseFloat(rawLat), - lng = parseFloat(rawLng); + lng = parseFloat(rawLng); if (isNaN(lat) || isNaN(lng)) { throw new Error('Invalid LatLng object: (' + rawLat + ', ' + rawLng + ')'); @@ -937,8 +937,8 @@ L.LatLng.prototype = { toString: function (precision) { // -> String return 'LatLng(' + - L.Util.formatNum(this.lat, precision) + ', ' + - L.Util.formatNum(this.lng, precision) + ')'; + L.Util.formatNum(this.lat, precision) + ', ' + + L.Util.formatNum(this.lng, precision) + ')'; }, // Haversine distance formula, see http://en.wikipedia.org/wiki/Haversine_formula @@ -946,13 +946,13 @@ L.LatLng.prototype = { other = L.latLng(other); var R = 6378137, // earth radius in meters - d2r = L.LatLng.DEG_TO_RAD, - dLat = (other.lat - this.lat) * d2r, - dLon = (other.lng - this.lng) * d2r, - lat1 = this.lat * d2r, - lat2 = other.lat * d2r, - sin1 = Math.sin(dLat / 2), - sin2 = Math.sin(dLon / 2); + d2r = L.LatLng.DEG_TO_RAD, + dLat = (other.lat - this.lat) * d2r, + dLon = (other.lng - this.lng) * d2r, + lat1 = this.lat * d2r, + lat2 = other.lat * d2r, + sin1 = Math.sin(dLat / 2), + sin2 = Math.sin(dLon / 2); var a = sin1 * sin1 + sin2 * sin2 * Math.cos(lat1) * Math.cos(lat2); @@ -1011,7 +1011,7 @@ L.LatLngBounds = L.Class.extend({ } } else if (obj instanceof L.LatLngBounds) { this.extend(obj._southWest); - this.extend(obj._northEast); + this.extend(obj._northEast); } return this; }, @@ -1019,19 +1019,19 @@ L.LatLngBounds = L.Class.extend({ // extend the bounds by a percentage pad: function (bufferRatio) { // (Number) -> LatLngBounds var sw = this._southWest, - ne = this._northEast, - heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, - widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio; + ne = this._northEast, + heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, + widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio; return new L.LatLngBounds( - new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), - new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); + new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), + new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); }, getCenter: function () { // -> LatLng return new L.LatLng( - (this._southWest.lat + this._northEast.lat) / 2, - (this._southWest.lng + this._northEast.lng) / 2); + (this._southWest.lat + this._northEast.lat) / 2, + (this._southWest.lng + this._northEast.lng) / 2); }, getSouthWest: function () { @@ -1058,8 +1058,8 @@ L.LatLngBounds = L.Class.extend({ } var sw = this._southWest, - ne = this._northEast, - sw2, ne2; + ne = this._northEast, + sw2, ne2; if (obj instanceof L.LatLngBounds) { sw2 = obj.getSouthWest(); @@ -1069,26 +1069,27 @@ L.LatLngBounds = L.Class.extend({ } return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) && - (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng); + (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng); }, intersects: function (bounds) { // (LatLngBounds) bounds = L.latLngBounds(bounds); var sw = this._southWest, - ne = this._northEast, - sw2 = bounds.getSouthWest(), - ne2 = bounds.getNorthEast(); + ne = this._northEast, + sw2 = bounds.getSouthWest(), + ne2 = bounds.getNorthEast(), - var latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat), - lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng); + latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat), + lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng); return latIntersects && lngIntersects; }, toBBoxString: function () { var sw = this._southWest, - ne = this._northEast; + ne = this._northEast; + return [sw.lng, sw.lat, ne.lng, ne.lat].join(','); }, @@ -1129,10 +1130,11 @@ L.Projection.SphericalMercator = { project: function (latlng) { // (LatLng) -> Point var d = L.LatLng.DEG_TO_RAD, - max = this.MAX_LATITUDE, - lat = Math.max(Math.min(max, latlng.lat), -max), - x = latlng.lng * d, - y = lat * d; + max = this.MAX_LATITUDE, + lat = Math.max(Math.min(max, latlng.lat), -max), + x = latlng.lng * d, + y = lat * d; + y = Math.log(Math.tan((Math.PI / 4) + (y / 2))); return new L.Point(x, y); @@ -1140,8 +1142,8 @@ L.Projection.SphericalMercator = { unproject: function (point) { // (Point, Boolean) -> LatLng var d = L.LatLng.RAD_TO_DEG, - lng = point.x * d, - lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d; + lng = point.x * d, + lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d; // TODO refactor LatLng wrapping return new L.LatLng(lat, lng, true); @@ -1203,7 +1205,7 @@ L.CRS.EPSG3857 = L.Util.extend({}, L.CRS, { project: function (latlng) { // (LatLng) -> Point var projectedPoint = this.projection.project(latlng), - earthRadius = 6378137; + earthRadius = 6378137; return projectedPoint.multiplyBy(earthRadius); } }); @@ -1512,7 +1514,10 @@ L.Map = L.Class.extend({ zoom++; nePoint = this.project(ne, zoom); swPoint = this.project(sw, zoom); - boundsSize = new L.Point(Math.abs(nePoint.x - swPoint.x), Math.abs(swPoint.y - nePoint.y)); + + boundsSize = new L.Point( + Math.abs(nePoint.x - swPoint.x), + Math.abs(swPoint.y - nePoint.y)); if (!inside) { zoomNotFound = boundsSize.x <= size.x && boundsSize.y <= size.y; @@ -1666,8 +1671,7 @@ L.Map = L.Class.extend({ this._mapPane = panes.mapPane = this._createPane('leaflet-map-pane', this._container); this._tilePane = panes.tilePane = this._createPane('leaflet-tile-pane', this._mapPane); - this._objectsPane = panes.objectsPane = this._createPane('leaflet-objects-pane', this._mapPane); - + panes.objectsPane = this._createPane('leaflet-objects-pane', this._mapPane); panes.shadowPane = this._createPane('leaflet-shadow-pane'); panes.overlayPane = this._createPane('leaflet-overlay-pane'); panes.markerPane = this._createPane('leaflet-marker-pane'); @@ -1683,7 +1687,7 @@ L.Map = L.Class.extend({ }, _createPane: function (className, container) { - return L.DomUtil.create('div', className, container || this._objectsPane); + return L.DomUtil.create('div', className, container || this._panes.objectsPane); }, _initializers: [], @@ -1765,8 +1769,9 @@ L.Map = L.Class.extend({ L.DomEvent.on(this._container, 'click', this._onMouseClick, this); - var events = ['dblclick', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'mousemove', 'contextmenu'], - i, len; + var events = ['dblclick', 'mousedown', 'mouseup', 'mouseenter', + 'mouseleave', 'mousemove', 'contextmenu'], + i, len; for (i = 0, len = events.length; i < len; i++) { L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this); @@ -1779,7 +1784,8 @@ L.Map = L.Class.extend({ _onResize: function () { L.Util.cancelAnimFrame(this._resizeRequest); - this._resizeRequest = L.Util.requestAnimFrame(this.invalidateSize, this, false, this._container); + this._resizeRequest = L.Util.requestAnimFrame( + this.invalidateSize, this, false, this._container); }, _onMouseClick: function (e) { @@ -1803,8 +1809,8 @@ L.Map = L.Class.extend({ } var containerPoint = this.mouseEventToContainerPoint(e), - layerPoint = this.containerPointToLayerPoint(containerPoint), - latlng = this.layerPointToLatLng(layerPoint); + layerPoint = this.containerPointToLayerPoint(containerPoint), + latlng = this.layerPointToLatLng(layerPoint); this.fire(type, { latlng: latlng, @@ -1869,7 +1875,7 @@ L.Map = L.Class.extend({ _limitZoom: function (zoom) { var min = this.getMinZoom(), - max = this.getMaxZoom(); + max = this.getMaxZoom(); return Math.max(min, Math.min(max, zoom)); } @@ -1899,15 +1905,15 @@ L.Projection.Mercator = { project: function (latlng) { // (LatLng) -> Point var d = L.LatLng.DEG_TO_RAD, - max = this.MAX_LATITUDE, - lat = Math.max(Math.min(max, latlng.lat), -max), - r = this.R_MAJOR, - r2 = this.R_MINOR, - x = latlng.lng * d * r, - y = lat * d, - tmp = r2 / r, - eccent = Math.sqrt(1.0 - tmp * tmp), - con = eccent * Math.sin(y); + max = this.MAX_LATITUDE, + lat = Math.max(Math.min(max, latlng.lat), -max), + r = this.R_MAJOR, + r2 = this.R_MINOR, + x = latlng.lng * d * r, + y = lat * d, + tmp = r2 / r, + eccent = Math.sqrt(1.0 - tmp * tmp), + con = eccent * Math.sin(y); con = Math.pow((1 - con) / (1 + con), eccent * 0.5); @@ -1919,22 +1925,23 @@ L.Projection.Mercator = { unproject: function (point) { // (Point, Boolean) -> LatLng var d = L.LatLng.RAD_TO_DEG, - r = this.R_MAJOR, - r2 = this.R_MINOR, - lng = point.x * d / r, - tmp = r2 / r, - eccent = Math.sqrt(1 - (tmp * tmp)), - ts = Math.exp(- point.y / r2), - phi = (Math.PI / 2) - 2 * Math.atan(ts), - numIter = 15, - tol = 1e-7, - i = numIter, - dphi = 0.1, - con; + r = this.R_MAJOR, + r2 = this.R_MINOR, + lng = point.x * d / r, + tmp = r2 / r, + eccent = Math.sqrt(1 - (tmp * tmp)), + ts = Math.exp(- point.y / r2), + phi = (Math.PI / 2) - 2 * Math.atan(ts), + numIter = 15, + tol = 1e-7, + i = numIter, + dphi = 0.1, + con; while ((Math.abs(dphi) > tol) && (--i > 0)) { con = eccent * Math.sin(phi); - dphi = (Math.PI / 2) - 2 * Math.atan(ts * Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi; + dphi = (Math.PI / 2) - 2 * Math.atan(ts * + Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi; phi += dphi; } @@ -1951,8 +1958,8 @@ L.CRS.EPSG3395 = L.Util.extend({}, L.CRS, { transformation: (function () { var m = L.Projection.Mercator, - r = m.R_MAJOR, - r2 = m.R_MINOR; + r = m.R_MAJOR, + r2 = m.R_MINOR; return new L.Transformation(0.5 / (Math.PI * r), 0.5, -0.5 / (Math.PI * r2), 0.5); }()) @@ -2128,10 +2135,10 @@ L.TileLayer = L.Class.extend({ _setAutoZIndex: function (pane, compare) { var layers = pane.getElementsByClassName('leaflet-layer'), - edgeZIndex = -compare(Infinity, -Infinity), // -Ifinity for max, Infinity for min - zIndex; + edgeZIndex = -compare(Infinity, -Infinity), // -Ifinity for max, Infinity for min + zIndex, i, len; - for (var i = 0, len = layers.length; i < len; i++) { + for (i = 0, len = layers.length; i < len; i++) { if (layers[i] !== this._container) { zIndex = parseInt(layers[i].style.zIndex, 10); @@ -2142,7 +2149,8 @@ L.TileLayer = L.Class.extend({ } } - this.options.zIndex = this._container.style.zIndex = (isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1); + this.options.zIndex = this._container.style.zIndex = + (isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1); }, _updateOpacity: function () { @@ -2150,7 +2158,7 @@ L.TileLayer = L.Class.extend({ // stupid webkit hack to force redrawing of tiles var i, - tiles = this._tiles; + tiles = this._tiles; if (L.Browser.webkit) { for (i in tiles) { @@ -2182,10 +2190,9 @@ L.TileLayer = L.Class.extend({ }, _reset: function (clearOldContainer) { - var key, - tiles = this._tiles; + var tiles = this._tiles; - for (key in tiles) { + for (var key in tiles) { if (tiles.hasOwnProperty(key)) { this.fire('tileunload', {tile: tiles[key]}); } @@ -2209,8 +2216,8 @@ L.TileLayer = L.Class.extend({ if (!this._map) { return; } - var bounds = this._map.getPixelBounds(), - zoom = this._map.getZoom(), + var bounds = this._map.getPixelBounds(), + zoom = this._map.getZoom(), tileSize = this.options.tileSize; if (zoom > this.options.maxZoom || zoom < this.options.minZoom) { @@ -2218,12 +2225,14 @@ L.TileLayer = L.Class.extend({ } var nwTilePoint = new L.Point( - Math.floor(bounds.min.x / tileSize), - Math.floor(bounds.min.y / tileSize)), - seTilePoint = new L.Point( - Math.floor(bounds.max.x / tileSize), - Math.floor(bounds.max.y / tileSize)), - tileBounds = new L.Bounds(nwTilePoint, seTilePoint); + Math.floor(bounds.min.x / tileSize), + Math.floor(bounds.min.y / tileSize)), + + seTilePoint = new L.Point( + Math.floor(bounds.max.x / tileSize), + Math.floor(bounds.max.y / tileSize)), + + tileBounds = new L.Bounds(nwTilePoint, seTilePoint); this._addTilesFromCenterOut(tileBounds); @@ -2234,7 +2243,7 @@ L.TileLayer = L.Class.extend({ _addTilesFromCenterOut: function (bounds) { var queue = [], - center = bounds.getCenter(); + center = bounds.getCenter(); var j, i, point; @@ -2315,11 +2324,13 @@ L.TileLayer = L.Class.extend({ if (this.options.reuseTiles) { L.DomUtil.removeClass(tile, 'leaflet-tile-loaded'); this._unusedTiles.push(tile); + } else if (tile.parentNode === this._container) { this._container.removeChild(tile); } - if (!L.Browser.android) { //For https://github.com/CloudMade/Leaflet/issues/137 + // for https://github.com/CloudMade/Leaflet/issues/137 + if (!L.Browser.android) { tile.src = L.Util.emptyImageUrl; } @@ -2332,11 +2343,14 @@ L.TileLayer = L.Class.extend({ // get unused tile - or create a new tile var tile = this._getTile(); - // Chrome 20 layouts much faster with top/left (Verify with timeline, frames) - // android 4 browser has display issues with top/left and requires transform instead - // android 3 browser not tested - // android 2 browser requires top/left or tiles disappear on load or first drag (reappear after zoom) https://github.com/CloudMade/Leaflet/issues/866 - // (other browsers don't currently care) - see debug/hacks/jitter.html for an example + /* + Chrome 20 layouts much faster with top/left (verify with timeline, frames) + Android 4 browser has display issues with top/left and requires transform instead + Android 3 browser not tested + Android 2 browser requires top/left or tiles disappear on load or first drag + (reappear after zoom) https://github.com/CloudMade/Leaflet/issues/866 + (other browsers don't currently care) - see debug/hacks/jitter.html for an example + */ L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome || L.Browser.android23); this._tiles[tilePoint.x + ':' + tilePoint.y] = tile; @@ -2351,7 +2365,7 @@ L.TileLayer = L.Class.extend({ _getZoomForUrl: function () { var options = this.options, - zoom = this._map.getZoom(); + zoom = this._map.getZoom(); if (options.zoomReverse) { zoom = options.maxZoom - zoom; @@ -2362,7 +2376,7 @@ L.TileLayer = L.Class.extend({ _getTilePos: function (tilePoint) { var origin = this._map.getPixelOrigin(), - tileSize = this.options.tileSize; + tileSize = this.options.tileSize; return tilePoint.multiplyBy(tileSize).subtract(origin); }, @@ -2406,11 +2420,8 @@ L.TileLayer = L.Class.extend({ _createTileProto: function () { var img = this._tileImg = L.DomUtil.create('img', 'leaflet-tile'); + img.style.width = img.style.height = this.options.tileSize + 'px'; img.galleryimg = 'no'; - - var tileSize = this.options.tileSize; - img.style.width = tileSize + 'px'; - img.style.height = tileSize + 'px'; }, _getTile: function () { @@ -2532,18 +2543,18 @@ L.TileLayer.WMS = L.TileLayer.extend({ getTileUrl: function (tilePoint, zoom) { // (Point, Number) -> String var map = this._map, - crs = map.options.crs, - tileSize = this.options.tileSize, + crs = map.options.crs, + tileSize = this.options.tileSize, - nwPoint = tilePoint.multiplyBy(tileSize), - sePoint = nwPoint.add(new L.Point(tileSize, tileSize)), + nwPoint = tilePoint.multiplyBy(tileSize), + sePoint = nwPoint.add(new L.Point(tileSize, tileSize)), - nw = crs.project(map.unproject(nwPoint, zoom)), - se = crs.project(map.unproject(sePoint, zoom)), + nw = crs.project(map.unproject(nwPoint, zoom)), + se = crs.project(map.unproject(sePoint, zoom)), - bbox = [nw.x, se.y, se.x, nw.y].join(','), + bbox = [nw.x, se.y, se.x, nw.y].join(','), - url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)}); + url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)}); return url + L.Util.getParamString(this.wmsParams) + "&bbox=" + bbox; }, @@ -2575,10 +2586,9 @@ L.TileLayer.Canvas = L.TileLayer.extend({ }, redraw: function () { - var i, - tiles = this._tiles; + var tiles = this._tiles; - for (i in tiles) { + for (var i in tiles) { if (tiles.hasOwnProperty(i)) { this._redrawTile(tiles[i]); } @@ -2591,10 +2601,7 @@ L.TileLayer.Canvas = L.TileLayer.extend({ _createTileProto: function () { var proto = this._canvasProto = L.DomUtil.create('canvas', 'leaflet-tile'); - - var tileSize = this.options.tileSize; - proto.width = tileSize; - proto.height = tileSize; + proto.width = proto.height = this.options.tileSize; }, _createTile: function () { @@ -2606,7 +2613,7 @@ L.TileLayer.Canvas = L.TileLayer.extend({ _loadTile: function (tile, tilePoint) { tile._layer = this; tile._tilePoint = tilePoint; - + this._redrawTile(tile); if (!this.options.async) { @@ -2628,6 +2635,7 @@ L.tileLayer.canvas = function (options) { return new L.TileLayer.Canvas(options); }; + L.ImageOverlay = L.Class.extend({ includes: L.Mixin.Events, @@ -2720,7 +2728,7 @@ L.ImageOverlay = L.Class.extend({ _animateZoom: function (e) { var map = this._map, - image = this._image, + image = this._image, scale = map.getZoomScale(e.zoom), nw = this._bounds.getNorthWest(), se = this._bounds.getSouthEast(), @@ -2730,7 +2738,8 @@ L.ImageOverlay = L.Class.extend({ currentSize = map.latLngToLayerPoint(se)._subtract(map.latLngToLayerPoint(nw)), origin = topLeft._add(size._subtract(currentSize)._divideBy(2)); - image.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') '; + image.style[L.DomUtil.TRANSFORM] = + L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') '; }, _reset: function () { @@ -2763,7 +2772,7 @@ L.Icon = L.Class.extend({ /* iconUrl: (String) (required) iconSize: (Point) (can be set through CSS) - iconAnchor: (Point) (centered by default if size is specified, can be set in CSS with negative margins) + iconAnchor: (Point) (centered by default, can be set in CSS with negative margins) popupAnchor: (Point) (if not specified, popup opens in the anchor point) shadowUrl: (Point) (no shadow by default) shadowSize: (Point) @@ -2802,8 +2811,8 @@ L.Icon = L.Class.extend({ _setIconStyles: function (img, name) { var options = this.options, - size = L.point(options[name + 'Size']), - anchor; + size = L.point(options[name + 'Size']), + anchor; if (name === 'shadow') { anchor = L.point(options.shadowAnchor || options.iconAnchor); @@ -2836,7 +2845,8 @@ L.Icon = L.Class.extend({ el.src = src; } else { el = document.createElement('div'); - el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")'; + el.style.filter = + 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '")'; } return el; }, @@ -3041,8 +3051,8 @@ L.Marker = L.Class.extend({ if (this.options.riseOnHover) { L.DomEvent - .off(this._icon, 'mouseover', this._bringToFront) - .off(this._icon, 'mouseout', this._resetZIndex); + .off(this._icon, 'mouseover', this._bringToFront) + .off(this._icon, 'mouseout', this._resetZIndex); } panes.markerPane.removeChild(this._icon); @@ -3082,7 +3092,7 @@ L.Marker = L.Class.extend({ } var icon = this._icon, - events = ['dblclick', 'mousedown', 'mouseover', 'mouseout']; + events = ['dblclick', 'mousedown', 'mouseover', 'mouseout']; L.DomUtil.addClass(icon, 'leaflet-clickable'); L.DomEvent.on(icon, 'click', this._onMouseClick, this); @@ -3101,10 +3111,11 @@ L.Marker = L.Class.extend({ }, _onMouseClick: function (e) { - if (this.hasEventListeners(e.type)) { + var wasDragged = this.dragging && this.dragging.moved(); + if (this.hasEventListeners(e.type) || wasDragged) { L.DomEvent.stopPropagation(e); } - if (this.dragging && this.dragging.moved()) { return; } + if (wasDragged) { return; } if (this._map.dragging && this._map.dragging.moved()) { return; } this.fire(e.type, { originalEvent: e @@ -3170,7 +3181,7 @@ L.DivIcon = L.Icon.extend({ if (options.bgPos) { div.style.backgroundPosition = - (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px'; + (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px'; } this._setIconStyles(div, 'icon'); @@ -3291,25 +3302,28 @@ L.Popup = L.Class.extend({ map._popup = null; map - .removeLayer(this) - .fire('popupclose', {popup: this}); + .removeLayer(this) + .fire('popupclose', {popup: this}); } }, _initLayout: function () { var prefix = 'leaflet-popup', - container = this._container = L.DomUtil.create('div', prefix + ' ' + this.options.className + ' leaflet-zoom-animated'), + containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-animated', + container = this._container = L.DomUtil.create('div', containerClass), closeButton; if (this.options.closeButton) { - closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container); + closeButton = this._closeButton = + L.DomUtil.create('a', prefix + '-close-button', container); closeButton.href = '#close'; closeButton.innerHTML = '×'; L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this); } - var wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container); + var wrapper = this._wrapper = + L.DomUtil.create('div', prefix + '-content-wrapper', container); L.DomEvent.disableClickPropagation(wrapper); this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper); @@ -3349,7 +3363,7 @@ L.Popup = L.Class.extend({ _updateLayout: function () { var container = this._contentNode, - style = container.style; + style = container.style; style.width = ''; style.whiteSpace = 'nowrap'; @@ -3364,8 +3378,8 @@ L.Popup = L.Class.extend({ style.height = ''; var height = container.offsetHeight, - maxHeight = this.options.maxHeight, - scrolledClass = 'leaflet-popup-scrolled'; + maxHeight = this.options.maxHeight, + scrolledClass = 'leaflet-popup-scrolled'; if (maxHeight && height > maxHeight) { style.height = maxHeight + 'px'; @@ -3381,8 +3395,8 @@ L.Popup = L.Class.extend({ if (!this._map) { return; } var pos = this._map.latLngToLayerPoint(this._latlng), - is3d = L.Browser.any3d, - offset = this.options.offset; + is3d = L.Browser.any3d, + offset = this.options.offset; if (is3d) { L.DomUtil.setPosition(this._container, pos); @@ -3406,20 +3420,20 @@ L.Popup = L.Class.extend({ if (!this.options.autoPan) { return; } var map = this._map, - containerHeight = this._container.offsetHeight, - containerWidth = this._containerWidth, + containerHeight = this._container.offsetHeight, + containerWidth = this._containerWidth, - layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom); + layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom); if (L.Browser.any3d) { layerPos._add(L.DomUtil.getPosition(this._container)); } var containerPos = map.layerPointToContainerPoint(layerPos), - padding = this.options.autoPanPadding, - size = map.getSize(), - dx = 0, - dy = 0; + padding = this.options.autoPanPadding, + size = map.getSize(), + dx = 0, + dy = 0; if (containerPos.x < 0) { dx = containerPos.x - padding.x; @@ -3484,9 +3498,9 @@ L.Marker.include({ if (!this._popup) { this - .on('click', this.openPopup, this) - .on('remove', this.closePopup, this) - .on('move', this._movePopup, this); + .on('click', this.openPopup, this) + .on('remove', this.closePopup, this) + .on('move', this._movePopup, this); } this._popup = new L.Popup(options, this) @@ -3499,9 +3513,9 @@ L.Marker.include({ if (this._popup) { this._popup = null; this - .off('click', this.openPopup) - .off('remove', this.closePopup) - .off('move', this._movePopup); + .off('click', this.openPopup) + .off('remove', this.closePopup) + .off('move', this._movePopup); } return this; }, @@ -3520,8 +3534,8 @@ L.Map.include({ this._popup = popup; return this - .addLayer(popup) - .fire('popupopen', {popup: this._popup}); + .addLayer(popup) + .fire('popupopen', {popup: this._popup}); }, closePopup: function () { @@ -3532,6 +3546,7 @@ 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. */ @@ -3580,7 +3595,7 @@ L.LayerGroup = L.Class.extend({ invoke: function (methodName) { var args = Array.prototype.slice.call(arguments, 1), - i, layer; + i, layer; for (i in this._layers) { if (this._layers.hasOwnProperty(i)) { @@ -3631,12 +3646,16 @@ L.layerGroup = function (layers) { L.FeatureGroup = L.LayerGroup.extend({ includes: L.Mixin.Events, + statics: { + EVENTS: 'click dblclick mouseover mouseout mousemove contextmenu' + }, + addLayer: function (layer) { if (this._layers[L.Util.stamp(layer)]) { return this; } - layer.on('click dblclick mouseover mouseout mousemove contextmenu', this._propagateEvent, this); + layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this); L.LayerGroup.prototype.addLayer.call(this, layer); @@ -3644,19 +3663,20 @@ L.FeatureGroup = L.LayerGroup.extend({ layer.bindPopup(this._popupContent); } - return this; + return this.fire('layeradd', {layer: layer}); }, removeLayer: function (layer) { - layer.off('click dblclick mouseover mouseout mousemove contextmenu', this._propagateEvent, this); + layer.off(L.FeatureGroup.EVENTS, this._propagateEvent, this); L.LayerGroup.prototype.removeLayer.call(this, layer); + if (this._popupContent) { - return this.invoke('unbindPopup'); - } else { - return this; + this.invoke('unbindPopup'); } + + return this.fire('layerremove', {layer: layer}); }, bindPopup: function (content) { @@ -3678,9 +3698,11 @@ L.FeatureGroup = L.LayerGroup.extend({ getBounds: function () { var bounds = new L.LatLngBounds(); + this.eachLayer(function (layer) { bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds()); - }, this); + }); + return bounds; }, @@ -3698,7 +3720,7 @@ L.featureGroup = function (layers) { /* - * L.Path is a base class for rendering vector paths on a map. It's inherited by Polyline, Circle, etc. + * L.Path is a base class for rendering vector paths on a map. Inherited by Polyline, Circle, etc. */ L.Path = L.Class.extend({ @@ -3707,11 +3729,10 @@ L.Path = L.Class.extend({ statics: { // how much to extend the clip area around the map view // (relative to its size, e.g. 0.5 is half the screen in each direction) - // set in such way that SVG element doesn't exceed 1280px (vector layers flicker on dragend if it is) + // set it so that SVG element doesn't exceed 1280px (vectors flicker on dragend if it is) CLIP_PADDING: L.Browser.mobile ? Math.max(0, Math.min(0.5, - (1280 / Math.max(window.innerWidth, window.innerHeight) - 1) / 2)) - : 0.5 + (1280 / Math.max(window.innerWidth, window.innerHeight) - 1) / 2)) : 0.5 }, options: { @@ -3803,10 +3824,10 @@ L.Path = L.Class.extend({ L.Map.include({ _updatePathViewport: function () { var p = L.Path.CLIP_PADDING, - size = this.getSize(), - panePos = L.DomUtil.getPosition(this._mapPane), - min = panePos.multiplyBy(-1)._subtract(size.multiplyBy(p)._round()), - max = min.add(size.multiplyBy(1 + p * 2)._round()); + size = this.getSize(), + panePos = L.DomUtil.getPosition(this._mapPane), + min = panePos.multiplyBy(-1)._subtract(size.multiplyBy(p)._round()), + max = min.add(size.multiplyBy(1 + p * 2)._round()); this._pathViewport = new L.Bounds(min, max); } @@ -3824,7 +3845,7 @@ L.Path = L.Path.extend({ bringToFront: function () { var root = this._map._pathRoot, - path = this._container; + path = this._container; if (path && root.lastChild !== path) { root.appendChild(path); @@ -3834,8 +3855,8 @@ L.Path = L.Path.extend({ bringToBack: function () { var root = this._map._pathRoot, - path = this._container, - first = root.firstChild; + path = this._container, + first = root.firstChild; if (path && first !== path) { root.insertBefore(path, first); @@ -3914,7 +3935,8 @@ L.Path = L.Path.extend({ L.DomEvent.on(this._container, 'click', this._onMouseClick, this); - var events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'mousemove', 'contextmenu']; + var events = ['dblclick', 'mousedown', 'mouseover', + 'mouseout', 'mousemove', 'contextmenu']; for (var i = 0; i < events.length; i++) { L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this); } @@ -3922,22 +3944,18 @@ L.Path = L.Path.extend({ }, _onMouseClick: function (e) { - if (this._map.dragging && this._map.dragging.moved()) { - return; - } + if (this._map.dragging && this._map.dragging.moved()) { return; } this._fireMouseEvent(e); }, _fireMouseEvent: function (e) { - if (!this.hasEventListeners(e.type)) { - return; - } + if (!this.hasEventListeners(e.type)) { return; } var map = this._map, - containerPoint = map.mouseEventToContainerPoint(e), - layerPoint = map.containerPointToLayerPoint(containerPoint), - latlng = map.layerPointToLatLng(layerPoint); + containerPoint = map.mouseEventToContainerPoint(e), + layerPoint = map.containerPointToLayerPoint(containerPoint), + latlng = map.layerPointToLatLng(layerPoint); this.fire(e.type, { latlng: latlng, @@ -3949,7 +3967,9 @@ L.Path = L.Path.extend({ if (e.type === 'contextmenu') { L.DomEvent.preventDefault(e); } - L.DomEvent.stopPropagation(e); + if (e.type !== 'mousemove') { + L.DomEvent.stopPropagation(e); + } } }); @@ -3977,11 +3997,11 @@ L.Map.include({ _animatePathZoom: function (opt) { var scale = this.getZoomScale(opt.zoom), - offset = this._getCenterOffset(opt.center), - translate = offset.multiplyBy(-scale)._add(this._pathViewport.min); + offset = this._getCenterOffset(opt.center), + translate = offset.multiplyBy(-scale)._add(this._pathViewport.min); this._pathRoot.style[L.DomUtil.TRANSFORM] = - L.DomUtil.getTranslateString(translate) + ' scale(' + scale + ') '; + L.DomUtil.getTranslateString(translate) + ' scale(' + scale + ') '; this._pathZooming = true; }, @@ -3991,6 +4011,7 @@ L.Map.include({ }, _updateSvgViewport: function () { + if (this._pathZooming) { // Do not update SVGs while a zoom animation is going on otherwise the animation will break. // When the zoom animation ends we will be updated again anyway @@ -4001,12 +4022,12 @@ L.Map.include({ this._updatePathViewport(); var vp = this._pathViewport, - min = vp.min, - max = vp.max, - width = max.x - min.x, - height = max.y - min.y, - root = this._pathRoot, - pane = this._panes.overlayPane; + min = vp.min, + max = vp.max, + width = max.x - min.x, + height = max.y - min.y, + root = this._pathRoot, + pane = this._panes.overlayPane; // Hack to make flicker on drag end on mobile webkit less irritating if (L.Browser.mobileWebkit) { @@ -4041,8 +4062,8 @@ L.Path.include({ if (!this._popupHandlersAdded) { this - .on('click', this._openPopup, this) - .on('remove', this.closePopup, this); + .on('click', this._openPopup, this) + .on('remove', this.closePopup, this); this._popupHandlersAdded = true; } @@ -4054,8 +4075,8 @@ L.Path.include({ if (this._popup) { this._popup = null; this - .off('click', this.openPopup) - .off('remove', this.closePopup); + .off('click', this.openPopup) + .off('remove', this.closePopup); this._popupHandlersAdded = false; } @@ -4067,7 +4088,7 @@ L.Path.include({ if (this._popup) { // open the popup from one of the path's points if not specified latlng = latlng || this._latlng || - this._latlngs[Math.floor(this._latlngs.length / 2)]; + this._latlngs[Math.floor(this._latlngs.length / 2)]; this._openPopup({latlng: latlng}); } @@ -4103,6 +4124,7 @@ L.Browser.vml = !L.Browser.svg && (function () { shape.style.behavior = 'url(#default#VML)'; return shape && (typeof shape.adj === 'object'); + } catch (e) { return false; } @@ -4122,7 +4144,8 @@ L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({ }; } catch (e) { return function (name) { - return document.createElement('<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">'); + return document.createElement( + '<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">'); }; } }()), @@ -4147,9 +4170,9 @@ L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({ _updateStyle: function () { var stroke = this._stroke, - fill = this._fill, - options = this.options, - container = this._container; + fill = this._fill, + options = this.options, + container = this._container; container.stroked = options.stroke; container.filled = options.fill; @@ -4307,7 +4330,7 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : if (this._checkIfEmpty()) { return; } var ctx = this._ctx, - options = this.options; + options = this.options; this._drawPath(); ctx.save(); @@ -4350,7 +4373,7 @@ L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {} : { _initPathRoot: function () { var root = this._pathRoot, - ctx; + ctx; if (!root) { root = this._pathRoot = document.createElement("canvas"); @@ -4373,16 +4396,14 @@ L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {} }, _updateCanvasViewport: function () { - if (this._pathZooming) { - //Don't redraw while zooming. See _updateSvgViewport for more details - return; - } + // don't redraw while zooming. See _updateSvgViewport for more details + if (this._pathZooming) { return; } this._updatePathViewport(); var vp = this._pathViewport, - min = vp.min, - size = vp.max.subtract(min), - root = this._pathRoot; + min = vp.min, + size = vp.max.subtract(min), + root = this._pathRoot; //TODO check if this works properly on mobile webkit L.DomUtil.setPosition(root, min); @@ -4432,15 +4453,15 @@ L.LineUtil = { _simplifyDP: function (points, sqTolerance) { var len = points.length, - ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array, - markers = new ArrayConstructor(len); + ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array, + markers = new ArrayConstructor(len); markers[0] = markers[len - 1] = 1; this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1); var i, - newPoints = []; + newPoints = []; for (i = 0; i < len; i++) { if (markers[i]) { @@ -4454,7 +4475,7 @@ L.LineUtil = { _simplifyDPStep: function (points, markers, sqTolerance, first, last) { var maxSqDist = 0, - index, i, sqDist; + index, i, sqDist; for (i = first + 1; i <= last - 1; i++) { sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true); @@ -4496,10 +4517,12 @@ L.LineUtil = { clipSegment: function (a, b, bounds, useLastCode) { var min = bounds.min, - max = bounds.max; + max = bounds.max, - var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds), - codeB = this._getBitCode(b, bounds); + codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds), + codeB = this._getBitCode(b, bounds), + + codeOut, p, newCode; // save 2nd code to avoid calculating it on the next segment this._lastCode = codeB; @@ -4513,9 +4536,9 @@ L.LineUtil = { return false; // other cases } else { - var codeOut = codeA || codeB, - p = this._getEdgeIntersection(a, b, codeOut, bounds), - newCode = this._getBitCode(p, bounds); + codeOut = codeA || codeB, + p = this._getEdgeIntersection(a, b, codeOut, bounds), + newCode = this._getBitCode(p, bounds); if (codeOut === codeA) { a = p; @@ -4530,9 +4553,9 @@ L.LineUtil = { _getEdgeIntersection: function (a, b, code, bounds) { var dx = b.x - a.x, - dy = b.y - a.y, - min = bounds.min, - max = bounds.max; + dy = b.y - a.y, + min = bounds.min, + max = bounds.max; if (code & 8) { // top return new L.Point(a.x + dx * (max.y - a.y) / dy, max.y); @@ -4567,18 +4590,18 @@ L.LineUtil = { // square distance (to avoid unnecessary Math.sqrt calls) _sqDist: function (p1, p2) { var dx = p2.x - p1.x, - dy = p2.y - p1.y; + dy = p2.y - p1.y; return dx * dx + dy * dy; }, // return closest point on segment or distance to that point _sqClosestPointOnSegment: function (p, p1, p2, sqDist) { var x = p1.x, - y = p1.y, - dx = p2.x - x, - dy = p2.y - y, - dot = dx * dx + dy * dy, - t; + y = p1.y, + dx = p2.x - x, + dy = p2.y - y, + dot = dx * dx + dy * dy, + t; if (dot > 0) { t = ((p.x - x) * dx + (p.y - y) * dy) / dot; @@ -4681,12 +4704,15 @@ L.Polyline = L.Path.extend({ }, getBounds: function () { - var b = new L.LatLngBounds(); - var latLngs = this.getLatLngs(); - for (var i = 0, len = latLngs.length; i < len; i++) { - b.extend(latLngs[i]); + var bounds = new L.LatLngBounds(), + latLngs = this.getLatLngs(), + i, len; + + for (i = 0, len = latLngs.length; i < len; i++) { + bounds.extend(latLngs[i]); } - return b; + + return bounds; }, // TODO refactor: move to Polyline.Edit.js @@ -4736,8 +4762,8 @@ L.Polyline = L.Path.extend({ _clipPoints: function () { var points = this._originalPoints, - len = points.length, - i, k, segment; + len = points.length, + i, k, segment; if (this.options.noClip) { this._parts = [points]; @@ -4747,8 +4773,8 @@ L.Polyline = L.Path.extend({ this._parts = []; var parts = this._parts, - vp = this._map._pathViewport, - lu = L.LineUtil; + vp = this._map._pathViewport, + lu = L.LineUtil; for (i = 0, k = 0; i < len - 1; i++) { segment = lu.clipSegment(points[i], points[i + 1], vp, i); @@ -4770,7 +4796,7 @@ L.Polyline = L.Path.extend({ // simplify each clipped part of the polyline _simplifyPoints: function () { var parts = this._parts, - lu = L.LineUtil; + lu = L.LineUtil; for (var i = 0, len = parts.length; i < len; i++) { parts[i] = lu.simplify(parts[i], this.options.smoothFactor); @@ -4806,13 +4832,13 @@ L.PolyUtil = {}; */ L.PolyUtil.clipPolygon = function (points, bounds) { var min = bounds.min, - max = bounds.max, - clippedPoints, - edges = [1, 4, 2, 8], - i, j, k, - a, b, - len, edge, p, - lu = L.LineUtil; + max = bounds.max, + clippedPoints, + edges = [1, 4, 2, 8], + i, j, k, + a, b, + len, edge, p, + lu = L.LineUtil; for (i = 0, len = points.length; i < len; i++) { points[i]._code = lu._getBitCode(points[i], bounds); @@ -4878,14 +4904,14 @@ L.Polygon = L.Polyline.extend({ // TODO move this logic to Polyline to get rid of duplication this._holePoints = []; - if (!this._holes) { - return; - } + if (!this._holes) { return; } - for (var i = 0, len = this._holes.length, hole; i < len; i++) { + var i, j, len, len2, hole; + + for (i = 0, len = this._holes.length; i < len; i++) { this._holePoints[i] = []; - for (var j = 0, len2 = this._holes[i].length; j < len2; j++) { + for (j = 0, len2 = this._holes[i].length; j < len2; j++) { this._holePoints[i][j] = this._map.latLngToLayerPoint(this._holes[i][j]); } } @@ -4893,20 +4919,17 @@ L.Polygon = L.Polyline.extend({ _clipPoints: function () { var points = this._originalPoints, - newParts = []; + newParts = []; this._parts = [points].concat(this._holePoints); - if (this.options.noClip) { - return; - } + if (this.options.noClip) { return; } for (var i = 0, len = this._parts.length; i < len; i++) { var clipped = L.PolyUtil.clipPolygon(this._parts[i], this._map._pathViewport); - if (!clipped.length) { - continue; + if (clipped.length) { + newParts.push(clipped); } - newParts.push(clipped); } this._parts = newParts; @@ -4929,7 +4952,9 @@ L.polygon = function (latlngs, options) { (function () { function createMulti(Klass) { + return L.FeatureGroup.extend({ + initialize: function (latlngs, options) { this._layers = {}; this._options = options; @@ -4937,7 +4962,8 @@ L.polygon = function (latlngs, options) { }, setLatLngs: function (latlngs) { - var i = 0, len = latlngs.length; + var i = 0, + len = latlngs.length; this.eachLayer(function (layer) { if (i < len) { @@ -4984,13 +5010,13 @@ L.Rectangle = L.Polygon.extend({ _boundsToLatLngs: function (latLngBounds) { latLngBounds = L.latLngBounds(latLngBounds); - return [ - latLngBounds.getSouthWest(), - latLngBounds.getNorthWest(), - latLngBounds.getNorthEast(), - latLngBounds.getSouthEast(), - latLngBounds.getSouthWest() - ]; + return [ + latLngBounds.getSouthWest(), + latLngBounds.getNorthWest(), + latLngBounds.getNorthEast(), + latLngBounds.getSouthEast(), + latLngBounds.getSouthWest() + ]; } }); @@ -5027,8 +5053,8 @@ L.Circle = L.Path.extend({ projectLatlngs: function () { var lngRadius = this._getLngRadius(), - latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngRadius, true), - point2 = this._map.latLngToLayerPoint(latlng2); + latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngRadius, true), + point2 = this._map.latLngToLayerPoint(latlng2); this._point = this._map.latLngToLayerPoint(this._latlng); this._radius = Math.max(Math.round(this._point.x - point2.x), 1); @@ -5036,10 +5062,10 @@ L.Circle = L.Path.extend({ getBounds: function () { var lngRadius = this._getLngRadius(), - latRadius = (this._mRadius / 40075017) * 360, - latlng = this._latlng, - sw = new L.LatLng(latlng.lat - latRadius, latlng.lng - lngRadius), - ne = new L.LatLng(latlng.lat + latRadius, latlng.lng + lngRadius); + latRadius = (this._mRadius / 40075017) * 360, + latlng = this._latlng, + sw = new L.LatLng(latlng.lat - latRadius, latlng.lng - lngRadius), + ne = new L.LatLng(latlng.lat + latRadius, latlng.lng + lngRadius); return new L.LatLngBounds(sw, ne); }, @@ -5050,7 +5076,7 @@ L.Circle = L.Path.extend({ getPathString: function () { var p = this._point, - r = this._radius; + r = this._radius; if (this._checkIfEmpty()) { return ''; @@ -5058,8 +5084,8 @@ L.Circle = L.Path.extend({ if (L.Browser.svg) { return "M" + p.x + "," + (p.y - r) + - "A" + r + "," + r + ",0,1,1," + - (p.x - 0.1) + "," + (p.y - r) + " z"; + "A" + r + "," + r + ",0,1,1," + + (p.x - 0.1) + "," + (p.y - r) + " z"; } else { p._round(); r = Math.round(r); @@ -5086,11 +5112,11 @@ L.Circle = L.Path.extend({ return false; } var vp = this._map._pathViewport, - r = this._radius, - p = this._point; + r = this._radius, + p = this._point; return p.x - r > vp.max.x || p.y - r > vp.max.y || - p.x + r < vp.min.x || p.y + r < vp.min.y; + p.x + r < vp.min.x || p.y + r < vp.min.y; } }); @@ -5133,7 +5159,7 @@ L.circleMarker = function (latlng, options) { L.Polyline.include(!L.Path.CANVAS ? {} : { _containsPoint: function (p, closed) { var i, j, k, len, len2, dist, part, - w = this.options.weight / 2; + w = this.options.weight / 2; if (L.Browser.touch) { w += 10; // polyline click tolerance on touch devices @@ -5162,9 +5188,9 @@ L.Polyline.include(!L.Path.CANVAS ? {} : { L.Polygon.include(!L.Path.CANVAS ? {} : { _containsPoint: function (p) { var inside = false, - part, p1, p2, - i, j, k, - len, len2; + part, p1, p2, + i, j, k, + len, len2; // TODO optimization: check if within bounds first @@ -5207,7 +5233,7 @@ L.Circle.include(!L.Path.CANVAS ? {} : { _containsPoint: function (p) { var center = this._point, - w2 = this.options.stroke ? this.options.weight / 2 : 0; + w2 = this.options.stroke ? this.options.weight / 2 : 0; return (p.distanceTo(center) <= this._radius + w2); } @@ -5337,8 +5363,8 @@ L.Util.extend(L.GeoJSON, { for (i = 0, len = coords.length; i < len; i++) { latlng = levelsDeep ? - this.coordsToLatLngs(coords[i], levelsDeep - 1, reverse) : - this.coordsToLatLng(coords[i], reverse); + this.coordsToLatLngs(coords[i], levelsDeep - 1, reverse) : + this.coordsToLatLng(coords[i], reverse); latlngs.push(latlng); } @@ -5361,8 +5387,8 @@ L.DomEvent = { addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object]) var id = L.Util.stamp(fn), - key = '_leaflet_' + type + id, - handler, originalHandler, newType; + key = '_leaflet_' + type + id, + handler, originalHandler, newType; if (obj[key]) { return this; } @@ -5376,7 +5402,7 @@ L.DomEvent = { return this.addDoubleTapListener(obj, handler, id); } else if ('addEventListener' in obj) { - + if (type === 'mousewheel') { obj.addEventListener('DOMMouseScroll', handler, false); obj.addEventListener(type, handler, false); @@ -5409,8 +5435,8 @@ L.DomEvent = { removeListener: function (obj, type, fn) { // (HTMLElement, String, Function) var id = L.Util.stamp(fn), - key = '_leaflet_' + type + id, - handler = obj[key]; + key = '_leaflet_' + type + id, + handler = obj[key]; if (!handler) { return; } @@ -5452,7 +5478,7 @@ L.DomEvent = { disableClickPropagation: function (el) { var stop = L.DomEvent.stopPropagation; - + return L.DomEvent .addListener(el, L.Draggable.START, stop) .addListener(el, 'click', stop) @@ -5476,10 +5502,10 @@ L.DomEvent = { getMousePosition: function (e, container) { var body = document.body, - docEl = document.documentElement, - x = e.pageX ? e.pageX : e.clientX + body.scrollLeft + docEl.scrollLeft, - y = e.pageY ? e.pageY : e.clientY + body.scrollTop + docEl.scrollTop, - pos = new L.Point(x, y); + docEl = document.documentElement, + x = e.pageX ? e.pageX : e.clientX + body.scrollLeft + docEl.scrollLeft, + y = e.pageY ? e.pageY : e.clientY + body.scrollTop + docEl.scrollTop, + pos = new L.Point(x, y); return (container ? pos._subtract(L.DomUtil.getViewportOffset(container)) : pos); }, @@ -5536,6 +5562,7 @@ L.DomEvent = { L.DomEvent.on = L.DomEvent.addListener; L.DomEvent.off = L.DomEvent.removeListener; + /* * L.Draggable allows you to add dragging capabilities to any element. Supports mobile devices too. */ @@ -5557,17 +5584,15 @@ L.Draggable = L.Class.extend({ }, enable: function () { - if (this._enabled) { - return; - } + if (this._enabled) { return; } + L.DomEvent.on(this._dragStartTarget, L.Draggable.START, this._onDown, this); this._enabled = true; }, disable: function () { - if (!this._enabled) { - return; - } + if (!this._enabled) { return; } + L.DomEvent.off(this._dragStartTarget, L.Draggable.START, this._onDown); this._enabled = false; this._moved = false; @@ -5575,7 +5600,7 @@ L.Draggable = L.Class.extend({ _onDown: function (e) { if ((!L.Browser.touch && e.shiftKey) || - ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; } + ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; } L.DomEvent.preventDefault(e); L.DomEvent.stopPropagation(e); @@ -5591,16 +5616,14 @@ L.Draggable = L.Class.extend({ } var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e), - el = first.target; + el = first.target; if (L.Browser.touch && el.tagName.toLowerCase() === 'a') { L.DomUtil.addClass(el, 'leaflet-active'); } this._moved = false; - if (this._moving) { - return; - } + if (this._moving) { return; } this._startPoint = new L.Point(first.clientX, first.clientY); this._startPos = this._newPos = L.DomUtil.getPosition(this._element); @@ -5626,8 +5649,8 @@ L.Draggable = L.Class.extend({ if (e.touches && e.touches.length > 1) { return; } var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e), - newPoint = new L.Point(first.clientX, first.clientY), - diffVec = newPoint.subtract(this._startPoint); + newPoint = new L.Point(first.clientX, first.clientY), + diffVec = newPoint.subtract(this._startPoint); if (!diffVec.x && !diffVec.y) { return; } @@ -5663,8 +5686,8 @@ L.Draggable = L.Class.extend({ clearTimeout(this._longPressTimeout); if (this._simulateClick && e.changedTouches) { var first = e.changedTouches[0], - el = first.target, - dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0; + el = first.target, + dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0; if (el.tagName.toLowerCase() === 'a') { L.DomUtil.removeClass(el, 'leaflet-active'); @@ -5709,10 +5732,10 @@ L.Draggable = L.Class.extend({ var simulatedEvent = document.createEvent('MouseEvents'); simulatedEvent.initMouseEvent( - type, true, true, window, 1, - e.screenX, e.screenY, - e.clientX, e.clientY, - false, false, false, false, 0, null); + type, true, true, window, 1, + e.screenX, e.screenY, + e.clientX, e.clientY, + false, false, false, false, 0, null); e.target.dispatchEvent(simulatedEvent); } @@ -5769,9 +5792,9 @@ L.Map.mergeOptions({ L.Map.Drag = L.Handler.extend({ addHooks: function () { if (!this._draggable) { - var options = this._map.options; + var map = this._map; - this._draggable = new L.Draggable(this._map._mapPane, this._map._container, options.longPress); + this._draggable = new L.Draggable(map._mapPane, map._container, map.options.longPress); this._draggable.on({ 'dragstart': this._onDragStart, @@ -5779,9 +5802,9 @@ L.Map.Drag = L.Handler.extend({ 'dragend': this._onDragEnd }, this); - if (options.worldCopyJump) { + if (map.options.worldCopyJump) { this._draggable.on('predrag', this._onPreDrag, this); - this._map.on('viewreset', this._onViewReset, this); + map.on('viewreset', this._onViewReset, this); } } this._draggable.enable(); @@ -5803,8 +5826,8 @@ L.Map.Drag = L.Handler.extend({ } map - .fire('movestart') - .fire('dragstart'); + .fire('movestart') + .fire('dragstart'); if (map.options.inertia) { this._positions = []; @@ -5827,13 +5850,13 @@ L.Map.Drag = L.Handler.extend({ } this._map - .fire('move') - .fire('drag'); + .fire('move') + .fire('drag'); }, _onViewReset: function () { var pxCenter = this._map.getSize()._divideBy(2), - pxWorldCenter = this._map.latLngToLayerPoint(new L.LatLng(0, 0)); + pxWorldCenter = this._map.latLngToLayerPoint(new L.LatLng(0, 0)); this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x; this._worldWidth = this._map.project(new L.LatLng(0, 180)).x; @@ -5842,25 +5865,25 @@ L.Map.Drag = L.Handler.extend({ _onPreDrag: function () { // TODO refactor to be able to adjust map pane position after zoom var map = this._map, - worldWidth = this._worldWidth, - halfWidth = Math.round(worldWidth / 2), - dx = this._initialWorldOffset, - x = this._draggable._newPos.x, - newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx, - newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx, - newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2; + worldWidth = this._worldWidth, + halfWidth = Math.round(worldWidth / 2), + dx = this._initialWorldOffset, + x = this._draggable._newPos.x, + newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx, + newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx, + newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2; this._draggable._newPos.x = newX; }, _onDragEnd: function () { var map = this._map, - options = map.options, - delay = +new Date() - this._lastTime, + options = map.options, + delay = +new Date() - this._lastTime, - noInertia = !options.inertia || - delay > options.inertiaThreshold || - this._positions[0] === undefined; + noInertia = !options.inertia || + delay > options.inertiaThreshold || + !this._positions[0]; if (noInertia) { map.fire('moveend'); @@ -5868,20 +5891,20 @@ L.Map.Drag = L.Handler.extend({ } else { var direction = this._lastPos.subtract(this._positions[0]), - duration = (this._lastTime + delay - this._times[0]) / 1000, + duration = (this._lastTime + delay - this._times[0]) / 1000, - speedVector = direction.multiplyBy(0.58 / duration), - speed = speedVector.distanceTo(new L.Point(0, 0)), + speedVector = direction.multiplyBy(0.58 / duration), + speed = speedVector.distanceTo(new L.Point(0, 0)), - limitedSpeed = Math.min(options.inertiaMaxSpeed, speed), - limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed), + limitedSpeed = Math.min(options.inertiaMaxSpeed, speed), + limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed), - decelerationDuration = limitedSpeed / options.inertiaDeceleration, - offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round(); + decelerationDuration = limitedSpeed / options.inertiaDeceleration, + offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round(); - L.Util.requestAnimFrame(L.Util.bind(function () { - this._map.panBy(offset, decelerationDuration); - }, this)); + L.Util.requestAnimFrame(function () { + map.panBy(offset, decelerationDuration); + }); } map.fire('dragend'); @@ -5925,7 +5948,7 @@ L.Map.DoubleClickZoom = L.Handler.extend({ L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom); /* - * L.Handler.ScrollWheelZoom is used internally by L.Map to enable mouse scroll wheel zooming on the map. + * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map. */ L.Map.mergeOptions({ @@ -5963,8 +5986,8 @@ L.Map.ScrollWheelZoom = L.Handler.extend({ _performZoom: function () { var map = this._map, - delta = Math.round(this._delta), - zoom = map.getZoom(); + delta = Math.round(this._delta), + zoom = map.getZoom(); delta = Math.max(Math.min(delta, 4), -4); delta = map._limitZoom(zoom + delta) - zoom; @@ -5976,17 +5999,17 @@ L.Map.ScrollWheelZoom = L.Handler.extend({ if (!delta) { return; } var newZoom = zoom + delta, - newCenter = this._getCenterForScrollWheelZoom(newZoom); + newCenter = this._getCenterForScrollWheelZoom(newZoom); map.setView(newCenter, newZoom); }, _getCenterForScrollWheelZoom: function (newZoom) { var map = this._map, - scale = map.getZoomScale(newZoom), - viewHalf = map.getSize()._divideBy(2), - centerOffset = this._lastMousePos._subtract(viewHalf)._multiplyBy(1 - 1 / scale), - newCenterPoint = map._getTopLeftPoint()._add(viewHalf)._add(centerOffset); + scale = map.getZoomScale(newZoom), + viewHalf = map.getSize()._divideBy(2), + centerOffset = this._lastMousePos._subtract(viewHalf)._multiplyBy(1 - 1 / scale), + newCenterPoint = map._getTopLeftPoint()._add(viewHalf)._add(centerOffset); return map.unproject(newCenterPoint); } @@ -6003,13 +6026,13 @@ L.Util.extend(L.DomEvent, { // inspired by Zepto touch code by Thomas Fuchs addDoubleTapListener: function (obj, handler, id) { var last, - doubleTap = false, - delay = 250, - touch, - pre = '_leaflet_', - touchstart = this._touchstart, - touchend = this._touchend, - trackedTouches = []; + doubleTap = false, + delay = 250, + touch, + pre = '_leaflet_', + touchstart = this._touchstart, + touchend = this._touchend, + trackedTouches = []; function onTouchStart(e) { var count; @@ -6112,7 +6135,7 @@ L.Util.extend(L.DomEvent, { addMsTouchListenerStart: function (obj, type, handler, id) { var pre = '_leaflet_', - touches = this._msTouches; + touches = this._msTouches; var cb = function (e) { @@ -6136,8 +6159,8 @@ L.Util.extend(L.DomEvent, { obj[pre + 'touchstart' + id] = cb; obj.addEventListener('MSPointerDown', cb, false); - //Need to also listen for end events to keep the _msTouches list accurate - //this needs to be on the body and never go away + // need to also listen for end events to keep the _msTouches list accurate + // this needs to be on the body and never go away if (!this._msDocumentListener) { var internalCb = function (e) { for (var i = 0; i < touches.length; i++) { @@ -6158,15 +6181,13 @@ L.Util.extend(L.DomEvent, { }, addMsTouchListenerMove: function (obj, type, handler, id) { - var pre = '_leaflet_'; + var pre = '_leaflet_', + touches = this._msTouches; - var touches = this._msTouches; - var cb = function (e) { + function cb(e) { - //Don't fire touch moves when mouse isn't down - if (e.pointerType === e.MSPOINTER_TYPE_MOUSE && e.buttons === 0) { - return; - } + // don't fire touch moves when mouse isn't down + if (e.pointerType === e.MSPOINTER_TYPE_MOUSE && e.buttons === 0) { return; } for (var i = 0; i < touches.length; i++) { if (touches[i].pointerId === e.pointerId) { @@ -6179,7 +6200,7 @@ L.Util.extend(L.DomEvent, { e.changedTouches = [e]; handler(e); - }; + } obj[pre + 'touchmove' + id] = cb; obj.addEventListener('MSPointerMove', cb, false); @@ -6189,7 +6210,7 @@ L.Util.extend(L.DomEvent, { addMsTouchListenerEnd: function (obj, type, handler, id) { var pre = '_leaflet_', - touches = this._msTouches; + touches = this._msTouches; var cb = function (e) { for (var i = 0; i < touches.length; i++) { @@ -6235,7 +6256,7 @@ L.Util.extend(L.DomEvent, { /* - * L.Handler.TouchZoom is used internally by L.Map to add touch-zooming on Webkit-powered mobile browsers. + * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers. */ L.Map.mergeOptions({ @@ -6257,8 +6278,8 @@ L.Map.TouchZoom = L.Handler.extend({ if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; } var p1 = map.mouseEventToLayerPoint(e.touches[0]), - p2 = map.mouseEventToLayerPoint(e.touches[1]), - viewCenter = map._getCenterLayerPoint(); + p2 = map.mouseEventToLayerPoint(e.touches[1]), + viewCenter = map._getCenterLayerPoint(); this._startCenter = p1.add(p2)._divideBy(2); this._startDist = p1.distanceTo(p2); @@ -6273,8 +6294,8 @@ L.Map.TouchZoom = L.Handler.extend({ } L.DomEvent - .on(document, 'touchmove', this._onTouchMove, this) - .on(document, 'touchend', this._onTouchEnd, this); + .on(document, 'touchmove', this._onTouchMove, this) + .on(document, 'touchend', this._onTouchEnd, this); L.DomEvent.preventDefault(e); }, @@ -6285,7 +6306,7 @@ L.Map.TouchZoom = L.Handler.extend({ var map = this._map; var p1 = map.mouseEventToLayerPoint(e.touches[0]), - p2 = map.mouseEventToLayerPoint(e.touches[1]); + p2 = map.mouseEventToLayerPoint(e.touches[1]); this._scale = p1.distanceTo(p2) / this._startDist; this._delta = p1._add(p2)._divideBy(2)._subtract(this._startCenter); @@ -6296,23 +6317,24 @@ L.Map.TouchZoom = L.Handler.extend({ L.DomUtil.addClass(map._mapPane, 'leaflet-zoom-anim leaflet-touching'); map - .fire('movestart') - .fire('zoomstart') - ._prepareTileBg(); + .fire('movestart') + .fire('zoomstart') + ._prepareTileBg(); this._moved = true; } L.Util.cancelAnimFrame(this._animRequest); - this._animRequest = L.Util.requestAnimFrame(this._updateOnMove, this, true, this._map._container); + this._animRequest = L.Util.requestAnimFrame( + this._updateOnMove, this, true, this._map._container); L.DomEvent.preventDefault(e); }, _updateOnMove: function () { var map = this._map, - origin = this._getScaleOrigin(), - center = map.layerPointToLatLng(origin); + origin = this._getScaleOrigin(), + center = map.layerPointToLatLng(origin); map.fire('zoomanim', { center: center, @@ -6323,8 +6345,8 @@ L.Map.TouchZoom = L.Handler.extend({ // it didn't count the origin on the first touch-zoom but worked correctly afterwards map._tileBg.style[L.DomUtil.TRANSFORM] = - L.DomUtil.getTranslateString(this._delta) + ' ' + - L.DomUtil.getScaleString(this._scale, this._startCenter); + L.DomUtil.getTranslateString(this._delta) + ' ' + + L.DomUtil.getScaleString(this._scale, this._startCenter); }, _onTouchEnd: function (e) { @@ -6336,16 +6358,18 @@ L.Map.TouchZoom = L.Handler.extend({ L.DomUtil.removeClass(map._mapPane, 'leaflet-touching'); L.DomEvent - .off(document, 'touchmove', this._onTouchMove) - .off(document, 'touchend', this._onTouchEnd); + .off(document, 'touchmove', this._onTouchMove) + .off(document, 'touchend', this._onTouchEnd); var origin = this._getScaleOrigin(), - center = map.layerPointToLatLng(origin), + center = map.layerPointToLatLng(origin), - oldZoom = map.getZoom(), - floatZoomDelta = map.getScaleZoom(this._scale) - oldZoom, - roundZoomDelta = (floatZoomDelta > 0 ? Math.ceil(floatZoomDelta) : Math.floor(floatZoomDelta)), - zoom = map._limitZoom(oldZoom + roundZoomDelta); + oldZoom = map.getZoom(), + floatZoomDelta = map.getScaleZoom(this._scale) - oldZoom, + roundZoomDelta = (floatZoomDelta > 0 ? + Math.ceil(floatZoomDelta) : Math.floor(floatZoomDelta)), + + zoom = map._limitZoom(oldZoom + roundZoomDelta); map.fire('zoomanim', { center: center, @@ -6401,23 +6425,23 @@ L.Map.BoxZoom = L.Handler.extend({ this._container.style.cursor = 'crosshair'; L.DomEvent - .on(document, 'mousemove', this._onMouseMove, this) - .on(document, 'mouseup', this._onMouseUp, this) - .preventDefault(e); - + .on(document, 'mousemove', this._onMouseMove, this) + .on(document, 'mouseup', this._onMouseUp, this) + .preventDefault(e); + this._map.fire("boxzoomstart"); }, _onMouseMove: function (e) { var startPoint = this._startLayerPoint, - box = this._box, + box = this._box, - layerPoint = this._map.mouseEventToLayerPoint(e), - offset = layerPoint.subtract(startPoint), + layerPoint = this._map.mouseEventToLayerPoint(e), + offset = layerPoint.subtract(startPoint), - newPos = new L.Point( - Math.min(layerPoint.x, startPoint.x), - Math.min(layerPoint.y, startPoint.y)); + newPos = new L.Point( + Math.min(layerPoint.x, startPoint.x), + Math.min(layerPoint.y, startPoint.y)); L.DomUtil.setPosition(box, newPos); @@ -6433,18 +6457,18 @@ L.Map.BoxZoom = L.Handler.extend({ L.DomUtil.enableTextSelection(); L.DomEvent - .off(document, 'mousemove', this._onMouseMove) - .off(document, 'mouseup', this._onMouseUp); + .off(document, 'mousemove', this._onMouseMove) + .off(document, 'mouseup', this._onMouseUp); var map = this._map, - layerPoint = map.mouseEventToLayerPoint(e); + layerPoint = map.mouseEventToLayerPoint(e), - var bounds = new L.LatLngBounds( - map.layerPointToLatLng(this._startLayerPoint), - map.layerPointToLatLng(layerPoint)); + bounds = new L.LatLngBounds( + map.layerPointToLatLng(this._startLayerPoint), + map.layerPointToLatLng(layerPoint)); map.fitBounds(bounds); - + map.fire("boxzoomend", { boxZoomBounds: bounds }); @@ -6488,27 +6512,28 @@ L.Map.Keyboard = L.Handler.extend({ } L.DomEvent - .addListener(container, 'focus', this._onFocus, this) - .addListener(container, 'blur', this._onBlur, this) - .addListener(container, 'mousedown', this._onMouseDown, this); + .addListener(container, 'focus', this._onFocus, this) + .addListener(container, 'blur', this._onBlur, this) + .addListener(container, 'mousedown', this._onMouseDown, this); this._map - .on('focus', this._addHooks, this) - .on('blur', this._removeHooks, this); + .on('focus', this._addHooks, this) + .on('blur', this._removeHooks, this); }, removeHooks: function () { this._removeHooks(); var container = this._map._container; + L.DomEvent - .removeListener(container, 'focus', this._onFocus, this) - .removeListener(container, 'blur', this._onBlur, this) - .removeListener(container, 'mousedown', this._onMouseDown, this); + .removeListener(container, 'focus', this._onFocus, this) + .removeListener(container, 'blur', this._onBlur, this) + .removeListener(container, 'mousedown', this._onMouseDown, this); this._map - .off('focus', this._addHooks, this) - .off('blur', this._removeHooks, this); + .off('focus', this._addHooks, this) + .off('blur', this._removeHooks, this); }, _onMouseDown: function () { @@ -6548,7 +6573,7 @@ L.Map.Keyboard = L.Handler.extend({ _setZoomOffset: function (zoom) { var keys = this._zoomKeys = {}, - codes = this.keyCodes, + codes = this.keyCodes, i, len; for (i = 0, len = codes.zoomIn.length; i < len; i++) { @@ -6600,9 +6625,9 @@ L.Handler.MarkerDrag = L.Handler.extend({ var icon = this._marker._icon; if (!this._draggable) { this._draggable = new L.Draggable(icon, icon) - .on('dragstart', this._onDragStart, this) - .on('drag', this._onDrag, this) - .on('dragend', this._onDragEnd, this); + .on('dragstart', this._onDragStart, this) + .on('drag', this._onDrag, this) + .on('dragend', this._onDragEnd, this); } this._draggable.enable(); }, @@ -6617,16 +6642,16 @@ L.Handler.MarkerDrag = L.Handler.extend({ _onDragStart: function (e) { this._marker - .closePopup() - .fire('movestart') - .fire('dragstart'); + .closePopup() + .fire('movestart') + .fire('dragstart'); }, _onDrag: function (e) { var marker = this._marker, - shadow = marker._shadow, - iconPos = L.DomUtil.getPosition(marker._icon), - latlng = marker._map.layerPointToLatLng(iconPos); + shadow = marker._shadow, + iconPos = L.DomUtil.getPosition(marker._icon), + latlng = marker._map.layerPointToLatLng(iconPos); // update shadow position if (shadow) { @@ -6636,14 +6661,14 @@ L.Handler.MarkerDrag = L.Handler.extend({ marker._latlng = latlng; marker - .fire('move', { latlng: latlng }) - .fire('drag'); + .fire('move', {latlng: latlng}) + .fire('drag'); }, _onDragEnd: function () { this._marker - .fire('moveend') - .fire('dragend'); + .fire('moveend') + .fire('dragend'); } }); @@ -6753,36 +6778,40 @@ 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; - } + // we want to remove the marker on click, but if latlng count < 3, polyline would be invalid + 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); - } else if (!marker._prev) { - marker._next._middleLeft = null; - } else if (!marker._next) { - marker._prev._middleRight = null; - } + // remove the marker + this._markerGroup.removeLayer(marker); + this._markers.splice(i, 1); + this._poly.spliceLatLngs(i, 1); + this._updateIndexes(i, -1); + + // update prev/next links of adjacent markers this._updatePrevNext(marker._prev, marker._next); - // 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 + // remove ghost markers near the removed marker if (marker._middleLeft) { this._markerGroup.removeLayer(marker._middleLeft); } if (marker._middleRight) { this._markerGroup.removeLayer(marker._middleRight); } - this._markers.splice(i, 1); - this._poly.spliceLatLngs(i, 1); - this._updateIndexes(i, -1); + + // create a ghost marker in place of the removed one + if (marker._prev && marker._next) { + this._createMiddleMarker(marker._prev, marker._next); + + } else if (!marker._prev) { + marker._next._middleLeft = null; + + } else if (!marker._next) { + marker._prev._middleRight = null; + } + this._poly.fire('edit'); }, @@ -6796,10 +6825,10 @@ L.Handler.PolyEdit = L.Handler.extend({ _createMiddleMarker: function (marker1, marker2) { var latlng = this._getMiddleLatLng(marker1, marker2), - marker = this._createMarker(latlng), - onClick, - onDragStart, - onDragEnd; + marker = this._createMarker(latlng), + onClick, + onDragStart, + onDragEnd; marker.setOpacity(0.6); @@ -6811,8 +6840,8 @@ L.Handler.PolyEdit = L.Handler.extend({ marker._index = i; marker - .off('click', onClick) - .on('click', this._onMarkerClick, this); + .off('click', onClick) + .on('click', this._onMarkerClick, this); latlng.lat = marker.getLatLng().lat; latlng.lng = marker.getLatLng().lng; @@ -6842,9 +6871,9 @@ L.Handler.PolyEdit = L.Handler.extend({ }; marker - .on('click', onClick, this) - .on('dragstart', onDragStart, this) - .on('dragend', onDragEnd, this); + .on('click', onClick, this) + .on('dragstart', onDragStart, this) + .on('dragend', onDragEnd, this); this._markerGroup.addLayer(marker); }, @@ -6903,7 +6932,7 @@ L.Control = L.Class.extend({ var container = this._container = this.onAdd(map), pos = this.getPosition(), - corner = map._controlCorners[pos]; + corner = map._controlCorners[pos]; L.DomUtil.addClass(container, 'leaflet-control'); @@ -6918,7 +6947,7 @@ L.Control = L.Class.extend({ removeFrom: function (map) { var pos = this.getPosition(), - corner = map._controlCorners[pos]; + corner = map._controlCorners[pos]; corner.removeChild(this._container); this._map = null; @@ -6951,13 +6980,12 @@ L.Map.include({ var corners = this._controlCorners = {}, l = 'leaflet-', container = this._controlContainer = - L.DomUtil.create('div', l + 'control-container', this._container); + L.DomUtil.create('div', l + 'control-container', this._container); function createCorner(vSide, hSide) { var className = l + vSide + ' ' + l + hSide; - corners[vSide + hSide] = - L.DomUtil.create('div', className, container); + corners[vSide + hSide] = L.DomUtil.create('div', className, container); } createCorner('top', 'left'); @@ -6999,11 +7027,11 @@ L.Control.Zoom = L.Control.extend({ link.title = title; L.DomEvent - .on(link, 'click', L.DomEvent.stopPropagation) - .on(link, 'mousedown', L.DomEvent.stopPropagation) - .on(link, 'dblclick', L.DomEvent.stopPropagation) - .on(link, 'click', L.DomEvent.preventDefault) - .on(link, 'click', fn, context); + .on(link, 'click', L.DomEvent.stopPropagation) + .on(link, 'mousedown', L.DomEvent.stopPropagation) + .on(link, 'dblclick', L.DomEvent.stopPropagation) + .on(link, 'click', L.DomEvent.preventDefault) + .on(link, 'click', fn, context); return link; } @@ -7043,8 +7071,8 @@ L.Control.Attribution = L.Control.extend({ L.DomEvent.disableClickPropagation(this._container); map - .on('layeradd', this._onLayerAdd, this) - .on('layerremove', this._onLayerRemove, this); + .on('layeradd', this._onLayerAdd, this) + .on('layerremove', this._onLayerRemove, this); this._update(); @@ -7053,8 +7081,8 @@ L.Control.Attribution = L.Control.extend({ onRemove: function (map) { map - .off('layeradd', this._onLayerAdd) - .off('layerremove', this._onLayerRemove); + .off('layeradd', this._onLayerAdd) + .off('layerremove', this._onLayerRemove); }, @@ -7210,8 +7238,8 @@ L.Control.Scale = L.Control.extend({ _updateImperial: function (maxMeters) { var maxFeet = maxMeters * 3.2808399, - scale = this._iScale, - maxMiles, miles, feet; + scale = this._iScale, + maxMiles, miles, feet; if (maxFeet > 5280) { maxMiles = maxFeet / 5280; @@ -7313,8 +7341,8 @@ L.Control.Layers = L.Control.extend({ if (this.options.collapsed) { L.DomEvent - .on(container, 'mouseover', this._expand, this) - .on(container, 'mouseout', this._collapse, this); + .on(container, 'mouseover', this._expand, this) + .on(container, 'mouseout', this._collapse, this); var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container); link.href = '#'; @@ -7322,9 +7350,9 @@ L.Control.Layers = L.Control.extend({ if (L.Browser.touch) { L.DomEvent - .on(link, 'click', L.DomEvent.stopPropagation) - .on(link, 'click', L.DomEvent.preventDefault) - .on(link, 'click', this._expand, this); + .on(link, 'click', L.DomEvent.stopPropagation) + .on(link, 'click', L.DomEvent.preventDefault) + .on(link, 'click', this._expand, this); } else { L.DomEvent.on(link, 'focus', this._expand, this); @@ -7367,7 +7395,7 @@ L.Control.Layers = L.Control.extend({ this._overlaysList.innerHTML = ''; var baseLayersPresent = false, - overlaysPresent = false; + overlaysPresent = false; for (var i in this._layers) { if (this._layers.hasOwnProperty(i)) { @@ -7426,9 +7454,9 @@ L.Control.Layers = L.Control.extend({ _onInputClick: function () { var i, input, obj, - inputs = this._form.getElementsByTagName('input'), - inputsLen = inputs.length, - baseLayer; + inputs = this._form.getElementsByTagName('input'), + inputsLen = inputs.length, + baseLayer; for (i = 0; i < inputsLen; i++) { input = inputs[i]; @@ -7507,8 +7535,8 @@ L.PosAnimation = L.Class.extend({ _getPos: function () { var left, top, matches, - el = this._el, - style = window.getComputedStyle(el); + el = this._el, + style = window.getComputedStyle(el); if (L.Browser.any3d) { matches = style[L.DomUtil.TRANSFORM].match(this._transformRe); @@ -7553,8 +7581,8 @@ L.Map.include({ } var done = (zoomChanged ? - this._zoomToIfClose && this._zoomToIfClose(center, zoom) : - this._panByIfClose(center)); + this._zoomToIfClose && this._zoomToIfClose(center, zoom) : + this._panByIfClose(center)); // exit if animated pan or zoom started if (done) { @@ -7617,10 +7645,10 @@ L.Map.include({ _offsetIsWithinView: function (offset, multiplyFactor) { var m = multiplyFactor || 1, - size = this.getSize(); + size = this.getSize(); return (Math.abs(offset.x) <= size.x * m) && - (Math.abs(offset.y) <= size.y * m); + (Math.abs(offset.y) <= size.y * m); } }); @@ -7664,7 +7692,7 @@ L.PosAnimation = L.DomUtil.TRANSITION ? L.PosAnimation : L.PosAnimation.extend({ _step: function () { var elapsed = (+new Date()) - this._startTime, - duration = this._duration * 1000; + duration = this._duration * 1000; if (elapsed < duration) { this._runFrame(this._ease(elapsed / duration)); @@ -7716,7 +7744,7 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { if (!this.options.zoomAnimation) { return false; } var scale = this.getZoomScale(zoom), - offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale); + offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale); // if offset does not exceed half of the view if (!this._offsetIsWithinView(offset, 1)) { return false; } @@ -7724,8 +7752,8 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim'); this - .fire('movestart') - .fire('zoomstart'); + .fire('movestart') + .fire('zoomstart'); this.fire('zoomanim', { center: center, @@ -7756,28 +7784,27 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { } var transform = L.DomUtil.TRANSFORM, - tileBg = this._tileBg; + tileBg = this._tileBg; clearTimeout(this._clearTileBgTimer); L.Util.falseFn(tileBg.offsetWidth); //hack to make sure transform is updated before running animation var scaleStr = L.DomUtil.getScaleString(scale, origin), - oldTransform = tileBg.style[transform]; + oldTransform = tileBg.style[transform]; tileBg.style[transform] = backwardsTransform ? - oldTransform + ' ' + scaleStr : - scaleStr + ' ' + oldTransform; + oldTransform + ' ' + scaleStr : + scaleStr + ' ' + oldTransform; }, _prepareTileBg: function () { var tilePane = this._tilePane, - tileBg = this._tileBg; + tileBg = this._tileBg; // If foreground layer doesn't have many tiles but bg layer does, keep the existing bg layer and just zoom it some more - if (tileBg && - this._getLoadedTilesPercentage(tileBg) > 0.5 && - this._getLoadedTilesPercentage(tilePane) < 0.5) { + if (tileBg && this._getLoadedTilesPercentage(tileBg) > 0.5 && + this._getLoadedTilesPercentage(tilePane) < 0.5) { tilePane.style.visibility = 'hidden'; tilePane.empty = true; @@ -7809,7 +7836,7 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { _getLoadedTilesPercentage: function (container) { var tiles = container.getElementsByTagName('img'), - i, len, count = 0; + i, len, count = 0; for (i = 0, len = tiles.length; i < len; i++) { if (tiles[i].complete) { @@ -7822,7 +7849,7 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { // stops loading all tiles in the background layer _stopLoadingImages: function (container) { var tiles = Array.prototype.slice.call(container.getElementsByTagName('img')), - i, len, tile; + i, len, tile; for (i = 0, len = tiles.length; i < len; i++) { tile = tiles[i]; @@ -7895,7 +7922,8 @@ L.Map.include({ onError = L.Util.bind(this._handleGeolocationError, this); if (options.watch) { - this._locationWatchId = navigator.geolocation.watchPosition(onResponse, onError, options); + this._locationWatchId = + navigator.geolocation.watchPosition(onResponse, onError, options); } else { navigator.geolocation.getCurrentPosition(onResponse, onError, options); } @@ -7911,9 +7939,9 @@ L.Map.include({ _handleGeolocationError: function (error) { var c = error.code, - message = error.message || - (c === 1 ? "permission denied" : - (c === 2 ? "position unavailable" : "timeout")); + message = error.message || + (c === 1 ? "permission denied" : + (c === 2 ? "position unavailable" : "timeout")); if (this._locationOptions.setView && !this._loaded) { this.fitWorld(); @@ -7927,17 +7955,17 @@ L.Map.include({ _handleGeolocationResponse: function (pos) { var latAccuracy = 180 * pos.coords.accuracy / 4e7, - lngAccuracy = latAccuracy * 2, + lngAccuracy = latAccuracy * 2, - lat = pos.coords.latitude, - lng = pos.coords.longitude, - latlng = new L.LatLng(lat, lng), + lat = pos.coords.latitude, + lng = pos.coords.longitude, + latlng = new L.LatLng(lat, lng), - sw = new L.LatLng(lat - latAccuracy, lng - lngAccuracy), - ne = new L.LatLng(lat + latAccuracy, lng + lngAccuracy), - bounds = new L.LatLngBounds(sw, ne), + sw = new L.LatLng(lat - latAccuracy, lng - lngAccuracy), + ne = new L.LatLng(lat + latAccuracy, lng + lngAccuracy), + bounds = new L.LatLngBounds(sw, ne), - options = this._locationOptions; + options = this._locationOptions; if (options.setView) { var zoom = Math.min(this.getBoundsZoom(bounds), options.maxZoom); diff --git a/dist/leaflet.js b/dist/leaflet.js index 60fe2d5d..73a1eaac 100644 --- a/dist/leaflet.js +++ b/dist/leaflet.js @@ -3,4 +3,4 @@ Leaflet is an open-source JavaScript library for mobile-friendly interactive maps. http://leafletjs.com */ -(function(e,t){var n,r;typeof exports!=t+""?n=exports:(r=e.L,n={},n.noConflict=function(){return e.L=r,this},e.L=n),n.version="0.4.4",n.Util={extend:function(e){var t=Array.prototype.slice.call(arguments,1);for(var n=0,r=t.length,i;n2?Array.prototype.slice.call(arguments,2):null;return function(){return e.apply(t,n||arguments)}},stamp:function(){var e=0,t="_leaflet_id";return function(n){return n[t]=n[t]||++e,n[t]}}(),limitExecByInterval:function(e,t,n){var r,i;return function s(){var o=arguments;if(r){i=!0;return}r=!0,setTimeout(function(){r=!1,i&&(s.apply(n,o),i=!1)},t),e.apply(n,o)}},falseFn:function(){return!1},formatNum:function(e,t){var n=Math.pow(10,t||5);return Math.round(e*n)/n},splitWords:function(e){return e.replace(/^\s+|\s+$/g,"").split(/\s+/)},setOptions:function(e,t){return e.options=n.Util.extend({},e.options,t),e.options},getParamString:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n+"="+e[n]);return"?"+t.join("&")},template:function(e,t){return e.replace(/\{ *([\w_]+) *\}/g,function(e,n){var r=t[n];if(!t.hasOwnProperty(n))throw Error("No value provided for variable "+e);return r})},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},function(){function t(t){var n,r,i=["webkit","moz","o","ms"];for(n=0;n0},removeEventListener:function(e,t,r){var s=this[i],o,u,a,f,l;if(typeof e=="object"){for(o in e)e.hasOwnProperty(o)&&this.removeEventListener(o,e[o],t);return this}e=n.Util.splitWords(e);for(u=0,a=e.length;u=0;l--)(!t||f[l].action===t)&&(!r||f[l].context===r)&&f.splice(l,1)}return this},fireEvent:function(e,t){if(!this.hasEventListeners(e))return this;var r=n.Util.extend({type:e,target:this},t),s=this[i][e].slice();for(var o=0,u=s.length;o1||"matchMedia"in e&&e.matchMedia("(min-resolution:144dpi)").matches,d=document.documentElement,v=r&&"transition"in d.style,m="WebKitCSSMatrix"in e&&"m11"in new e.WebKitCSSMatrix,g="MozPerspective"in d.style,y="OTransition"in d.style,b=!e.L_DISABLE_3D&&(v||m||g||y),w=!e.L_NO_TOUCH&&function(){var e="ontouchstart";if(h||e in d)return!0;var t=document.createElement("div"),n=!1;return t.setAttribute?(t.setAttribute(e,"return;"),typeof t[e]=="function"&&(n=!0),t.removeAttribute(e),t=null,n):!1}();n.Browser={ie6:i,ie7:s,webkit:u,android:f,android23:l,chrome:a,ie3d:v,webkit3d:m,gecko3d:g,opera3d:y,any3d:b,mobile:c,mobileWebkit:c&&u,mobileWebkit3d:c&&m,mobileOpera:c&&e.opera,touch:w,msTouch:h,retina:p}}(),n.Point=function(e,t,n){this.x=n?Math.round(e):e,this.y=n?Math.round(t):t},n.Point.prototype={clone:function(){return new n.Point(this.x,this.y)},add:function(e){return this.clone()._add(n.point(e))},_add:function(e){return this.x+=e.x,this.y+=e.y,this},subtract:function(e){return this.clone()._subtract(n.point(e))},_subtract:function(e){return this.x-=e.x,this.y-=e.y,this},divideBy:function(e){return this.clone()._divideBy(e)},_divideBy:function(e){return this.x/=e,this.y/=e,this},multiplyBy:function(e){return this.clone()._multiplyBy(e)},_multiplyBy:function(e){return this.x*=e,this.y*=e,this},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},distanceTo:function(e){e=n.point(e);var t=e.x-this.x,r=e.y-this.y;return Math.sqrt(t*t+r*r)},toString:function(){return"Point("+n.Util.formatNum(this.x)+", "+n.Util.formatNum(this.y)+")"}},n.point=function(e,t,r){return e instanceof n.Point?e:e instanceof Array?new n.Point(e[0],e[1]):isNaN(e)?e:new n.Point(e,t,r)},n.Bounds=n.Class.extend({initialize:function(e,t){if(!e)return;var n=t?[e,t]:e;for(var r=0,i=n.length;r=this.min.x&&r.x<=this.max.x&&t.y>=this.min.y&&r.y<=this.max.y},intersects:function(e){e=n.bounds(e);var t=this.min,r=this.max,i=e.min,s=e.max,o=s.x>=t.x&&i.x<=r.x,u=s.y>=t.y&&i.y<=r.y;return o&&u},isValid:function(){return!!this.min&&!!this.max}}),n.bounds=function(e,t){return!e||e instanceof n.Bounds?e:new n.Bounds(e,t)},n.Transformation=n.Class.extend({initialize:function(e,t,n,r){this._a=e,this._b=t,this._c=n,this._d=r},transform:function(e,t){return this._transform(e.clone(),t)},_transform:function(e,t){return t=t||1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e},untransform:function(e,t){return t=t||1,new n.Point((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}}),n.DomUtil={get:function(e){return typeof e=="string"?document.getElementById(e):e},getStyle:function(e,t){var n=e.style[t];!n&&e.currentStyle&&(n=e.currentStyle[t]);if((!n||n==="auto")&&document.defaultView){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n==="auto"?null:n},getViewportOffset:function(e){var t=0,r=0,i=e,s=document.body,o,u=n.Browser.ie7;do{t+=i.offsetTop||0,r+=i.offsetLeft||0,o=n.DomUtil.getStyle(i,"position");if(i.offsetParent===s&&o==="absolute")break;if(o==="fixed"){t+=s.scrollTop||0,r+=s.scrollLeft||0;break}i=i.offsetParent}while(i);i=e;do{if(i===s)break;t-=i.scrollTop||0,r-=i.scrollLeft||0,!n.DomUtil.documentIsLtr()&&(n.Browser.webkit||u)&&(r+=i.scrollWidth-i.clientWidth,u&&n.DomUtil.getStyle(i,"overflow-y")!=="hidden"&&n.DomUtil.getStyle(i,"overflow")!=="hidden"&&(r+=17)),i=i.parentNode}while(i);return new n.Point(r,t)},documentIsLtr:function(){return n.DomUtil._docIsLtrCached||(n.DomUtil._docIsLtrCached=!0,n.DomUtil._docIsLtr=n.DomUtil.getStyle(document.body,"direction")==="ltr"),n.DomUtil._docIsLtr},create:function(e,t,n){var r=document.createElement(e);return r.className=t,n&&n.appendChild(r),r},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=n.Util.falseFn)},enableTextSelection:function(){document.onselectstart===n.Util.falseFn&&(document.onselectstart=this._onselectstart,this._onselectstart=null)},hasClass:function(e,t){return e.className.length>0&&RegExp("(^|\\s)"+t+"(\\s|$)").test(e.className)},addClass:function(e,t){n.DomUtil.hasClass(e,t)||(e.className+=(e.className?" ":"")+t)},removeClass:function(e,t){function n(e,n){return n===t?"":e}e.className=e.className.replace(/(\S+)\s*/g,n).replace(/(^\s+|\s+$)/,"")},setOpacity:function(e,t){if("opacity"in e.style)e.style.opacity=t;else if("filter"in e.style){var n=!1,r="DXImageTransform.Microsoft.Alpha";try{n=e.filters.item(r)}catch(i){}t=Math.round(t*100),n?(n.Enabled=t!==100,n.Opacity=t):e.style.filter+=" progid:"+r+"(opacity="+t+")"}},testProp:function(e){var t=document.documentElement.style;for(var n=0;n=t.lat&&s.lat<=r.lat&&i.lng>=t.lng&&s.lng<=r.lng},intersects:function(e){e=n.latLngBounds(e);var t=this._southWest,r=this._northEast,i=e.getSouthWest(),s=e.getNorthEast(),o=s.lat>=t.lat&&i.lat<=r.lat,u=s.lng>=t.lng&&i.lng<=r.lng;return o&&u},toBBoxString:function(){var e=this._southWest,t=this._northEast;return[e.lng,e.lat,t.lng,t.lat].join(",")},equals:function(e){return e?(e=n.latLngBounds(e),this._southWest.equals(e.getSouthWest())&&this._northEast.equals(e.getNorthEast())):!1},isValid:function(){return!!this._southWest&&!!this._northEast}}),n.latLngBounds=function(e,t){return!e||e instanceof n.LatLngBounds?e:new n.LatLngBounds(e,t)},n.Projection={},n.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(e){var t=n.LatLng.DEG_TO_RAD,r=this.MAX_LATITUDE,i=Math.max(Math.min(r,e.lat),-r),s=e.lng*t,o=i*t;return o=Math.log(Math.tan(Math.PI/4+o/2)),new n.Point(s,o)},unproject:function(e){var t=n.LatLng.RAD_TO_DEG,r=e.x*t,i=(2*Math.atan(Math.exp(e.y))-Math.PI/2)*t;return new n.LatLng(i,r,!0)}},n.Projection.LonLat={project:function(e){return new n.Point(e.lng,e.lat)},unproject:function(e){return new n.LatLng(e.y,e.x,!0)}},n.CRS={latLngToPoint:function(e,t){var n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)},pointToLatLng:function(e,t){var n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)},project:function(e){return this.projection.project(e)},scale:function(e){return 256*Math.pow(2,e)}},n.CRS.Simple=n.Util.extend({},n.CRS,{projection:n.Projection.LonLat,transformation:new n.Transformation(1,0,1,0)}),n.CRS.EPSG3857=n.Util.extend({},n.CRS,{code:"EPSG:3857",projection:n.Projection.SphericalMercator,transformation:new n.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(e){var t=this.projection.project(e),n=6378137;return t.multiplyBy(n)}}),n.CRS.EPSG900913=n.Util.extend({},n.CRS.EPSG3857,{code:"EPSG:900913"}),n.CRS.EPSG4326=n.Util.extend({},n.CRS,{code:"EPSG:4326",projection:n.Projection.LonLat,transformation:new n.Transformation(1/360,.5,-1/360,.5)}),n.Map=n.Class.extend({includes:n.Mixin.Events,options:{crs:n.CRS.EPSG3857,fadeAnimation:n.DomUtil.TRANSITION&&!n.Browser.android23,trackResize:!0,markerZoomAnimation:n.DomUtil.TRANSITION&&n.Browser.any3d},initialize:function(e,r){r=n.Util.setOptions(this,r),this._initContainer(e),this._initLayout(),this._initHooks(),this._initEvents(),r.maxBounds&&this.setMaxBounds(r.maxBounds),r.center&&r.zoom!==t&&this.setView(n.latLng(r.center),r.zoom,!0),this._initLayers(r.layers)},setView:function(e,t){return this._resetView(n.latLng(e),this._limitZoom(t)),this},setZoom:function(e){return this.setView(this.getCenter(),e)},zoomIn:function(e){return this.setZoom(this._zoom+(e||1))},zoomOut:function(e){return this.setZoom(this._zoom-(e||1))},fitBounds:function(e){var t=this.getBoundsZoom(e);return this.setView(n.latLngBounds(e).getCenter(),t)},fitWorld:function(){var e=new n.LatLng(-60,-170),t=new n.LatLng(85,179);return this.fitBounds(new n.LatLngBounds(e,t))},panTo:function(e){return this.setView(e,this._zoom)},panBy:function(e){return this.fire("movestart"),this._rawPanBy(n.point(e)),this.fire("move"),this.fire("moveend")},setMaxBounds:function(e){e=n.latLngBounds(e),this.options.maxBounds=e;if(!e)return this._boundsMinZoom=null,this;var t=this.getBoundsZoom(e,!0);return this._boundsMinZoom=t,this._loaded&&(this._zoomo.x&&(u=o.x-i.x),r.y>s.y&&(a=s.y-r.y),r.xc&&--h>0)d=u*Math.sin(f),p=Math.PI/2-2*Math.atan(a*Math.pow((1-d)/(1+d),.5*u))-f,f+=p;return new n.LatLng(f*t,s,!0)}},n.CRS.EPSG3395=n.Util.extend({},n.CRS,{code:"EPSG:3395",projection:n.Projection.Mercator,transformation:function(){var e=n.Projection.Mercator,t=e.R_MAJOR,r=e.R_MINOR;return new n.Transformation(.5/(Math.PI*t),.5,-0.5/(Math.PI*r),.5)}()}),n.TileLayer=n.Class.extend({includes:n.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:n.Browser.mobile,updateWhenIdle:n.Browser.mobile},initialize:function(e,t){t=n.Util.setOptions(this,t),t.detectRetina&&n.Browser.retina&&t.maxZoom>0&&(t.tileSize=Math.floor(t.tileSize/2),t.zoomOffset++,t.minZoom>0&&t.minZoom--,this.options.maxZoom--),this._url=e;var r=this.options.subdomains;typeof r=="string"&&(this.options.subdomains=r.split(""))},onAdd:function(e){this._map=e,this._initContainer(),this._createTileProto(),e.on({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||(this._limitedUpdate=n.Util.limitExecByInterval(this._update,150,this),e.on("move",this._limitedUpdate,this)),this._reset(),this._update()},addTo:function(e){return e.addLayer(this),this},onRemove:function(e){e._panes.tilePane.removeChild(this._container),e.off({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||e.off("move",this._limitedUpdate,this),this._container=null,this._map=null},bringToFront:function(){var e=this._map._panes.tilePane;return this._container&&(e.appendChild(this._container),this._setAutoZIndex(e,Math.max)),this},bringToBack:function(){var e=this._map._panes.tilePane;return this._container&&(e.insertBefore(this._container,e.firstChild),this._setAutoZIndex(e,Math.min)),this},getAttribution:function(){return this.options.attribution},setOpacity:function(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},setUrl:function(e,t){return this._url=e,t||this.redraw(),this},redraw:function(){return this._map&&(this._map._panes.tilePane.empty=!1,this._reset(!0),this._update()),this},_updateZIndex:function(){this._container&&this.options.zIndex!==t&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(e,t){var n=e.getElementsByClassName("leaflet-layer"),r=-t(Infinity,-Infinity),i;for(var s=0,o=n.length;sthis.options.maxZoom||r=t)||e.y<0||e.y>=t)return!1}return!0},_removeOtherTiles:function(e){var t,n,r,i;for(i in this._tiles)this._tiles.hasOwnProperty(i)&&(t=i.split(":"),n=parseInt(t[0],10),r=parseInt(t[1],10),(ne.max.x||re.max.y)&&this._removeTile(i))},_removeTile:function(e){var t=this._tiles[e];this.fire("tileunload",{tile:t,url:t.src}),this.options.reuseTiles?(n.DomUtil.removeClass(t,"leaflet-tile-loaded"),this._unusedTiles.push(t)):t.parentNode===this._container&&this._container.removeChild(t),n.Browser.android||(t.src=n.Util.emptyImageUrl),delete this._tiles[e]},_addTile:function(e,t){var r=this._getTilePos(e),i=this._getTile();n.DomUtil.setPosition(i,r,n.Browser.chrome||n.Browser.android23),this._tiles[e.x+":"+e.y]=i,this._loadTile(i,e),i.parentNode!==this._container&&t.appendChild(i)},_getZoomForUrl:function(){var e=this.options,t=this._map.getZoom();return e.zoomReverse&&(t=e.maxZoom-t),t+e.zoomOffset},_getTilePos:function(e){var t=this._map.getPixelOrigin(),n=this.options.tileSize;return e.multiplyBy(n).subtract(t)},getTileUrl:function(e){return this._adjustTilePoint(e),n.Util.template(this._url,n.Util.extend({s:this._getSubdomain(e),z:this._getZoomForUrl(),x:e.x,y:e.y},this.options))},_getWrapTileNum:function(){return Math.pow(2,this._getZoomForUrl())},_adjustTilePoint:function(e){var t=this._getWrapTileNum();!this.options.continuousWorld&&!this.options.noWrap&&(e.x=(e.x%t+t)%t),this.options.tms&&(e.y=t-e.y-1)},_getSubdomain:function(e){var t=(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]},_createTileProto:function(){var e=this._tileImg=n.DomUtil.create("img","leaflet-tile");e.galleryimg="no";var t=this.options.tileSize;e.style.width=t+"px",e.style.height=t+"px"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var e=this._unusedTiles.pop();return this._resetTile(e),e}return this._createTile()},_resetTile:function(e){},_createTile:function(){var e=this._tileImg.cloneNode(!1);return e.onselectstart=e.onmousemove=n.Util.falseFn,e},_loadTile:function(e,t){e._layer=this,e.onload=this._tileOnLoad,e.onerror=this._tileOnError,e.src=this.getTileUrl(t)},_tileLoaded:function(){this._tilesToLoad--,this._tilesToLoad||this.fire("load")},_tileOnLoad:function(e){var t=this._layer;this.src!==n.Util.emptyImageUrl&&(n.DomUtil.addClass(this,"leaflet-tile-loaded"),t.fire("tileload",{tile:this,url:this.src})),t._tileLoaded()},_tileOnError:function(e){var t=this._layer;t.fire("tileerror",{tile:this,url:this.src});var n=t.options.errorTileUrl;n&&(this.src=n),t._tileLoaded()}}),n.tileLayer=function(e,t){return new n.TileLayer(e,t)},n.TileLayer.WMS=n.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(e,t){this._url=e;var r=n.Util.extend({},this.defaultWmsParams);t.detectRetina&&n.Browser.retina?r.width=r.height=this.options.tileSize*2:r.width=r.height=this.options.tileSize;for(var i in t)this.options.hasOwnProperty(i)||(r[i]=t[i]);this.wmsParams=r,n.Util.setOptions(this,t)},onAdd:function(e){var t=parseFloat(this.wmsParams.version)>=1.3?"crs":"srs";this.wmsParams[t]=e.options.crs.code,n.TileLayer.prototype.onAdd.call(this,e)},getTileUrl:function(e,t){var r=this._map,i=r.options.crs,s=this.options.tileSize,o=e.multiplyBy(s),u=o.add(new n.Point(s,s)),a=i.project(r.unproject(o,t)),f=i.project(r.unproject(u,t)),l=[a.x,f.y,f.x,a.y].join(","),c=n.Util.template(this._url,{s:this._getSubdomain(e)});return c+n.Util.getParamString(this.wmsParams)+"&bbox="+l},setParams:function(e,t){return n.Util.extend(this.wmsParams,e),t||this.redraw(),this}}),n.tileLayer.wms=function(e,t){return new n.TileLayer.WMS(e,t)},n.TileLayer.Canvas=n.TileLayer.extend({options:{async:!1},initialize:function(e){n.Util.setOptions(this,e)},redraw:function(){var e,t=this._tiles;for(e in t)t.hasOwnProperty(e)&&this._redrawTile(t[e])},_redrawTile:function(e){this.drawTile(e,e._tilePoint,this._map._zoom)},_createTileProto:function(){var e=this._canvasProto=n.DomUtil.create("canvas","leaflet-tile"),t=this.options.tileSize;e.width=t,e.height=t},_createTile:function(){var e=this._canvasProto.cloneNode(!1);return e.onselectstart=e.onmousemove=n.Util.falseFn,e},_loadTile:function(e,t){e._layer=this,e._tilePoint=t,this._redrawTile(e),this.options.async||this.tileDrawn(e)},drawTile:function(e,t){},tileDrawn:function(e){this._tileOnLoad.call(e)}}),n.tileLayer.canvas=function(e){return new n.TileLayer.Canvas(e)},n.ImageOverlay=n.Class.extend({includes:n.Mixin.Events,options:{opacity:1},initialize:function(e,t,r){this._url=e,this._bounds=n.latLngBounds(t),n.Util.setOptions(this,r)},onAdd:function(e){this._map=e,this._image||this._initImage(),e._panes.overlayPane.appendChild(this._image),e.on("viewreset",this._reset,this),e.options.zoomAnimation&&n.Browser.any3d&&e.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(e){e.getPanes().overlayPane.removeChild(this._image),e.off("viewreset",this._reset,this),e.options.zoomAnimation&&e.off("zoomanim",this._animateZoom,this)},addTo:function(e){return e.addLayer(this),this},setOpacity:function(e){return this.options.opacity=e,this._updateOpacity(),this},bringToFront:function(){return this._image&&this._map._panes.overlayPane.appendChild(this._image),this},bringToBack:function(){var e=this._map._panes.overlayPane;return this._image&&e.insertBefore(this._image,e.firstChild),this},_initImage:function(){this._image=n.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&n.Browser.any3d?n.DomUtil.addClass(this._image,"leaflet-zoom-animated"):n.DomUtil.addClass(this._image,"leaflet-zoom-hide"),this._updateOpacity(),n.Util.extend(this._image,{galleryimg:"no",onselectstart:n.Util.falseFn,onmousemove:n.Util.falseFn,onload:n.Util.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(e){var t=this._map,r=this._image,i=t.getZoomScale(e.zoom),s=this._bounds.getNorthWest(),o=this._bounds.getSouthEast(),u=t._latLngToNewLayerPoint(s,e.zoom,e.center),a=t._latLngToNewLayerPoint(o,e.zoom,e.center)._subtract(u),f=t.latLngToLayerPoint(o)._subtract(t.latLngToLayerPoint(s)),l=u._add(a._subtract(f)._divideBy(2));r.style[n.DomUtil.TRANSFORM]=n.DomUtil.getTranslateString(l)+" scale("+i+") "},_reset:function(){var e=this._image,t=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),r=this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(t);n.DomUtil.setPosition(e,t),e.style.width=r.x+"px",e.style.height=r.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){n.DomUtil.setOpacity(this._image,this.options.opacity)}}),n.imageOverlay=function(e,t,r){return new n.ImageOverlay(e,t,r)},n.Icon=n.Class.extend({options:{className:""},initialize:function(e){n.Util.setOptions(this,e)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this._createIcon("shadow")},_createIcon:function(e){var t=this._getIconUrl(e);if(!t){if(e==="icon")throw Error("iconUrl not set in Icon options (see the docs).");return null}var n=this._createImg(t);return this._setIconStyles(n,e),n},_setIconStyles:function(e,t){var r=this.options,i=n.point(r[t+"Size"]),s;t==="shadow"?s=n.point(r.shadowAnchor||r.iconAnchor):s=n.point(r.iconAnchor),!s&&i&&(s=i.divideBy(2,!0)),e.className="leaflet-marker-"+t+" "+r.className,s&&(e.style.marginLeft=-s.x+"px",e.style.marginTop=-s.y+"px"),i&&(e.style.width=i.x+"px",e.style.height=i.y+"px")},_createImg:function(e){var t;return n.Browser.ie6?(t=document.createElement("div"),t.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+e+'")'):(t=document.createElement("img"),t.src=e),t},_getIconUrl:function(e){return this.options[e+"Url"]}}),n.icon=function(e){return new n.Icon(e)},n.Icon.Default=n.Icon.extend({options:{iconSize:new n.Point(25,41),iconAnchor:new n.Point(12,41),popupAnchor:new n.Point(1,-34),shadowSize:new n.Point(41,41)},_getIconUrl:function(e){var t=e+"Url";if(this.options[t])return this.options[t];var r=n.Icon.Default.imagePath;if(!r)throw Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");return r+"/marker-"+e+".png"}}),n.Icon.Default.imagePath=function(){var e=document.getElementsByTagName("script"),t=/\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/,n,r,i,s;for(n=0,r=e.length;ns?(t.height=s+"px",n.DomUtil.addClass(e,o)):n.DomUtil.removeClass(e,o),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){if(!this._map)return;var e=this._map.latLngToLayerPoint(this._latlng),t=n.Browser.any3d,r=this.options.offset;t&&n.DomUtil.setPosition(this._container,e),this._containerBottom=-r.y-(t?0:e.y),this._containerLeft=-Math.round(this._containerWidth/2)+r.x+(t?0:e.x),this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_zoomAnimation:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);n.DomUtil.setPosition(this._container,t)},_adjustPan:function(){if(!this.options.autoPan)return;var e=this._map,t=this._container.offsetHeight,r=this._containerWidth,i=new n.Point(this._containerLeft,-t-this._containerBottom);n.Browser.any3d&&i._add(n.DomUtil.getPosition(this._container));var s=e.layerPointToContainerPoint(i),o=this.options.autoPanPadding,u=e.getSize(),a=0,f=0;s.x<0&&(a=s.x-o.x),s.x+r>u.x&&(a=s.x+r-u.x+o.x),s.y<0&&(f=s.y-o.y),s.y+t>u.y&&(f=s.y+t-u.y+o.y),(a||f)&&e.panBy(new n.Point(a,f))},_onCloseButtonClick:function(e){this._close(),n.DomEvent.stop(e)}}),n.popup=function(e,t){return new n.Popup(e,t)},n.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(e,t){var r=n.point(this.options.icon.options.popupAnchor)||new n.Point(0,0);return r=r.add(n.Popup.prototype.options.offset),t&&t.offset&&(r=r.add(t.offset)),t=n.Util.extend({offset:r},t),this._popup||this.on("click",this.openPopup,this).on("remove",this.closePopup,this).on("move",this._movePopup,this),this._popup=(new n.Popup(t,this)).setContent(e),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup).off("remove",this.closePopup).off("move",this._movePopup)),this},_movePopup:function(e){this._popup.setLatLng(e.latlng)}}),n.Map.include({openPopup:function(e){return this.closePopup(),this._popup=e,this.addLayer(e).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&this._popup._close(),this}}),n.LayerGroup=n.Class.extend({initialize:function(e){this._layers={};var t,n;if(e)for(t=0,n=e.length;t';var t=e.firstChild;return t.style.behavior="url(#default#VML)",t&&typeof t.adj=="object"}catch(n){return!1}}(),n.Path=n.Browser.svg||!n.Browser.vml?n.Path:n.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(e){return document.createElement("')}}catch(e){return function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var e=this._container=this._createElement("shape");n.DomUtil.addClass(e,"leaflet-vml-shape"),this.options.clickable&&n.DomUtil.addClass(e,"leaflet-clickable"),e.coordsize="1 1",this._path=this._createElement("path"),e.appendChild(this._path),this._map._pathRoot.appendChild(e)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var e=this._stroke,t=this._fill,n=this.options,r=this._container;r.stroked=n.stroke,r.filled=n.fill,n.stroke?(e||(e=this._stroke=this._createElement("stroke"),e.endcap="round",r.appendChild(e)),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=n.dashArray.replace(/ *, */g," "):e.dashStyle=""):e&&(r.removeChild(e),this._stroke=null),n.fill?(t||(t=this._fill=this._createElement("fill"),r.appendChild(t)),t.color=n.fillColor||n.color,t.opacity=n.fillOpacity):t&&(r.removeChild(t),this._fill=null)},_updatePath:function(){var e=this._container.style;e.display="none",this._path.v=this.getPathString()+" ",e.display=""}}),n.Map.include(n.Browser.svg||!n.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var e=this._pathRoot=document.createElement("div");e.className="leaflet-vml-container",this._panes.overlayPane.appendChild(e),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),n.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),n.Path=n.Path.SVG&&!e.L_PREFER_CANVAS||!n.Browser.canvas?n.Path:n.Path.extend({statics:{CANVAS:!0,SVG:!1},redraw:function(){return this._map&&(this.projectLatlngs(),this._requestUpdate()),this},setStyle:function(e){return n.Util.setOptions(this,e),this._map&&(this._updateStyle(),this._requestUpdate()),this},onRemove:function(e){e.off("viewreset",this.projectLatlngs,this).off("moveend",this._updatePath,this),this._requestUpdate(),this._map=null},_requestUpdate:function(){this._map&&!n.Path._updateRequest&&(n.Path._updateRequest=n.Util.requestAnimFrame(this._fireMapMoveEnd,this._map))},_fireMapMoveEnd:function(){n.Path._updateRequest=null,this.fire("moveend")},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var e=this.options;e.stroke&&(this._ctx.lineWidth=e.weight,this._ctx.strokeStyle=e.color),e.fill&&(this._ctx.fillStyle=e.fillColor||e.color)},_drawPath:function(){var e,t,r,i,s,o;this._ctx.beginPath();for(e=0,r=this._parts.length;es&&(o=u,s=a);s>n&&(t[o]=1,this._simplifyDPStep(e,t,n,r,o),this._simplifyDPStep(e,t,n,o,i))},_reducePoints:function(e,t){var n=[e[0]];for(var r=1,i=0,s=e.length;rt&&(n.push(e[r]),i=r);return it.max.x&&(n|=2),e.yt.max.y&&(n|=8),n},_sqDist:function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},_sqClosestPointOnSegment:function(e,t,r,i){var s=t.x,o=t.y,u=r.x-s,a=r.y-o,f=u*u+a*a,l;return f>0&&(l=((e.x-s)*u+(e.y-o)*a)/f,l>1?(s=r.x,o=r.y):l>0&&(s+=u*l,o+=a*l)),u=e.x-s,a=e.y-o,i?u*u+a*a:new n.Point(s,o)}},n.Polyline=n.Path.extend({initialize:function(e,t){n.Path.prototype.initialize.call(this,t),this._latlngs=this._convertLatLngs(e),n.Handler.PolyEdit&&(this.editing=new n.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var e=0,t=this._latlngs.length;ee.max.x||n.y-t>e.max.y||n.x+te.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(t=!t)}return t}}:{}),n.Circle.include(n.Path.CANVAS?{_drawPath:function(){var e=this._point;this._ctx.beginPath(),this._ctx.arc(e.x,e.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(e){var t=this._point,n=this.options.stroke?this.options.weight/2:0;return e.distanceTo(t)<=this._radius+n}}:{}),n.GeoJSON=n.FeatureGroup.extend({initialize:function(e,t){n.Util.setOptions(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t=e instanceof Array?e:e.features,r,i;if(t){for(r=0,i=t.length;r1){this._simulateClick=!1,clearTimeout(this._longPressTimeout);return}var t=e.touches&&e.touches.length===1?e.touches[0]:e,r=t.target;n.Browser.touch&&r.tagName.toLowerCase()==="a"&&n.DomUtil.addClass(r,"leaflet-active"),this._moved=!1;if(this._moving)return;this._startPoint=new n.Point(t.clientX,t.clientY),this._startPos=this._newPos=n.DomUtil.getPosition(this._element),e.touches&&e.touches.length===1&&n.Browser.touch&&this._longPress&&(this._longPressTimeout=setTimeout(n.Util.bind(function(){var e=this._newPos&&this._newPos.distanceTo(this._startPos)||0;e1)return;var t=e.touches&&e.touches.length===1?e.touches[0]:e,r=new n.Point(t.clientX,t.clientY),i=r.subtract(this._startPoint);if(!i.x&&!i.y)return;n.DomEvent.preventDefault(e),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=n.DomUtil.getPosition(this._element).subtract(i),n.Browser.touch||(n.DomUtil.disableTextSelection(),this._setMovingCursor())),this._newPos=this._startPos.add(i),this._moving=!0,n.Util.cancelAnimFrame(this._animRequest),this._animRequest=n.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),n.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(e){var t;clearTimeout(this._longPressTimeout);if(this._simulateClick&&e.changedTouches){var r=e.changedTouches[0],i=r.target,s=this._newPos&&this._newPos.distanceTo(this._startPos)||0;i.tagName.toLowerCase()==="a"&&n.DomUtil.removeClass(i,"leaflet-active"),s200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var e=this._map.getSize()._divideBy(2),t=this._map.latLngToLayerPoint(new n.LatLng(0,0));this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.project(new n.LatLng(0,180)).x},_onPreDrag:function(){var e=this._map,t=this._worldWidth,n=Math.round(t/2),r=this._initialWorldOffset,i=this._draggable._newPos.x,s=(i-n+r)%t+n-r,o=(i+n+r)%t-n-r,u=Math.abs(s+r)r.inertiaThreshold||this._positions[0]===t;if(s)e.fire("moveend");else{var o=this._lastPos.subtract(this._positions[0]),u=(this._lastTime+i-this._times[0])/1e3,a=o.multiplyBy(.58/u),f=a.distanceTo(new n.Point(0,0)),l=Math.min(r.inertiaMaxSpeed,f),c=a.multiplyBy(l/f),h=l/r.inertiaDeceleration,p=c.multiplyBy(-h/2).round();n.Util.requestAnimFrame(n.Util.bind(function(){this._map.panBy(p,h)},this))}e.fire("dragend"),r.maxBounds&&n.Util.requestAnimFrame(this._panInsideMaxBounds,e,!0,e._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),n.Map.addInitHook("addHandler","dragging",n.Map.Drag),n.Map.mergeOptions({doubleClickZoom:!0}),n.Map.DoubleClickZoom=n.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(e){this.setView(e.latlng,this._zoom+1)}}),n.Map.addInitHook("addHandler","doubleClickZoom",n.Map.DoubleClickZoom),n.Map.mergeOptions({scrollWheelZoom:!n.Browser.touch||n.Browser.msTouch}),n.Map.ScrollWheelZoom=n.Handler.extend({addHooks:function(){n.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){n.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(e){var t=n.DomEvent.getWheelDelta(e);this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._startTime||(this._startTime=+(new Date));var r=Math.max(40-(+(new Date)-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(n.Util.bind(this._performZoom,this),r),n.DomEvent.preventDefault(e),n.DomEvent.stopPropagation(e)},_performZoom:function(){var e=this._map,t=Math.round(this._delta),n=e.getZoom();t=Math.max(Math.min(t,4),-4),t=e._limitZoom(n+t)-n,this._delta=0,this._startTime=null;if(!t)return;var r=n+t,i=this._getCenterForScrollWheelZoom(r);e.setView(i,r)},_getCenterForScrollWheelZoom:function(e){var t=this._map,n=t.getZoomScale(e),r=t.getSize()._divideBy(2),i=this._lastMousePos._subtract(r)._multiplyBy(1-1/n),s=t._getTopLeftPoint()._add(r)._add(i);return t.unproject(s)}}),n.Map.addInitHook("addHandler","scrollWheelZoom",n.Map.ScrollWheelZoom),n.Util.extend(n.DomEvent,{_touchstart:n.Browser.msTouch?"MSPointerDown":"touchstart",_touchend:n.Browser.msTouch?"MSPointerUp":"touchend",addDoubleTapListener:function(e,t,r){function h(e){var t;n.Browser.msTouch?(c.push(e.pointerId),t=c.length):t=e.touches.length;if(t>1)return;var r=Date.now(),a=r-(i||r);u=e.touches?e.touches[0]:e,s=a>0&&a<=o,i=r}function p(e){if(n.Browser.msTouch){var r=c.indexOf(e.pointerId);if(r===-1)return;c.splice(r,1)}if(s){if(n.Browser.msTouch){var o={},a;for(var f in u)a=u[f],typeof a=="function"?o[f]=a.bind(u):o[f]=a;u=o}u.type="dblclick",t(u),i=null}}var i,s=!1,o=250,u,a="_leaflet_",f=this._touchstart,l=this._touchend,c=[];e[a+f+r]=h,e[a+l+r]=p;var d=n.Browser.msTouch?document.documentElement:e;return e.addEventListener(f,h,!1),d.addEventListener(l,p,!1),n.Browser.msTouch&&d.addEventListener("MSPointerCancel",p,!1),this},removeDoubleTapListener:function(e,t){var r="_leaflet_";return e.removeEventListener(this._touchstart,e[r+this._touchstart+t],!1),(n.Browser.msTouch?document.documentElement:e).removeEventListener(this._touchend,e[r+this._touchend+t],!1),n.Browser.msTouch&&document.documentElement.removeEventListener("MSPointerCancel",e[r+this._touchend+t],!1),this}}),n.Util.extend(n.DomEvent,{_msTouches:[],_msDocumentListener:!1,addMsTouchListener:function(e,t,n,r){switch(t){case"touchstart":return this.addMsTouchListenerStart(e,t,n,r);case"touchend":return this.addMsTouchListenerEnd(e,t,n,r);case"touchmove":return this.addMsTouchListenerMove(e,t,n,r);default:throw"Unknown touch event type"}},addMsTouchListenerStart:function(e,t,n,r){var i="_leaflet_",s=this._msTouches,o=function(e){var t=!1;for(var r=0;r0?Math.ceil(o):Math.floor(o),a=t._limitZoom(s+u);t.fire("zoomanim",{center:i,zoom:a}),t._runAnimation(i,a,t.getZoomScale(a)/this._scale,r,!0)},_getScaleOrigin:function(){var e=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(e)}}),n.Map.addInitHook("addHandler","touchZoom",n.Map.TouchZoom),n.Map.mergeOptions({boxZoom:!0}),n.Map.BoxZoom=n.Handler.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane},addHooks:function(){n.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){n.DomEvent.off(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(e){if(!e.shiftKey||e.which!==1&&e.button!==1)return!1;n.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(e),this._box=n.DomUtil.create("div","leaflet-zoom-box",this._pane),n.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",n.DomEvent.on(document,"mousemove",this._onMouseMove,this).on(document,"mouseup",this._onMouseUp,this).preventDefault(e),this._map.fire("boxzoomstart")},_onMouseMove:function(e){var t=this._startLayerPoint,r=this._box,i=this._map.mouseEventToLayerPoint(e),s=i.subtract(t),o=new n.Point(Math.min(i.x,t.x),Math.min(i.y,t.y));n.DomUtil.setPosition(r,o),r.style.width=Math.max(0,Math.abs(s.x)-4)+"px",r.style.height=Math.max(0,Math.abs(s.y)-4)+"px"},_onMouseUp:function(e){this._pane.removeChild(this._box),this._container.style.cursor="",n.DomUtil.enableTextSelection(),n.DomEvent.off(document,"mousemove",this._onMouseMove).off(document,"mouseup",this._onMouseUp);var t=this._map,r=t.mouseEventToLayerPoint(e),i=new n.LatLngBounds(t.layerPointToLatLng(this._startLayerPoint),t.layerPointToLatLng(r));t.fitBounds(i),t.fire("boxzoomend",{boxZoomBounds:i})}}),n.Map.addInitHook("addHandler","boxZoom",n.Map.BoxZoom),n.Map.mergeOptions({keyboard:!0,keyboardPanOffset:80,keyboardZoomOffset:1}),n.Map.Keyboard=n.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61],zoomOut:[189,109]},initialize:function(e){this._map=e,this._setPanOffset(e.options.keyboardPanOffset),this._setZoomOffset(e.options.keyboardZoomOffset)},addHooks:function(){var e=this._map._container;e.tabIndex===-1&&(e.tabIndex="0"),n.DomEvent.addListener(e,"focus",this._onFocus,this).addListener(e,"blur",this._onBlur,this).addListener(e,"mousedown",this._onMouseDown,this),this._map.on("focus",this._addHooks,this).on("blur",this._removeHooks,this)},removeHooks:function(){this._removeHooks();var e=this._map._container;n.DomEvent.removeListener(e,"focus",this._onFocus,this).removeListener(e,"blur",this._onBlur,this).removeListener(e,"mousedown",this._onMouseDown,this),this._map.off("focus",this._addHooks,this).off("blur",this._removeHooks,this)},_onMouseDown:function(){this._focused||this._map._container.focus()},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanOffset:function(e){var t=this._panKeys={},n=this.keyCodes,r,i;for(r=0,i=n.left.length;re&&(n._index+=t)})},_createMiddleMarker:function(e,t){var n=this._getMiddleLatLng(e,t),r=this._createMarker(n),i,s,o;r.setOpacity(.6),e._middleRight=t._middleLeft=r,s=function(){var s=t._index;r._index=s,r.off("click",i).on("click",this._onMarkerClick,this),n.lat=r.getLatLng().lat,n.lng=r.getLatLng().lng,this._poly.spliceLatLngs(s,0,n),this._markers.splice(s,0,r),r.setOpacity(1),this._updateIndexes(s,1),t._index++,this._updatePrevNext(e,r),this._updatePrevNext(r,t)},o=function(){r.off("dragstart",s,this),r.off("dragend",o,this),this._createMiddleMarker(e,r),this._createMiddleMarker(r,t)},i=function(){s.call(this),o.call(this),this._poly.fire("edit")},r.on("click",i,this).on("dragstart",s,this).on("dragend",o,this),this._markerGroup.addLayer(r)},_updatePrevNext:function(e,t){e&&(e._next=t),t&&(t._prev=e)},_getMiddleLatLng:function(e,t){var n=this._poly._map,r=n.latLngToLayerPoint(e.getLatLng()),i=n.latLngToLayerPoint(t.getLatLng());return n.layerPointToLatLng(r._add(i)._divideBy(2))}}),n.Control=n.Class.extend({options:{position:"topright"},initialize:function(e){n.Util.setOptions(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},addTo:function(e){this._map=e;var t=this._container=this.onAdd(e),r=this.getPosition(),i=e._controlCorners[r];return n.DomUtil.addClass(t,"leaflet-control"),r.indexOf("bottom")!==-1?i.insertBefore(t,i.firstChild):i.appendChild(t),this},removeFrom:function(e){var t=this.getPosition(),n=e._controlCorners[t];return n.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(e),this}}),n.control=function(e){return new n.Control(e)},n.Map.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.removeFrom(this),this},_initControlPos:function(){function i(i,s){var o=t+i+" "+t+s;e[i+s]=n.DomUtil.create("div",o,r)}var e=this._controlCorners={},t="leaflet-",r=this._controlContainer=n.DomUtil.create("div",t+"control-container",this._container);i("top","left"),i("top","right"),i("bottom","left"),i("bottom","right")}}),n.Control.Zoom=n.Control.extend({options:{position:"topleft"},onAdd:function(e){var t="leaflet-control-zoom",r=n.DomUtil.create("div",t);return this._map=e,this._createButton("Zoom in",t+"-in",r,this._zoomIn,this),this._createButton("Zoom out",t+"-out",r,this._zoomOut,this),r},_zoomIn:function(e){this._map.zoomIn(e.shiftKey?3:1)},_zoomOut:function(e){this._map.zoomOut(e.shiftKey?3:1)},_createButton:function(e,t,r,i,s){var o=n.DomUtil.create("a",t,r);return o.href="#",o.title=e,n.DomEvent.on(o,"click",n.DomEvent.stopPropagation).on(o,"mousedown",n.DomEvent.stopPropagation).on(o,"dblclick",n.DomEvent.stopPropagation).on(o,"click",n.DomEvent.preventDefault).on(o,"click",i,s),o}}),n.Map.mergeOptions({zoomControl:!0}),n.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new n.Control.Zoom,this.addControl(this.zoomControl))}),n.control.zoom=function(e){return new n.Control.Zoom(e)},n.Control.Attribution=n.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(e){n.Util.setOptions(this,e),this._attributions={}},onAdd:function(e){return this._container=n.DomUtil.create("div","leaflet-control-attribution"),n.DomEvent.disableClickPropagation(this._container),e.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this),this._update(),this._container},onRemove:function(e){e.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){if(!e)return;return this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update(),this},removeAttribution:function(e){if(!e)return;return this._attributions[e]--,this._update(),this},_update:function(){if(!this._map)return;var e=[];for(var t in this._attributions)this._attributions.hasOwnProperty(t)&&this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(", ")),this._container.innerHTML=n.join(" — ")},_onLayerAdd:function(e){e.layer.getAttribution&&this.addAttribution(e.layer.getAttribution())},_onLayerRemove:function(e){e.layer.getAttribution&&this.removeAttribution(e.layer.getAttribution())}}),n.Map.mergeOptions({attributionControl:!0}),n.Map.addInitHook(function(){this.options.attributionControl&&(this.attributionControl=(new n.Control.Attribution).addTo(this))}),n.control.attribution=function(e){return new n.Control.Attribution(e)},n.Control.Scale=n.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(e){this._map=e;var t="leaflet-control-scale",r=n.DomUtil.create("div",t),i=this.options;return this._addScales(i,t,r),e.on(i.updateWhenIdle?"moveend":"move",this._update,this),e.whenReady(this._update,this),r},onRemove:function(e){e.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(e,t,r){e.metric&&(this._mScale=n.DomUtil.create("div",t+"-line",r)),e.imperial&&(this._iScale=n.DomUtil.create("div",t+"-line",r))},_update:function(){var e=this._map.getBounds(),t=e.getCenter().lat,n=6378137*Math.PI*Math.cos(t*Math.PI/180),r=n*(e.getNorthEast().lng-e.getSouthWest().lng)/180,i=this._map.getSize(),s=this.options,o=0;i.x>0&&(o=r*(s.maxWidth/i.x)),this._updateScales(s,o)},_updateScales:function(e,t){e.metric&&t&&this._updateMetric(t),e.imperial&&t&&this._updateImperial(t)},_updateMetric:function(e){var t=this._getRoundNum(e);this._mScale.style.width=this._getScaleWidth(t/e)+"px",this._mScale.innerHTML=t<1e3?t+" m":t/1e3+" km"},_updateImperial:function(e){var t=e*3.2808399,n=this._iScale,r,i,s;t>5280?(r=t/5280,i=this._getRoundNum(r),n.style.width=this._getScaleWidth(i/r)+"px",n.innerHTML=i+" mi"):(s=this._getRoundNum(t),n.style.width=this._getScaleWidth(s/t)+"px",n.innerHTML=s+" ft")},_getScaleWidth:function(e){return Math.round(this.options.maxWidth*e)-10},_getRoundNum:function(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}}),n.control.scale=function(e){return new n.Control.Scale(e)},n.Control.Layers=n.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0},initialize:function(e,t,r){n.Util.setOptions(this,r),this._layers={},this._lastZIndex=0;for(var i in e)e.hasOwnProperty(i)&&this._addLayer(e[i],i);for(i in t)t.hasOwnProperty(i)&&this._addLayer(t[i],i,!0)},onAdd:function(e){return this._initLayout(),this._update(),this._container},addBaseLayer:function(e,t){return this._addLayer(e,t),this._update(),this},addOverlay:function(e,t){return this._addLayer(e,t,!0),this._update(),this},removeLayer:function(e){var t=n.Util.stamp(e);return delete this._layers[t],this._update(),this},_initLayout:function(){var e="leaflet-control-layers",t=this._container=n.DomUtil.create("div",e);n.Browser.touch?n.DomEvent.on(t,"click",n.DomEvent.stopPropagation):n.DomEvent.disableClickPropagation(t);var r=this._form=n.DomUtil.create("form",e+"-list");if(this.options.collapsed){n.DomEvent.on(t,"mouseover",this._expand,this).on(t,"mouseout",this._collapse,this);var i=this._layersLink=n.DomUtil.create("a",e+"-toggle",t);i.href="#",i.title="Layers",n.Browser.touch?n.DomEvent.on(i,"click",n.DomEvent.stopPropagation).on(i,"click",n.DomEvent.preventDefault).on(i,"click",this._expand,this):n.DomEvent.on(i,"focus",this._expand,this),this._map.on("movestart",this._collapse,this)}else this._expand();this._baseLayersList=n.DomUtil.create("div",e+"-base",r),this._separator=n.DomUtil.create("div",e+"-separator",r),this._overlaysList=n.DomUtil.create("div",e+"-overlays",r),t.appendChild(r)},_addLayer:function(e,t,r){var i=n.Util.stamp(e);this._layers[i]={layer:e,name:t,overlay:r},this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex))},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var e=!1,t=!1;for(var n in this._layers)if(this._layers.hasOwnProperty(n)){var r=this._layers[n];this._addItem(r),t=t||r.overlay,e=e||!r.overlay}this._separator.style.display=t&&e?"":"none"},_createRadioElement:function(e,t){var n='.5&&this._getLoadedTilesPercentage(e)<.5){e.style.visibility="hidden",e.empty=!0,this._stopLoadingImages(e);return}t||(t=this._tileBg=this._createPane("leaflet-tile-pane",this._mapPane),t.style.zIndex=1),t.style[n.DomUtil.TRANSFORM]="",t.style.visibility="hidden",t.empty=!0,e.empty=!1,this._tilePane=this._panes.tilePane=t;var r=this._tileBg=e;n.DomUtil.addClass(r,"leaflet-zoom-animated"),this._stopLoadingImages(r)},_getLoadedTilesPercentage:function(e){var t=e.getElementsByTagName("img"),n,r,i=0;for(n=0,r=t.length;n2?Array.prototype.slice.call(arguments,2):null;return function(){return e.apply(t,n||arguments)}},stamp:function(){var e=0,t="_leaflet_id";return function(n){return n[t]=n[t]||++e,n[t]}}(),limitExecByInterval:function(e,t,n){var r,i;return function s(){var o=arguments;if(r){i=!0;return}r=!0,setTimeout(function(){r=!1,i&&(s.apply(n,o),i=!1)},t),e.apply(n,o)}},falseFn:function(){return!1},formatNum:function(e,t){var n=Math.pow(10,t||5);return Math.round(e*n)/n},splitWords:function(e){return e.replace(/^\s+|\s+$/g,"").split(/\s+/)},setOptions:function(e,t){return e.options=n.Util.extend({},e.options,t),e.options},getParamString:function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n+"="+e[n]);return"?"+t.join("&")},template:function(e,t){return e.replace(/\{ *([\w_]+) *\}/g,function(e,n){var r=t[n];if(!t.hasOwnProperty(n))throw Error("No value provided for variable "+e);return r})},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},function(){function t(t){var n,r,i=["webkit","moz","o","ms"];for(n=0;n0},removeEventListener:function(e,t,r){var s=this[i],o,u,a,f,l;if(typeof e=="object"){for(o in e)e.hasOwnProperty(o)&&this.removeEventListener(o,e[o],t);return this}e=n.Util.splitWords(e);for(u=0,a=e.length;u=0;l--)(!t||f[l].action===t)&&(!r||f[l].context===r)&&f.splice(l,1)}return this},fireEvent:function(e,t){if(!this.hasEventListeners(e))return this;var r=n.Util.extend({type:e,target:this},t),s=this[i][e].slice();for(var o=0,u=s.length;o1||"matchMedia"in e&&e.matchMedia("(min-resolution:144dpi)").matches,d=document.documentElement,v=r&&"transition"in d.style,m="WebKitCSSMatrix"in e&&"m11"in new e.WebKitCSSMatrix,g="MozPerspective"in d.style,y="OTransition"in d.style,b=!e.L_DISABLE_3D&&(v||m||g||y),w=!e.L_NO_TOUCH&&function(){var e="ontouchstart";if(h||e in d)return!0;var t=document.createElement("div"),n=!1;return t.setAttribute?(t.setAttribute(e,"return;"),typeof t[e]=="function"&&(n=!0),t.removeAttribute(e),t=null,n):!1}();n.Browser={ie6:i,ie7:s,webkit:u,android:f,android23:l,chrome:a,ie3d:v,webkit3d:m,gecko3d:g,opera3d:y,any3d:b,mobile:c,mobileWebkit:c&&u,mobileWebkit3d:c&&m,mobileOpera:c&&e.opera,touch:w,msTouch:h,retina:p}}(),n.Point=function(e,t,n){this.x=n?Math.round(e):e,this.y=n?Math.round(t):t},n.Point.prototype={clone:function(){return new n.Point(this.x,this.y)},add:function(e){return this.clone()._add(n.point(e))},_add:function(e){return this.x+=e.x,this.y+=e.y,this},subtract:function(e){return this.clone()._subtract(n.point(e))},_subtract:function(e){return this.x-=e.x,this.y-=e.y,this},divideBy:function(e){return this.clone()._divideBy(e)},_divideBy:function(e){return this.x/=e,this.y/=e,this},multiplyBy:function(e){return this.clone()._multiplyBy(e)},_multiplyBy:function(e){return this.x*=e,this.y*=e,this},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},distanceTo:function(e){e=n.point(e);var t=e.x-this.x,r=e.y-this.y;return Math.sqrt(t*t+r*r)},toString:function(){return"Point("+n.Util.formatNum(this.x)+", "+n.Util.formatNum(this.y)+")"}},n.point=function(e,t,r){return e instanceof n.Point?e:e instanceof Array?new n.Point(e[0],e[1]):isNaN(e)?e:new n.Point(e,t,r)},n.Bounds=n.Class.extend({initialize:function(e,t){if(!e)return;var n=t?[e,t]:e;for(var r=0,i=n.length;r=this.min.x&&r.x<=this.max.x&&t.y>=this.min.y&&r.y<=this.max.y},intersects:function(e){e=n.bounds(e);var t=this.min,r=this.max,i=e.min,s=e.max,o=s.x>=t.x&&i.x<=r.x,u=s.y>=t.y&&i.y<=r.y;return o&&u},isValid:function(){return!!this.min&&!!this.max}}),n.bounds=function(e,t){return!e||e instanceof n.Bounds?e:new n.Bounds(e,t)},n.Transformation=n.Class.extend({initialize:function(e,t,n,r){this._a=e,this._b=t,this._c=n,this._d=r},transform:function(e,t){return this._transform(e.clone(),t)},_transform:function(e,t){return t=t||1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e},untransform:function(e,t){return t=t||1,new n.Point((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}}),n.DomUtil={get:function(e){return typeof e=="string"?document.getElementById(e):e},getStyle:function(e,t){var n=e.style[t];!n&&e.currentStyle&&(n=e.currentStyle[t]);if((!n||n==="auto")&&document.defaultView){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n==="auto"?null:n},getViewportOffset:function(e){var t=0,r=0,i=e,s=document.body,o,u=n.Browser.ie7;do{t+=i.offsetTop||0,r+=i.offsetLeft||0,o=n.DomUtil.getStyle(i,"position");if(i.offsetParent===s&&o==="absolute")break;if(o==="fixed"){t+=s.scrollTop||0,r+=s.scrollLeft||0;break}i=i.offsetParent}while(i);i=e;do{if(i===s)break;t-=i.scrollTop||0,r-=i.scrollLeft||0,!n.DomUtil.documentIsLtr()&&(n.Browser.webkit||u)&&(r+=i.scrollWidth-i.clientWidth,u&&n.DomUtil.getStyle(i,"overflow-y")!=="hidden"&&n.DomUtil.getStyle(i,"overflow")!=="hidden"&&(r+=17)),i=i.parentNode}while(i);return new n.Point(r,t)},documentIsLtr:function(){return n.DomUtil._docIsLtrCached||(n.DomUtil._docIsLtrCached=!0,n.DomUtil._docIsLtr=n.DomUtil.getStyle(document.body,"direction")==="ltr"),n.DomUtil._docIsLtr},create:function(e,t,n){var r=document.createElement(e);return r.className=t,n&&n.appendChild(r),r},disableTextSelection:function(){document.selection&&document.selection.empty&&document.selection.empty(),this._onselectstart||(this._onselectstart=document.onselectstart,document.onselectstart=n.Util.falseFn)},enableTextSelection:function(){document.onselectstart===n.Util.falseFn&&(document.onselectstart=this._onselectstart,this._onselectstart=null)},hasClass:function(e,t){return e.className.length>0&&RegExp("(^|\\s)"+t+"(\\s|$)").test(e.className)},addClass:function(e,t){n.DomUtil.hasClass(e,t)||(e.className+=(e.className?" ":"")+t)},removeClass:function(e,t){function n(e,n){return n===t?"":e}e.className=e.className.replace(/(\S+)\s*/g,n).replace(/(^\s+|\s+$)/,"")},setOpacity:function(e,t){if("opacity"in e.style)e.style.opacity=t;else if("filter"in e.style){var n=!1,r="DXImageTransform.Microsoft.Alpha";try{n=e.filters.item(r)}catch(i){}t=Math.round(t*100),n?(n.Enabled=t!==100,n.Opacity=t):e.style.filter+=" progid:"+r+"(opacity="+t+")"}},testProp:function(e){var t=document.documentElement.style;for(var n=0;n=t.lat&&s.lat<=r.lat&&i.lng>=t.lng&&s.lng<=r.lng},intersects:function(e){e=n.latLngBounds(e);var t=this._southWest,r=this._northEast,i=e.getSouthWest(),s=e.getNorthEast(),o=s.lat>=t.lat&&i.lat<=r.lat,u=s.lng>=t.lng&&i.lng<=r.lng;return o&&u},toBBoxString:function(){var e=this._southWest,t=this._northEast;return[e.lng,e.lat,t.lng,t.lat].join(",")},equals:function(e){return e?(e=n.latLngBounds(e),this._southWest.equals(e.getSouthWest())&&this._northEast.equals(e.getNorthEast())):!1},isValid:function(){return!!this._southWest&&!!this._northEast}}),n.latLngBounds=function(e,t){return!e||e instanceof n.LatLngBounds?e:new n.LatLngBounds(e,t)},n.Projection={},n.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(e){var t=n.LatLng.DEG_TO_RAD,r=this.MAX_LATITUDE,i=Math.max(Math.min(r,e.lat),-r),s=e.lng*t,o=i*t;return o=Math.log(Math.tan(Math.PI/4+o/2)),new n.Point(s,o)},unproject:function(e){var t=n.LatLng.RAD_TO_DEG,r=e.x*t,i=(2*Math.atan(Math.exp(e.y))-Math.PI/2)*t;return new n.LatLng(i,r,!0)}},n.Projection.LonLat={project:function(e){return new n.Point(e.lng,e.lat)},unproject:function(e){return new n.LatLng(e.y,e.x,!0)}},n.CRS={latLngToPoint:function(e,t){var n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)},pointToLatLng:function(e,t){var n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)},project:function(e){return this.projection.project(e)},scale:function(e){return 256*Math.pow(2,e)}},n.CRS.Simple=n.Util.extend({},n.CRS,{projection:n.Projection.LonLat,transformation:new n.Transformation(1,0,1,0)}),n.CRS.EPSG3857=n.Util.extend({},n.CRS,{code:"EPSG:3857",projection:n.Projection.SphericalMercator,transformation:new n.Transformation(.5/Math.PI,.5,-0.5/Math.PI,.5),project:function(e){var t=this.projection.project(e),n=6378137;return t.multiplyBy(n)}}),n.CRS.EPSG900913=n.Util.extend({},n.CRS.EPSG3857,{code:"EPSG:900913"}),n.CRS.EPSG4326=n.Util.extend({},n.CRS,{code:"EPSG:4326",projection:n.Projection.LonLat,transformation:new n.Transformation(1/360,.5,-1/360,.5)}),n.Map=n.Class.extend({includes:n.Mixin.Events,options:{crs:n.CRS.EPSG3857,fadeAnimation:n.DomUtil.TRANSITION&&!n.Browser.android23,trackResize:!0,markerZoomAnimation:n.DomUtil.TRANSITION&&n.Browser.any3d},initialize:function(e,r){r=n.Util.setOptions(this,r),this._initContainer(e),this._initLayout(),this._initHooks(),this._initEvents(),r.maxBounds&&this.setMaxBounds(r.maxBounds),r.center&&r.zoom!==t&&this.setView(n.latLng(r.center),r.zoom,!0),this._initLayers(r.layers)},setView:function(e,t){return this._resetView(n.latLng(e),this._limitZoom(t)),this},setZoom:function(e){return this.setView(this.getCenter(),e)},zoomIn:function(e){return this.setZoom(this._zoom+(e||1))},zoomOut:function(e){return this.setZoom(this._zoom-(e||1))},fitBounds:function(e){var t=this.getBoundsZoom(e);return this.setView(n.latLngBounds(e).getCenter(),t)},fitWorld:function(){var e=new n.LatLng(-60,-170),t=new n.LatLng(85,179);return this.fitBounds(new n.LatLngBounds(e,t))},panTo:function(e){return this.setView(e,this._zoom)},panBy:function(e){return this.fire("movestart"),this._rawPanBy(n.point(e)),this.fire("move"),this.fire("moveend")},setMaxBounds:function(e){e=n.latLngBounds(e),this.options.maxBounds=e;if(!e)return this._boundsMinZoom=null,this;var t=this.getBoundsZoom(e,!0);return this._boundsMinZoom=t,this._loaded&&(this._zoomo.x&&(u=o.x-i.x),r.y>s.y&&(a=s.y-r.y),r.xc&&--h>0)d=u*Math.sin(f),p=Math.PI/2-2*Math.atan(a*Math.pow((1-d)/(1+d),.5*u))-f,f+=p;return new n.LatLng(f*t,s,!0)}},n.CRS.EPSG3395=n.Util.extend({},n.CRS,{code:"EPSG:3395",projection:n.Projection.Mercator,transformation:function(){var e=n.Projection.Mercator,t=e.R_MAJOR,r=e.R_MINOR;return new n.Transformation(.5/(Math.PI*t),.5,-0.5/(Math.PI*r),.5)}()}),n.TileLayer=n.Class.extend({includes:n.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:n.Browser.mobile,updateWhenIdle:n.Browser.mobile},initialize:function(e,t){t=n.Util.setOptions(this,t),t.detectRetina&&n.Browser.retina&&t.maxZoom>0&&(t.tileSize=Math.floor(t.tileSize/2),t.zoomOffset++,t.minZoom>0&&t.minZoom--,this.options.maxZoom--),this._url=e;var r=this.options.subdomains;typeof r=="string"&&(this.options.subdomains=r.split(""))},onAdd:function(e){this._map=e,this._initContainer(),this._createTileProto(),e.on({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||(this._limitedUpdate=n.Util.limitExecByInterval(this._update,150,this),e.on("move",this._limitedUpdate,this)),this._reset(),this._update()},addTo:function(e){return e.addLayer(this),this},onRemove:function(e){e._panes.tilePane.removeChild(this._container),e.off({viewreset:this._resetCallback,moveend:this._update},this),this.options.updateWhenIdle||e.off("move",this._limitedUpdate,this),this._container=null,this._map=null},bringToFront:function(){var e=this._map._panes.tilePane;return this._container&&(e.appendChild(this._container),this._setAutoZIndex(e,Math.max)),this},bringToBack:function(){var e=this._map._panes.tilePane;return this._container&&(e.insertBefore(this._container,e.firstChild),this._setAutoZIndex(e,Math.min)),this},getAttribution:function(){return this.options.attribution},setOpacity:function(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},setUrl:function(e,t){return this._url=e,t||this.redraw(),this},redraw:function(){return this._map&&(this._map._panes.tilePane.empty=!1,this._reset(!0),this._update()),this},_updateZIndex:function(){this._container&&this.options.zIndex!==t&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(e,t){var n=e.getElementsByClassName("leaflet-layer"),r=-t(Infinity,-Infinity),i,s,o;for(s=0,o=n.length;sthis.options.maxZoom||r=t)||e.y<0||e.y>=t)return!1}return!0},_removeOtherTiles:function(e){var t,n,r,i;for(i in this._tiles)this._tiles.hasOwnProperty(i)&&(t=i.split(":"),n=parseInt(t[0],10),r=parseInt(t[1],10),(ne.max.x||re.max.y)&&this._removeTile(i))},_removeTile:function(e){var t=this._tiles[e];this.fire("tileunload",{tile:t,url:t.src}),this.options.reuseTiles?(n.DomUtil.removeClass(t,"leaflet-tile-loaded"),this._unusedTiles.push(t)):t.parentNode===this._container&&this._container.removeChild(t),n.Browser.android||(t.src=n.Util.emptyImageUrl),delete this._tiles[e]},_addTile:function(e,t){var r=this._getTilePos(e),i=this._getTile();n.DomUtil.setPosition(i,r,n.Browser.chrome||n.Browser.android23),this._tiles[e.x+":"+e.y]=i,this._loadTile(i,e),i.parentNode!==this._container&&t.appendChild(i)},_getZoomForUrl:function(){var e=this.options,t=this._map.getZoom();return e.zoomReverse&&(t=e.maxZoom-t),t+e.zoomOffset},_getTilePos:function(e){var t=this._map.getPixelOrigin(),n=this.options.tileSize;return e.multiplyBy(n).subtract(t)},getTileUrl:function(e){return this._adjustTilePoint(e),n.Util.template(this._url,n.Util.extend({s:this._getSubdomain(e),z:this._getZoomForUrl(),x:e.x,y:e.y},this.options))},_getWrapTileNum:function(){return Math.pow(2,this._getZoomForUrl())},_adjustTilePoint:function(e){var t=this._getWrapTileNum();!this.options.continuousWorld&&!this.options.noWrap&&(e.x=(e.x%t+t)%t),this.options.tms&&(e.y=t-e.y-1)},_getSubdomain:function(e){var t=(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]},_createTileProto:function(){var e=this._tileImg=n.DomUtil.create("img","leaflet-tile");e.style.width=e.style.height=this.options.tileSize+"px",e.galleryimg="no"},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var e=this._unusedTiles.pop();return this._resetTile(e),e}return this._createTile()},_resetTile:function(e){},_createTile:function(){var e=this._tileImg.cloneNode(!1);return e.onselectstart=e.onmousemove=n.Util.falseFn,e},_loadTile:function(e,t){e._layer=this,e.onload=this._tileOnLoad,e.onerror=this._tileOnError,e.src=this.getTileUrl(t)},_tileLoaded:function(){this._tilesToLoad--,this._tilesToLoad||this.fire("load")},_tileOnLoad:function(e){var t=this._layer;this.src!==n.Util.emptyImageUrl&&(n.DomUtil.addClass(this,"leaflet-tile-loaded"),t.fire("tileload",{tile:this,url:this.src})),t._tileLoaded()},_tileOnError:function(e){var t=this._layer;t.fire("tileerror",{tile:this,url:this.src});var n=t.options.errorTileUrl;n&&(this.src=n),t._tileLoaded()}}),n.tileLayer=function(e,t){return new n.TileLayer(e,t)},n.TileLayer.WMS=n.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(e,t){this._url=e;var r=n.Util.extend({},this.defaultWmsParams);t.detectRetina&&n.Browser.retina?r.width=r.height=this.options.tileSize*2:r.width=r.height=this.options.tileSize;for(var i in t)this.options.hasOwnProperty(i)||(r[i]=t[i]);this.wmsParams=r,n.Util.setOptions(this,t)},onAdd:function(e){var t=parseFloat(this.wmsParams.version)>=1.3?"crs":"srs";this.wmsParams[t]=e.options.crs.code,n.TileLayer.prototype.onAdd.call(this,e)},getTileUrl:function(e,t){var r=this._map,i=r.options.crs,s=this.options.tileSize,o=e.multiplyBy(s),u=o.add(new n.Point(s,s)),a=i.project(r.unproject(o,t)),f=i.project(r.unproject(u,t)),l=[a.x,f.y,f.x,a.y].join(","),c=n.Util.template(this._url,{s:this._getSubdomain(e)});return c+n.Util.getParamString(this.wmsParams)+"&bbox="+l},setParams:function(e,t){return n.Util.extend(this.wmsParams,e),t||this.redraw(),this}}),n.tileLayer.wms=function(e,t){return new n.TileLayer.WMS(e,t)},n.TileLayer.Canvas=n.TileLayer.extend({options:{async:!1},initialize:function(e){n.Util.setOptions(this,e)},redraw:function(){var e=this._tiles;for(var t in e)e.hasOwnProperty(t)&&this._redrawTile(e[t])},_redrawTile:function(e){this.drawTile(e,e._tilePoint,this._map._zoom)},_createTileProto:function(){var e=this._canvasProto=n.DomUtil.create("canvas","leaflet-tile");e.width=e.height=this.options.tileSize},_createTile:function(){var e=this._canvasProto.cloneNode(!1);return e.onselectstart=e.onmousemove=n.Util.falseFn,e},_loadTile:function(e,t){e._layer=this,e._tilePoint=t,this._redrawTile(e),this.options.async||this.tileDrawn(e)},drawTile:function(e,t){},tileDrawn:function(e){this._tileOnLoad.call(e)}}),n.tileLayer.canvas=function(e){return new n.TileLayer.Canvas(e)},n.ImageOverlay=n.Class.extend({includes:n.Mixin.Events,options:{opacity:1},initialize:function(e,t,r){this._url=e,this._bounds=n.latLngBounds(t),n.Util.setOptions(this,r)},onAdd:function(e){this._map=e,this._image||this._initImage(),e._panes.overlayPane.appendChild(this._image),e.on("viewreset",this._reset,this),e.options.zoomAnimation&&n.Browser.any3d&&e.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(e){e.getPanes().overlayPane.removeChild(this._image),e.off("viewreset",this._reset,this),e.options.zoomAnimation&&e.off("zoomanim",this._animateZoom,this)},addTo:function(e){return e.addLayer(this),this},setOpacity:function(e){return this.options.opacity=e,this._updateOpacity(),this},bringToFront:function(){return this._image&&this._map._panes.overlayPane.appendChild(this._image),this},bringToBack:function(){var e=this._map._panes.overlayPane;return this._image&&e.insertBefore(this._image,e.firstChild),this},_initImage:function(){this._image=n.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&n.Browser.any3d?n.DomUtil.addClass(this._image,"leaflet-zoom-animated"):n.DomUtil.addClass(this._image,"leaflet-zoom-hide"),this._updateOpacity(),n.Util.extend(this._image,{galleryimg:"no",onselectstart:n.Util.falseFn,onmousemove:n.Util.falseFn,onload:n.Util.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(e){var t=this._map,r=this._image,i=t.getZoomScale(e.zoom),s=this._bounds.getNorthWest(),o=this._bounds.getSouthEast(),u=t._latLngToNewLayerPoint(s,e.zoom,e.center),a=t._latLngToNewLayerPoint(o,e.zoom,e.center)._subtract(u),f=t.latLngToLayerPoint(o)._subtract(t.latLngToLayerPoint(s)),l=u._add(a._subtract(f)._divideBy(2));r.style[n.DomUtil.TRANSFORM]=n.DomUtil.getTranslateString(l)+" scale("+i+") "},_reset:function(){var e=this._image,t=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),r=this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(t);n.DomUtil.setPosition(e,t),e.style.width=r.x+"px",e.style.height=r.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){n.DomUtil.setOpacity(this._image,this.options.opacity)}}),n.imageOverlay=function(e,t,r){return new n.ImageOverlay(e,t,r)},n.Icon=n.Class.extend({options:{className:""},initialize:function(e){n.Util.setOptions(this,e)},createIcon:function(){return this._createIcon("icon")},createShadow:function(){return this._createIcon("shadow")},_createIcon:function(e){var t=this._getIconUrl(e);if(!t){if(e==="icon")throw Error("iconUrl not set in Icon options (see the docs).");return null}var n=this._createImg(t);return this._setIconStyles(n,e),n},_setIconStyles:function(e,t){var r=this.options,i=n.point(r[t+"Size"]),s;t==="shadow"?s=n.point(r.shadowAnchor||r.iconAnchor):s=n.point(r.iconAnchor),!s&&i&&(s=i.divideBy(2,!0)),e.className="leaflet-marker-"+t+" "+r.className,s&&(e.style.marginLeft=-s.x+"px",e.style.marginTop=-s.y+"px"),i&&(e.style.width=i.x+"px",e.style.height=i.y+"px")},_createImg:function(e){var t;return n.Browser.ie6?(t=document.createElement("div"),t.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+e+'")'):(t=document.createElement("img"),t.src=e),t},_getIconUrl:function(e){return this.options[e+"Url"]}}),n.icon=function(e){return new n.Icon(e)},n.Icon.Default=n.Icon.extend({options:{iconSize:new n.Point(25,41),iconAnchor:new n.Point(12,41),popupAnchor:new n.Point(1,-34),shadowSize:new n.Point(41,41)},_getIconUrl:function(e){var t=e+"Url";if(this.options[t])return this.options[t];var r=n.Icon.Default.imagePath;if(!r)throw Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");return r+"/marker-"+e+".png"}}),n.Icon.Default.imagePath=function(){var e=document.getElementsByTagName("script"),t=/\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/,n,r,i,s;for(n=0,r=e.length;ns?(t.height=s+"px",n.DomUtil.addClass(e,o)):n.DomUtil.removeClass(e,o),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){if(!this._map)return;var e=this._map.latLngToLayerPoint(this._latlng),t=n.Browser.any3d,r=this.options.offset;t&&n.DomUtil.setPosition(this._container,e),this._containerBottom=-r.y-(t?0:e.y),this._containerLeft=-Math.round(this._containerWidth/2)+r.x+(t?0:e.x),this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"},_zoomAnimation:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);n.DomUtil.setPosition(this._container,t)},_adjustPan:function(){if(!this.options.autoPan)return;var e=this._map,t=this._container.offsetHeight,r=this._containerWidth,i=new n.Point(this._containerLeft,-t-this._containerBottom);n.Browser.any3d&&i._add(n.DomUtil.getPosition(this._container));var s=e.layerPointToContainerPoint(i),o=this.options.autoPanPadding,u=e.getSize(),a=0,f=0;s.x<0&&(a=s.x-o.x),s.x+r>u.x&&(a=s.x+r-u.x+o.x),s.y<0&&(f=s.y-o.y),s.y+t>u.y&&(f=s.y+t-u.y+o.y),(a||f)&&e.panBy(new n.Point(a,f))},_onCloseButtonClick:function(e){this._close(),n.DomEvent.stop(e)}}),n.popup=function(e,t){return new n.Popup(e,t)},n.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(e,t){var r=n.point(this.options.icon.options.popupAnchor)||new n.Point(0,0);return r=r.add(n.Popup.prototype.options.offset),t&&t.offset&&(r=r.add(t.offset)),t=n.Util.extend({offset:r},t),this._popup||this.on("click",this.openPopup,this).on("remove",this.closePopup,this).on("move",this._movePopup,this),this._popup=(new n.Popup(t,this)).setContent(e),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.openPopup).off("remove",this.closePopup).off("move",this._movePopup)),this},_movePopup:function(e){this._popup.setLatLng(e.latlng)}}),n.Map.include({openPopup:function(e){return this.closePopup(),this._popup=e,this.addLayer(e).fire("popupopen",{popup:this._popup})},closePopup:function(){return this._popup&&this._popup._close(),this}}),n.LayerGroup=n.Class.extend({initialize:function(e){this._layers={};var t,n;if(e)for(t=0,n=e.length;t';var t=e.firstChild;return t.style.behavior="url(#default#VML)",t&&typeof t.adj=="object"}catch(n){return!1}}(),n.Path=n.Browser.svg||!n.Browser.vml?n.Path:n.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(e){return document.createElement("')}}catch(e){return function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var e=this._container=this._createElement("shape");n.DomUtil.addClass(e,"leaflet-vml-shape"),this.options.clickable&&n.DomUtil.addClass(e,"leaflet-clickable"),e.coordsize="1 1",this._path=this._createElement("path"),e.appendChild(this._path),this._map._pathRoot.appendChild(e)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var e=this._stroke,t=this._fill,n=this.options,r=this._container;r.stroked=n.stroke,r.filled=n.fill,n.stroke?(e||(e=this._stroke=this._createElement("stroke"),e.endcap="round",r.appendChild(e)),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=n.dashArray.replace(/ *, */g," "):e.dashStyle=""):e&&(r.removeChild(e),this._stroke=null),n.fill?(t||(t=this._fill=this._createElement("fill"),r.appendChild(t)),t.color=n.fillColor||n.color,t.opacity=n.fillOpacity):t&&(r.removeChild(t),this._fill=null)},_updatePath:function(){var e=this._container.style;e.display="none",this._path.v=this.getPathString()+" ",e.display=""}}),n.Map.include(n.Browser.svg||!n.Browser.vml?{}:{_initPathRoot:function(){if(this._pathRoot)return;var e=this._pathRoot=document.createElement("div");e.className="leaflet-vml-container",this._panes.overlayPane.appendChild(e),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}),n.Browser.canvas=function(){return!!document.createElement("canvas").getContext}(),n.Path=n.Path.SVG&&!e.L_PREFER_CANVAS||!n.Browser.canvas?n.Path:n.Path.extend({statics:{CANVAS:!0,SVG:!1},redraw:function(){return this._map&&(this.projectLatlngs(),this._requestUpdate()),this},setStyle:function(e){return n.Util.setOptions(this,e),this._map&&(this._updateStyle(),this._requestUpdate()),this},onRemove:function(e){e.off("viewreset",this.projectLatlngs,this).off("moveend",this._updatePath,this),this._requestUpdate(),this._map=null},_requestUpdate:function(){this._map&&!n.Path._updateRequest&&(n.Path._updateRequest=n.Util.requestAnimFrame(this._fireMapMoveEnd,this._map))},_fireMapMoveEnd:function(){n.Path._updateRequest=null,this.fire("moveend")},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var e=this.options;e.stroke&&(this._ctx.lineWidth=e.weight,this._ctx.strokeStyle=e.color),e.fill&&(this._ctx.fillStyle=e.fillColor||e.color)},_drawPath:function(){var e,t,r,i,s,o;this._ctx.beginPath();for(e=0,r=this._parts.length;es&&(o=u,s=a);s>n&&(t[o]=1,this._simplifyDPStep(e,t,n,r,o),this._simplifyDPStep(e,t,n,o,i))},_reducePoints:function(e,t){var n=[e[0]];for(var r=1,i=0,s=e.length;rt&&(n.push(e[r]),i=r);return it.max.x&&(n|=2),e.yt.max.y&&(n|=8),n},_sqDist:function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},_sqClosestPointOnSegment:function(e,t,r,i){var s=t.x,o=t.y,u=r.x-s,a=r.y-o,f=u*u+a*a,l;return f>0&&(l=((e.x-s)*u+(e.y-o)*a)/f,l>1?(s=r.x,o=r.y):l>0&&(s+=u*l,o+=a*l)),u=e.x-s,a=e.y-o,i?u*u+a*a:new n.Point(s,o)}},n.Polyline=n.Path.extend({initialize:function(e,t){n.Path.prototype.initialize.call(this,t),this._latlngs=this._convertLatLngs(e),n.Handler.PolyEdit&&(this.editing=new n.Handler.PolyEdit(this),this.options.editable&&this.editing.enable())},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var e=0,t=this._latlngs.length;ee.max.x||n.y-t>e.max.y||n.x+te.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(t=!t)}return t}}:{}),n.Circle.include(n.Path.CANVAS?{_drawPath:function(){var e=this._point;this._ctx.beginPath(),this._ctx.arc(e.x,e.y,this._radius,0,Math.PI*2,!1)},_containsPoint:function(e){var t=this._point,n=this.options.stroke?this.options.weight/2:0;return e.distanceTo(t)<=this._radius+n}}:{}),n.GeoJSON=n.FeatureGroup.extend({initialize:function(e,t){n.Util.setOptions(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t=e instanceof Array?e:e.features,r,i;if(t){for(r=0,i=t.length;r1){this._simulateClick=!1,clearTimeout(this._longPressTimeout);return}var t=e.touches&&e.touches.length===1?e.touches[0]:e,r=t.target;n.Browser.touch&&r.tagName.toLowerCase()==="a"&&n.DomUtil.addClass(r,"leaflet-active"),this._moved=!1;if(this._moving)return;this._startPoint=new n.Point(t.clientX,t.clientY),this._startPos=this._newPos=n.DomUtil.getPosition(this._element),e.touches&&e.touches.length===1&&n.Browser.touch&&this._longPress&&(this._longPressTimeout=setTimeout(n.Util.bind(function(){var e=this._newPos&&this._newPos.distanceTo(this._startPos)||0;e1)return;var t=e.touches&&e.touches.length===1?e.touches[0]:e,r=new n.Point(t.clientX,t.clientY),i=r.subtract(this._startPoint);if(!i.x&&!i.y)return;n.DomEvent.preventDefault(e),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=n.DomUtil.getPosition(this._element).subtract(i),n.Browser.touch||(n.DomUtil.disableTextSelection(),this._setMovingCursor())),this._newPos=this._startPos.add(i),this._moving=!0,n.Util.cancelAnimFrame(this._animRequest),this._animRequest=n.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)},_updatePosition:function(){this.fire("predrag"),n.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(e){var t;clearTimeout(this._longPressTimeout);if(this._simulateClick&&e.changedTouches){var r=e.changedTouches[0],i=r.target,s=this._newPos&&this._newPos.distanceTo(this._startPos)||0;i.tagName.toLowerCase()==="a"&&n.DomUtil.removeClass(i,"leaflet-active"),s200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var e=this._map.getSize()._divideBy(2),t=this._map.latLngToLayerPoint(new n.LatLng(0,0));this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.project(new n.LatLng(0,180)).x},_onPreDrag:function(){var e=this._map,t=this._worldWidth,n=Math.round(t/2),r=this._initialWorldOffset,i=this._draggable._newPos.x,s=(i-n+r)%t+n-r,o=(i+n+r)%t-n-r,u=Math.abs(s+r)t.inertiaThreshold||!this._positions[0];if(i)e.fire("moveend");else{var s=this._lastPos.subtract(this._positions[0]),o=(this._lastTime+r-this._times[0])/1e3,u=s.multiplyBy(.58/o),a=u.distanceTo(new n.Point(0,0)),f=Math.min(t.inertiaMaxSpeed,a),l=u.multiplyBy(f/a),c=f/t.inertiaDeceleration,h=l.multiplyBy(-c/2).round();n.Util.requestAnimFrame(function(){e.panBy(h,c)})}e.fire("dragend"),t.maxBounds&&n.Util.requestAnimFrame(this._panInsideMaxBounds,e,!0,e._container)},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)}}),n.Map.addInitHook("addHandler","dragging",n.Map.Drag),n.Map.mergeOptions({doubleClickZoom:!0}),n.Map.DoubleClickZoom=n.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick)},_onDoubleClick:function(e){this.setView(e.latlng,this._zoom+1)}}),n.Map.addInitHook("addHandler","doubleClickZoom",n.Map.DoubleClickZoom),n.Map.mergeOptions({scrollWheelZoom:!n.Browser.touch||n.Browser.msTouch}),n.Map.ScrollWheelZoom=n.Handler.extend({addHooks:function(){n.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){n.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll)},_onWheelScroll:function(e){var t=n.DomEvent.getWheelDelta(e);this._delta+=t,this._lastMousePos=this._map.mouseEventToContainerPoint(e),this._startTime||(this._startTime=+(new Date));var r=Math.max(40-(+(new Date)-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(n.Util.bind(this._performZoom,this),r),n.DomEvent.preventDefault(e),n.DomEvent.stopPropagation(e)},_performZoom:function(){var e=this._map,t=Math.round(this._delta),n=e.getZoom();t=Math.max(Math.min(t,4),-4),t=e._limitZoom(n+t)-n,this._delta=0,this._startTime=null;if(!t)return;var r=n+t,i=this._getCenterForScrollWheelZoom(r);e.setView(i,r)},_getCenterForScrollWheelZoom:function(e){var t=this._map,n=t.getZoomScale(e),r=t.getSize()._divideBy(2),i=this._lastMousePos._subtract(r)._multiplyBy(1-1/n),s=t._getTopLeftPoint()._add(r)._add(i);return t.unproject(s)}}),n.Map.addInitHook("addHandler","scrollWheelZoom",n.Map.ScrollWheelZoom),n.Util.extend(n.DomEvent,{_touchstart:n.Browser.msTouch?"MSPointerDown":"touchstart",_touchend:n.Browser.msTouch?"MSPointerUp":"touchend",addDoubleTapListener:function(e,t,r){function h(e){var t;n.Browser.msTouch?(c.push(e.pointerId),t=c.length):t=e.touches.length;if(t>1)return;var r=Date.now(),a=r-(i||r);u=e.touches?e.touches[0]:e,s=a>0&&a<=o,i=r}function p(e){if(n.Browser.msTouch){var r=c.indexOf(e.pointerId);if(r===-1)return;c.splice(r,1)}if(s){if(n.Browser.msTouch){var o={},a;for(var f in u)a=u[f],typeof a=="function"?o[f]=a.bind(u):o[f]=a;u=o}u.type="dblclick",t(u),i=null}}var i,s=!1,o=250,u,a="_leaflet_",f=this._touchstart,l=this._touchend,c=[];e[a+f+r]=h,e[a+l+r]=p;var d=n.Browser.msTouch?document.documentElement:e;return e.addEventListener(f,h,!1),d.addEventListener(l,p,!1),n.Browser.msTouch&&d.addEventListener("MSPointerCancel",p,!1),this},removeDoubleTapListener:function(e,t){var r="_leaflet_";return e.removeEventListener(this._touchstart,e[r+this._touchstart+t],!1),(n.Browser.msTouch?document.documentElement:e).removeEventListener(this._touchend,e[r+this._touchend+t],!1),n.Browser.msTouch&&document.documentElement.removeEventListener("MSPointerCancel",e[r+this._touchend+t],!1),this}}),n.Util.extend(n.DomEvent,{_msTouches:[],_msDocumentListener:!1,addMsTouchListener:function(e,t,n,r){switch(t){case"touchstart":return this.addMsTouchListenerStart(e,t,n,r);case"touchend":return this.addMsTouchListenerEnd(e,t,n,r);case"touchmove":return this.addMsTouchListenerMove(e,t,n,r);default:throw"Unknown touch event type"}},addMsTouchListenerStart:function(e,t,n,r){var i="_leaflet_",s=this._msTouches,o=function(e){var t=!1;for(var r=0;r0?Math.ceil(o):Math.floor(o),a=t._limitZoom(s+u);t.fire("zoomanim",{center:i,zoom:a}),t._runAnimation(i,a,t.getZoomScale(a)/this._scale,r,!0)},_getScaleOrigin:function(){var e=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(e)}}),n.Map.addInitHook("addHandler","touchZoom",n.Map.TouchZoom),n.Map.mergeOptions({boxZoom:!0}),n.Map.BoxZoom=n.Handler.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane},addHooks:function(){n.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){n.DomEvent.off(this._container,"mousedown",this._onMouseDown)},_onMouseDown:function(e){if(!e.shiftKey||e.which!==1&&e.button!==1)return!1;n.DomUtil.disableTextSelection(),this._startLayerPoint=this._map.mouseEventToLayerPoint(e),this._box=n.DomUtil.create("div","leaflet-zoom-box",this._pane),n.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",n.DomEvent.on(document,"mousemove",this._onMouseMove,this).on(document,"mouseup",this._onMouseUp,this).preventDefault(e),this._map.fire("boxzoomstart")},_onMouseMove:function(e){var t=this._startLayerPoint,r=this._box,i=this._map.mouseEventToLayerPoint(e),s=i.subtract(t),o=new n.Point(Math.min(i.x,t.x),Math.min(i.y,t.y));n.DomUtil.setPosition(r,o),r.style.width=Math.max(0,Math.abs(s.x)-4)+"px",r.style.height=Math.max(0,Math.abs(s.y)-4)+"px"},_onMouseUp:function(e){this._pane.removeChild(this._box),this._container.style.cursor="",n.DomUtil.enableTextSelection(),n.DomEvent.off(document,"mousemove",this._onMouseMove).off(document,"mouseup",this._onMouseUp);var t=this._map,r=t.mouseEventToLayerPoint(e),i=new n.LatLngBounds(t.layerPointToLatLng(this._startLayerPoint),t.layerPointToLatLng(r));t.fitBounds(i),t.fire("boxzoomend",{boxZoomBounds:i})}}),n.Map.addInitHook("addHandler","boxZoom",n.Map.BoxZoom),n.Map.mergeOptions({keyboard:!0,keyboardPanOffset:80,keyboardZoomOffset:1}),n.Map.Keyboard=n.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61],zoomOut:[189,109]},initialize:function(e){this._map=e,this._setPanOffset(e.options.keyboardPanOffset),this._setZoomOffset(e.options.keyboardZoomOffset)},addHooks:function(){var e=this._map._container;e.tabIndex===-1&&(e.tabIndex="0"),n.DomEvent.addListener(e,"focus",this._onFocus,this).addListener(e,"blur",this._onBlur,this).addListener(e,"mousedown",this._onMouseDown,this),this._map.on("focus",this._addHooks,this).on("blur",this._removeHooks,this)},removeHooks:function(){this._removeHooks();var e=this._map._container;n.DomEvent.removeListener(e,"focus",this._onFocus,this).removeListener(e,"blur",this._onBlur,this).removeListener(e,"mousedown",this._onMouseDown,this),this._map.off("focus",this._addHooks,this).off("blur",this._removeHooks,this)},_onMouseDown:function(){this._focused||this._map._container.focus()},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanOffset:function(e){var t=this._panKeys={},n=this.keyCodes,r,i;for(r=0,i=n.left.length;re&&(n._index+=t)})},_createMiddleMarker:function(e,t){var n=this._getMiddleLatLng(e,t),r=this._createMarker(n),i,s,o;r.setOpacity(.6),e._middleRight=t._middleLeft=r,s=function(){var s=t._index;r._index=s,r.off("click",i).on("click",this._onMarkerClick,this),n.lat=r.getLatLng().lat,n.lng=r.getLatLng().lng,this._poly.spliceLatLngs(s,0,n),this._markers.splice(s,0,r),r.setOpacity(1),this._updateIndexes(s,1),t._index++,this._updatePrevNext(e,r),this._updatePrevNext(r,t)},o=function(){r.off("dragstart",s,this),r.off("dragend",o,this),this._createMiddleMarker(e,r),this._createMiddleMarker(r,t)},i=function(){s.call(this),o.call(this),this._poly.fire("edit")},r.on("click",i,this).on("dragstart",s,this).on("dragend",o,this),this._markerGroup.addLayer(r)},_updatePrevNext:function(e,t){e&&(e._next=t),t&&(t._prev=e)},_getMiddleLatLng:function(e,t){var n=this._poly._map,r=n.latLngToLayerPoint(e.getLatLng()),i=n.latLngToLayerPoint(t.getLatLng());return n.layerPointToLatLng(r._add(i)._divideBy(2))}}),n.Control=n.Class.extend({options:{position:"topright"},initialize:function(e){n.Util.setOptions(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},addTo:function(e){this._map=e;var t=this._container=this.onAdd(e),r=this.getPosition(),i=e._controlCorners[r];return n.DomUtil.addClass(t,"leaflet-control"),r.indexOf("bottom")!==-1?i.insertBefore(t,i.firstChild):i.appendChild(t),this},removeFrom:function(e){var t=this.getPosition(),n=e._controlCorners[t];return n.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(e),this}}),n.control=function(e){return new n.Control(e)},n.Map.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.removeFrom(this),this},_initControlPos:function(){function i(i,s){var o=t+i+" "+t+s;e[i+s]=n.DomUtil.create("div",o,r)}var e=this._controlCorners={},t="leaflet-",r=this._controlContainer=n.DomUtil.create("div",t+"control-container",this._container);i("top","left"),i("top","right"),i("bottom","left"),i("bottom","right")}}),n.Control.Zoom=n.Control.extend({options:{position:"topleft"},onAdd:function(e){var t="leaflet-control-zoom",r=n.DomUtil.create("div",t);return this._map=e,this._createButton("Zoom in",t+"-in",r,this._zoomIn,this),this._createButton("Zoom out",t+"-out",r,this._zoomOut,this),r},_zoomIn:function(e){this._map.zoomIn(e.shiftKey?3:1)},_zoomOut:function(e){this._map.zoomOut(e.shiftKey?3:1)},_createButton:function(e,t,r,i,s){var o=n.DomUtil.create("a",t,r);return o.href="#",o.title=e,n.DomEvent.on(o,"click",n.DomEvent.stopPropagation).on(o,"mousedown",n.DomEvent.stopPropagation).on(o,"dblclick",n.DomEvent.stopPropagation).on(o,"click",n.DomEvent.preventDefault).on(o,"click",i,s),o}}),n.Map.mergeOptions({zoomControl:!0}),n.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new n.Control.Zoom,this.addControl(this.zoomControl))}),n.control.zoom=function(e){return new n.Control.Zoom(e)},n.Control.Attribution=n.Control.extend({options:{position:"bottomright",prefix:'Powered by Leaflet'},initialize:function(e){n.Util.setOptions(this,e),this._attributions={}},onAdd:function(e){return this._container=n.DomUtil.create("div","leaflet-control-attribution"),n.DomEvent.disableClickPropagation(this._container),e.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this),this._update(),this._container},onRemove:function(e){e.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){if(!e)return;return this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update(),this},removeAttribution:function(e){if(!e)return;return this._attributions[e]--,this._update(),this},_update:function(){if(!this._map)return;var e=[];for(var t in this._attributions)this._attributions.hasOwnProperty(t)&&this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(", ")),this._container.innerHTML=n.join(" — ")},_onLayerAdd:function(e){e.layer.getAttribution&&this.addAttribution(e.layer.getAttribution())},_onLayerRemove:function(e){e.layer.getAttribution&&this.removeAttribution(e.layer.getAttribution())}}),n.Map.mergeOptions({attributionControl:!0}),n.Map.addInitHook(function(){this.options.attributionControl&&(this.attributionControl=(new n.Control.Attribution).addTo(this))}),n.control.attribution=function(e){return new n.Control.Attribution(e)},n.Control.Scale=n.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(e){this._map=e;var t="leaflet-control-scale",r=n.DomUtil.create("div",t),i=this.options;return this._addScales(i,t,r),e.on(i.updateWhenIdle?"moveend":"move",this._update,this),e.whenReady(this._update,this),r},onRemove:function(e){e.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(e,t,r){e.metric&&(this._mScale=n.DomUtil.create("div",t+"-line",r)),e.imperial&&(this._iScale=n.DomUtil.create("div",t+"-line",r))},_update:function(){var e=this._map.getBounds(),t=e.getCenter().lat,n=6378137*Math.PI*Math.cos(t*Math.PI/180),r=n*(e.getNorthEast().lng-e.getSouthWest().lng)/180,i=this._map.getSize(),s=this.options,o=0;i.x>0&&(o=r*(s.maxWidth/i.x)),this._updateScales(s,o)},_updateScales:function(e,t){e.metric&&t&&this._updateMetric(t),e.imperial&&t&&this._updateImperial(t)},_updateMetric:function(e){var t=this._getRoundNum(e);this._mScale.style.width=this._getScaleWidth(t/e)+"px",this._mScale.innerHTML=t<1e3?t+" m":t/1e3+" km"},_updateImperial:function(e){var t=e*3.2808399,n=this._iScale,r,i,s;t>5280?(r=t/5280,i=this._getRoundNum(r),n.style.width=this._getScaleWidth(i/r)+"px",n.innerHTML=i+" mi"):(s=this._getRoundNum(t),n.style.width=this._getScaleWidth(s/t)+"px",n.innerHTML=s+" ft")},_getScaleWidth:function(e){return Math.round(this.options.maxWidth*e)-10},_getRoundNum:function(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}}),n.control.scale=function(e){return new n.Control.Scale(e)},n.Control.Layers=n.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0},initialize:function(e,t,r){n.Util.setOptions(this,r),this._layers={},this._lastZIndex=0;for(var i in e)e.hasOwnProperty(i)&&this._addLayer(e[i],i);for(i in t)t.hasOwnProperty(i)&&this._addLayer(t[i],i,!0)},onAdd:function(e){return this._initLayout(),this._update(),this._container},addBaseLayer:function(e,t){return this._addLayer(e,t),this._update(),this},addOverlay:function(e,t){return this._addLayer(e,t,!0),this._update(),this},removeLayer:function(e){var t=n.Util.stamp(e);return delete this._layers[t],this._update(),this},_initLayout:function(){var e="leaflet-control-layers",t=this._container=n.DomUtil.create("div",e);n.Browser.touch?n.DomEvent.on(t,"click",n.DomEvent.stopPropagation):n.DomEvent.disableClickPropagation(t);var r=this._form=n.DomUtil.create("form",e+"-list");if(this.options.collapsed){n.DomEvent.on(t,"mouseover",this._expand,this).on(t,"mouseout",this._collapse,this);var i=this._layersLink=n.DomUtil.create("a",e+"-toggle",t);i.href="#",i.title="Layers",n.Browser.touch?n.DomEvent.on(i,"click",n.DomEvent.stopPropagation).on(i,"click",n.DomEvent.preventDefault).on(i,"click",this._expand,this):n.DomEvent.on(i,"focus",this._expand,this),this._map.on("movestart",this._collapse,this)}else this._expand();this._baseLayersList=n.DomUtil.create("div",e+"-base",r),this._separator=n.DomUtil.create("div",e+"-separator",r),this._overlaysList=n.DomUtil.create("div",e+"-overlays",r),t.appendChild(r)},_addLayer:function(e,t,r){var i=n.Util.stamp(e);this._layers[i]={layer:e,name:t,overlay:r},this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex))},_update:function(){if(!this._container)return;this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var e=!1,t=!1;for(var n in this._layers)if(this._layers.hasOwnProperty(n)){var r=this._layers[n];this._addItem(r),t=t||r.overlay,e=e||!r.overlay}this._separator.style.display=t&&e?"":"none"},_createRadioElement:function(e,t){var n='.5&&this._getLoadedTilesPercentage(e)<.5){e.style.visibility="hidden",e.empty=!0,this._stopLoadingImages(e);return}t||(t=this._tileBg=this._createPane("leaflet-tile-pane",this._mapPane),t.style.zIndex=1),t.style[n.DomUtil.TRANSFORM]="",t.style.visibility="hidden",t.empty=!0,e.empty=!1,this._tilePane=this._panes.tilePane=t;var r=this._tileBg=e;n.DomUtil.addClass(r,"leaflet-zoom-animated"),this._stopLoadingImages(r)},_getLoadedTilesPercentage:function(e){var t=e.getElementsByTagName("img"),n,r,i=0;for(n=0,r=t.length;n 1) || - ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches)), + ('matchMedia' in window && window.matchMedia("(min-resolution:144dpi)").matches)), doc = document.documentElement, ie3d = ie && ('transition' in doc.style), diff --git a/src/dom/DomEvent.MsTouch.js b/src/dom/DomEvent.MsTouch.js index 0ed58911..06251e5e 100644 --- a/src/dom/DomEvent.MsTouch.js +++ b/src/dom/DomEvent.MsTouch.js @@ -87,7 +87,7 @@ L.Util.extend(L.DomEvent, { e.changedTouches = [e]; handler(e); - }; + } obj[pre + 'touchmove' + id] = cb; obj.addEventListener('MSPointerMove', cb, false); diff --git a/src/layer/FeatureGroup.js b/src/layer/FeatureGroup.js index 56e1cb86..5f435e79 100644 --- a/src/layer/FeatureGroup.js +++ b/src/layer/FeatureGroup.js @@ -22,7 +22,7 @@ L.FeatureGroup = L.LayerGroup.extend({ layer.bindPopup(this._popupContent); } - return this; + return this.fire('layeradd', {layer: layer}); }, removeLayer: function (layer) { @@ -30,11 +30,12 @@ L.FeatureGroup = L.LayerGroup.extend({ L.LayerGroup.prototype.removeLayer.call(this, layer); + if (this._popupContent) { - return this.invoke('unbindPopup'); - } else { - return this; + this.invoke('unbindPopup'); } + + return this.fire('layerremove', {layer: layer}); }, bindPopup: function (content) { diff --git a/src/layer/LayerGroup.js b/src/layer/LayerGroup.js index d605d8b3..0287cf4e 100644 --- a/src/layer/LayerGroup.js +++ b/src/layer/LayerGroup.js @@ -24,8 +24,6 @@ L.LayerGroup = L.Class.extend({ this._map.addLayer(layer); } - this.fire('layeradd', { layer: layer }); - return this; }, @@ -38,8 +36,6 @@ L.LayerGroup = L.Class.extend({ this._map.removeLayer(layer); } - this.fire('layerremove', { layer: layer }); - return this; }, diff --git a/src/layer/vector/Polygon.js b/src/layer/vector/Polygon.js index 181fb13b..6a38687b 100644 --- a/src/layer/vector/Polygon.js +++ b/src/layer/vector/Polygon.js @@ -25,9 +25,9 @@ L.Polygon = L.Polyline.extend({ if (!this._holes) { return; } - var i, j, len, len2; + var i, j, len, len2, hole; - for (i = 0, len = this._holes.length, hole; i < len; i++) { + for (i = 0, len = this._holes.length; i < len; i++) { this._holePoints[i] = []; for (j = 0, len2 = this._holes[i].length; j < len2; j++) {