Open charliejhadley opened 7 years ago
So leaflet already does support this.
When you call any of the add*
methods, we internally also call expandLimits
or expandLimitsBox
to expand the bounding box to accommodate the new limits. This is done regardless of which projection you are using.
I think the only time this doesn't happen is for the addGeoJSON
and addTopoJSON
calls, and that too can be probably supported (if required).
How ever what we don't do is call setMaxBounds
because the bounds can change as you are overlaying more and more data.
If there's a strong use case we can probably support setting auto max bounds.
As discussed here it can be difficult to calculate good bounding boxes when working with specific regions.
Generally solving this problem is difficult, however in the case of choropleth with shapefiles (such as http://rpubs.com/bhaskarvk/proj4leaflet) would it be possible to compute a sensible bounding box from the SPDF. This might work as follows: