[OpenLayers-Users] Using overview map, no layers showing up

Planet)x andrew.stewart at reddeer.ca
Mon Aug 9 10:35:25 EDT 2010


Not sure if I am doing this correctly, I am trying to experiment with using
an overview map and I just want to set it to be a copy of the layers on my
map already existing. Below is my code but I just get an empty blue overview
map with no layers showing and also it won't move my map around if I click
on it. Any help appreciated whether to define new layers for my overview or
make an exact copy of the existing map, thanks.


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Redgis - WMS Service</title>        
        <link rel="stylesheet" href="style.css" type="text/css" />
        <style type="text/css">
            body {
                margin: 0;
            }
            #map {
                width: 100%;
                height: 100%;
            }
 
            #text {
                position: absolute;
                bottom: 1em;
                left: 1em;
                width: 512px;
            }
            
            #overview{
            display:block;
            
            /* set the div in the bottom right */
            position:absolute;
            bottom:0;
            right:0;
            width:350px;
            
            border:1px solid #ddd;
            }
</style>

        
       <!-- (commented out google maps API key, readd if using google maps
layer) <script
src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAmxEu3pgjOVMKW70xRnZ1YxR0mfnfRZQjoAkWM97eIDxNT8rs-xT5NYTmYFApu1-LGwQBNRBUweZGdg'
type="text/javascript"></script>-->
 
        
        <script type="text/javascript"
src="OpenLayers-2.9.1/OpenLayers.js"></script>
        <script type="text/javascript">
            var map;
            function init(){
            map = new OpenLayers.Map('map',{
                    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")
                }
            );
            
            
            
 //Commented out adding google maps as a layer, readd if using google as
base layer
             //var gmap = new OpenLayers.Layer.Google(
                //"Google Streets", // the default
                //{numZoomLevels: 20
                //, sphericalMercator: true
               // }
            //);
            
            //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); 
            
      
                    //map.addLayers([gmap, wms]);
                    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]);

            var startupLat = 52.27210;
            var startupLon = -113.80288;

            var startupLevel = 11.5;
            //var lonLat = new OpenLayers.LonLat(startupLon, startupLat); 
            var lonLat = new OpenLayers.LonLat(startupLon,
startupLat).transform(new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject());

            map.setCenter(lonLat, startupLevel);
            
            // Define Controls
            var redgisLegend = new OpenLayers.Control.LayerSwitcher();
            var redgisOverview = new OpenLayers.Control.OverviewMap();
            var keyboard = new OpenLayers.Control.KeyboardDefaults();
            var mousePosition = new OpenLayers.Control.MousePosition();
            
            // add controls to map
            map.addControl(redgisLegend);
            map.addControl(redgisOverview);
            map.addControl(keyboard);
            map.addControl(mousePosition);
            
            redgisLegend.maximizeControl();
            redgisOverview.maximizeControl();
            
        }
        </script>
    </head>
    <body onload="init()">
        <div id="map"></div>
    </body>
</html>


-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Using-overview-map-no-layers-showing-up-tp5389216p5389216.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list