From f54450f893f155b86dd4eb2dd6d307ebcd93b646 Mon Sep 17 00:00:00 2001 From: Morten Ditlevsen Date: Thu, 2 Feb 2012 09:40:23 +0100 Subject: [PATCH] Added 'intersection' method for Bounds - just like the current implementation for LatLngBounds --- src/geometry/Bounds.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/geometry/Bounds.js b/src/geometry/Bounds.js index 162cc4704ca..dd70edceefc 100644 --- a/src/geometry/Bounds.js +++ b/src/geometry/Bounds.js @@ -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; } + });