Skip to content

Commit a26e36b

Browse files
authored
fix: apply zoomMarkers on first render (#467)
1 parent e2a02a8 commit a26e36b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/map/map.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ export abstract class BaseMap extends Events implements BaseMapDefinition {
214214
this.leafletInstance.on("click", (evt: L.LeafletMouseEvent) =>
215215
this.handleMapClick(evt)
216216
);
217+
this.on('rendered', () => {
218+
if (this.options.zoomMarkers) {
219+
this.log(`Zooming to markers.`);
220+
this.zoomAllMarkers();
221+
}
222+
})
217223

218224
this.on("first-layer-ready", () => {
219225
this.addFeatures();
@@ -250,12 +256,6 @@ export abstract class BaseMap extends Events implements BaseMapDefinition {
250256
this.featureLayer.addTo(this.currentGroup.group);
251257
this.currentGroup.group.addTo(this.leafletInstance);
252258
this.tileOverlayLayer.addTo(this.leafletInstance);
253-
254-
if (this.options.zoomMarkers) {
255-
this.log(`Zooming to markers.`);
256-
257-
this.zoomAllMarkers();
258-
}
259259
});
260260

261261
this.leafletInstance.on(

0 commit comments

Comments
 (0)