Fix panFocus on icon with no iconSize (#8091)

This commit is contained in:
Florian Bischof
2022-03-28 09:58:49 +02:00
committed by GitHub
parent 4e6604c70f
commit 09dab3c1cb
2 changed files with 13 additions and 1 deletions

View File

@ -214,7 +214,19 @@ describe("Marker", function () {
done(); done();
}, 100); }, 100);
});
it("pan map to focus marker with no iconSize", function (done) {
var marker = L.marker([70, 0], {icon: L.divIcon({iconSize: null})});
map.addLayer(marker);
setTimeout(function () {
expect(function () {
marker._panOnFocus();
}).to.not.throwException();
done();
}, 100);
}); });
}); });

View File

@ -389,7 +389,7 @@ export var Marker = Layer.extend({
if (!map) { return; } if (!map) { return; }
var iconOpts = this.options.icon.options; var iconOpts = this.options.icon.options;
var size = point(iconOpts.iconSize); var size = iconOpts.iconSize ? point(iconOpts.iconSize) : point(0, 0);
var anchor = iconOpts.iconAnchor ? point(iconOpts.iconAnchor) : point(0, 0); var anchor = iconOpts.iconAnchor ? point(iconOpts.iconAnchor) : point(0, 0);
map.panInside(this._latlng, { map.panInside(this._latlng, {