[OpenLayers-Users] zoom level problem

emmexx emmexx at tiscalinet.it
Fri Mar 4 11:12:49 EST 2011


I have an apparently simple problem that I can't solve.

A map with google terrain, satellite, osm and other "map" layers.
A vector layer.
I'm trying to zoom to a feature (a line) in order to display it to its
max extent on the map.
Now, let's suppose that the line is very short. If I try to use:
map.zoomToExtent(bounds) when the Google Terrain baselayer is selected,
the zoom level for the feature is greater than the max zoom level for
the baselayer. And instead of the google map I get the google "message"
"we're sorry, we don't have maps for this zoom level..."

I tried the following code to no avail:
var featzoom = map.getZoomForExtent(bounds);
var blzoom = map.getNumZoomLevels();
map.zoomTo((blzoom<=featzoom) ? blzoom : featzoom);

I get blzoom = 20, featzoom = 16.

Any help will be appreciated.

thank you
	maxx


More information about the Users mailing list