<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>GeoExt WFS Editor</title>

      <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAFZSQ3NR3Cl-3OnEoy3lKgBSVjRVMYjPsHufR-_q5TcK3vIp8DBTze2V6TWT-UUpniyto-Lzb61-lIA'></script>


        <script type="text/javascript" src="../ext/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="../ext/ext-all.js"></script>
        <link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css" />
          <script src="http://openlayers.org/api/OpenLayers.js"></script>

        <script type="text/javascript" src="../geoext/lib/GeoExt.js"></script>
   <script src="../LoadingPanel.js"></script>

        <script type="text/javascript">
        
        Ext.BLANK_IMAGE_URL = "../ext/resources/images/default/s.gif";

         Ext.onReady(function() {

 // create Google layer
            var gsat = new OpenLayers.Layer.Google(
                "Google Satellite",
                {type: G_SATELLITE_MAP, sphericalMercator: true},
                {isBaseLayer: false, opacity: 0.8}
            );


var layer_zgbgrenze = new OpenLayers.Layer.Vector("Landkreisgrenzen", {
                                styleMap: new OpenLayers.StyleMap({
                    "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                        fillColor: "none",
                        strokeColor: "#0F0F0F",
                                                strokeWidth: 2
                    }, OpenLayers.Feature.Vector.style["default"]))
                    
                }),
                            strategies: [new OpenLayers.Strategy.Fixed()],
                            protocol: new OpenLayers.Protocol.WFS({
                        url: "/geoserver/ows",
                        version: "1.1.0",
                        featureType: "Grenzen_wgs84",
                        featureNS: "http://zgb.energie.de",
                        srsName: "EPSG:900913"
                                 
                    })
                });


                        var layer_wea = new OpenLayers.Layer.Vector("Windenergieanlagen", {
                                styleMap: new OpenLayers.StyleMap({
                    "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                       graphicName: "circle",
                                           fillColor: "#F4F6D0",
                                                strokeColor: "#F4F6D0",
                                                strokeWidth: 2,
              //          graphicOpacity: 1,
                        rotation: -45,
                        pointRadius: 4
                    }, OpenLayers.Feature.Vector.style["default"])),
                    "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                        graphicName: "circle",
                                                fillColor: "#55FF7F",
                                                strokeColor: "red",
                                                strokeWidth: 2,
                                        //        graphicOpacity: 1,
                        rotation: 45,
                        pointRadius:9
                    }, OpenLayers.Feature.Vector.style["select"]))
                }),
                            strategies: [new OpenLayers.Strategy.Fixed()],
                            protocol: new OpenLayers.Protocol.WFS({
                        url: "/geoserver/ows",
                        version: "1.1.0",
                        featureType: "WEA_wgs84",
                        featureNS: "http://zgb.energie.de",
                        srsName: "EPSG:900913"
                    })
                });
        
        var layer_biogas = new OpenLayers.Layer.Vector("Biogasanlagen", {
                                styleMap: new OpenLayers.StyleMap({
                    "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                       graphicName: "circle",
                                           fillColor: "#E2C22C",
                                                strokeColor: "#E2C22C",
                                                strokeWidth: 2,
                                //                graphicOpacity: 1,
                        rotation: -45,
                        pointRadius: 4
                    }, OpenLayers.Feature.Vector.style["default"])),
                    "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                        graphicName: "circle",
                                                fillColor: "#D38F57",
                                                strokeColor: "red",
                                                strokeWidth: 2,
                                        //        graphicOpacity: 1,
                        rotation: 45,
                        pointRadius:9
                    }, OpenLayers.Feature.Vector.style["select"]))
                }),
                            strategies: [new OpenLayers.Strategy.Fixed()],
                            protocol: new OpenLayers.Protocol.WFS({
                        url: "/geoserver/ows",
                        version: "1.1.0",
                        featureType: "Biogas_wgs84",
                        featureNS: "http://zgb.energie.de",
                        srsName: "EPSG:900913"
                    })
                });
        
        var layer_wasserkraft = new OpenLayers.Layer.Vector("Wasserkraft", {
                                styleMap: new OpenLayers.StyleMap({
                    "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                       graphicName: "circle",
                                           fillColor: "#00D4FF",
                                                strokeColor: "#00D4FF",
                                                strokeWidth: 2,
                                //                graphicOpacity: 1,
                        rotation: -45,
                        pointRadius: 4
                    }, OpenLayers.Feature.Vector.style["default"])),
                    "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                        graphicName: "circle",
                                                fillColor: "#0AB055",
                                                strokeColor: "red",
                                                strokeWidth: 2,
                                //                graphicOpacity: 1,
                        rotation: 45,
                        pointRadius:9
                    }, OpenLayers.Feature.Vector.style["select"]))
                }),
                            strategies: [new OpenLayers.Strategy.Fixed()],
                            protocol: new OpenLayers.Protocol.WFS({
                        url: "/geoserver/ows",
                        version: "1.1.0",
                        featureType: "Wasserkraft_wgs84",
                        featureNS: "http://zgb.energie.de",
                        srsName: "EPSG:900913"
                    })
                });
                
                
                
                
                var mapnik = new OpenLayers.Layer.OSM();

                
           var store = new GeoExt.data.FeatureStore({
                            fields: [
                                {name: "Bez", type: "string"},
                                {name: "Standort", type: "string"},
                                {name: "Betreiber", type: "string"},
                                {name: "number_fac", type: "int", defaultValue: 0}
                            ],
                                layer: layer_wea
                        });
                
                
                var store_biogas = new GeoExt.data.FeatureStore({
                            fields: [
                                {name: "Ort", type: "string"},
                                {name: "Antr_St", type: "string"},
                                {name: "ID", type: "int", defaultValue: 0}
                            ],
                                layer: layer_biogas
                        });
                        
                var store_wasserkraft = new GeoExt.data.FeatureStore({
                            fields: [
                                {name: "ID", type: "int"},
                                {name: "Bez", type: "string"},
                                {name: "Anmerkung", type: "int", defaultValue: 0}
                            ],
                                layer: layer_wasserkraft
                        });
                
                
                var options = { 
         projection: new OpenLayers.Projection("EPSG:900913"), 
         displayProjection: new OpenLayers.Projection("EPSG:4326"), 
         units: "m", 
         numZoomLevels: 18, 
         maxResolution: 156543.0339, 
         maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34),
                 controls:[
                 new OpenLayers.Control.Permalink(),
                 new OpenLayers.Control.MouseDefaults(),
                 new OpenLayers.Control.LayerSwitcher(),
                 new OpenLayers.Control.MousePosition(),
                 new OpenLayers.Control.PanZoomBar()
                 
                ] 
    }; 
        var attribgridPanel_wea = new Ext.grid.GridPanel({
         
                title: "WEA",
                region: "center",
                viewConfig: {forceFit: true},
                store: store,
                                collapsible : true,
                                sm: new GeoExt.grid.FeatureSelectionModel(),
                cm: new Ext.grid.ColumnModel({
                    defaults: {
                        sortable: true
                    },
                    columns: [
                        {header: "Bez", dataIndex: "Bez",width: 25},
                        {header: "Standort", dataIndex: "Standort"},
                        {header: "Betreiber", dataIndex: "Betreiber", width: 135},
                        {header: "Typ", dataIndex: "Typ", width: 35}
                    ]
                }),
                                bbar: [{
                                text:"<h1>an Auswahl heranzoomen</h1>",
                                cls: 'x-btn-text-icon',
                                  icon: '../styles/magnifier.png',
                                handler:function()
                                        {
                                        attribgridPanel_wea.getSelectionModel().each(function(rec){
                                                var feature = rec.get("feature");
                                                mapPanel.map.zoomToExtent(feature.geometry.getBounds());
                                                })
                                        }        
                                }]
                                
                                
            });        
                
                
                var attribgridPanel_biogas = new Ext.grid.GridPanel({
         
                title: "Biogas",
                region: "center",
                viewConfig: {forceFit: true},
                store: store_biogas,
                                collapsible : true,
                                sm: new GeoExt.grid.FeatureSelectionModel(),
                cm: new Ext.grid.ColumnModel({
                    defaults: {
                        sortable: true
                    },
                    columns: [
                        {header: "Ort", dataIndex: "Ort",width: 25},
                        {header: "Antr_St", dataIndex: "Antr_St"},
                        {header: "ID", dataIndex: "ID", width: 35}
                    ]
                }),
                                bbar: [{
                                text:"<h1>an Auswahl heranzoomen</h1>",
                                cls: 'x-btn-text-icon',
                                  icon: '../styles/magnifier.png',
                                handler:function()
                                        {
                                        attribgridPanel_biogas.getSelectionModel().each(function(rec){
                                                var feature = rec.get("feature");
                                                mapPanel.map.zoomToExtent(feature.geometry.getBounds());
                                                })
                                        }        
                                }]
                                
                                
            });        
                
                var attribgridPanel_wasserkraft = new Ext.grid.GridPanel({
         
                title: "Wasserkraft",
                region: "center",
                viewConfig: {forceFit: true},
                store: store_wasserkraft,
                                collapsible : true,
                                sm: new GeoExt.grid.FeatureSelectionModel(),
                cm: new Ext.grid.ColumnModel({
                    defaults: {
                        sortable: true
                    },
                    columns: [
                        {header: "Bez", dataIndex: "Bez",width: 25},
                        {header: "Anmerkung", dataIndex: "Anmerkung", width: 135},
                        {header: "ID", dataIndex: "ID", width: 35}
                    ]
                }),
                                bbar: [{
                                text:"<h1>an Auswahl heranzoomen</h1>",
                                cls: 'x-btn-text-icon',
                                  icon: '../styles/magnifier.png',
                                handler:function()
                                        {
                                        attribgridPanel_wasserkraft.getSelectionModel().each(function(rec){
                                                var feature = rec.get("feature");
                                                mapPanel.map.zoomToExtent(feature.geometry.getBounds());
                                                })
                                        }        
                                }]
                                
                                
            });        
                
                
        

        



                
                var loadingpanel = new OpenLayers.Control.LoadingPanel();
                
                map = new OpenLayers.Map('map', options); 
                map.addControl(loadingpanel);


/*
        var tree = new Ext.tree.TreePanel({
    region: "west",
    title: "Map Layers",
    width: 200,
    autoScroll: true,
    enableDD: true,
    lines: false,
    rootVisible: false,
    root: new GeoExt.tree.LayerContainer({
    layerStore: mapPanel.layers,
    expanded: true
    })

});
*/



    new Ext.Viewport({
        layout: "border",
        items: [{
            region: "north",
            contentEl: "title",
            height: 50
        }, {
            region: "center",
            id: "mappanel",
            title: "Map",
            xtype: "gx_mappanel",
            map: map,                                
            layers: [gsat, mapnik,layer_wea,layer_biogas,layer_wasserkraft,layer_zgbgrenze],  
                        minScale: 500000,
                        maxScale: 100000,
                        numZoomLevels: 2,
                         center: [1169180, 6843865],
              zoom: 9,
            split: true
        }
                /*
                , {
            region: "west",
            title: "Karteninhalt",
            items:[],
            width: 0,
            split: true
        }
        */
        , {
            region: "east",
                        split: true,
                        collapsed:false,
                        collapsible:true,
                        xtype: 'tabpanel',
                        title: 'WEA',
            width: 500,
                        items: [
                        attribgridPanel_wea,attribgridPanel_biogas,attribgridPanel_wasserkraft
                        ]
                        
        }]
    });

   var mapPanel = Ext.getCmp("mappanel");

});

  </script>
  <style type="text/css">
   
                   .olControlMousePosition {
                    bottom: 5px;
                        background-color:white;
                    color: black;
            }
                                
                        .olControlLoadingPanel {
            background-image:url(../styles/loading.gif);
            position: relative;
                        left:200px;
                        top:300px;
            width: 195px;
            height: 11px;
            background-position:center;
            background-repeat:no-repeat;
            display: none;
                      }
                
 .title{font-family:arial;color:#3E4B54;padding:5px;}                
                                
                </style>
    </head>
    <body>
             <div id="title" class ="title">
            <h1>Erneuerbare Energiequelle im Zweckverband Gro&szlig;raum Braunschweig</h1>
        </div>

        <div id="description">
            <p></p>
                </div>
            
            

    </body>
</html>