From 13f649d4cd849dc7f20c444577cc7e173f07c228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 20 Feb 2019 16:39:10 +0100 Subject: [PATCH] Update L.Polyline's _pxBounds when their stroke weight changes (#6516) --- src/layer/vector/Path.js | 3 +++ src/layer/vector/Polyline.js | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/layer/vector/Path.js b/src/layer/vector/Path.js index 032343737..db329e4b0 100644 --- a/src/layer/vector/Path.js +++ b/src/layer/vector/Path.js @@ -105,6 +105,9 @@ export var Path = Layer.extend({ Util.setOptions(this, style); if (this._renderer) { this._renderer._updateStyle(this); + if (this.options.stroke && style.hasOwnProperty('weight')) { + this._updateBounds(); + } } return this; }, diff --git a/src/layer/vector/Polyline.js b/src/layer/vector/Polyline.js index bbc6558f6..bb03520c7 100644 --- a/src/layer/vector/Polyline.js +++ b/src/layer/vector/Polyline.js @@ -203,14 +203,19 @@ export var Polyline = Path.extend({ this._rings = []; this._projectLatlngs(this._latlngs, this._rings, pxBounds); + if (this._bounds.isValid() && pxBounds.isValid()) { + this._rawPxBounds = pxBounds; + this._updateBounds(); + } + }, + + _updateBounds: function () { var w = this._clickTolerance(), p = new Point(w, w); - - if (this._bounds.isValid() && pxBounds.isValid()) { - pxBounds.min._subtract(p); - pxBounds.max._add(p); - this._pxBounds = pxBounds; - } + this._pxBounds = new Bounds([ + this._rawPxBounds.min.subtract(p), + this._rawPxBounds.max.add(p) + ]); }, // recursively turns latlngs into a set of rings with projected coordinates