Merge pull request #1318 from yohanboniface/add_lbrt_getters
Add LatLngBounds.getLeft/getBottom/getRight/getTop
This commit is contained in:
commit
80f107cba3
@ -20,4 +20,54 @@ describe('LatLngBounds', function() {
|
|||||||
expect(c.isValid()).toBeTruthy();
|
expect(c.isValid()).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getWest', function () {
|
||||||
|
it('should return a proper bbox west value', function() {
|
||||||
|
expect(a.getWest()).toEqual(12);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#getSouth', function () {
|
||||||
|
it('should return a proper bbox south value', function() {
|
||||||
|
expect(a.getSouth()).toEqual(14);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#getEast', function () {
|
||||||
|
it('should return a proper bbox east value', function() {
|
||||||
|
expect(a.getEast()).toEqual(40);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#getNorth', function () {
|
||||||
|
it('should return a proper bbox north value', function() {
|
||||||
|
expect(a.getNorth()).toEqual(30);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#toBBoxString', function () {
|
||||||
|
it('should return a proper left,bottom,right,top bbox', function() {
|
||||||
|
expect(a.toBBoxString()).toEqual("12,14,40,30");
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#getNorthWest', function () {
|
||||||
|
it('should return a proper north-west LatLng', function() {
|
||||||
|
expect(a.getNorthWest()).toEqual(new L.LatLng(a.getNorth(), a.getWest()));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#getSouthEast', function () {
|
||||||
|
it('should return a proper south-east LatLng', function() {
|
||||||
|
expect(a.getSouthEast()).toEqual(new L.LatLng(a.getSouth(), a.getEast()));
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
@ -66,11 +66,27 @@ L.LatLngBounds.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getNorthWest: function () {
|
getNorthWest: function () {
|
||||||
return new L.LatLng(this._northEast.lat, this._southWest.lng);
|
return new L.LatLng(this.getNorth(), this.getWest());
|
||||||
},
|
},
|
||||||
|
|
||||||
getSouthEast: function () {
|
getSouthEast: function () {
|
||||||
return new L.LatLng(this._southWest.lat, this._northEast.lng);
|
return new L.LatLng(this.getSouth(), this.getEast());
|
||||||
|
},
|
||||||
|
|
||||||
|
getWest: function () {
|
||||||
|
return this._southWest.lng;
|
||||||
|
},
|
||||||
|
|
||||||
|
getSouth: function () {
|
||||||
|
return this._southWest.lat;
|
||||||
|
},
|
||||||
|
|
||||||
|
getEast: function () {
|
||||||
|
return this._northEast.lng;
|
||||||
|
},
|
||||||
|
|
||||||
|
getNorth: function () {
|
||||||
|
return this._northEast.lat;
|
||||||
},
|
},
|
||||||
|
|
||||||
contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean
|
contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean
|
||||||
@ -110,10 +126,7 @@ L.LatLngBounds.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toBBoxString: function () {
|
toBBoxString: function () {
|
||||||
var sw = this._southWest,
|
return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');
|
||||||
ne = this._northEast;
|
|
||||||
|
|
||||||
return [sw.lng, sw.lat, ne.lng, ne.lat].join(',');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
equals: function (bounds) { // (LatLngBounds)
|
equals: function (bounds) { // (LatLngBounds)
|
||||||
|
Loading…
Reference in New Issue
Block a user