From 5e7857cdff77e9d2392e38ccf79601d69b4c97bb Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 26 Feb 2013 14:40:08 -0800 Subject: [PATCH] Normalize polygon holes (fixes #1459) --- src/layer/vector/Polygon.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/layer/vector/Polygon.js b/src/layer/vector/Polygon.js index 157b4b45..be5f52f0 100644 --- a/src/layer/vector/Polygon.js +++ b/src/layer/vector/Polygon.js @@ -8,11 +8,20 @@ L.Polygon = L.Polyline.extend({ }, initialize: function (latlngs, options) { + var i, len, hole; + L.Polyline.prototype.initialize.call(this, latlngs, options); if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) { this._latlngs = this._convertLatLngs(latlngs[0]); this._holes = latlngs.slice(1); + + for (i = 0, len = this._holes.length; i < len; i++) { + hole = this._holes[i] = this._convertLatLngs(this._holes[i]); + if (hole[0].equals(hole[hole.length - 1])) { + hole.pop(); + } + } } // filter out last point if its equal to the first one