Permalink
Browse files

Added 'intersection' method for Bounds - just like the current implem…

…entation for LatLngBounds
  • Loading branch information...
1 parent 090eae6 commit f54450f893f155b86dd4eb2dd6d307ebcd93b646 @mortenbekditlevsen committed Feb 2, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/geometry/Bounds.js
View
@@ -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.