[OpenLayers-Users] Panel not showing my custom buttons

Planet)x andrew.stewart at reddeer.ca
Fri Aug 20 14:07:03 EDT 2010


I have used the example to move my control panel off of the page, but now any
custom button I try to add to the panel does not show up. All other map
controls are showing just fine but not my custom buttons which were working
before when my panel was attached to the map in the same div. Below is my
length code (I apologize) just wondering if anyone might see something wrong
with it as to why the buttons are not showing up, very much appreciate any
assistance!




<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Redgis GIS Viewer</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript"
src="OpenLayers-2.9.1/lib/Firebug/firebug.js"></script>
<script type="text/javascript"
src="OpenLayers-2.9.1/OpenLayers.js"></script>
<script type="text/javascript"> // Begin Map Initialization Script

//-------------------------------------------------------Begin Define Map
Layers-------------------------------

           //Bridge
            var wmsBridge = new OpenLayers.Layer.WMS("Bridge",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Bridge'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsBridge.setOpacity(0.8); 
                    
            //Rural_Highway
            var wmsRural_Highway = new OpenLayers.Layer.WMS("Rural Highway",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Rural_Highway'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsRural_Highway.setOpacity(0.8); 
                    
            //Highway
            var wmsHighway = new OpenLayers.Layer.WMS("Highway",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Highway'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsHighway.setOpacity(0.8); 
                    
            //Arterial
            var wmsArterial = new OpenLayers.Layer.WMS("Arterial",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Arterial'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsArterial.setOpacity(0.8); 
                    
            //City_Boundary
            var wmsCity_Boundary = new OpenLayers.Layer.WMS("City Boundary",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['City_Boundary'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsCity_Boundary.setOpacity(0.8); 
                    
            //Hydrology
            var wmsHydrology = new OpenLayers.Layer.WMS("Hydrology",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Hydrology'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsHydrology.setOpacity(0.8); 
                    
            //Neighbourhood Area (Clear)
            var wmsNeighbourhood_Clear = new
OpenLayers.Layer.WMS("Neighbourhood Area (Clear)",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Neighbourhood_Area__Clear_'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsNeighbourhood_Clear.setOpacity(0.8); 
                    
            //Neighbourhood Boundary
            var wmsNeighbourhood_Boundary = new
OpenLayers.Layer.WMS("Neighbourhood Boundary",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Neighbourhood_Boundary'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsNeighbourhood_Boundary.setOpacity(0.8); 
                             
            //Major Parks
            var wmsMajor_Parks = new OpenLayers.Layer.WMS("Major Parks",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Major_Parks'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsMajor_Parks.setOpacity(0.8); 
                    
                    
             //Neighbourhood Parks
            var wmsNeighbourhood_Parks = new
OpenLayers.Layer.WMS("Neighbourhood Parks",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Neighbourhood_Parks'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsMajor_Parks.setOpacity(0.8); 
                    
            //Recreation Sites
            var wmsRecreation_Sites= new OpenLayers.Layer.WMS("Recreation
Sites", "http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Recreation_Sites'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsRecreation_Sites.setOpacity(0.8); 
                    
            //School Sites
            var wmsSchool_Sites= new OpenLayers.Layer.WMS("School Sites",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['School_Sites'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsSchool_Sites.setOpacity(0.8); 
                    
            //Linear Parks
            var wmsLinear_Parks= new OpenLayers.Layer.WMS("Linear Parks",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Linear_Parks'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsLinear_Parks.setOpacity(0.8); 
                    
            //Section Lines
            var wmsSection_Lines= new OpenLayers.Layer.WMS("Section Lines",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Section_Lines'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: true
                        , singleTile: true
                    }
                );
                    wmsSection_Lines.setOpacity(0.8); 
                    wmsSection_Lines.displayInLayerSwitcher = false //hides
layer from displaying in layerswitcher control
                   
                    
            //Rural Block Line
            var wmsRural_Block_Line= new OpenLayers.Layer.WMS("Rural Block
Line", "http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Rural_Block_Line'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsRural_Block_Line.setOpacity(0.8);
                    
            //Rural Lot Line
            var wmsRural_Lot_Line= new OpenLayers.Layer.WMS("Rural Lot
Line", "http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Rural_Lot_Line'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                    }
                );
                    wmsRural_Lot_Line.setOpacity(0.8);
                    
            //Ortho Image 2010
            var wmsOrtho2010= new OpenLayers.Layer.WMS("Ortho Image 2010",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Ortho_2010'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                        , visibility: false
                    }
                );
                    wmsRural_Lot_Line.setOpacity(0.8);
                    
            //Parcels
            var wmsParcels= new OpenLayers.Layer.WMS("Parcels",
"http://ITS701X5J1/RedWMS/Request.aspx",
                    {
                        layers: ['Parcels'],
                        format: 'image/png',
                        VERSION: "1.1.1",
                        transparent: true
                    },
                    { isBaseLayer: false
                        , singleTile: true
                        , visibility: false
                    }
                );
                    wmsParcels.setOpacity(0.8);
                    
//-------------------------------------------------------End Define Map
Layers-------------------------------

function init(){
            var map = new OpenLayers.Map('map',{ controls: [],
                    maxExtent: new OpenLayers.Bounds(-20037508.34,
-20037508.34, 20037508.34, 20037508.34),
                    maxResolution: 156543.0399,
                    numZoomLevels: 20,
                    units: 'm',
                    projection: new OpenLayers.Projection("EPSG:900913"),
                    displayProjection: new
OpenLayers.Projection("EPSG:4326")
                }
            );    
            map.addLayers([wmsBridge, wmsRural_Highway, wmsHighway,
wmsArterial, wmsCity_Boundary, wmsHydrology, wmsNeighbourhood_Clear,
wmsNeighbourhood_Boundary, wmsMajor_Parks, wmsNeighbourhood_Parks,
wmsRecreation_Sites, wmsSchool_Sites, wmsLinear_Parks, wmsSection_Lines,
wmsRural_Block_Line, wmsRural_Lot_Line, wmsOrtho2010, wmsParcels]);


            //Define Redline Layer (Vector)
            vlayer = new OpenLayers.Layer.Vector( "Red Lines" );
            vlayer.displayInLayerSwitcher = false
            map.addLayer(vlayer);
            
//------------------------------------------BEGIN Create Control Panel, Add
Map Controls--------------------------------------
           
            //declare all Map Controls
            var btnHome = new OpenLayers.Control.Button({trigger:
triggerHome, title: "Reload Website", displayClass: 'olControlButtonHome'});
            var btnQuery = new OpenLayers.Control.Button({trigger:
triggerQuery, title: "Pre-Defined Queries", displayClass:
'olControlButtonQueries'});  
            var nav = new OpenLayers.Control.NavigationHistory({title: "Zoom
to Previous View"});
            var mouseDefaults = new OpenLayers.Control.MouseDefaults({title:
"Pan Tool - Click and drag on map window"});
            var drawFeature = new OpenLayers.Control.DrawFeature(vlayer,
OpenLayers.Handler.Path, {title: "Draw feature"});
            var zoomMax = new OpenLayers.Control.ZoomToMaxExtent({title:
"Zoom to max Range"});
            var btnPrint = new OpenLayers.Control.Button({trigger:
triggerPrint, title: "Print Page", displayClass: 'olControlButtonPrint'});
            var btnHelp = new OpenLayers.Control.Button({trigger:
triggerHelp, title: "Redgis Help", displayClass: 'olControlButtonHelp'});
            var btnTutorial = new OpenLayers.Control.Button({trigger:
triggerTutorial, title: "Redgis Tutorials", displayClass:
'olControlButtonTutorial'});
            var zb = new OpenLayers.Control.ZoomBox({title:"Zoom by Area,
Click and drag to zoom."}); 
            

            
            //declare control trigger functions
            var triggerHome = function() {window.location.reload(); }
            var triggerQuery = function() {window.open
("queries.aspx","Queries"); }
            var triggerPrint = function() {window.print(); }
            var triggerHelp = function() {window.open ("help.aspx","Help");
}
            var triggerTutorial = function(){window.open
("tutorial.aspx","Tutorial"); }
            
            //Define custom controls
            var redgisLegend = new OpenLayers.Control.LayerSwitcher();
            var redgisOverview = new OpenLayers.Control.OverviewMap();
            var redgisScale =  new OpenLayers.Control.Scale();
            var redgisScaleLine = new OpenLayers.Control.ScaleLine();
            
            var container_toolbar = document.getElementById("toolbar");
  
            var panel = new OpenLayers.Control.Panel({defaultControl:
mouseDefaults, div: container_toolbar});
            panel.addControls([btnHome, btnQuery, zb, nav.previous,
mouseDefaults, drawFeature, zoomMax, btnPrint, btnHelp, btnTutorial]);
            

            //add controls to Map
            map.addControl(nav);
            map.addControl(panel);
            map.addControl(redgisLegend);
            map.addControl(redgisOverview);
            map.addControl(redgisScale);
            map.addControl(redgisScaleLine);
            
            //redgisOverview.maximizeControl();
            //redgisLegend.maximizeControl();  
            

//------------------------------------------End Map
Controls----------------------------------------------------------------

        //Define Map Longitude/Latitude and Start zoom levels
        var startupLat = 52.27210;
        var startupLon = -113.80288;    
        var startupLevel = 12;
        var lonLat = new OpenLayers.LonLat(startupLon,
startupLat).transform(new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject());

        map.setCenter(lonLat,startupLevel);
        
}
</script>
<body onload="init();">
        <div id="map" class="smallmap"></div>
        <div id="toolbar" class="olControlPanel"></div>    
        <div id="legend"> Images/legend_header.PNG </div>
        <div id="selection">
             Images/map_header.PNG 
            <ul>
            <li> Default.aspx Base Map </li>
            <li>Common</li>
            <li>Traffic Count</li>
            <li>Transit Routes</li>
            <li>Land Use Bylaw</li>
            <li>Lot Sales</li>
            <li>Annexation</li>
            <li>Infrastructure</li>
            <li>Economic Development</li>
            <li>Census 2007</li>
            <li>Census 2006</li>
            <li>Assessment</li>
            <li>Traffic</li>
            <li>Garbage Update</li>
            <li>Endeavors Update</li>
            <li>EMS Incidents</li>
            </ul>
            </div>
</body>
</html>

-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Panel-not-showing-my-custom-buttons-tp5445530p5445530.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list