I need to hide a layer with a function, use this script:
function hideLayer(layerName) { layerName.setVisibility(false);}
I have this error: 'map' is null or undefined
my code pagevar map;var lon =9.10;var lat =45.46;var zoom =10;
function init(){ epsg4326 = new OpenLayers.Projection("EPSG:4326") map = new OpenLayers.Map("map", {displayProjection:epsg4326, controls: [ new OpenLayers.Control.Navigation(), new OpenLayers.Control.MousePosition(), new OpenLayers.Control.LayerSwitcher() ] }); var newLayer = new OpenLayers.Layer.OSM("Mappa locale", "Tiles/${z}/${x}/${y}.png", {numZoomLevels: 19, alpha: false, isBaseLayer: true}); map.addLayer(newLayer); var layer = new OpenLayers.Layer.Vector("Mezzi disponibili", { strategies: [new OpenLayers.Strategy.BBOX({resFactor: 1.1})], protocol: new OpenLayers.Protocol.HTTP({ url: "./sinottico_mezziliberi.txt", format: new OpenLayers.Format.Text() }) }); map.addLayer(layer); ....
thanks
أكثر...
function hideLayer(layerName) { layerName.setVisibility(false);}
I have this error: 'map' is null or undefined
my code pagevar map;var lon =9.10;var lat =45.46;var zoom =10;
function init(){ epsg4326 = new OpenLayers.Projection("EPSG:4326") map = new OpenLayers.Map("map", {displayProjection:epsg4326, controls: [ new OpenLayers.Control.Navigation(), new OpenLayers.Control.MousePosition(), new OpenLayers.Control.LayerSwitcher() ] }); var newLayer = new OpenLayers.Layer.OSM("Mappa locale", "Tiles/${z}/${x}/${y}.png", {numZoomLevels: 19, alpha: false, isBaseLayer: true}); map.addLayer(newLayer); var layer = new OpenLayers.Layer.Vector("Mezzi disponibili", { strategies: [new OpenLayers.Strategy.BBOX({resFactor: 1.1})], protocol: new OpenLayers.Protocol.HTTP({ url: "./sinottico_mezziliberi.txt", format: new OpenLayers.Format.Text() }) }); map.addLayer(layer); ....
thanks
أكثر...