The issue is that if the data is a single point, the data extent is
infinitely small, and OpenLayers will zoom too far in for many base
layers. So a sensible default of "zoomToDataExtent" breaks down if the
geometry might be a single point.
I agree that the current solution probably isn't ideal, as it doesn't
give sensible defaults for the most common cases of "show me some zoom
level when there is no geometry" and "show me the geometry if there is one".
Currently, the following options control zooming:
zoomToDataExtent: (default true)
defaultZoom: (default 4)
mapOptions: {
numZoomLevels: (layer dependent default)
}
I'm hesitant to just throw more options in, as there are already so
many, but it seems like in this case it would make sense to add a
further option:
minInitialZoom
which would replace defaultZoom on line 316. This is different from the
idea of a "minZoom" that to me expresses a limit on zooming.
Does this seem like a reasonable solution?
It looks like philipn has been trying a similar solution here:
https://github.com/philipn/olwidget/commit/5236d058e01c16dc35a4e416aac19dcaca4c7b0f
though I find the name zoomToDataExtentMin a little cumbersome.
-charlie