Skip to content

Commit

Permalink
Update L.Polyline's _pxBounds when their stroke weight changes (#6516)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanSanchez authored and mourner committed Feb 20, 2019
1 parent dc6a0ae commit 13f649d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/layer/vector/Path.js
Expand Up @@ -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;
},
Expand Down
17 changes: 11 additions & 6 deletions src/layer/vector/Polyline.js
Expand Up @@ -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,
Expand Down

0 comments on commit 13f649d

Please sign in to comment.