diff gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp @ 570:cbd397712ecf

Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation. gnv/trunk@698 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 22 Feb 2010 18:04:55 +0000
parents b5733f9f386b
children f2ba58011a2d
line wrap: on
line diff
--- a/gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp	Mon Feb 15 11:42:29 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp	Mon Feb 22 18:04:55 2010 +0000
@@ -43,9 +43,56 @@
 "-1.5763 58.3616))";
             }
         </script>
+        <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
+        <script type="text/javascript">
+            var lon  = 5;
+            var lat  = 55;
+            var zoom = 5;
+            var map, layer;
+
+            function init() {
+                if (getURLParam("target") == "wms") {
+                    console.log("LAYER NAME: " + getURLParam("layer"));
+                    map   = new OpenLayers.Map('map');
+                    layer = new OpenLayers.Layer.WMS(
+                        "MyWMS",
+                        "http://denmark.atlas/cgi-bin/mapserv-gp?MAP=/opt/artifacts/mapfiles/mapfile.map",
+                        {
+                            layers: getURLParam("layer")
+                        },
+                        {
+                            singleTile: 'true'
+                        }
+                    );
+
+                    map.addLayer(layer);
+                    map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
+                }
+            }
+
+            function getURLParam(strParamName){
+                var strReturn = "";
+                var strHref = window.location.href;
+
+                if ( strHref.indexOf("?") > -1 ){
+                    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
+                    var aQueryString = strQueryString.split("&");
+
+                    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
+                        if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ) {
+                            var aParam = aQueryString[iParam].split("=");
+                            strReturn = aParam[1];
+                            break;
+                        }
+                    }
+                }
+
+                return strReturn;
+            }
+        </script>
     </head>
 
-    <body id="gnviewerbody">
+    <body id="gnviewerbody" onLoad="init()">
     <div id="overlay"></div>
     <div style="width:100%;left:0;top:0;width:100%;height:100%;position:absolute">
         <div id="overlayContent">

http://dive4elements.wald.intevation.org