Code coverage report for src/layer/vector/MultiPoly.js

Statements: 35% (7 / 20)      Branches: 0% (0 / 2)      Functions: 28.57% (2 / 7)      Lines: 35% (7 / 20)     

All files » src/layer/vector/ » MultiPoly.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48        1 1   2                                                         1 1   1       1        
/*
 * Contains L.MultiPolyline and L.MultiPolygon layers.
 */
 
(function () {
	function createMulti(Klass) {
 
		return L.FeatureGroup.extend({
 
			initialize: function (latlngs, options) {
				this._layers = {};
				this._options = options;
				this.setLatLngs(latlngs);
			},
 
			setLatLngs: function (latlngs) {
				var i = 0,
				    len = latlngs.length;
 
				this.eachLayer(function (layer) {
					if (i < len) {
						layer.setLatLngs(latlngs[i++]);
					} else {
						this.removeLayer(layer);
					}
				}, this);
 
				while (i < len) {
					this.addLayer(new Klass(latlngs[i++], this._options));
				}
 
				return this;
			}
		});
	}
 
	L.MultiPolyline = createMulti(L.Polyline);
	L.MultiPolygon = createMulti(L.Polygon);
 
	L.multiPolyline = function (latlngs, options) {
		return new L.MultiPolyline(latlngs, options);
	};
 
	L.multiPolygon = function (latlngs, options) {
		return new L.MultiPolygon(latlngs, options);
	};
}());