Hi ,
My task is so simple yet it had taken already 2-3 days of mine..i have 3
baselayers ,google hybrid,google streets,yahoo ...i have all the three in a
dropdown..when i toggle the entry in the dropdown,i want the layers also
toggling in the map..i have read the posts regarding the toggling of basmaps
without the help of layerswitcher control.In all of the replies,i found the
use of setVisibility or setBaseLayer...but unfortunately for me ,nothing
seems to be working...my code looks like the one below....any amt of help is
deeply appreciated...
<form>
dropdown stuff onchange = swapmap();
</form>
<script>
// first ill find the map selected.
// for simplicity the ids of all the 3 options in the dropdown is in the
range of 1 to 3.
function swapmap(){
for(i=1;i<=3;i++){
if(document.getElementById(i).selected == true ){
break;
}
}
var options = {
projection: "srs",
controls:[],
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508)
};
map = new OpenLayers.Map('map', options);
googleDem = new OpenLayers.Layer.Google(
"GoogleDEM" ,
{
type: G_PHYSICAL_MAP,
sphericalMercator:true
}
);
googleDem.addOptions({isBaseLayer: true, buffer: 0,
minZoomLevel: 2, maxZoomLevel: 8});
map.addLayer(googleDem);
googleHyb = new OpenLayers.Layer.Google(
"GoogleHyb" ,
{
type: G_HYBRID_MAP,
sphericalMercator:true
}
);
googleHyb.addOptions({isBaseLayer: true, buffer: 0,
minZoomLevel: 2, maxZoomLevel: 8});
map.addLayer(googleHyb);
ym = new OpenLayers.Layer.Yahoo( "YahooMap" , {
sphericalMercator:true});
ym.addOptions({isBaseLayer: true, buffer: 1, minZoomLevel:2,
maxZoomLevels:8});
map.addLayer(ym);
if(i==1){
googleDem.setVisibility(1);
googleHyb.setVisibility(0);
ym.setVisibility(0);
map.setBaseLayer(googleDem);
}if(i==2){
googleHyb.setVisibility(1);
googleDem.setVisibility(0);
ym.setVisibility(0);
map.setBaseLayer(googleHyb);
}if(i==3){
ym.setVisibility(1);
googleHyb.setVisibility(0);
googleDem.setVisibility(0);
map.setBaseLayer(ym);
}
var bounds = new OpenLayers.Bounds(
-14392000, 2436200, -7279500, 6594375
);
map.zoomToExtent(bounds);
}
</script>
};
<script>
=============
thanx in advance.
[email protected]
--
View this message in context:
http://n2.nabble.com/openlayer-switcher-replacement...-tp1666390p1666390.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users