diff --git a/spec/suites/geo/LatLngBoundsSpec.js b/spec/suites/geo/LatLngBoundsSpec.js index 384f5ab6..379a73fe 100644 --- a/spec/suites/geo/LatLngBoundsSpec.js +++ b/spec/suites/geo/LatLngBoundsSpec.js @@ -20,4 +20,39 @@ describe('LatLngBounds', function() { expect(c.isValid()).toBeTruthy(); }); }); + + describe('#getLeft', function () { + it('should return a proper bbox left value', function() { + expect(a.getLeft()).toEqual(12); + }); + + }); + + describe('#getBottom', function () { + it('should return a proper bbox bottom value', function() { + expect(a.getBottom()).toEqual(14); + }); + + }); + + describe('#getRight', function () { + it('should return a proper bbox right value', function() { + expect(a.getRight()).toEqual(40); + }); + + }); + + describe('#getTop', function () { + it('should return a proper bbox top value', function() { + expect(a.getTop()).toEqual(30); + }); + + }); + + describe('#toBBoxString', function () { + it('should return a proper left,bottom,right,top bbox', function() { + expect(a.toBBoxString()).toEqual("12,14,40,30"); + }); + + }); }); \ No newline at end of file diff --git a/src/geo/LatLngBounds.js b/src/geo/LatLngBounds.js index bb407069..b19f5101 100644 --- a/src/geo/LatLngBounds.js +++ b/src/geo/LatLngBounds.js @@ -73,6 +73,22 @@ L.LatLngBounds.prototype = { return new L.LatLng(this._southWest.lat, this._northEast.lng); }, + getLeft: function () { + return this._southWest.lng; + }, + + getBottom: function () { + return this._southWest.lat; + }, + + getRight: function () { + return this._northEast.lng; + }, + + getTop: function () { + return this._northEast.lat; + }, + contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean if (typeof obj[0] === 'number' || obj instanceof L.LatLng) { obj = L.latLng(obj); @@ -110,10 +126,7 @@ L.LatLngBounds.prototype = { }, toBBoxString: function () { - var sw = this._southWest, - ne = this._northEast; - - return [sw.lng, sw.lat, ne.lng, ne.lat].join(','); + return [this.getLeft(), this.getBottom(), this.getRight(), this.getTop()].join(','); }, equals: function (bounds) { // (LatLngBounds)