decidim 0.26.9 → 0.26.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/decidim/version.rb +1 -1
  3. data/package-lock.json +7 -7
  4. data/packages/browserslist-config/package.json +1 -1
  5. data/packages/core/node_modules/leaflet/CHANGELOG.md +2191 -0
  6. data/packages/core/node_modules/leaflet/LICENSE +26 -0
  7. data/packages/core/node_modules/leaflet/README.md +55 -0
  8. data/packages/core/node_modules/leaflet/dist/images/layers-2x.png +0 -0
  9. data/packages/core/node_modules/leaflet/dist/images/layers.png +0 -0
  10. data/packages/core/node_modules/leaflet/dist/images/marker-icon-2x.png +0 -0
  11. data/packages/core/node_modules/leaflet/dist/images/marker-icon.png +0 -0
  12. data/packages/core/node_modules/leaflet/dist/images/marker-shadow.png +0 -0
  13. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js +14419 -0
  14. data/packages/core/node_modules/leaflet/dist/leaflet-src.esm.js.map +1 -0
  15. data/packages/core/node_modules/leaflet/dist/leaflet-src.js +14512 -0
  16. data/packages/core/node_modules/leaflet/dist/leaflet-src.js.map +1 -0
  17. data/packages/core/node_modules/leaflet/dist/leaflet.css +661 -0
  18. data/packages/core/node_modules/leaflet/dist/leaflet.js +6 -0
  19. data/packages/core/node_modules/leaflet/dist/leaflet.js.map +1 -0
  20. data/packages/core/node_modules/leaflet/package.json +149 -0
  21. data/packages/core/node_modules/leaflet/src/Leaflet.js +24 -0
  22. data/packages/core/node_modules/leaflet/src/control/Control.Attribution.js +148 -0
  23. data/packages/core/node_modules/leaflet/src/control/Control.Layers.js +443 -0
  24. data/packages/core/node_modules/leaflet/src/control/Control.Scale.js +132 -0
  25. data/packages/core/node_modules/leaflet/src/control/Control.Zoom.js +146 -0
  26. data/packages/core/node_modules/leaflet/src/control/Control.js +174 -0
  27. data/packages/core/node_modules/leaflet/src/control/index.js +17 -0
  28. data/packages/core/node_modules/leaflet/src/core/Browser.js +220 -0
  29. data/packages/core/node_modules/leaflet/src/core/Class.js +135 -0
  30. data/packages/core/node_modules/leaflet/src/core/Class.leafdoc +197 -0
  31. data/packages/core/node_modules/leaflet/src/core/Events.js +344 -0
  32. data/packages/core/node_modules/leaflet/src/core/Events.leafdoc +143 -0
  33. data/packages/core/node_modules/leaflet/src/core/Handler.js +57 -0
  34. data/packages/core/node_modules/leaflet/src/core/Util.js +241 -0
  35. data/packages/core/node_modules/leaflet/src/core/index.js +15 -0
  36. data/packages/core/node_modules/leaflet/src/dom/DomEvent.DoubleTap.js +91 -0
  37. data/packages/core/node_modules/leaflet/src/dom/DomEvent.Pointer.js +97 -0
  38. data/packages/core/node_modules/leaflet/src/dom/DomEvent.js +315 -0
  39. data/packages/core/node_modules/leaflet/src/dom/DomUtil.js +349 -0
  40. data/packages/core/node_modules/leaflet/src/dom/Draggable.js +220 -0
  41. data/packages/core/node_modules/leaflet/src/dom/PosAnimation.js +113 -0
  42. data/packages/core/node_modules/leaflet/src/dom/index.js +9 -0
  43. data/packages/core/node_modules/leaflet/src/geo/LatLng.js +137 -0
  44. data/packages/core/node_modules/leaflet/src/geo/LatLngBounds.js +251 -0
  45. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3395.js +20 -0
  46. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG3857.js +27 -0
  47. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.EPSG4326.js +23 -0
  48. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Earth.js +33 -0
  49. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.Simple.js +36 -0
  50. data/packages/core/node_modules/leaflet/src/geo/crs/CRS.js +139 -0
  51. data/packages/core/node_modules/leaflet/src/geo/crs/index.js +15 -0
  52. data/packages/core/node_modules/leaflet/src/geo/index.js +7 -0
  53. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.LonLat.js +28 -0
  54. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.Mercator.js +49 -0
  55. data/packages/core/node_modules/leaflet/src/geo/projection/Projection.SphericalMercator.js +44 -0
  56. data/packages/core/node_modules/leaflet/src/geo/projection/index.js +26 -0
  57. data/packages/core/node_modules/leaflet/src/geometry/Bounds.js +219 -0
  58. data/packages/core/node_modules/leaflet/src/geometry/LineUtil.js +306 -0
  59. data/packages/core/node_modules/leaflet/src/geometry/Point.js +222 -0
  60. data/packages/core/node_modules/leaflet/src/geometry/PolyUtil.js +129 -0
  61. data/packages/core/node_modules/leaflet/src/geometry/Transformation.js +79 -0
  62. data/packages/core/node_modules/leaflet/src/geometry/index.js +8 -0
  63. data/packages/core/node_modules/leaflet/src/images/layers.svg +1 -0
  64. data/packages/core/node_modules/leaflet/src/images/logo.svg +1 -0
  65. data/packages/core/node_modules/leaflet/src/images/marker.svg +1 -0
  66. data/packages/core/node_modules/leaflet/src/layer/DivOverlay.js +348 -0
  67. data/packages/core/node_modules/leaflet/src/layer/FeatureGroup.js +94 -0
  68. data/packages/core/node_modules/leaflet/src/layer/GeoJSON.js +452 -0
  69. data/packages/core/node_modules/leaflet/src/layer/ImageOverlay.js +270 -0
  70. data/packages/core/node_modules/leaflet/src/layer/Layer.Interactive.leafdoc +39 -0
  71. data/packages/core/node_modules/leaflet/src/layer/Layer.js +275 -0
  72. data/packages/core/node_modules/leaflet/src/layer/LayerGroup.js +159 -0
  73. data/packages/core/node_modules/leaflet/src/layer/Popup.js +506 -0
  74. data/packages/core/node_modules/leaflet/src/layer/SVGOverlay.js +50 -0
  75. data/packages/core/node_modules/leaflet/src/layer/Tooltip.js +444 -0
  76. data/packages/core/node_modules/leaflet/src/layer/VideoOverlay.js +106 -0
  77. data/packages/core/node_modules/leaflet/src/layer/index.js +24 -0
  78. data/packages/core/node_modules/leaflet/src/layer/marker/DivIcon.js +74 -0
  79. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.Default.js +66 -0
  80. data/packages/core/node_modules/leaflet/src/layer/marker/Icon.js +165 -0
  81. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.Drag.js +161 -0
  82. data/packages/core/node_modules/leaflet/src/layer/marker/Marker.js +419 -0
  83. data/packages/core/node_modules/leaflet/src/layer/marker/index.js +8 -0
  84. data/packages/core/node_modules/leaflet/src/layer/tile/GridLayer.js +923 -0
  85. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.WMS.js +137 -0
  86. data/packages/core/node_modules/leaflet/src/layer/tile/TileLayer.js +289 -0
  87. data/packages/core/node_modules/leaflet/src/layer/tile/index.js +6 -0
  88. data/packages/core/node_modules/leaflet/src/layer/vector/Canvas.js +492 -0
  89. data/packages/core/node_modules/leaflet/src/layer/vector/Circle.js +113 -0
  90. data/packages/core/node_modules/leaflet/src/layer/vector/CircleMarker.js +109 -0
  91. data/packages/core/node_modules/leaflet/src/layer/vector/Path.js +148 -0
  92. data/packages/core/node_modules/leaflet/src/layer/vector/Polygon.js +159 -0
  93. data/packages/core/node_modules/leaflet/src/layer/vector/Polyline.js +307 -0
  94. data/packages/core/node_modules/leaflet/src/layer/vector/Rectangle.js +57 -0
  95. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.getRenderer.js +45 -0
  96. data/packages/core/node_modules/leaflet/src/layer/vector/Renderer.js +133 -0
  97. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.Util.js +39 -0
  98. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.VML.js +144 -0
  99. data/packages/core/node_modules/leaflet/src/layer/vector/SVG.js +207 -0
  100. data/packages/core/node_modules/leaflet/src/layer/vector/index.js +14 -0
  101. data/packages/core/node_modules/leaflet/src/map/Map.js +1751 -0
  102. data/packages/core/node_modules/leaflet/src/map/Map.methodOptions.leafdoc +112 -0
  103. data/packages/core/node_modules/leaflet/src/map/handler/Map.BoxZoom.js +152 -0
  104. data/packages/core/node_modules/leaflet/src/map/handler/Map.DoubleClickZoom.js +55 -0
  105. data/packages/core/node_modules/leaflet/src/map/handler/Map.Drag.js +235 -0
  106. data/packages/core/node_modules/leaflet/src/map/handler/Map.Keyboard.js +183 -0
  107. data/packages/core/node_modules/leaflet/src/map/handler/Map.ScrollWheelZoom.js +91 -0
  108. data/packages/core/node_modules/leaflet/src/map/handler/Map.TapHold.js +102 -0
  109. data/packages/core/node_modules/leaflet/src/map/handler/Map.TouchZoom.js +130 -0
  110. data/packages/core/node_modules/leaflet/src/map/index.js +17 -0
  111. data/packages/core/package.json +1 -1
  112. data/packages/dev/package.json +1 -1
  113. data/packages/elections/package.json +1 -1
  114. data/packages/eslint-config/package.json +1 -1
  115. data/packages/stylelint-config/package.json +1 -1
  116. data/packages/webpacker/package.json +1 -1
  117. metadata +148 -42
@@ -0,0 +1,45 @@
1
+ import {Map} from '../../map/Map';
2
+ import {canvas} from './Canvas';
3
+ import {svg} from './SVG';
4
+
5
+ Map.include({
6
+ // @namespace Map; @method getRenderer(layer: Path): Renderer
7
+ // Returns the instance of `Renderer` that should be used to render the given
8
+ // `Path`. It will ensure that the `renderer` options of the map and paths
9
+ // are respected, and that the renderers do exist on the map.
10
+ getRenderer: function (layer) {
11
+ // @namespace Path; @option renderer: Renderer
12
+ // Use this specific instance of `Renderer` for this path. Takes
13
+ // precedence over the map's [default renderer](#map-renderer).
14
+ var renderer = layer.options.renderer || this._getPaneRenderer(layer.options.pane) || this.options.renderer || this._renderer;
15
+
16
+ if (!renderer) {
17
+ renderer = this._renderer = this._createRenderer();
18
+ }
19
+
20
+ if (!this.hasLayer(renderer)) {
21
+ this.addLayer(renderer);
22
+ }
23
+ return renderer;
24
+ },
25
+
26
+ _getPaneRenderer: function (name) {
27
+ if (name === 'overlayPane' || name === undefined) {
28
+ return false;
29
+ }
30
+
31
+ var renderer = this._paneRenderers[name];
32
+ if (renderer === undefined) {
33
+ renderer = this._createRenderer({pane: name});
34
+ this._paneRenderers[name] = renderer;
35
+ }
36
+ return renderer;
37
+ },
38
+
39
+ _createRenderer: function (options) {
40
+ // @namespace Map; @option preferCanvas: Boolean = false
41
+ // Whether `Path`s should be rendered on a `Canvas` renderer.
42
+ // By default, all `Path`s are rendered in a `SVG` renderer.
43
+ return (this.options.preferCanvas && canvas(options)) || svg(options);
44
+ }
45
+ });
@@ -0,0 +1,133 @@
1
+ import {Layer} from '../Layer';
2
+ import * as DomUtil from '../../dom/DomUtil';
3
+ import * as Util from '../../core/Util';
4
+ import Browser from '../../core/Browser';
5
+ import {Bounds} from '../../geometry/Bounds';
6
+
7
+
8
+
9
+ /*
10
+ * @class Renderer
11
+ * @inherits Layer
12
+ * @aka L.Renderer
13
+ *
14
+ * Base class for vector renderer implementations (`SVG`, `Canvas`). Handles the
15
+ * DOM container of the renderer, its bounds, and its zoom animation.
16
+ *
17
+ * A `Renderer` works as an implicit layer group for all `Path`s - the renderer
18
+ * itself can be added or removed to the map. All paths use a renderer, which can
19
+ * be implicit (the map will decide the type of renderer and use it automatically)
20
+ * or explicit (using the [`renderer`](#path-renderer) option of the path).
21
+ *
22
+ * Do not use this class directly, use `SVG` and `Canvas` instead.
23
+ *
24
+ * @event update: Event
25
+ * Fired when the renderer updates its bounds, center and zoom, for example when
26
+ * its map has moved
27
+ */
28
+
29
+ export var Renderer = Layer.extend({
30
+
31
+ // @section
32
+ // @aka Renderer options
33
+ options: {
34
+ // @option padding: Number = 0.1
35
+ // How much to extend the clip area around the map view (relative to its size)
36
+ // e.g. 0.1 would be 10% of map view in each direction
37
+ padding: 0.1
38
+ },
39
+
40
+ initialize: function (options) {
41
+ Util.setOptions(this, options);
42
+ Util.stamp(this);
43
+ this._layers = this._layers || {};
44
+ },
45
+
46
+ onAdd: function () {
47
+ if (!this._container) {
48
+ this._initContainer(); // defined by renderer implementations
49
+
50
+ // always keep transform-origin as 0 0
51
+ DomUtil.addClass(this._container, 'leaflet-zoom-animated');
52
+ }
53
+
54
+ this.getPane().appendChild(this._container);
55
+ this._update();
56
+ this.on('update', this._updatePaths, this);
57
+ },
58
+
59
+ onRemove: function () {
60
+ this.off('update', this._updatePaths, this);
61
+ this._destroyContainer();
62
+ },
63
+
64
+ getEvents: function () {
65
+ var events = {
66
+ viewreset: this._reset,
67
+ zoom: this._onZoom,
68
+ moveend: this._update,
69
+ zoomend: this._onZoomEnd
70
+ };
71
+ if (this._zoomAnimated) {
72
+ events.zoomanim = this._onAnimZoom;
73
+ }
74
+ return events;
75
+ },
76
+
77
+ _onAnimZoom: function (ev) {
78
+ this._updateTransform(ev.center, ev.zoom);
79
+ },
80
+
81
+ _onZoom: function () {
82
+ this._updateTransform(this._map.getCenter(), this._map.getZoom());
83
+ },
84
+
85
+ _updateTransform: function (center, zoom) {
86
+ var scale = this._map.getZoomScale(zoom, this._zoom),
87
+ viewHalf = this._map.getSize().multiplyBy(0.5 + this.options.padding),
88
+ currentCenterPoint = this._map.project(this._center, zoom),
89
+
90
+ topLeftOffset = viewHalf.multiplyBy(-scale).add(currentCenterPoint)
91
+ .subtract(this._map._getNewPixelOrigin(center, zoom));
92
+
93
+ if (Browser.any3d) {
94
+ DomUtil.setTransform(this._container, topLeftOffset, scale);
95
+ } else {
96
+ DomUtil.setPosition(this._container, topLeftOffset);
97
+ }
98
+ },
99
+
100
+ _reset: function () {
101
+ this._update();
102
+ this._updateTransform(this._center, this._zoom);
103
+
104
+ for (var id in this._layers) {
105
+ this._layers[id]._reset();
106
+ }
107
+ },
108
+
109
+ _onZoomEnd: function () {
110
+ for (var id in this._layers) {
111
+ this._layers[id]._project();
112
+ }
113
+ },
114
+
115
+ _updatePaths: function () {
116
+ for (var id in this._layers) {
117
+ this._layers[id]._update();
118
+ }
119
+ },
120
+
121
+ _update: function () {
122
+ // Update pixel bounds of renderer container (for positioning/sizing/clipping later)
123
+ // Subclasses are responsible of firing the 'update' event.
124
+ var p = this.options.padding,
125
+ size = this._map.getSize(),
126
+ min = this._map.containerPointToLayerPoint(size.multiplyBy(-p)).round();
127
+
128
+ this._bounds = new Bounds(min, min.add(size.multiplyBy(1 + p * 2)).round());
129
+
130
+ this._center = this._map.getCenter();
131
+ this._zoom = this._map.getZoom();
132
+ }
133
+ });
@@ -0,0 +1,39 @@
1
+ import Browser from '../../core/Browser';
2
+
3
+ // @namespace SVG; @section
4
+ // There are several static functions which can be called without instantiating L.SVG:
5
+
6
+ // @function create(name: String): SVGElement
7
+ // Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement),
8
+ // corresponding to the class name passed. For example, using 'line' will return
9
+ // an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement).
10
+ export function svgCreate(name) {
11
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
12
+ }
13
+
14
+ // @function pointsToPath(rings: Point[], closed: Boolean): String
15
+ // Generates a SVG path string for multiple rings, with each ring turning
16
+ // into "M..L..L.." instructions
17
+ export function pointsToPath(rings, closed) {
18
+ var str = '',
19
+ i, j, len, len2, points, p;
20
+
21
+ for (i = 0, len = rings.length; i < len; i++) {
22
+ points = rings[i];
23
+
24
+ for (j = 0, len2 = points.length; j < len2; j++) {
25
+ p = points[j];
26
+ str += (j ? 'L' : 'M') + p.x + ' ' + p.y;
27
+ }
28
+
29
+ // closes the ring for polygons; "x" is VML syntax
30
+ str += closed ? (Browser.svg ? 'z' : 'x') : '';
31
+ }
32
+
33
+ // SVG complains about empty path strings
34
+ return str || 'M0 0';
35
+ }
36
+
37
+
38
+
39
+
@@ -0,0 +1,144 @@
1
+ import * as DomUtil from '../../dom/DomUtil';
2
+ import * as Util from '../../core/Util';
3
+ import {Renderer} from './Renderer';
4
+
5
+ /*
6
+ * Thanks to Dmitry Baranovsky and his Raphael library for inspiration!
7
+ */
8
+
9
+
10
+ export var vmlCreate = (function () {
11
+ try {
12
+ document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml');
13
+ return function (name) {
14
+ return document.createElement('<lvml:' + name + ' class="lvml">');
15
+ };
16
+ } catch (e) {
17
+ // Do not return fn from catch block so `e` can be garbage collected
18
+ // See https://github.com/Leaflet/Leaflet/pull/7279
19
+ }
20
+ return function (name) {
21
+ return document.createElement('<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">');
22
+ };
23
+ })();
24
+
25
+
26
+ /*
27
+ * @class SVG
28
+ *
29
+ *
30
+ * VML was deprecated in 2012, which means VML functionality exists only for backwards compatibility
31
+ * with old versions of Internet Explorer.
32
+ */
33
+
34
+ // mixin to redefine some SVG methods to handle VML syntax which is similar but with some differences
35
+ export var vmlMixin = {
36
+
37
+ _initContainer: function () {
38
+ this._container = DomUtil.create('div', 'leaflet-vml-container');
39
+ },
40
+
41
+ _update: function () {
42
+ if (this._map._animatingZoom) { return; }
43
+ Renderer.prototype._update.call(this);
44
+ this.fire('update');
45
+ },
46
+
47
+ _initPath: function (layer) {
48
+ var container = layer._container = vmlCreate('shape');
49
+
50
+ DomUtil.addClass(container, 'leaflet-vml-shape ' + (this.options.className || ''));
51
+
52
+ container.coordsize = '1 1';
53
+
54
+ layer._path = vmlCreate('path');
55
+ container.appendChild(layer._path);
56
+
57
+ this._updateStyle(layer);
58
+ this._layers[Util.stamp(layer)] = layer;
59
+ },
60
+
61
+ _addPath: function (layer) {
62
+ var container = layer._container;
63
+ this._container.appendChild(container);
64
+
65
+ if (layer.options.interactive) {
66
+ layer.addInteractiveTarget(container);
67
+ }
68
+ },
69
+
70
+ _removePath: function (layer) {
71
+ var container = layer._container;
72
+ DomUtil.remove(container);
73
+ layer.removeInteractiveTarget(container);
74
+ delete this._layers[Util.stamp(layer)];
75
+ },
76
+
77
+ _updateStyle: function (layer) {
78
+ var stroke = layer._stroke,
79
+ fill = layer._fill,
80
+ options = layer.options,
81
+ container = layer._container;
82
+
83
+ container.stroked = !!options.stroke;
84
+ container.filled = !!options.fill;
85
+
86
+ if (options.stroke) {
87
+ if (!stroke) {
88
+ stroke = layer._stroke = vmlCreate('stroke');
89
+ }
90
+ container.appendChild(stroke);
91
+ stroke.weight = options.weight + 'px';
92
+ stroke.color = options.color;
93
+ stroke.opacity = options.opacity;
94
+
95
+ if (options.dashArray) {
96
+ stroke.dashStyle = Util.isArray(options.dashArray) ?
97
+ options.dashArray.join(' ') :
98
+ options.dashArray.replace(/( *, *)/g, ' ');
99
+ } else {
100
+ stroke.dashStyle = '';
101
+ }
102
+ stroke.endcap = options.lineCap.replace('butt', 'flat');
103
+ stroke.joinstyle = options.lineJoin;
104
+
105
+ } else if (stroke) {
106
+ container.removeChild(stroke);
107
+ layer._stroke = null;
108
+ }
109
+
110
+ if (options.fill) {
111
+ if (!fill) {
112
+ fill = layer._fill = vmlCreate('fill');
113
+ }
114
+ container.appendChild(fill);
115
+ fill.color = options.fillColor || options.color;
116
+ fill.opacity = options.fillOpacity;
117
+
118
+ } else if (fill) {
119
+ container.removeChild(fill);
120
+ layer._fill = null;
121
+ }
122
+ },
123
+
124
+ _updateCircle: function (layer) {
125
+ var p = layer._point.round(),
126
+ r = Math.round(layer._radius),
127
+ r2 = Math.round(layer._radiusY || r);
128
+
129
+ this._setPath(layer, layer._empty() ? 'M0 0' :
130
+ 'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r2 + ' 0,' + (65535 * 360));
131
+ },
132
+
133
+ _setPath: function (layer, path) {
134
+ layer._path.v = path;
135
+ },
136
+
137
+ _bringToFront: function (layer) {
138
+ DomUtil.toFront(layer._container);
139
+ },
140
+
141
+ _bringToBack: function (layer) {
142
+ DomUtil.toBack(layer._container);
143
+ }
144
+ };
@@ -0,0 +1,207 @@
1
+ import {Renderer} from './Renderer';
2
+ import * as DomUtil from '../../dom/DomUtil';
3
+ import * as DomEvent from '../../dom/DomEvent';
4
+ import Browser from '../../core/Browser';
5
+ import {stamp} from '../../core/Util';
6
+ import {svgCreate, pointsToPath} from './SVG.Util';
7
+ export {pointsToPath};
8
+ import {vmlMixin, vmlCreate} from './SVG.VML';
9
+
10
+ export var create = Browser.vml ? vmlCreate : svgCreate;
11
+
12
+ /*
13
+ * @class SVG
14
+ * @inherits Renderer
15
+ * @aka L.SVG
16
+ *
17
+ * Allows vector layers to be displayed with [SVG](https://developer.mozilla.org/docs/Web/SVG).
18
+ * Inherits `Renderer`.
19
+ *
20
+ * Due to [technical limitations](https://caniuse.com/svg), SVG is not
21
+ * available in all web browsers, notably Android 2.x and 3.x.
22
+ *
23
+ * Although SVG is not available on IE7 and IE8, these browsers support
24
+ * [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language)
25
+ * (a now deprecated technology), and the SVG renderer will fall back to VML in
26
+ * this case.
27
+ *
28
+ * @example
29
+ *
30
+ * Use SVG by default for all paths in the map:
31
+ *
32
+ * ```js
33
+ * var map = L.map('map', {
34
+ * renderer: L.svg()
35
+ * });
36
+ * ```
37
+ *
38
+ * Use a SVG renderer with extra padding for specific vector geometries:
39
+ *
40
+ * ```js
41
+ * var map = L.map('map');
42
+ * var myRenderer = L.svg({ padding: 0.5 });
43
+ * var line = L.polyline( coordinates, { renderer: myRenderer } );
44
+ * var circle = L.circle( center, { renderer: myRenderer } );
45
+ * ```
46
+ */
47
+
48
+ export var SVG = Renderer.extend({
49
+
50
+ _initContainer: function () {
51
+ this._container = create('svg');
52
+
53
+ // makes it possible to click through svg root; we'll reset it back in individual paths
54
+ this._container.setAttribute('pointer-events', 'none');
55
+
56
+ this._rootGroup = create('g');
57
+ this._container.appendChild(this._rootGroup);
58
+ },
59
+
60
+ _destroyContainer: function () {
61
+ DomUtil.remove(this._container);
62
+ DomEvent.off(this._container);
63
+ delete this._container;
64
+ delete this._rootGroup;
65
+ delete this._svgSize;
66
+ },
67
+
68
+ _update: function () {
69
+ if (this._map._animatingZoom && this._bounds) { return; }
70
+
71
+ Renderer.prototype._update.call(this);
72
+
73
+ var b = this._bounds,
74
+ size = b.getSize(),
75
+ container = this._container;
76
+
77
+ // set size of svg-container if changed
78
+ if (!this._svgSize || !this._svgSize.equals(size)) {
79
+ this._svgSize = size;
80
+ container.setAttribute('width', size.x);
81
+ container.setAttribute('height', size.y);
82
+ }
83
+
84
+ // movement: update container viewBox so that we don't have to change coordinates of individual layers
85
+ DomUtil.setPosition(container, b.min);
86
+ container.setAttribute('viewBox', [b.min.x, b.min.y, size.x, size.y].join(' '));
87
+
88
+ this.fire('update');
89
+ },
90
+
91
+ // methods below are called by vector layers implementations
92
+
93
+ _initPath: function (layer) {
94
+ var path = layer._path = create('path');
95
+
96
+ // @namespace Path
97
+ // @option className: String = null
98
+ // Custom class name set on an element. Only for SVG renderer.
99
+ if (layer.options.className) {
100
+ DomUtil.addClass(path, layer.options.className);
101
+ }
102
+
103
+ if (layer.options.interactive) {
104
+ DomUtil.addClass(path, 'leaflet-interactive');
105
+ }
106
+
107
+ this._updateStyle(layer);
108
+ this._layers[stamp(layer)] = layer;
109
+ },
110
+
111
+ _addPath: function (layer) {
112
+ if (!this._rootGroup) { this._initContainer(); }
113
+ this._rootGroup.appendChild(layer._path);
114
+ layer.addInteractiveTarget(layer._path);
115
+ },
116
+
117
+ _removePath: function (layer) {
118
+ DomUtil.remove(layer._path);
119
+ layer.removeInteractiveTarget(layer._path);
120
+ delete this._layers[stamp(layer)];
121
+ },
122
+
123
+ _updatePath: function (layer) {
124
+ layer._project();
125
+ layer._update();
126
+ },
127
+
128
+ _updateStyle: function (layer) {
129
+ var path = layer._path,
130
+ options = layer.options;
131
+
132
+ if (!path) { return; }
133
+
134
+ if (options.stroke) {
135
+ path.setAttribute('stroke', options.color);
136
+ path.setAttribute('stroke-opacity', options.opacity);
137
+ path.setAttribute('stroke-width', options.weight);
138
+ path.setAttribute('stroke-linecap', options.lineCap);
139
+ path.setAttribute('stroke-linejoin', options.lineJoin);
140
+
141
+ if (options.dashArray) {
142
+ path.setAttribute('stroke-dasharray', options.dashArray);
143
+ } else {
144
+ path.removeAttribute('stroke-dasharray');
145
+ }
146
+
147
+ if (options.dashOffset) {
148
+ path.setAttribute('stroke-dashoffset', options.dashOffset);
149
+ } else {
150
+ path.removeAttribute('stroke-dashoffset');
151
+ }
152
+ } else {
153
+ path.setAttribute('stroke', 'none');
154
+ }
155
+
156
+ if (options.fill) {
157
+ path.setAttribute('fill', options.fillColor || options.color);
158
+ path.setAttribute('fill-opacity', options.fillOpacity);
159
+ path.setAttribute('fill-rule', options.fillRule || 'evenodd');
160
+ } else {
161
+ path.setAttribute('fill', 'none');
162
+ }
163
+ },
164
+
165
+ _updatePoly: function (layer, closed) {
166
+ this._setPath(layer, pointsToPath(layer._parts, closed));
167
+ },
168
+
169
+ _updateCircle: function (layer) {
170
+ var p = layer._point,
171
+ r = Math.max(Math.round(layer._radius), 1),
172
+ r2 = Math.max(Math.round(layer._radiusY), 1) || r,
173
+ arc = 'a' + r + ',' + r2 + ' 0 1,0 ';
174
+
175
+ // drawing a circle with two half-arcs
176
+ var d = layer._empty() ? 'M0 0' :
177
+ 'M' + (p.x - r) + ',' + p.y +
178
+ arc + (r * 2) + ',0 ' +
179
+ arc + (-r * 2) + ',0 ';
180
+
181
+ this._setPath(layer, d);
182
+ },
183
+
184
+ _setPath: function (layer, path) {
185
+ layer._path.setAttribute('d', path);
186
+ },
187
+
188
+ // SVG does not have the concept of zIndex so we resort to changing the DOM order of elements
189
+ _bringToFront: function (layer) {
190
+ DomUtil.toFront(layer._path);
191
+ },
192
+
193
+ _bringToBack: function (layer) {
194
+ DomUtil.toBack(layer._path);
195
+ }
196
+ });
197
+
198
+ if (Browser.vml) {
199
+ SVG.include(vmlMixin);
200
+ }
201
+
202
+ // @namespace SVG
203
+ // @factory L.svg(options?: Renderer options)
204
+ // Creates a SVG renderer with the given options.
205
+ export function svg(options) {
206
+ return Browser.svg || Browser.vml ? new SVG(options) : null;
207
+ }
@@ -0,0 +1,14 @@
1
+ export {Renderer} from './Renderer';
2
+ export {Canvas, canvas} from './Canvas';
3
+ import {SVG, create, pointsToPath, svg} from './SVG';
4
+ SVG.create = create;
5
+ SVG.pointsToPath = pointsToPath;
6
+ export {SVG, svg};
7
+ import './Renderer.getRenderer'; // This is a bit of a hack, but needed because circular dependencies
8
+
9
+ export {Path} from './Path';
10
+ export {CircleMarker, circleMarker} from './CircleMarker';
11
+ export {Circle, circle} from './Circle';
12
+ export {Polyline, polyline} from './Polyline';
13
+ export {Polygon, polygon} from './Polygon';
14
+ export {Rectangle, rectangle} from './Rectangle';