you can do this with some programmatic way as registering map with zoomend
:
eventListeners
{Object} If set as an option at construction, the
eventListeners object will be registered with .
EVENT_TYPES
{Array(String)} Supported application event types. Register a
listener for a particular event with the following syntax:
map.events.register(type, obj, listener);
Listeners will be called with a reference to an event object. The
properties of this event depends on exactly what happened.
Solution Code:
var layer1 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'}, {'displayInLayerSwitcher':false} );
var layer2 = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
"http://t1.hypercube.telascience.org/cgi-bin/landsat7",
{layers: "landsat7"}, {'isBaseLayer': false});
var layer3 = new OpenLayers.Layer.WMS( "DM Solutions Demo",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
"prov_bound,fedlimit,rail,road,popplace",
transparent: "true", format: "image/png" });
layer2.setVisibility(false);
layer3.setVisibility(false);
map.addLayers([layer1, layer2, layer3]);
map.events.register('zoomend', this, function (event) {
var zLevel = map.getZoom();
if( zLevel == 13 || zLevel == 14 || zLevel == 15 )
{
layer2.setVisibility(true);
}
if( zLevel == 16 || zLevel == 17 || zLevel == 18)
{
layer2.setVisibility(false);
layer3.setVisibility(true);
}
});
i hope it helps you...
you should try to get your shape extent via using CQL Filter. there is so good example in openlayers for filtering a feature here...
you can add your cql filter to iso codes..
wms.mergeNewParams({
'cql_filter': conditions // 'iso_code = your ISO country code'
});
then get vector layer extent (i write this code to the example which i give it above)
var dataExtent = states.getDataExtent();
map.zoomToExtent(dataExtent);
i hope it helps you...
Best Answer
OpenLayers.Map has the "client zoom" property that can help you creating zoom leves on the client side.
See the sample: http://openlayers.org/dev/examples/clientzoom.html