Added LatLngBounds intersects method, closed #350

This commit is contained in:
mourner 2011-12-13 16:01:04 +02:00
parent 43a405214c
commit 6f8698b93d
4 changed files with 22 additions and 1 deletions

View File

@ -23,6 +23,7 @@ Leaflet Changelog
#### API improvements
* Improved `LatLng` constructor to be more tolerant (and throw descriptive error if latitude or longitude can't be interpreted as a number). [#136](https://github.com/CloudMade/Leaflet/issues/136)
* Added `LatLngBounds` `intersects(otherBounds)` method (thanks to [@pagameba](https://github.com/pagameba)). [#350](https://github.com/CloudMade/Leaflet/pull/350)
* Added `urlParams` third optional argument to `TileLayer` constructor for convenience: an object with properties that will be evaluated in the URL template.
* Added `L.Util.template` method for simple string template evaluation.
* Added second argument `inside` to `map` `getBoundsZoom` method that allows you to get appropriate zoom for the view to fit *inside* the given bounds.

10
dist/leaflet-src.js vendored
View File

@ -757,6 +757,16 @@ L.LatLngBounds = L.Class.extend({
(sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
},
intersects: function (/*LatLngBounds*/ bounds) {
var sw = bounds.getSouthWest(),
ne = bounds.getNorthEast(),
nw = bounds.getNorthWest(),
se = bounds.getSouthEast();
return this.contains(sw) || this.contains(ne) ||
this.contains(nw) || this.contains(se);
},
toBBoxString: function () {
var sw = this._southWest,
ne = this._northEast;

2
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long

View File

@ -64,6 +64,16 @@ L.LatLngBounds = L.Class.extend({
(sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
},
intersects: function (/*LatLngBounds*/ bounds) {
var sw = bounds.getSouthWest(),
ne = bounds.getNorthEast(),
nw = bounds.getNorthWest(),
se = bounds.getSouthEast();
return this.contains(sw) || this.contains(ne) ||
this.contains(nw) || this.contains(se);
},
toBBoxString: function () {
var sw = this._southWest,
ne = this._northEast;