# Code coverage report for src/layer/vector/Rectangle.js

## Statements: 28.57% (2 / 7) Branches: 100% (0 / 0) Functions: 0% (0 / 4) Lines: 28.57% (2 / 7)

All files » src/layer/vector/ » Rectangle.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

    1

    1

     /*
     * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object.
     */

    L.Rectangle = L.Polygon.extend({
    	initialize: function (latLngBounds, options) {
    		L.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options);
    	},

    	setBounds: function (latLngBounds) {
    		this.setLatLngs(this._boundsToLatLngs(latLngBounds));
    	},

    	_boundsToLatLngs: function (latLngBounds) {
    		latLngBounds = L.latLngBounds(latLngBounds);
    		return [
    			latLngBounds.getSouthWest(),
    			latLngBounds.getNorthWest(),
    			latLngBounds.getNorthEast(),
    			latLngBounds.getSouthEast()
    		];
    	}
    });

    L.rectangle = function (latLngBounds, options) {
    	return new L.Rectangle(latLngBounds, options);
    };