[OpenLayers-Users] Can't get overview map to work
Planet)x
andrew.stewart at reddeer.ca
Mon Aug 23 18:16:48 EDT 2010
Still cannot get anything to show except for a blue image of nothing. Below
is my updated code, I have tried just defining a simple overviewmap with no
options, tried setting options and tried to set the zoom level but still I
just get an empty blue box as the overview, 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 rel="stylesheet" href="styles.css" 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);
var dm = new OpenLayers.Layer.WMS( "Testing Groups",
"http://ITS701X5J1/RedWMS/Request.aspx",
{layers: "Major_Parks, Hydrology",
transparent: "true", format: "image/png"
},
{
isBaseLayer: false,
singleTile: true,
group:"Test Group"
});
//-------------------------------------------------------End Define Map
Layers-------------------------------
</script>
<script type="text/javascript">
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: 'km',
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, dm]);
//Define Redline Layer (Vector) and Style for redline control
(DrawFeature)
var styleMap = new
OpenLayers.StyleMap(OpenLayers.Util.applyDefaults(
{fillColor: "red", fillOpacity: 10, strokeColor: "red",
strokeWidth: 2},
OpenLayers.Feature.Vector.style["default"]));
var vlayer = new OpenLayers.Layer.Vector("redlines", {styleMap:
styleMap});
vlayer.displayInLayerSwitcher = false;
map.addLayer(vlayer);
var s = OpenLayers.Util.applyDefaults({strokeWidth: 2,
fillColor: "red", strokeColor: "red"},
OpenLayers.Feature.Vector.style["default"]);
//------------------------------------------BEGIN Create Control Panel, Add
Map Controls--------------------------------------
//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"); }
//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: "Pan
Tool - Click and drag on map window"});
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 Redline Feature", handlerOptions:
{style: s}});
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 zoomIn = new OpenLayers.Control.ZoomBox({title:"Zoom in.
Click on map or click and drag to zoom in."});
var zoomOut = new OpenLayers.Control.ZoomBox({title:"Zoom out.
Click on map or click and drag to zoom out.", displayClass:
'olControlZoomOutBox', out: true})
var container_toolbar = document.getElementById("toolbar");
var container_legend = document.getElementById("legend");
var container_overview = document.getElementById("overview");
//Define custom controls
var redgisLegend = new
OpenLayers.Control.LayerSwitcher({displayClass: 'layer_switcher', div:
container_legend});
redgisLegend.ascending = true;
redgisLegend.useLegendGraphics = true;
var redgisOverview = new OpenLayers.Control.OverviewMap({div:
container_overview});
var redgisScale = new OpenLayers.Control.Scale();
var redgisScaleLine = new OpenLayers.Control.ScaleLine();
var panel = new OpenLayers.Control.Panel({defaultControl:
mouseDefaults, div: container_toolbar});
panel.addControls([btnHome, btnQuery, zoomIn, zoomOut,
nav.previous, mouseDefaults, drawFeature, 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"></div>
<div id="toolbar" class="olControlPanel"></div>
<div id="legend"> Images/legend_header.PNG </div>
<div id="selection">
Images/map_header.PNG
<ul>
<li> Default2.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>
<div id="overview"></div>
<div id="bottom"> redgis_logo.gif </div>
</body>
</html>
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Can-t-get-overview-map-to-work-tp5441450p5454510.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list