Skip to content

Commit

Permalink
Added 'intersection' method for Bounds - just like the current implem…
Browse files Browse the repository at this point in the history
…entation for LatLngBounds
  • Loading branch information
mortenbekditlevsen committed Feb 2, 2012
1 parent 090eae6 commit f54450f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/geometry/Bounds.js
Expand Up @@ -46,5 +46,18 @@ L.Bounds = L.Class.extend({
(max.x <= this.max.x) &&
(min.y >= this.min.y) &&
(max.y <= this.max.y);
},

intersects: function (/*Bounds*/ bounds) {
var min = this.min,
max = this.max,
min2 = bounds.min,
max2 = bounds.max;

var xIntersects = (max2.x >= min.x) && (min2.x <= max.x),
yIntersects = (max2.y >= min.y) && (min2.y <= max.y);

return xIntersects && yIntersects;
}

});

0 comments on commit f54450f

Please sign in to comment.