@eotl/core
Version:
Assortment of data structures, Vue.js components, and utilities across EOTL apps and sites.
1,523 lines • 328 kB
JavaScript
/* @preserve
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/
var version = "1.9.4";
function extend(dest) {
var i, j, len, src;
for (j = 1, len = arguments.length; j < len; j++) {
src = arguments[j];
for (i in src) {
dest[i] = src[i];
}
}
return dest;
}
var create$2 = Object.create || /* @__PURE__ */ function() {
function F() {
}
return function(proto) {
F.prototype = proto;
return new F();
};
}();
function bind(fn, obj) {
var slice = Array.prototype.slice;
if (fn.bind) {
return fn.bind.apply(fn, slice.call(arguments, 1));
}
var args = slice.call(arguments, 2);
return function() {
return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);
};
}
var lastId = 0;
function stamp(obj) {
if (!("_leaflet_id" in obj)) {
obj["_leaflet_id"] = ++lastId;
}
return obj._leaflet_id;
}
function throttle(fn, time, context) {
var lock, args, wrapperFn, later;
later = function() {
lock = false;
if (args) {
wrapperFn.apply(context, args);
args = false;
}
};
wrapperFn = function() {
if (lock) {
args = arguments;
} else {
fn.apply(context, arguments);
setTimeout(later, time);
lock = true;
}
};
return wrapperFn;
}
function wrapNum(x, range, includeMax) {
var max = range[1], min = range[0], d = max - min;
return x === max && includeMax ? x : ((x - min) % d + d) % d + min;
}
function falseFn() {
return false;
}
function formatNum(num, precision) {
if (precision === false) {
return num;
}
var pow = Math.pow(10, precision === void 0 ? 6 : precision);
return Math.round(num * pow) / pow;
}
function trim(str) {
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
}
function splitWords(str) {
return trim(str).split(/\s+/);
}
function setOptions(obj, options) {
if (!Object.prototype.hasOwnProperty.call(obj, "options")) {
obj.options = obj.options ? create$2(obj.options) : {};
}
for (var i in options) {
obj.options[i] = options[i];
}
return obj.options;
}
function getParamString(obj, existingUrl, uppercase) {
var params = [];
for (var i in obj) {
params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + "=" + encodeURIComponent(obj[i]));
}
return (!existingUrl || existingUrl.indexOf("?") === -1 ? "?" : "&") + params.join("&");
}
var templateRe = /\{ *([\w_ -]+) *\}/g;
function template(str, data) {
return str.replace(templateRe, function(str2, key) {
var value = data[key];
if (value === void 0) {
throw new Error("No value provided for variable " + str2);
} else if (typeof value === "function") {
value = value(data);
}
return value;
});
}
var isArray = Array.isArray || function(obj) {
return Object.prototype.toString.call(obj) === "[object Array]";
};
function indexOf(array, el) {
for (var i = 0; i < array.length; i++) {
if (array[i] === el) {
return i;
}
}
return -1;
}
var emptyImageUrl = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
function getPrefixed(name) {
return window["webkit" + name] || window["moz" + name] || window["ms" + name];
}
var lastTime = 0;
function timeoutDefer(fn) {
var time = +/* @__PURE__ */ new Date(), timeToCall = Math.max(0, 16 - (time - lastTime));
lastTime = time + timeToCall;
return window.setTimeout(fn, timeToCall);
}
var requestFn = window.requestAnimationFrame || getPrefixed("RequestAnimationFrame") || timeoutDefer;
var cancelFn = window.cancelAnimationFrame || getPrefixed("CancelAnimationFrame") || getPrefixed("CancelRequestAnimationFrame") || function(id) {
window.clearTimeout(id);
};
function requestAnimFrame(fn, context, immediate) {
if (immediate && requestFn === timeoutDefer) {
fn.call(context);
} else {
return requestFn.call(window, bind(fn, context));
}
}
function cancelAnimFrame(id) {
if (id) {
cancelFn.call(window, id);
}
}
var Util = {
__proto__: null,
extend,
create: create$2,
bind,
get lastId() {
return lastId;
},
stamp,
throttle,
wrapNum,
falseFn,
formatNum,
trim,
splitWords,
setOptions,
getParamString,
template,
isArray,
indexOf,
emptyImageUrl,
requestFn,
cancelFn,
requestAnimFrame,
cancelAnimFrame
};
function Class() {
}
Class.extend = function(props) {
var NewClass = function() {
setOptions(this);
if (this.initialize) {
this.initialize.apply(this, arguments);
}
this.callInitHooks();
};
var parentProto = NewClass.__super__ = this.prototype;
var proto = create$2(parentProto);
proto.constructor = NewClass;
NewClass.prototype = proto;
for (var i in this) {
if (Object.prototype.hasOwnProperty.call(this, i) && i !== "prototype" && i !== "__super__") {
NewClass[i] = this[i];
}
}
if (props.statics) {
extend(NewClass, props.statics);
}
if (props.includes) {
checkDeprecatedMixinEvents(props.includes);
extend.apply(null, [proto].concat(props.includes));
}
extend(proto, props);
delete proto.statics;
delete proto.includes;
if (proto.options) {
proto.options = parentProto.options ? create$2(parentProto.options) : {};
extend(proto.options, props.options);
}
proto._initHooks = [];
proto.callInitHooks = function() {
if (this._initHooksCalled) {
return;
}
if (parentProto.callInitHooks) {
parentProto.callInitHooks.call(this);
}
this._initHooksCalled = true;
for (var i2 = 0, len = proto._initHooks.length; i2 < len; i2++) {
proto._initHooks[i2].call(this);
}
};
return NewClass;
};
Class.include = function(props) {
var parentOptions = this.prototype.options;
extend(this.prototype, props);
if (props.options) {
this.prototype.options = parentOptions;
this.mergeOptions(props.options);
}
return this;
};
Class.mergeOptions = function(options) {
extend(this.prototype.options, options);
return this;
};
Class.addInitHook = function(fn) {
var args = Array.prototype.slice.call(arguments, 1);
var init = typeof fn === "function" ? fn : function() {
this[fn].apply(this, args);
};
this.prototype._initHooks = this.prototype._initHooks || [];
this.prototype._initHooks.push(init);
return this;
};
function checkDeprecatedMixinEvents(includes) {
if (typeof L === "undefined" || !L || !L.Mixin) {
return;
}
includes = isArray(includes) ? includes : [includes];
for (var i = 0; i < includes.length; i++) {
if (includes[i] === L.Mixin.Events) {
console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.", new Error().stack);
}
}
}
var Events = {
/* @method on(type: String, fn: Function, context?: Object): this
* Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`).
*
* @alternative
* @method on(eventMap: Object): this
* Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`
*/
on: function(types, fn, context) {
if (typeof types === "object") {
for (var type in types) {
this._on(type, types[type], fn);
}
} else {
types = splitWords(types);
for (var i = 0, len = types.length; i < len; i++) {
this._on(types[i], fn, context);
}
}
return this;
},
/* @method off(type: String, fn?: Function, context?: Object): this
* Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener.
*
* @alternative
* @method off(eventMap: Object): this
* Removes a set of type/listener pairs.
*
* @alternative
* @method off: this
* Removes all listeners to all events on the object. This includes implicitly attached events.
*/
off: function(types, fn, context) {
if (!arguments.length) {
delete this._events;
} else if (typeof types === "object") {
for (var type in types) {
this._off(type, types[type], fn);
}
} else {
types = splitWords(types);
var removeAll = arguments.length === 1;
for (var i = 0, len = types.length; i < len; i++) {
if (removeAll) {
this._off(types[i]);
} else {
this._off(types[i], fn, context);
}
}
}
return this;
},
// attach listener (without syntactic sugar now)
_on: function(type, fn, context, _once) {
if (typeof fn !== "function") {
console.warn("wrong listener type: " + typeof fn);
return;
}
if (this._listens(type, fn, context) !== false) {
return;
}
if (context === this) {
context = void 0;
}
var newListener = { fn, ctx: context };
if (_once) {
newListener.once = true;
}
this._events = this._events || {};
this._events[type] = this._events[type] || [];
this._events[type].push(newListener);
},
_off: function(type, fn, context) {
var listeners, i, len;
if (!this._events) {
return;
}
listeners = this._events[type];
if (!listeners) {
return;
}
if (arguments.length === 1) {
if (this._firingCount) {
for (i = 0, len = listeners.length; i < len; i++) {
listeners[i].fn = falseFn;
}
}
delete this._events[type];
return;
}
if (typeof fn !== "function") {
console.warn("wrong listener type: " + typeof fn);
return;
}
var index2 = this._listens(type, fn, context);
if (index2 !== false) {
var listener = listeners[index2];
if (this._firingCount) {
listener.fn = falseFn;
this._events[type] = listeners = listeners.slice();
}
listeners.splice(index2, 1);
}
},
// @method fire(type: String, data?: Object, propagate?: Boolean): this
// Fires an event of the specified type. You can optionally provide a data
// object — the first argument of the listener function will contain its
// properties. The event can optionally be propagated to event parents.
fire: function(type, data, propagate) {
if (!this.listens(type, propagate)) {
return this;
}
var event = extend({}, data, {
type,
target: this,
sourceTarget: data && data.sourceTarget || this
});
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];
var fn = l.fn;
if (l.once) {
this.off(type, fn, l.ctx);
}
fn.call(l.ctx || this, event);
}
this._firingCount--;
}
}
if (propagate) {
this._propagateEvent(event);
}
return this;
},
// @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, fn, context, propagate) {
if (typeof type !== "string") {
console.warn('"string" type argument expected');
}
var _fn = fn;
if (typeof fn !== "function") {
propagate = !!fn;
_fn = void 0;
context = void 0;
}
var listeners = this._events && this._events[type];
if (listeners && listeners.length) {
if (this._listens(type, _fn, context) !== false) {
return true;
}
}
if (propagate) {
for (var id in this._eventParents) {
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) {
context = void 0;
}
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) {
if (typeof types === "object") {
for (var type in types) {
this._on(type, types[type], fn, true);
}
} else {
types = splitWords(types);
for (var i = 0, len = types.length; i < len; i++) {
this._on(types[i], fn, context, true);
}
}
return this;
},
// @method addEventParent(obj: Evented): this
// Adds an event parent - an `Evented` that will receive propagated events
addEventParent: function(obj) {
this._eventParents = this._eventParents || {};
this._eventParents[stamp(obj)] = obj;
return this;
},
// @method removeEventParent(obj: Evented): this
// Removes an event parent, so it will stop receiving propagated events
removeEventParent: function(obj) {
if (this._eventParents) {
delete this._eventParents[stamp(obj)];
}
return this;
},
_propagateEvent: function(e) {
for (var id in this._eventParents) {
this._eventParents[id].fire(e.type, extend({
layer: e.target,
propagatedFrom: e.target
}, e), true);
}
}
};
Events.addEventListener = Events.on;
Events.removeEventListener = Events.clearAllEventListeners = Events.off;
Events.addOneTimeEventListener = Events.once;
Events.fireEvent = Events.fire;
Events.hasEventListeners = Events.listens;
var Evented = Class.extend(Events);
function Point(x, y, round) {
this.x = round ? Math.round(x) : x;
this.y = round ? Math.round(y) : y;
}
var trunc = Math.trunc || function(v) {
return v > 0 ? Math.floor(v) : Math.ceil(v);
};
Point.prototype = {
// @method clone(): Point
// Returns a copy of the current point.
clone: function() {
return new Point(this.x, this.y);
},
// @method add(otherPoint: Point): Point
// Returns the result of addition of the current and the given points.
add: function(point) {
return this.clone()._add(toPoint(point));
},
_add: function(point) {
this.x += point.x;
this.y += point.y;
return this;
},
// @method subtract(otherPoint: Point): Point
// Returns the result of subtraction of the given point from the current.
subtract: function(point) {
return this.clone()._subtract(toPoint(point));
},
_subtract: function(point) {
this.x -= point.x;
this.y -= point.y;
return this;
},
// @method divideBy(num: Number): Point
// Returns the result of division of the current point by the given number.
divideBy: function(num) {
return this.clone()._divideBy(num);
},
_divideBy: function(num) {
this.x /= num;
this.y /= num;
return this;
},
// @method multiplyBy(num: Number): Point
// Returns the result of multiplication of the current point by the given number.
multiplyBy: function(num) {
return this.clone()._multiplyBy(num);
},
_multiplyBy: function(num) {
this.x *= num;
this.y *= num;
return this;
},
// @method scaleBy(scale: Point): Point
// Multiply each coordinate of the current point by each coordinate of
// `scale`. In linear algebra terms, multiply the point by the
// [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)
// defined by `scale`.
scaleBy: function(point) {
return new Point(this.x * point.x, this.y * point.y);
},
// @method unscaleBy(scale: Point): Point
// Inverse of `scaleBy`. Divide each coordinate of the current point by
// each coordinate of `scale`.
unscaleBy: function(point) {
return new Point(this.x / point.x, this.y / point.y);
},
// @method round(): Point
// Returns a copy of the current point with rounded coordinates.
round: function() {
return this.clone()._round();
},
_round: function() {
this.x = Math.round(this.x);
this.y = Math.round(this.y);
return this;
},
// @method floor(): Point
// Returns a copy of the current point with floored coordinates (rounded down).
floor: function() {
return this.clone()._floor();
},
_floor: function() {
this.x = Math.floor(this.x);
this.y = Math.floor(this.y);
return this;
},
// @method ceil(): Point
// Returns a copy of the current point with ceiled coordinates (rounded up).
ceil: function() {
return this.clone()._ceil();
},
_ceil: function() {
this.x = Math.ceil(this.x);
this.y = Math.ceil(this.y);
return this;
},
// @method trunc(): Point
// Returns a copy of the current point with truncated coordinates (rounded towards zero).
trunc: function() {
return this.clone()._trunc();
},
_trunc: function() {
this.x = trunc(this.x);
this.y = trunc(this.y);
return this;
},
// @method distanceTo(otherPoint: Point): Number
// Returns the cartesian distance between the current and the given points.
distanceTo: function(point) {
point = toPoint(point);
var x = point.x - this.x, y = point.y - this.y;
return Math.sqrt(x * x + y * y);
},
// @method equals(otherPoint: Point): Boolean
// Returns `true` if the given point has the same coordinates.
equals: function(point) {
point = toPoint(point);
return point.x === this.x && point.y === this.y;
},
// @method contains(otherPoint: Point): Boolean
// Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).
contains: function(point) {
point = toPoint(point);
return Math.abs(point.x) <= Math.abs(this.x) && Math.abs(point.y) <= Math.abs(this.y);
},
// @method toString(): String
// Returns a string representation of the point for debugging purposes.
toString: function() {
return "Point(" + formatNum(this.x) + ", " + formatNum(this.y) + ")";
}
};
function toPoint(x, y, round) {
if (x instanceof Point) {
return x;
}
if (isArray(x)) {
return new Point(x[0], x[1]);
}
if (x === void 0 || x === null) {
return x;
}
if (typeof x === "object" && "x" in x && "y" in x) {
return new Point(x.x, x.y);
}
return new Point(x, y, round);
}
function Bounds(a, b) {
if (!a) {
return;
}
var points = b ? [a, b] : a;
for (var i = 0, len = points.length; i < len; i++) {
this.extend(points[i]);
}
}
Bounds.prototype = {
// @method extend(point: Point): this
// Extends the bounds to contain the given 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;
}
}
if (!this.min && !this.max) {
this.min = min2.clone();
this.max = max2.clone();
} else {
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;
},
// @method getCenter(round?: Boolean): Point
// Returns the center point of the bounds.
getCenter: function(round) {
return toPoint(
(this.min.x + this.max.x) / 2,
(this.min.y + this.max.y) / 2,
round
);
},
// @method getBottomLeft(): Point
// Returns the bottom-left point of the bounds.
getBottomLeft: function() {
return toPoint(this.min.x, this.max.y);
},
// @method getTopRight(): Point
// Returns the top-right point of the bounds.
getTopRight: function() {
return toPoint(this.max.x, this.min.y);
},
// @method getTopLeft(): Point
// Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)).
getTopLeft: function() {
return this.min;
},
// @method getBottomRight(): Point
// Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)).
getBottomRight: function() {
return this.max;
},
// @method getSize(): Point
// Returns the size of the given bounds
getSize: function() {
return this.max.subtract(this.min);
},
// @method contains(otherBounds: Bounds): Boolean
// Returns `true` if the rectangle contains the given one.
// @alternative
// @method contains(point: Point): Boolean
// Returns `true` if the rectangle contains the given point.
contains: function(obj) {
var min, max;
if (typeof obj[0] === "number" || obj instanceof Point) {
obj = toPoint(obj);
} else {
obj = toBounds(obj);
}
if (obj instanceof Bounds) {
min = obj.min;
max = obj.max;
} else {
min = max = obj;
}
return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y;
},
// @method intersects(otherBounds: Bounds): Boolean
// Returns `true` if the rectangle intersects the given bounds. Two bounds
// intersect if they have at least one point in common.
intersects: function(bounds) {
bounds = toBounds(bounds);
var min = this.min, 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;
},
// @method overlaps(otherBounds: Bounds): Boolean
// Returns `true` if the rectangle overlaps the given bounds. Two bounds
// overlap if their intersection is an area.
overlaps: function(bounds) {
bounds = toBounds(bounds);
var min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xOverlaps = max2.x > min.x && min2.x < max.x, yOverlaps = max2.y > min.y && min2.y < max.y;
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): Boolean
// Returns `true` if the rectangle is equivalent to the given bounds.
equals: function(bounds) {
if (!bounds) {
return false;
}
bounds = toBounds(bounds);
return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
}
};
function toBounds(a, b) {
if (!a || a instanceof Bounds) {
return a;
}
return new Bounds(a, b);
}
function LatLngBounds(corner1, corner2) {
if (!corner1) {
return;
}
var latlngs = corner2 ? [corner1, corner2] : corner1;
for (var i = 0, len = latlngs.length; i < len; i++) {
this.extend(latlngs[i]);
}
}
LatLngBounds.prototype = {
// @method extend(latlng: LatLng): this
// Extend the bounds to contain the given point
// @alternative
// @method extend(otherBounds: LatLngBounds): this
// Extend the bounds to contain the given bounds
extend: function(obj) {
var sw = this._southWest, ne = this._northEast, sw2, ne2;
if (obj instanceof LatLng) {
sw2 = obj;
ne2 = obj;
} else if (obj instanceof LatLngBounds) {
sw2 = obj._southWest;
ne2 = obj._northEast;
if (!sw2 || !ne2) {
return this;
}
} else {
return obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this;
}
if (!sw && !ne) {
this._southWest = new LatLng(sw2.lat, sw2.lng);
this._northEast = new LatLng(ne2.lat, ne2.lng);
} else {
sw.lat = Math.min(sw2.lat, sw.lat);
sw.lng = Math.min(sw2.lng, sw.lng);
ne.lat = Math.max(ne2.lat, ne.lat);
ne.lng = Math.max(ne2.lng, ne.lng);
}
return this;
},
// @method pad(bufferRatio: Number): LatLngBounds
// 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 sw = this._southWest, ne = this._northEast, heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
return new LatLngBounds(
new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),
new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)
);
},
// @method getCenter(): LatLng
// Returns the center point of the bounds.
getCenter: function() {
return new LatLng(
(this._southWest.lat + this._northEast.lat) / 2,
(this._southWest.lng + this._northEast.lng) / 2
);
},
// @method getSouthWest(): LatLng
// Returns the south-west point of the bounds.
getSouthWest: function() {
return this._southWest;
},
// @method getNorthEast(): LatLng
// Returns the north-east point of the bounds.
getNorthEast: function() {
return this._northEast;
},
// @method getNorthWest(): LatLng
// Returns the north-west point of the bounds.
getNorthWest: function() {
return new LatLng(this.getNorth(), this.getWest());
},
// @method getSouthEast(): LatLng
// Returns the south-east point of the bounds.
getSouthEast: function() {
return new LatLng(this.getSouth(), this.getEast());
},
// @method getWest(): Number
// Returns the west longitude of the bounds
getWest: function() {
return this._southWest.lng;
},
// @method getSouth(): Number
// Returns the south latitude of the bounds
getSouth: function() {
return this._southWest.lat;
},
// @method getEast(): Number
// Returns the east longitude of the bounds
getEast: function() {
return this._northEast.lng;
},
// @method getNorth(): Number
// Returns the north latitude of the bounds
getNorth: function() {
return this._northEast.lat;
},
// @method contains(otherBounds: LatLngBounds): Boolean
// Returns `true` if the rectangle contains the given one.
// @alternative
// @method contains (latlng: LatLng): Boolean
// Returns `true` if the rectangle contains the given point.
contains: function(obj) {
if (typeof obj[0] === "number" || obj instanceof LatLng || "lat" in obj) {
obj = toLatLng(obj);
} else {
obj = toLatLngBounds(obj);
}
var sw = this._southWest, ne = this._northEast, sw2, ne2;
if (obj instanceof LatLngBounds) {
sw2 = obj.getSouthWest();
ne2 = obj.getNorthEast();
} else {
sw2 = ne2 = obj;
}
return sw2.lat >= sw.lat && ne2.lat <= ne.lat && sw2.lng >= sw.lng && ne2.lng <= ne.lng;
},
// @method intersects(otherBounds: LatLngBounds): Boolean
// Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.
intersects: function(bounds) {
bounds = toLatLngBounds(bounds);
var sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latIntersects = ne2.lat >= sw.lat && sw2.lat <= ne.lat, lngIntersects = ne2.lng >= sw.lng && sw2.lng <= ne.lng;
return latIntersects && lngIntersects;
},
// @method overlaps(otherBounds: LatLngBounds): Boolean
// Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.
overlaps: function(bounds) {
bounds = toLatLngBounds(bounds);
var sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps = ne2.lat > sw.lat && sw2.lat < ne.lat, lngOverlaps = ne2.lng > sw.lng && sw2.lng < ne.lng;
return latOverlaps && lngOverlaps;
},
// @method toBBoxString(): String
// Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.
toBBoxString: function() {
return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(",");
},
// @method equals(otherBounds: LatLngBounds, 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, maxMargin) {
if (!bounds) {
return false;
}
bounds = toLatLngBounds(bounds);
return this._southWest.equals(bounds.getSouthWest(), maxMargin) && this._northEast.equals(bounds.getNorthEast(), maxMargin);
},
// @method isValid(): Boolean
// Returns `true` if the bounds are properly initialized.
isValid: function() {
return !!(this._southWest && this._northEast);
}
};
function toLatLngBounds(a, b) {
if (a instanceof LatLngBounds) {
return a;
}
return new LatLngBounds(a, b);
}
function LatLng(lat, lng, alt) {
if (isNaN(lat) || isNaN(lng)) {
throw new Error("Invalid LatLng object: (" + lat + ", " + lng + ")");
}
this.lat = +lat;
this.lng = +lng;
if (alt !== void 0) {
this.alt = +alt;
}
}
LatLng.prototype = {
// @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean
// Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number.
equals: function(obj, maxMargin) {
if (!obj) {
return false;
}
obj = toLatLng(obj);
var margin = Math.max(
Math.abs(this.lat - obj.lat),
Math.abs(this.lng - obj.lng)
);
return margin <= (maxMargin === void 0 ? 1e-9 : maxMargin);
},
// @method toString(): String
// Returns a string representation of the point (for debugging purposes).
toString: function(precision) {
return "LatLng(" + formatNum(this.lat, precision) + ", " + formatNum(this.lng, precision) + ")";
},
// @method distanceTo(otherLatLng: LatLng): Number
// Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines).
distanceTo: function(other) {
return Earth.distance(this, toLatLng(other));
},
// @method wrap(): LatLng
// Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.
wrap: function() {
return Earth.wrapLatLng(this);
},
// @method toBounds(sizeInMeters: Number): LatLngBounds
// Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`.
toBounds: function(sizeInMeters) {
var latAccuracy = 180 * sizeInMeters / 40075017, lngAccuracy = latAccuracy / Math.cos(Math.PI / 180 * this.lat);
return toLatLngBounds(
[this.lat - latAccuracy, this.lng - lngAccuracy],
[this.lat + latAccuracy, this.lng + lngAccuracy]
);
},
clone: function() {
return new LatLng(this.lat, this.lng, this.alt);
}
};
function toLatLng(a, b, c) {
if (a instanceof LatLng) {
return a;
}
if (isArray(a) && typeof a[0] !== "object") {
if (a.length === 3) {
return new LatLng(a[0], a[1], a[2]);
}
if (a.length === 2) {
return new LatLng(a[0], a[1]);
}
return null;
}
if (a === void 0 || a === null) {
return a;
}
if (typeof a === "object" && "lat" in a) {
return new LatLng(a.lat, "lng" in a ? a.lng : a.lon, a.alt);
}
if (b === void 0) {
return null;
}
return new LatLng(a, b, c);
}
var CRS = {
// @method latLngToPoint(latlng: LatLng, zoom: Number): Point
// Projects geographical coordinates into pixel coordinates for a given zoom.
latLngToPoint: function(latlng, zoom2) {
var projectedPoint = this.projection.project(latlng), scale2 = this.scale(zoom2);
return this.transformation._transform(projectedPoint, scale2);
},
// @method pointToLatLng(point: Point, zoom: Number): LatLng
// The inverse of `latLngToPoint`. Projects pixel coordinates on a given
// zoom into geographical coordinates.
pointToLatLng: function(point, zoom2) {
var scale2 = this.scale(zoom2), untransformedPoint = this.transformation.untransform(point, scale2);
return this.projection.unproject(untransformedPoint);
},
// @method project(latlng: LatLng): Point
// Projects geographical coordinates into coordinates in units accepted for
// this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
project: function(latlng) {
return this.projection.project(latlng);
},
// @method unproject(point: Point): LatLng
// Given a projected coordinate returns the corresponding LatLng.
// The inverse of `project`.
unproject: function(point) {
return this.projection.unproject(point);
},
// @method scale(zoom: Number): Number
// Returns the scale used when transforming projected coordinates into
// pixel coordinates for a particular zoom. For example, it returns
// `256 * 2^zoom` for Mercator-based CRS.
scale: function(zoom2) {
return 256 * Math.pow(2, zoom2);
},
// @method zoom(scale: Number): Number
// Inverse of `scale()`, returns the zoom level corresponding to a scale
// factor of `scale`.
zoom: function(scale2) {
return Math.log(scale2 / 256) / Math.LN2;
},
// @method getProjectedBounds(zoom: Number): Bounds
// Returns the projection's bounds scaled and transformed for the provided `zoom`.
getProjectedBounds: function(zoom2) {
if (this.infinite) {
return null;
}
var b = this.projection.bounds, s = this.scale(zoom2), min = this.transformation.transform(b.min, s), max = this.transformation.transform(b.max, s);
return new Bounds(min, max);
},
// @method distance(latlng1: LatLng, latlng2: LatLng): Number
// Returns the distance between two geographical coordinates.
// @property code: String
// Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)
//
// @property wrapLng: Number[]
// An array of two numbers defining whether the longitude (horizontal) coordinate
// axis wraps around a given range and how. Defaults to `[-180, 180]` in most
// geographical CRSs. If `undefined`, the longitude axis does not wrap around.
//
// @property wrapLat: Number[]
// Like `wrapLng`, but for the latitude (vertical) axis.
// wrapLng: [min, max],
// wrapLat: [min, max],
// @property infinite: Boolean
// If true, the coordinate space will be unbounded (infinite in both axes)
infinite: false,
// @method wrapLatLng(latlng: LatLng): LatLng
// Returns a `LatLng` where lat and lng has been wrapped according to the
// CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.
wrapLatLng: function(latlng) {
var lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, alt = latlng.alt;
return new LatLng(lat, lng, alt);
},
// @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds
// Returns a `LatLngBounds` with the same size as the given one, ensuring
// that its center is within the CRS's bounds.
// Only accepts actual `L.LatLngBounds` instances, not arrays.
wrapLatLngBounds: function(bounds) {
var center = bounds.getCenter(), newCenter = this.wrapLatLng(center), latShift = center.lat - newCenter.lat, lngShift = center.lng - newCenter.lng;
if (latShift === 0 && lngShift === 0) {
return bounds;
}
var sw = bounds.getSouthWest(), ne = bounds.getNorthEast(), newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift), newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);
return new LatLngBounds(newSw, newNe);
}
};
var Earth = extend({}, CRS, {
wrapLng: [-180, 180],
// Mean Earth Radius, as recommended for use by
// the International Union of Geodesy and Geophysics,
// see https://rosettacode.org/wiki/Haversine_formula
R: 6371e3,
// distance between two geographical points using spherical law of cosines approximation
distance: function(latlng1, latlng2) {
var rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon, c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return this.R * c;
}
});
var earthRadius = 6378137;
var SphericalMercator = {
R: earthRadius,
MAX_LATITUDE: 85.0511287798,
project: function(latlng) {
var d = Math.PI / 180, max = this.MAX_LATITUDE, lat = Math.max(Math.min(max, latlng.lat), -max), sin = Math.sin(lat * d);
return new Point(
this.R * latlng.lng * d,
this.R * Math.log((1 + sin) / (1 - sin)) / 2
);
},
unproject: function(point) {
var d = 180 / Math.PI;
return new LatLng(
(2 * Math.atan(Math.exp(point.y / this.R)) - Math.PI / 2) * d,
point.x * d / this.R
);
},
bounds: function() {
var d = earthRadius * Math.PI;
return new Bounds([-d, -d], [d, d]);
}()
};
function Transformation(a, b, c, d) {
if (isArray(a)) {
this._a = a[0];
this._b = a[1];
this._c = a[2];
this._d = a[3];
return;
}
this._a = a;
this._b = b;
this._c = c;
this._d = d;
}
Transformation.prototype = {
// @method transform(point: Point, scale?: Number): Point
// Returns a transformed point, optionally multiplied by the given scale.
// Only accepts actual `L.Point` instances, not arrays.
transform: function(point, scale2) {
return this._transform(point.clone(), scale2);
},
// destructive transform (faster)
_transform: function(point, scale2) {
scale2 = scale2 || 1;
point.x = scale2 * (this._a * point.x + this._b);
point.y = scale2 * (this._c * point.y + this._d);
return point;
},
// @method untransform(point: Point, scale?: Number): Point
// Returns the reverse transformation of the given point, optionally divided
// by the given scale. Only accepts actual `L.Point` instances, not arrays.
untransform: function(point, scale2) {
scale2 = scale2 || 1;
return new Point(
(point.x / scale2 - this._b) / this._a,
(point.y / scale2 - this._d) / this._c
);
}
};
function toTransformation(a, b, c, d) {
return new Transformation(a, b, c, d);
}
var EPSG3857 = extend({}, Earth, {
code: "EPSG:3857",
projection: SphericalMercator,
transformation: function() {
var scale2 = 0.5 / (Math.PI * SphericalMercator.R);
return toTransformation(scale2, 0.5, -scale2, 0.5);
}()
});
var EPSG900913 = extend({}, EPSG3857, {
code: "EPSG:900913"
});
function svgCreate(name) {
return document.createElementNS("http://www.w3.org/2000/svg", name);
}
function pointsToPath(rings, closed) {
var str = "", i, j, len, len2, points, p;
for (i = 0, len = rings.length; i < len; i++) {
points = rings[i];
for (j = 0, len2 = points.length; j < len2; j++) {
p = points[j];
str += (j ? "L" : "M") + p.x + " " + p.y;
}
str += closed ? Browser.svg ? "z" : "x" : "";
}
return str || "M0 0";
}
var style = document.documentElement.style;
var ie = "ActiveXObject" in window;
var ielt9 = ie && !document.addEventListener;
var edge = "msLaunchUri" in navigator && !("documentMode" in document);
var webkit = userAgentContains("webkit");
var android = userAgentContains("android");
var android23 = userAgentContains("android 2") || userAgentContains("android 3");
var webkitVer = parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10);
var androidStock = android && userAgentContains("Google") && webkitVer < 537 && !("AudioNode" in window);
var opera = !!window.opera;
var chrome = !edge && userAgentContains("chrome");
var gecko = userAgentContains("gecko") && !webkit && !opera && !ie;
var safari = !chrome && userAgentContains("safari");
var phantom = userAgentContains("phantom");
var opera12 = "OTransition" in style;
var win = navigator.platform.indexOf("Win") === 0;
var ie3d = ie && "transition" in style;
var webkit3d = "WebKitCSSMatrix" in window && "m11" in new window.WebKitCSSMatrix() && !android23;
var gecko3d = "MozPerspective" in style;
var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom;
var mobile = typeof orientation !== "undefined" || userAgentContains("mobile");
var mobileWebkit = mobile && webkit;
var mobileWebkit3d = mobile && webkit3d;
var msPointer = !window.PointerEvent && window.MSPointerEvent;
var pointer = !!(window.PointerEvent || msPointer);
var touchNative = "ontouchstart" in window || !!window.TouchEvent;
var touch = !window.L_NO_TOUCH && (touchNative || pointer);
var mobileOpera = mobile && opera;
var mobileGecko = mobile && gecko;
var retina = (window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI) > 1;
var passiveEvents = function() {
var supportsPassiveOption = false;
try {
var opts = Object.defineProperty({}, "passive", {
get: function() {
supportsPassiveOption = true;
}
});
window.addEventListener("testPassiveEventSupport", falseFn, opts);
window.removeEventListener("testPassiveEventSupport", falseFn, opts);
} catch (e) {
}
return supportsPassiveOption;
}();
var canvas$1 = function() {
return !!document.createElement("canvas").getContext;
}();
var svg$1 = !!(document.createElementNS && svgCreate("svg").createSVGRect);
var inlineSvg = !!svg$1 && function() {
var div = document.createElement("div");
div.innerHTML = "<svg/>";
return (div.firstChild && div.firstChild.namespaceURI) === "http://www.w3.org/2000/svg";
}();
var vml = !svg$1 && function() {
try {
var div = document.createElement("div");
div.innerHTML = '<v:shape adj="1"/>';
var shape = div.firstChild;
shape.style.behavior = "url(#default#VML)";
return shape && typeof shape.adj === "object";
} catch (e) {
return false;
}
}();
var mac = navigator.platform.indexOf("Mac") === 0;
var linux = navigator.platform.indexOf("Linux") === 0;
function userAgentContains(str) {
return navigator.userAgent.toLowerCase().indexOf(str) >= 0;
}
var Browser = {
ie,
ielt9,
edge,
webkit,
android,
android23,
androidStock,
opera,
chrome,
gecko,
safari,
phantom,
opera12,
win,
ie3d,
webkit3d,
gecko3d,
any3d,
mobile,
mobileWebkit,
mobileWebkit3d,
msPointer,
pointer,
touch,
touchNative,
mobileOpera,
mobileGecko,
retina,
passiveEvents,
canvas: canvas$1,
svg: svg$1,
vml,
inlineSvg,
mac,
linux
};
var POINTER_DOWN = Browser.msPointer ? "MSPointerDown" : "pointerdown";
var POINTER_MOVE = Browser.msPointer ? "MSPointerMove" : "pointermove";
var POINTER_UP = Browser.msPointer ? "MSPointerUp" : "pointerup";
var POINTER_CANCEL = Browser.msPointer ? "MSPointerCancel" : "pointercancel";
var pEvent = {
touchstart: POINTER_DOWN,
touchmove: POINTER_MOVE,
touchend: POINTER_UP,
touchcancel: POINTER_CANCEL
};
var handle = {
touchstart: _onPointerStart,
touchmove: _handlePointer,
touchend: _handlePointer,
touchcancel: _handlePointer
};
var _pointers = {};
var _pointerDocListener = false;
function addPointerListener(obj, type, handler) {
if (type === "touchstart") {
_addPointerDocListener();
}
if (!handle[type]) {
console.warn("wrong event specified:", type);
return falseFn;
}
handler = handle[type].bind(this, handler);
obj.addEventListener(pEvent[type], handler, false);
return handler;
}
function removePointerListener(obj, type, handler) {
if (!pEvent[type]) {
console.warn("wrong event specified:", type);
return;
}
obj.removeEventListener(pEvent[type], handler, false);
}
function _globalPointerDown(e) {
_pointers[e.pointerId] = e;
}
function _globalPointerMove(e) {
if (_pointers[e.pointerId]) {
_pointers[e.pointerId] = e;
}
}
function _globalPointerUp(e) {
delete _pointers[e.pointerId];
}
function _addPointerDocListener() {
if (!_pointerDocListener) {
document.addEventListener(POINTER_DOWN, _globalPointerDown, true);
document.addEventListener(POINTER_MOVE, _globalPointerMove, true);
document.addEventListener(POINTER_UP, _globalPointerUp, true);
document.addEventListener(POINTER_CANCEL, _globalPointerUp, true);
_pointerDocListener = true;
}
}
function _handlePointer(handler, e) {
if (e.pointerType === (e.MSPOINTER_TYPE_MOUSE || "mouse")) {
return;
}
e.touches = [];
for (var i in _pointers) {
e.touches.push(_pointers[i]);
}
e.changedTouches = [e];
handler(e);
}
function _onPointerStart(handler, e) {
if (e.MSPOINTER_TYPE_TOUCH && e.pointerType === e.MSPOINTER_TYPE_TOUCH) {
preventDefault(e);
}
_handlePointer(handler, e);
}
function makeDblclick(event) {
var newEvent = {}, prop, i;
for (i in event) {
prop = event[i];
newEvent[i] = prop && prop.bind ? prop.bind(event) : prop;
}
event = newEvent;
newEvent.type = "dblclick";
newEvent.detail = 2;
newEvent.isTrusted = false;
newEvent._simulated = true;
return newEvent;
}
var delay = 200;
function addDoubleTapListener(obj, handler) {
obj.addEventListener("dblclick", handler);
var last = 0, detail;
function simDblclick(e) {
if (e.detail !== 1) {
detail = e.detail;
return;
}
if (e.pointerType === "mouse" || e.sourceCapabilities && !e.sourceCapabilities.firesTouchEvents) {
return;
}
var path = getPropagationPath(e);
if (path.some(function(el) {
return el instanceof HTMLLabelElement && el.attributes.for;
}) && !path.some(function(el) {
return el instanceof HTMLInputElement || el instanceof HTMLSelectElement;
})) {
return;
}
var now = Date.now();
if (now - last <= delay) {
detail++;
if (detail === 2) {
handler(makeDblclick(e));
}
} else {
detail = 1;
}
last = now;
}
obj.addEventListener("click", simDblclick);
return {
dblclick: handler,
simDblclick
};
}
function removeDoubleTapListener(obj, handlers) {
obj.removeEventListener("dblclick", handlers.dblclick);
obj.removeEventListener("click", handlers.simDblclick);
}
var TRANSFORM = testProp(
["transform", "webkitTransform", "OTransform", "MozTransform", "msTransform"]
);
var TRANSITION = testProp(
["webkitTransition", "transition", "OTransition", "MozTransition", "msTransition"]
);
var TRANSITION_END = TRANSITION === "webkitTransition" || TRANSITION === "OTransition" ? TRANSITION + "End" : "transitionend";
function get(id) {
return typeof id === "string" ? document.getElementById(id) : id;
}
function getStyle(el, style2) {
var value = el.style[style2] || el.currentStyle && el.currentStyle[style2];
if ((!value || value === "auto") && document.defaultView) {
var css = document.defaultView.getComputedStyle(el, null);
value = css ? css[style2] : null;
}
return value === "auto" ? null : value;
}
function create$1(tagName, className, container) {
var el = document.createElement(tagName);
el.className = className || "";
if (container) {
container.appendChild(el);
}
return el;
}
function remove(el) {
var parent = el.parentNode;
if (parent) {
parent.removeChild(el);
}
}
function empty(el) {
while (el.firstChild) {
el.removeChild(el.firstChild);
}
}
function toFront(el) {
var parent = el.parentNode;
if (parent && parent.lastChild !== el) {
parent.appendChild(el);
}
}
function toBack(el) {
var parent = el.parentNode;
if (parent && parent.firstChild !== el) {
parent.insertBefore(el, parent.firstChild);
}
}
function hasClass(el, name) {
if (el.classList !== void 0) {
return el.classList.contains(name);
}
var className = getClass(el);
return className.length > 0 && new RegExp("(^|\\s)" + name + "(\\s|$)").test(className);
}
function addClass(el, name) {
if (el.classList !== void 0) {
var classes = splitWords(name);
for (var i = 0, len = classes.length; i < len; i++) {
el.classList.add(classes[i]);
}
} else if (!hasClass(el, name)) {
var className = getClass(el);
setClass(el, (className ? className + " " : "") + name);
}
}
function removeClass(el, name) {
if (el.classList !== void 0) {
el.classList.remove(name);
} else {
setClass(el, trim((" " + getClass(el) + " ").replace(" " + name + " ", " ")));
}
}
function setClass(el, name) {
if (el.className.baseVal === void 0) {
el.className = name;
} else {
el.className.baseVal = name;
}
}
function getClass(el) {
if (el.correspondingElement) {
el = el.correspondingElement;
}
return el.className.baseVal === void 0 ? el.className : el.className.baseVal;
}
function setOpacity(el, value) {
if ("opacity" in el.style) {
el.style.opacity = value;
} else if ("filter" in el.style) {
_setOpacityIE(el, value);
}
}
function _setOpacityIE(el,