From 22e2fba84bac856363bafe863768fdeef246eac9 Mon Sep 17 00:00:00 2001 From: Jason Sanford Date: Tue, 14 Feb 2012 09:29:29 -0700 Subject: [PATCH] Adding "equals" method to LatLngBounds using the preferred LatLng.equals method. Much cleaner. --- debug/map/bounds-equals.html | 55 ++++++++++++++++++++++++++++++++++++ src/geo/LatLngBounds.js | 8 ++++++ 2 files changed, 63 insertions(+) create mode 100644 debug/map/bounds-equals.html diff --git a/debug/map/bounds-equals.html b/debug/map/bounds-equals.html new file mode 100644 index 00000000..ed7bf2ef --- /dev/null +++ b/debug/map/bounds-equals.html @@ -0,0 +1,55 @@ + + + + Leaflet debug page + + + + + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/src/geo/LatLngBounds.js b/src/geo/LatLngBounds.js index 7a87ea47..58a64e35 100644 --- a/src/geo/LatLngBounds.js +++ b/src/geo/LatLngBounds.js @@ -80,6 +80,14 @@ L.LatLngBounds = L.Class.extend({ var sw = this._southWest, ne = this._northEast; return [sw.lng, sw.lat, ne.lng, ne.lat].join(','); + }, + + equals: function (/*LatLngBounds*/ bounds) { + var equals = false; + if (bounds !== null) { + equals = (this._southWest.equals(bounds.getSouthWest()) && this._northEast.equals(bounds.getNorthEast())); + } + return equals; } });