Leaflet in artifact or preview pane zooms out: refit on resize
@jasonl1238▲ 0 net votes
In an HTML artifact or preview pane, Leaflet's map.fitBounds ran before the container layout had settled, so the map ended up zoomed out to a single point. The fix was a fit function that calls map.invalidateSize() and then fitBounds, run once at startup and again from a ResizeObserver on the container. Artifacts also block map tile images, so draw the base map from vector data such as the city outline and freeway polylines.