[OpenLayers-Users] Cannot set layer visibility...
Maps-R-us
mlaudon at laudontech.com
Wed Nov 19 10:35:54 EST 2008
I have three custom Google Maps tile layers in my project. The setVisibility
method does not seem to work for these types of layers. Does this make
sense? Here is my source code:
map = new OpenLayers.Map('map',options);
map.events.register("moveend", null, mapEvent);
map.events.register("changelayer", null, mapLayerChanged);
map.addControl(new OpenLayers.Control.LayerSwitcher());
var mylayer3 = new OpenLayers.Layer.TMS(
"Third Floor", "http://www.myurl.com.com//officeplans//3rd/Z", {
'type':'png', 'sphericalMercator': true, 'getURL':get_my_url });
var mylayer2 = new OpenLayers.Layer.TMS(
"Second Floor", "http://www.myurl.com//officeplans//2nd/Z", { 'type':'png',
'sphericalMercator': true, 'getURL':get_my_url });
var mylayer1 = new OpenLayers.Layer.TMS(
"First Floor", "http://www.myurl.com//officeplans//1st/Z", { 'type':'png',
'sphericalMercator': true, 'getURL':get_my_url });
map.addLayers([mylayer1, mylayer2, mylayer3]);
switch (office) {
case "Testing": if (floor==1){
alert("Floor 1 on");
var lonLat = new OpenLayers.LonLat(latitude, longitude) ;
lonLat.transform(map.displayProjection,map.getProjectionObject());
mylayer1.setVisibility(true);
mylayer2.setVisibility(false);
mylayer3.setVisibility(false);
map.setCenter(lonLat, 18);
newfloor = floor;
break;
} else if (floor==2) {
alert("Floor 2 on");
var lonLat = new OpenLayers.LonLat(latitude, longitude) ;
lonLat.transform(map.displayProjection,map.getProjectionObject());
mylayer1.setVisibility(false);
mylayer3.setVisibility(false);
mylayer2.setVisibility(true);
map.setCenter(lonLat, 18);
newfloor = floor;
break;
} else {
alert("Floor 3 on");
var lonLat = new OpenLayers.LonLat(latitude, longitude) ;
lonLat.transform(map.displayProjection,map.getProjectionObject());
mylayer1.setVisibility(false);
mylayer3.setVisibility(true);
mylayer3.setVisibility(false);
map.setCenter(lonLat, 18);
newfloor = floor;
break;
}
Thanks in advance!
M
--
View this message in context: http://www.nabble.com/Cannot-set-layer-visibility...-tp20582359p20582359.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list