diff --git a/src/layer/vector/Path.js b/src/layer/vector/Path.js index 032343737e4..db329e4b03c 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 bbc6558f660..bb03520c7b5 100644 --- a/src/layer/vector/Polyline.js +++ b/src/layer/vector/Polyline.js @@ -203,16 +203,21 @@ export var Polyline = Path.extend({ this._rings = []; this._projectLatlngs(this._latlngs, this._rings, pxBounds); - 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._rawPxBounds = pxBounds; + this._updateBounds(); } }, + _updateBounds: function () { + var w = this._clickTolerance(), + p = new Point(w, w); + 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 _projectLatlngs: function (latlngs, result, projectedBounds) { var flat = latlngs[0] instanceof LatLng,