Skip to content

Commit

Permalink
Fix panFocus on icon with no iconSize (Leaflet#8091)
Browse files Browse the repository at this point in the history
  • Loading branch information
Falke-Design authored Mar 28, 2022
1 parent 4e6604c commit 09dab3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions spec/suites/layer/marker/MarkerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,19 @@ describe("Marker", function () {

done();
}, 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);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/layer/marker/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export var Marker = Layer.extend({
if (!map) { return; }

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);

map.panInside(this._latlng, {
Expand Down

0 comments on commit 09dab3c

Please sign in to comment.