var map, sld, waterBodies; var format = new OpenLayers.Format.SLD(); function init() { map = new OpenLayers.Map('map', {allOverlays: true}); var layers = createLayers(); map.addLayers(layers); waterBodies = layers[2]; map.addControl(new OpenLayers.Control.SelectFeature( waterBodies, {hover: true, autoActivate: true} )); map.addControl(new OpenLayers.Control.LayerSwitcher()); OpenLayers.Request.GET({ url: "tasmania/sld-tasmania.xml", success: complete }); } // handler for the OpenLayers.Request.GET function in the init method function complete(req) { sld = format.read(req.responseXML || req.responseText); buildStyleChooser(); setLayerStyles(); map.zoomToExtent(new OpenLayers.Bounds(143,-39,150,-45)); } function createLayers() { // the name of each layer matches a NamedLayer name in the SLD document var layerData = [{ name: "Land", url: "tasmania/TasmaniaStateBoundaries.xml" }, { name: "Roads", url: "tasmania/TasmaniaRoads.xml" }, { name: "WaterBodies", url: "tasmania/TasmaniaWaterBodies.xml" }, { name: "Cities", url: "tasmania/TasmaniaCities.xml" }]; var layers = []; for (var i=0,ii=layerData.length; i