tim@980: <%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%> tim@982: <%@page import="de.intevation.gnv.action.MapClientStandaloneAction"%> tim@984: <%@page import="de.intevation.gnv.artifactdatabase.objects.map.MapService"%> tim@980: <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> tim@982: <% tim@982: boolean standalone = request.getParameter(MapClientStandaloneAction.MAPCLIENTSTANDALONE_KEY) != null && tim@982: request.getParameter(MapClientStandaloneAction.MAPCLIENTSTANDALONE_KEY).equals("true"); tim@984: MapService mapService = SessionModelFactory.getInstance().getSessionModel(request).getLocalMapService(); tim@982: %> tim@1000: OpenLayers.ImgPath = "images/ol/"; tim@971: OpenLayers.ProxyHost= "/cgi-bin/proxy.cgi?url="; tim@980: OpenLayers.Lang.setCode('<%=SessionModelFactory.getInstance().getSessionModel(request).getCurrentLocale().getLanguage() %>'); tim@971: Ext.BLANK_IMAGE_URL = "scripts/openlayers/OpenLayers-2.9/theme/default/img/blank.gif"; tim@971: tim@971: /** tim@971: * XXX tim@971: * Change specific attributes for map, wfs-t, etc here. Do not change these tim@971: * settings inline the code! tim@971: */ tim@971: PROJECTION = "EPSG:4326"; tim@984: MAX_EXTENT = new OpenLayers.Bounds(-90,-180,90,180); tim@984: CURRENT_EXTENT = new OpenLayers.Bounds(<%=mapService.getBBoxValue().replace(' ',',')%>); tim@971: INITIAL_CENTER = new OpenLayers.LonLat(5, 55); tim@984: GETFEATUREINFO_URL = "<%=mapService.getURL()%>"; tim@971: tim@971: Ext.onReady(function() { tim@971: tim@971: /* this function call initialized the layers that are defined by the user. tim@971: * The variable 'layer' and 'layers' are initialized in this function as tim@971: * well, that are used in the following code! So do not remove this function tim@971: * call. tim@971: */ tim@971: initLayers(); tim@971: tim@971: var options = { tim@971: maxExtent: MAX_EXTENT, tim@971: projection: PROJECTION, tim@971: controls: [], tim@971: units: 'm' tim@971: }; tim@971: tim@971: tim@971: /* ------------------------ Create map and add controls ---------------------*/ tim@971: // create map tim@971: map = new OpenLayers.Map(options); tim@971: map.displayProjection = new OpenLayers.Projection(PROJECTION); tim@971: tim@971: // add controls tim@971: tim@971: tim@971: var nav = new OpenLayers.Control.NavigationHistory(); tim@980: nav.previous.title = ""; tim@980: nav.next.title = ""; tim@971: map.addControl(nav); tim@971: tim@971: panel = new OpenLayers.Control.Panel(); tim@971: controls = { tim@971: previous: nav.previous, tim@971: next : nav.next, tim@971: navigate: new OpenLayers.Control.MouseDefaults( tim@971: { tim@971: displayClass: 'olControlPan', tim@980: title:'' tim@971: } tim@971: ), tim@971: zoombox: new OpenLayers.Control.ZoomBox( tim@971: { tim@971: displayClass: 'olControlZoomBox', tim@980: title: '' tim@971: } tim@971: ), tim@971: info : new OpenLayers.Control.WMSGetFeatureInfo({ tim@971: displayClass: "olControlFeatureInfo", tim@983: url: GETFEATUREINFO_URL, tim@980: title: '', tim@971: queryVisible: true, tim@983: infoFormat: 'application/vnd.ogc.gml', tim@971: eventListeners: { tim@997: getfeatureinfo: parseGetFeatureInfoData tim@971: } tim@971: }) tim@971: }; tim@997: tim@971: for (var key in controls) { tim@971: panel.addControls([controls[key]]); tim@971: } tim@971: tim@971: map.addControl(panel); tim@971: map.addControl(new OpenLayers.Control.PanZoomBar({zoomWorldIcon: 'true'})); tim@971: map.addControl(new OpenLayers.Control.MouseDefaults()); tim@971: // Displaying the mouse postion tim@971: mousePosition = new OpenLayers.Control.MousePosition(); tim@971: map.addControl(mousePosition); tim@971: tim@971: /* --------------------------------------------------------------------------- */ tim@971: tim@971: // create MapPanel tim@971: mapPanel = new GeoExt.MapPanel({ tim@971: border: true, tim@971: region: "center", tim@971: map: map, tim@973: layers: layers tim@973: tim@971: }); tim@971: tim@984: //map.setCenter(INITIAL_CENTER); tim@984: tim@975: tim@975: store = new GeoExt.data.WMSCapabilitiesStore({ tim@975: }); tim@975: tim@975: grid = new Ext.grid.GridPanel({ tim@975: id: 'wmsgrid', tim@975: collapsible: false, tim@975: split: false, tim@975: border: true, tim@975: //height: 400, tim@975: autoHeight: true, tim@975: store: store, tim@975: cm: new Ext.grid.ColumnModel([ tim@975: { tim@980: header: '', tim@975: dataIndex: 'name', tim@975: sortable: true tim@975: }, tim@975: { tim@975: id: 'title', tim@980: header: '', tim@975: dataIndex: 'title', tim@975: sortable: true tim@975: }]), tim@975: renderTo: 'capgrid', tim@975: bbar: [{ tim@980: text: '', tim@975: handler: addLayer tim@975: }] tim@975: }); tim@975: var cap = new Ext.Panel({ tim@975: id: 'wmspanel', tim@975: border: true, tim@975: region: 'east', tim@980: title: '', tim@975: collapsible: false, tim@975: split: false, tim@982: height: 400, tim@982: contentEl: 'cap' tim@982: tim@975: }); tim@975: tim@975: var capfield = new Ext.form.TextField({ tim@975: id: 'capfield', tim@975: region: 'east', tim@975: width: '100%', tim@975: renderTo: 'urlinput' tim@975: }); tim@975: tim@975: var capbutton = new Ext.Button({ tim@975: id: 'capbutton', tim@975: region: 'west', tim@975: handler: updateCapabilities, tim@980: text: '', tim@980: tooltip: '', tim@975: renderTo: 'urlbutton' tim@975: }); tim@975: tim@975: tim@975: tim@971: tim@971: /* --------------------------- Layer Tree ----------------------------------- */ tim@971: tim@971: tim@971: // LayerTree tim@971: var tree = new Ext.tree.TreePanel({ tim@971: border: true, tim@971: enableDD: true, tim@971: region: "east", tim@980: title: "", tim@971: width: 200, tim@971: split: true, tim@971: collapsible: false, tim@971: collapseMode: "mini", tim@971: autoScroll: true, tim@971: loader: new Ext.tree.TreeLoader({ tim@971: applyLoader: false, tim@971: }), tim@971: root: { tim@971: nodeType: "async", tim@971: children: [{ tim@971: nodeType: "gx_baselayercontainer", tim@980: text: "", tim@971: expanded: true tim@971: }, { tim@971: nodeType: "gx_overlaylayercontainer", tim@980: text: "", tim@971: expanded: true, tim@971: loader: { tim@971: filter: function(record) { tim@971: var layer = record.get("layer"); tim@971: return layer.displayInLayerSwitcher === true && tim@971: layer.isBaseLayer === false; tim@971: } tim@971: } tim@971: }] tim@971: }, tim@971: rootVisible: false, tim@971: lines: false tim@971: }); tim@971: tim@971: /*-------------------------------- Feature grid -------------------------------*/ tim@971: tim@982: // create legend paneclass="headerLineLinksl tim@971: legendPanel = new GeoExt.LegendPanel({ tim@971: id: 'legendpanel', tim@971: dynamic: true, tim@971: border: true, tim@980: title: '', tim@971: collapsible: false, tim@971: split: false, tim@971: defaults: { tim@971: labelCls: 'legend', tim@971: style: 'padding: 5px' tim@971: }, tim@971: bodyStyle: 'padding:5px', tim@971: width: 250, tim@971: autoScroll: true, tim@980: region: 'east', tim@971: }); tim@971: tim@971: tim@971: // use separate panels tim@971: // Create GUI tim@971: tim@971: var mylegend = new Ext.Panel( tim@971: { tim@971: region: "west", tim@971: title: '', tim@971: split: true, tim@971: width: 250, tim@971: minSize: 225, tim@971: maxSize: 400, tim@971: collapsible: false, tim@971: overflow: 'auto', tim@971: margins: '0 0 0 5', tim@971: layout: 'accordion', tim@971: layoutConfig: { tim@971: animate: true, tim@971: activeOnTop: false tim@971: }, tim@971: items: [ tim@971: tree, tim@1012: legendPanel, tim@1012: cap tim@971: ] tim@971: } tim@971: ); tim@982: <%if (!standalone){%> tim@971: // The main panel tim@971: new Ext.Panel({ tim@971: renderTo: "mapcontainer", tim@971: layout: "border", tim@980: height: 400, tim@971: items: [mapPanel, mylegend] tim@971: }); tim@982: <%}else{ %> tim@982: // Create GUI tim@982: new Ext.Viewport({ tim@982: layout: "border", tim@982: items: [ tim@982: { tim@982: region: "north", tim@1013: contentEl: "headline", tim@982: cls: 'title', tim@982: height: 40 tim@982: }, tim@982: mylegend, tim@982: mapPanel tim@982: ] tim@982: }); tim@982: <%}%> tim@984: map.zoomToExtent(CURRENT_EXTENT); tim@971: });