Update L.Polyline's _pxBounds when their stroke weight changes (#6516)

This commit is contained in:
Iván Sánchez Ortega
2019-02-20 16:39:10 +01:00
committed by Vladimir Agafonkin
parent dc6a0ae61a
commit 13f649d4cd
2 changed files with 14 additions and 6 deletions

View File

@ -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;
},

View File

@ -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