diff --git a/leaflet.module b/leaflet.module index 55171b8..2b08be7 100644 --- a/leaflet.module +++ b/leaflet.module @@ -29,8 +29,8 @@ function leaflet_library_info() { $libraries['leaflet'] = array( 'title' => t('Leaflet JavaScript Library'), - 'version' => '1.8.0', - 'website' => 'http://leafletjs.com/', + 'version' => '1.9.1', + 'website' => 'https://leafletjs.com/', 'js' => array( // This setting is needed in order to properly render market images. 'leaflet_root_url' => array( diff --git a/libraries/leaflet/leaflet-src.esm.js b/libraries/leaflet/leaflet-src.esm.js index a967bd7..481bae6 100644 --- a/libraries/leaflet/leaflet-src.esm.js +++ b/libraries/leaflet/leaflet-src.esm.js @@ -1,9 +1,9 @@ /* @preserve - * Leaflet 1.8.0, a JS library for interactive maps. https://leafletjs.com + * Leaflet 1.9.1, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2022 Vladimir Agafonkin, (c) 2010-2011 CloudMade */ -var version = "1.8.0"; +var version = "1.9.1"; /* * @namespace Util @@ -499,35 +499,30 @@ var Events = { }, // attach listener (without syntactic sugar now) - _on: function (type, fn, context) { + _on: function (type, fn, context, _once) { if (typeof fn !== 'function') { console.warn('wrong listener type: ' + typeof fn); return; } - this._events = this._events || {}; - /* get/init listeners for type */ - var typeListeners = this._events[type]; - if (!typeListeners) { - typeListeners = []; - this._events[type] = typeListeners; + // check if fn already there + if (this._listens(type, fn, context) !== false) { + return; } if (context === this) { // Less memory footprint. context = undefined; } - var newListener = {fn: fn, ctx: context}, - listeners = typeListeners; - // check if fn already there - for (var i = 0, len = listeners.length; i < len; i++) { - if (listeners[i].fn === fn && listeners[i].ctx === context) { - return; - } + var newListener = {fn: fn, ctx: context}; + if (_once) { + newListener.once = true; } - listeners.push(newListener); + this._events = this._events || {}; + this._events[type] = this._events[type] || []; + this._events[type].push(newListener); }, _off: function (type, fn, context) { @@ -535,10 +530,11 @@ var Events = { i, len; - if (!this._events) { return; } + if (!this._events) { + return; + } listeners = this._events[type]; - if (!listeners) { return; } @@ -556,32 +552,24 @@ var Events = { return; } - if (context === this) { - context = undefined; - } - if (typeof fn !== 'function') { console.warn('wrong listener type: ' + typeof fn); return; } + // find fn and remove it - for (i = 0, len = listeners.length; i < len; i++) { - var l = listeners[i]; - if (l.ctx !== context) { continue; } - if (l.fn === fn) { - if (this._firingCount) { - // set the removed listener to noop so that's not called if remove happens in fire - l.fn = falseFn; - - /* copy array in case events are being fired */ - this._events[type] = listeners = listeners.slice(); - } - listeners.splice(i, 1); + var index = this._listens(type, fn, context); + if (index !== false) { + var listener = listeners[index]; + if (this._firingCount) { + // set the removed listener to noop so that's not called if remove happens in fire + listener.fn = falseFn; - return; + /* copy array in case events are being fired */ + this._events[type] = listeners = listeners.slice(); } + listeners.splice(index, 1); } - console.warn('listener not found'); }, // @method fire(type: String, data?: Object, propagate?: Boolean): this @@ -599,12 +587,16 @@ var Events = { if (this._events) { var listeners = this._events[type]; - if (listeners) { this._firingCount = (this._firingCount + 1) || 1; for (var i = 0, len = listeners.length; i < len; i++) { var l = listeners[i]; - l.fn.call(l.ctx || this, event); + // off overwrites l.fn, so we need to copy fn to a var + var fn = l.fn; + if (l.once) { + this.off(type, fn, l.ctx); + } + fn.call(l.ctx || this, event); } this._firingCount--; @@ -620,45 +612,85 @@ var Events = { }, // @method listens(type: String, propagate?: Boolean): Boolean + // @method listens(type: String, fn: Function, context?: Object, propagate?: Boolean): Boolean // Returns `true` if a particular event type has any listeners attached to it. // The verification can optionally be propagated, it will return `true` if parents have the listener attached to it. - listens: function (type, propagate) { + listens: function (type, fn, context, propagate) { if (typeof type !== 'string') { console.warn('"string" type argument expected'); } + + // we don't overwrite the input `fn` value, because we need to use it for propagation + var _fn = fn; + if (typeof fn !== 'function') { + propagate = !!fn; + _fn = undefined; + context = undefined; + } + var listeners = this._events && this._events[type]; - if (listeners && listeners.length) { return true; } + if (listeners && listeners.length) { + if (this._listens(type, _fn, context) !== false) { + return true; + } + } if (propagate) { // also check parents for listeners if event propagates for (var id in this._eventParents) { - if (this._eventParents[id].listens(type, propagate)) { return true; } + if (this._eventParents[id].listens(type, fn, context, propagate)) { return true; } } } return false; }, + // returns the index (number) or false + _listens: function (type, fn, context) { + if (!this._events) { + return false; + } + + var listeners = this._events[type] || []; + if (!fn) { + return !!listeners.length; + } + + if (context === this) { + // Less memory footprint. + context = undefined; + } + + for (var i = 0, len = listeners.length; i < len; i++) { + if (listeners[i].fn === fn && listeners[i].ctx === context) { + return i; + } + } + return false; + + }, + // @method once(…): this // Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed. once: function (types, fn, context) { + // types can be a map of types/handlers if (typeof types === 'object') { for (var type in types) { - this.once(type, types[type], fn); + // we don't process space-separated events here for performance; + // it's a hot path since Layer uses the on(obj) syntax + this._on(type, types[type], fn, true); } - return this; - } - var handler = bind(function () { - this - .off(types, fn, context) - .off(types, handler, context); - }, this); + } else { + // types can be a string of space-separated words + types = splitWords(types); + + for (var i = 0, len = types.length; i < len; i++) { + this._on(types[i], fn, context, true); + } + } - // add a listener that's executed once and removed after that - return this - .on(types, fn, context) - .on(types, handler, context); + return this; }, // @method addEventParent(obj: Evented): this @@ -974,21 +1006,36 @@ function Bounds(a, b) { Bounds.prototype = { // @method extend(point: Point): this // Extends the bounds to contain the given point. - extend: function (point) { // (Point) - point = toPoint(point); + + // @alternative + // @method extend(otherBounds: Bounds): this + // Extend the bounds to contain the given bounds + extend: function (obj) { + var min2, max2; + if (!obj) { return this; } + + if (obj instanceof Point || typeof obj[0] === 'number' || 'x' in obj) { + min2 = max2 = toPoint(obj); + } else { + obj = toBounds(obj); + min2 = obj.min; + max2 = obj.max; + + if (!min2 || !max2) { return this; } + } // @property min: Point // The top left corner of the rectangle. // @property max: Point // The bottom right corner of the rectangle. if (!this.min && !this.max) { - this.min = point.clone(); - this.max = point.clone(); + this.min = min2.clone(); + this.max = max2.clone(); } else { - this.min.x = Math.min(point.x, this.min.x); - this.max.x = Math.max(point.x, this.max.x); - this.min.y = Math.min(point.y, this.min.y); - this.max.y = Math.max(point.y, this.max.y); + this.min.x = Math.min(min2.x, this.min.x); + this.max.x = Math.max(max2.x, this.max.x); + this.min.y = Math.min(min2.y, this.min.y); + this.max.y = Math.max(max2.y, this.max.y); } return this; }, @@ -996,7 +1043,7 @@ Bounds.prototype = { // @method getCenter(round?: Boolean): Point // Returns the center point of the bounds. getCenter: function (round) { - return new Point( + return toPoint( (this.min.x + this.max.x) / 2, (this.min.y + this.max.y) / 2, round); }, @@ -1004,13 +1051,13 @@ Bounds.prototype = { // @method getBottomLeft(): Point // Returns the bottom-left point of the bounds. getBottomLeft: function () { - return new Point(this.min.x, this.max.y); + return toPoint(this.min.x, this.max.y); }, // @method getTopRight(): Point // Returns the top-right point of the bounds. getTopRight: function () { // -> Point - return new Point(this.max.x, this.min.y); + return toPoint(this.max.x, this.min.y); }, // @method getTopLeft(): Point @@ -1090,9 +1137,40 @@ Bounds.prototype = { return xOverlaps && yOverlaps; }, + // @method isValid(): Boolean + // Returns `true` if the bounds are properly initialized. isValid: function () { return !!(this.min && this.max); - } + }, + + + // @method pad(bufferRatio: Number): Bounds + // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. + // For example, a ratio of 0.5 extends the bounds by 50% in each direction. + // Negative values will retract the bounds. + pad: function (bufferRatio) { + var min = this.min, + max = this.max, + heightBuffer = Math.abs(min.x - max.x) * bufferRatio, + widthBuffer = Math.abs(min.y - max.y) * bufferRatio; + + + return toBounds( + toPoint(min.x - heightBuffer, min.y - widthBuffer), + toPoint(max.x + heightBuffer, max.y + widthBuffer)); + }, + + + // @method equals(otherBounds: Bounds, maxMargin?: Number): Boolean + // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number. + equals: function (bounds) { + if (!bounds) { return false; } + + bounds = toBounds(bounds); + + return this.min.equals(bounds.getTopLeft()) && + this.max.equals(bounds.getBottomRight()); + }, }; @@ -2000,6 +2078,13 @@ var vml = !svg$1 && (function () { } }()); + +// @property mac: Boolean; `true` when the browser is running in a Mac platform +var mac = navigator.platform.indexOf('Mac') === 0; + +// @property mac: Boolean; `true` when the browser is running in a Linux platform +var linux = navigator.platform.indexOf('Linux') === 0; + function userAgentContains(str) { return navigator.userAgent.toLowerCase().indexOf(str) >= 0; } @@ -2038,7 +2123,9 @@ var Browser = { canvas: canvas$1, svg: svg$1, vml: vml, - inlineSvg: inlineSvg + inlineSvg: inlineSvg, + mac: mac, + linux: linux }; /* @@ -2181,6 +2268,25 @@ function addDoubleTapListener(obj, handler) { return; } + // When clicking on an , the browser generates a click on its + //