X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/983f7325ae08ded5bb0d5ed1f9ec25ae57f4a1c0..6da536e5c8870cb30594a7397e074803080e2708:/vendor/assets/leaflet/leaflet.js?ds=sidebyside
diff --git a/vendor/assets/leaflet/leaflet.js b/vendor/assets/leaflet/leaflet.js
index 12bf1f0cd..a845eb6ae 100644
--- a/vendor/assets/leaflet/leaflet.js
+++ b/vendor/assets/leaflet/leaflet.js
@@ -1,5 +1,5 @@
/* @preserve
- * Leaflet 1.3.4, a JS library for interactive maps. http://leafletjs.com
+ * Leaflet 1.5.1+build.2e3e0ff, a JS library for interactive maps. http://leafletjs.com
* (c) 2010-2018 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/
@@ -9,7 +9,7 @@
(factory((global.L = {})));
}(this, (function (exports) { 'use strict';
-var version = "1.3.4";
+var version = "1.5.1+build.2e3e0ffb";
/*
* @namespace Util
@@ -127,8 +127,8 @@ function falseFn() { return false; }
// @function formatNum(num: Number, digits?: Number): Number
// Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default.
function formatNum(num, digits) {
- var pow = Math.pow(10, (digits === undefined ? 6 : digits));
- return Math.round(num * pow) / pow;
+ digits = (digits === undefined ? 6 : digits);
+ return +(Math.round(num + ('e+' + digits)) + ('e-' + digits));
}
// @function trim(str: String): String
@@ -468,7 +468,7 @@ var Events = {
*
* @alternative
* @method off: this
- * Removes all listeners to all events on the object.
+ * Removes all listeners to all events on the object. This includes implicitly attached events.
*/
off: function (types, fn, context) {
@@ -1648,9 +1648,11 @@ var Earth = extend({}, CRS, {
* a sphere. Used by the `EPSG:3857` CRS.
*/
+var earthRadius = 6378137;
+
var SphericalMercator = {
- R: 6378137,
+ R: earthRadius,
MAX_LATITUDE: 85.0511287798,
project: function (latlng) {
@@ -1673,7 +1675,7 @@ var SphericalMercator = {
},
bounds: (function () {
- var d = 6378137 * Math.PI;
+ var d = earthRadius * Math.PI;
return new Bounds([-d, -d], [d, d]);
})()
};
@@ -2171,6 +2173,7 @@ function addDoubleTapListener(obj, handler, id) {
touch$$1 = newTouch;
}
touch$$1.type = 'dblclick';
+ touch$$1.button = 0;
handler(touch$$1);
last = null;
}
@@ -2290,7 +2293,7 @@ function empty(el) {
// Makes `el` the last child of its parent, so it renders in front of the other children.
function toFront(el) {
var parent = el.parentNode;
- if (parent.lastChild !== el) {
+ if (parent && parent.lastChild !== el) {
parent.appendChild(el);
}
}
@@ -2299,7 +2302,7 @@ function toFront(el) {
// Makes `el` the first child of its parent, so it renders behind the other children.
function toBack(el) {
var parent = el.parentNode;
- if (parent.firstChild !== el) {
+ if (parent && parent.firstChild !== el) {
parent.insertBefore(el, parent.firstChild);
}
}
@@ -2352,6 +2355,11 @@ function setClass(el, name) {
// @function getClass(el: HTMLElement): String
// Returns the element's class.
function getClass(el) {
+ // Check if the element is an SVGElementInstance and use the correspondingElement instead
+ // (Required for linked SVG elements in IE11.)
+ if (el.correspondingElement) {
+ el = el.correspondingElement;
+ }
return el.className.baseVal === undefined ? el.className : el.className.baseVal;
}
@@ -3113,6 +3121,13 @@ var Map = Evented.extend({
initialize: function (id, options) { // (HTMLElement or String, Object)
options = setOptions(this, options);
+ // Make sure to assign internal flags at the beginning,
+ // to avoid inconsistent state in some edge cases.
+ this._handlers = [];
+ this._layers = {};
+ this._zoomBoundLayers = {};
+ this._sizeChanged = true;
+
this._initContainer(id);
this._initLayout();
@@ -3133,11 +3148,6 @@ var Map = Evented.extend({
this.setView(toLatLng(options.center), options.zoom, {reset: true});
}
- this._handlers = [];
- this._layers = {};
- this._zoomBoundLayers = {};
- this._sizeChanged = true;
-
this.callInitHooks();
// don't animate on browsers without hardware-accelerated transitions or old Android/Opera
@@ -3496,6 +3506,51 @@ var Map = Evented.extend({
return this;
},
+ // @method panInside(latlng: LatLng, options?: options): this
+ // Pans the map the minimum amount to make the `latlng` visible. Use
+ // `padding`, `paddingTopLeft` and `paddingTopRight` options to fit
+ // the display to more restricted bounds, like [`fitBounds`](#map-fitbounds).
+ // If `latlng` is already within the (optionally padded) display bounds,
+ // the map will not be panned.
+ panInside: function (latlng, options) {
+ options = options || {};
+
+ var paddingTL = toPoint(options.paddingTopLeft || options.padding || [0, 0]),
+ paddingBR = toPoint(options.paddingBottomRight || options.padding || [0, 0]),
+ center = this.getCenter(),
+ pixelCenter = this.project(center),
+ pixelPoint = this.project(latlng),
+ pixelBounds = this.getPixelBounds(),
+ halfPixelBounds = pixelBounds.getSize().divideBy(2),
+ paddedBounds = toBounds([pixelBounds.min.add(paddingTL), pixelBounds.max.subtract(paddingBR)]);
+
+ if (!paddedBounds.contains(pixelPoint)) {
+ this._enforcingBounds = true;
+ var diff = pixelCenter.subtract(pixelPoint),
+ newCenter = toPoint(pixelPoint.x + diff.x, pixelPoint.y + diff.y);
+
+ if (pixelPoint.x < paddedBounds.min.x || pixelPoint.x > paddedBounds.max.x) {
+ newCenter.x = pixelCenter.x - diff.x;
+ if (diff.x > 0) {
+ newCenter.x += halfPixelBounds.x - paddingTL.x;
+ } else {
+ newCenter.x -= halfPixelBounds.x - paddingBR.x;
+ }
+ }
+ if (pixelPoint.y < paddedBounds.min.y || pixelPoint.y > paddedBounds.max.y) {
+ newCenter.y = pixelCenter.y - diff.y;
+ if (diff.y > 0) {
+ newCenter.y += halfPixelBounds.y - paddingTL.y;
+ } else {
+ newCenter.y -= halfPixelBounds.y - paddingBR.y;
+ }
+ }
+ this.panTo(this.unproject(newCenter), options);
+ this._enforcingBounds = false;
+ }
+ return this;
+ },
+
// @method invalidateSize(options: Zoom/pan options): this
// Checks if the map container size changed and updates the map if so â
// call it after you've changed the map size dynamically, also animating
@@ -4256,9 +4311,15 @@ var Map = Evented.extend({
// this event. Also fired on mobile when the user holds a single touch
// for a second (also called long press).
// @event keypress: KeyboardEvent
- // Fired when the user presses a key from the keyboard while the map is focused.
+ // Fired when the user presses a key from the keyboard that produces a character value while the map is focused.
+ // @event keydown: KeyboardEvent
+ // Fired when the user presses a key from the keyboard while the map is focused. Unlike the `keypress` event,
+ // the `keydown` event is fired for keys that produce a character value and for keys
+ // that do not produce a character value.
+ // @event keyup: KeyboardEvent
+ // Fired when the user releases a key from the keyboard while the map is focused.
onOff(this._container, 'click dblclick mousedown mouseup ' +
- 'mouseover mouseout mousemove contextmenu keypress', this._handleDOMEvent, this);
+ 'mouseover mouseout mousemove contextmenu keypress keydown keyup', this._handleDOMEvent, this);
if (this.options.trackResize) {
onOff(window, 'resize', this._onResize, this);
@@ -4322,7 +4383,7 @@ var Map = Evented.extend({
var type = e.type;
- if (type === 'mousedown' || type === 'keypress') {
+ if (type === 'mousedown' || type === 'keypress' || type === 'keyup' || type === 'keydown') {
// prevents outline when clicking on keyboard-focusable element
preventOutline(e.target || e.srcElement);
}
@@ -4361,7 +4422,7 @@ var Map = Evented.extend({
originalEvent: e
};
- if (e.type !== 'keypress') {
+ if (e.type !== 'keypress' && e.type !== 'keydown' && e.type !== 'keyup') {
var isMarker = target.getLatLng && (!target._radius || target._radius <= 10);
data.containerPoint = isMarker ?
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
@@ -4614,7 +4675,7 @@ var Map = Evented.extend({
}
// @event zoomanim: ZoomAnimEvent
- // Fired on every frame of a zoom animation
+ // Fired at least once per zoom animation. For continuous zoom, like pinch zooming, fired once per frame during zoom.
this.fire('zoomanim', {
center: center,
zoom: zoom,
@@ -4732,6 +4793,8 @@ var Control = Class.extend({
corner.appendChild(container);
}
+ this._map.on('unload', this.remove, this);
+
return this;
},
@@ -4748,6 +4811,7 @@ var Control = Class.extend({
this.onRemove(this._map);
}
+ this._map.off('unload', this.remove, this);
this._map = null;
return this;
@@ -4970,13 +5034,13 @@ var Layers = Control.extend({
// Expand the control container if collapsed.
expand: function () {
addClass(this._container, 'leaflet-control-layers-expanded');
- this._form.style.height = null;
+ this._section.style.height = null;
var acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);
- if (acceptableHeight < this._form.clientHeight) {
- addClass(this._form, 'leaflet-control-layers-scrollbar');
- this._form.style.height = acceptableHeight + 'px';
+ if (acceptableHeight < this._section.clientHeight) {
+ addClass(this._section, 'leaflet-control-layers-scrollbar');
+ this._section.style.height = acceptableHeight + 'px';
} else {
- removeClass(this._form, 'leaflet-control-layers-scrollbar');
+ removeClass(this._section, 'leaflet-control-layers-scrollbar');
}
this._checkDisabledLayers();
return this;
@@ -5000,7 +5064,7 @@ var Layers = Control.extend({
disableClickPropagation(container);
disableScrollPropagation(container);
- var form = this._form = create$1('form', className + '-list');
+ var section = this._section = create$1('section', className + '-list');
if (collapsed) {
this._map.on('click', this.collapse, this);
@@ -5028,11 +5092,11 @@ var Layers = Control.extend({
this.expand();
}
- this._baseLayersList = create$1('div', className + '-base', form);
- this._separator = create$1('div', className + '-separator', form);
- this._overlaysList = create$1('div', className + '-overlays', form);
+ this._baseLayersList = create$1('div', className + '-base', section);
+ this._separator = create$1('div', className + '-separator', section);
+ this._overlaysList = create$1('div', className + '-overlays', section);
- container.appendChild(form);
+ container.appendChild(section);
},
_getLayer: function (id) {
@@ -5145,7 +5209,7 @@ var Layers = Control.extend({
input.className = 'leaflet-control-layers-selector';
input.defaultChecked = checked;
} else {
- input = this._createRadioElement('leaflet-base-layers', checked);
+ input = this._createRadioElement('leaflet-base-layers_' + stamp(this), checked);
}
this._layerControlInputs.push(input);
@@ -5530,7 +5594,7 @@ var Attribution = Control.extend({
// @option prefix: String = 'Leaflet'
// The HTML text shown before the attributions. Pass `false` to disable.
- prefix: 'Leaflet'
+ prefix: 'Leaflet'
},
initialize: function (options) {
@@ -6275,7 +6339,7 @@ var LonLat = {
* @namespace Projection
* @projection L.Projection.Mercator
*
- * Elliptical Mercator projection â more complex than Spherical Mercator. Takes into account that Earth is a geoid, not a perfect sphere. Used by the EPSG:3395 CRS.
+ * Elliptical Mercator projection â more complex than Spherical Mercator. Assumes that Earth is an ellipsoid. Used by the EPSG:3395 CRS.
*/
var Mercator = {
@@ -6435,7 +6499,7 @@ CRS.Simple = Simple;
* @example
*
* ```js
- * var layer = L.Marker(latlng).addTo(map);
+ * var layer = L.marker(latlng).addTo(map);
* layer.addTo(map);
* layer.remove();
* ```
@@ -6457,7 +6521,7 @@ var Layer = Evented.extend({
pane: 'overlayPane',
// @option attribution: String = null
- // String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox".
+ // String to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
attribution: null,
bubblingMouseEvents: true
@@ -7366,6 +7430,10 @@ var Marker = Layer.extend({
// `Map pane` where the markers icon will be added.
pane: 'markerPane',
+ // @option pane: String = 'shadowPane'
+ // `Map pane` where the markers shadow will be added.
+ shadowPane: 'shadowPane',
+
// @option bubblingMouseEvents: Boolean = false
// When `true`, a mouse event on this marker will trigger the same event on the map
// (unless [`L.DomEvent.stopPropagation`](#domevent-stoppropagation) is used).
@@ -7458,6 +7526,12 @@ var Marker = Layer.extend({
return this.update();
},
+ // @method getIcon: Icon
+ // Returns the current icon used by the marker
+ getIcon: function () {
+ return this.options.icon;
+ },
+
// @method setIcon(icon: Icon): this
// Changes the marker icon.
setIcon: function (icon) {
@@ -7553,7 +7627,7 @@ var Marker = Layer.extend({
}
this._initInteraction();
if (newShadow && addShadow) {
- this.getPane('shadowPane').appendChild(this._shadow);
+ this.getPane(options.shadowPane).appendChild(this._shadow);
}
},
@@ -7637,7 +7711,9 @@ var Marker = Layer.extend({
_updateOpacity: function () {
var opacity = this.options.opacity;
- setOpacity(this._icon, opacity);
+ if (this._icon) {
+ setOpacity(this._icon, opacity);
+ }
if (this._shadow) {
setOpacity(this._shadow, opacity);
@@ -7774,6 +7850,9 @@ var Path = Layer.extend({
setOptions(this, style);
if (this._renderer) {
this._renderer._updateStyle(this);
+ if (this.options.stroke && style.hasOwnProperty('weight')) {
+ this._updateBounds();
+ }
}
return this;
},
@@ -8215,16 +8294,21 @@ var Polyline = Path.extend({
this._rings = [];
this._projectLatlngs(this._latlngs, this._rings, pxBounds);
- var w = this._clickTolerance(),
- p = new Point(w, w);
-
if (this._bounds.isValid() && pxBounds.isValid()) {
- pxBounds.min._subtract(p);
- pxBounds.max._add(p);
- this._pxBounds = pxBounds;
+ this._rawPxBounds = pxBounds;
+ this._updateBounds();
}
},
+ _updateBounds: function () {
+ var w = this._clickTolerance(),
+ p = new Point(w, w);
+ this._pxBounds = new Bounds([
+ this._rawPxBounds.min.subtract(p),
+ this._rawPxBounds.max.add(p)
+ ]);
+ },
+
// recursively turns latlngs into a set of rings with projected coordinates
_projectLatlngs: function (latlngs, result, projectedBounds) {
var flat = latlngs[0] instanceof LatLng,
@@ -8652,10 +8736,10 @@ var GeoJSON = FeatureGroup.extend({
},
_setLayerStyle: function (layer, style) {
- if (typeof style === 'function') {
- style = style(layer.feature);
- }
if (layer.setStyle) {
+ if (typeof style === 'function') {
+ style = style(layer.feature);
+ }
layer.setStyle(style);
}
}
@@ -8805,19 +8889,25 @@ var PointToGeoJSON = {
};
// @namespace Marker
-// @method toGeoJSON(): Object
+// @method toGeoJSON(precision?: Number): Object
+// `precision` is the number of decimal places for coordinates.
+// The default value is 6 places.
// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature).
Marker.include(PointToGeoJSON);
// @namespace CircleMarker
-// @method toGeoJSON(): Object
+// @method toGeoJSON(precision?: Number): Object
+// `precision` is the number of decimal places for coordinates.
+// The default value is 6 places.
// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature).
Circle.include(PointToGeoJSON);
CircleMarker.include(PointToGeoJSON);
// @namespace Polyline
-// @method toGeoJSON(): Object
+// @method toGeoJSON(precision?: Number): Object
+// `precision` is the number of decimal places for coordinates.
+// The default value is 6 places.
// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature).
Polyline.include({
toGeoJSON: function (precision) {
@@ -8833,7 +8923,9 @@ Polyline.include({
});
// @namespace Polygon
-// @method toGeoJSON(): Object
+// @method toGeoJSON(precision?: Number): Object
+// `precision` is the number of decimal places for coordinates.
+// The default value is 6 places.
// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature).
Polygon.include({
toGeoJSON: function (precision) {
@@ -8869,7 +8961,9 @@ LayerGroup.include({
});
},
- // @method toGeoJSON(): Object
+ // @method toGeoJSON(precision?: Number): Object
+ // `precision` is the number of decimal places for coordinates.
+ // The default value is 6 places.
// Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `FeatureCollection`, `GeometryCollection`, or `MultiPoint`).
toGeoJSON: function (precision) {
@@ -9214,7 +9308,12 @@ var VideoOverlay = ImageOverlay.extend({
// @option loop: Boolean = true
// Whether the video will loop back to the beginning when played.
- loop: true
+ loop: true,
+
+ // @option keepAspectRatio: Boolean = true
+ // Whether the video will save aspect ratio after the projection.
+ // Relevant for supported browsers. Browser compatibility- https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
+ keepAspectRatio: true
},
_initImage: function () {
@@ -9244,6 +9343,7 @@ var VideoOverlay = ImageOverlay.extend({
if (!isArray(this._url)) { this._url = [this._url]; }
+ if (!this.options.keepAspectRatio && vid.style.hasOwnProperty('objectFit')) { vid.style['objectFit'] = 'fill'; }
vid.autoplay = !!this.options.autoplay;
vid.loop = !!this.options.loop;
for (var i = 0; i < this._url.length; i++) {
@@ -9267,6 +9367,49 @@ function videoOverlay(video, bounds, options) {
return new VideoOverlay(video, bounds, options);
}
+/*
+ * @class SVGOverlay
+ * @aka L.SVGOverlay
+ * @inherits ImageOverlay
+ *
+ * Used to load, display and provide DOM access to an SVG file over specific bounds of the map. Extends `ImageOverlay`.
+ *
+ * An SVG overlay uses the [`