Mercurial > dive4elements > gnv-client
changeset 987:42da41835b54
Rename olutils.js to olutils.jsp to enable possibility of i18n in this file.
gnv/trunk@1173 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 08 Jun 2010 12:54:10 +0000 |
parents | d3e0f505f50c |
children | 556e16cc4da5 |
files | gnv/ChangeLog gnv/src/main/webapp/WEB-INF/jsp/includes/wms_header_inc.jsp gnv/src/main/webapp/scripts/olutils.jsp |
diffstat | 3 files changed, 203 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Tue Jun 08 12:44:06 2010 +0000 +++ b/gnv/ChangeLog Tue Jun 08 12:54:10 2010 +0000 @@ -1,3 +1,13 @@ +2010-06-08 Tim Englich <tim.englich@intevation.de> + + * src/main/webapp/scripts/olutils.jsp: + Rename olutils.js to olutils.jsp to enable possibility of i18n in this file. + Added references to resources in in Method addLayer. + + * src/main/webapp/WEB-INF/jsp/includes/wms_header_inc.jsp: + Replace linkt to olutils.js to olutils.jsp. + + 2010-06-08 Tim Englich <tim.englich@intevation.de> * src/main/webapp/WEB-INF/jsp/includes/wms_header_inc.jsp:
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/wms_header_inc.jsp Tue Jun 08 12:44:06 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/wms_header_inc.jsp Tue Jun 08 12:54:10 2010 +0000 @@ -27,7 +27,7 @@ <script type="text/javascript" src="scripts/ext/ext-2.3.0/ext-all.js"></script> <script type="text/javascript" src="scripts/openlayers/OpenLayers-2.9/OpenLayers.js"></script> <script type="text/javascript" src="scripts/geoext/geoext-0.6/script/GeoExt.js"></script> - <script type="text/javascript" src="scripts/olutils.js"></script> + <script type="text/javascript" src="<%=response.encodeURL("scripts/olutils.jsp?uid="+System.currentTimeMillis())%>">"></script> <script type="text/javascript" src="<%=response.encodeURL("scripts/layers.jsp?uid="+System.currentTimeMillis())%>"></script> <script type="text/javascript" src="<%=response.encodeURL("scripts/viewport.jsp?uid="+System.currentTimeMillis()+"&"+MapClientStandaloneAction.MAPCLIENTSTANDALONE_KEY+"="+standalone)%>"></script>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/main/webapp/scripts/olutils.jsp Tue Jun 08 12:54:10 2010 +0000 @@ -0,0 +1,192 @@ +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +function handleMeasurements(event) { + var geometry = event.geometry; + var units = event.units; + var order = event.order; + var measure = event.measure; + var element = document.getElementById('measurements'); + + var out = ""; + if(order == 1) { + out += "L\u00e4nge: " + measure.toFixed(3) + " " + units; + } else { + out += "Fl\u00e4che: " + measure.toFixed(3) + " " + units + "<sup>2</sup>"; + } + + element.innerHTML=out; +}; + + + +function readWMC(merge) { + var layers = mapPanel.layers; + map = mapPanel.map; + + var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}}); + var text = document.getElementById("wmc").value; + + merge = true; + if(merge) { + try { + map = format.read(text, {map: map}); + } catch(err) { + document.getElementById("wmc").value = err; + } + } else { + map.destroy(); + try { + var jsonFormat = new OpenLayers.Format.JSON(); + var mapOptions = jsonFormat.read(); + map = format.read(text, {map: mapOptions}); + } catch(err) { + document.getElementById("wmc").value = err; + } + } + + // create MapPanel + mapPanel = new GeoExt.MapPanel({ + border: true, + title: "Karte", + region: "center", + map: map, + zoom: 1, + layers: map.layers + }); +} + + +function writeWMC(merge) { + var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}}); + + try { + var text = format.write(map); + document.getElementById("wmc").value = text; + } catch(err) { + document.getElementById("wmc").value = err; + } +} + + + +function toggleGetFeatureInfo(evt) { + if (infoActive) { + infoControls.click.deactivate(); + infoActive = false; + } + else { + infoControls.click.activate(); + infoActive = true; + } +} + + +function showInfo(evt) { +} + + +function addLayer() { + var record = grid.getSelectionModel().getSelected(); + + if (record) { + var copy = record.copy(); + copy.set("layer", record.get("layer")); + copy.get("layer").mergeNewParams({ + format: "image/png", + transparent: true + }); + + mapPanel.layers.add(copy); + mapPanel.map.zoomToExtent(OpenLayers.Bounds.fromArray(copy.get("llbbox"))); + } +} + + +// this is just copied from OpenLayers.Util +function urlAppend(url, paramStr) { + var newUrl = url; + if(paramStr) { + var parts = (url + " ").split(/[?&]/); + newUrl += (parts.pop() === " " ? + paramStr : + parts.length ? "&" + paramStr : "?" + paramStr); + } + return newUrl; +} + + +function updateCapabilities() { + var ele = Ext.Element.get('capfield'); + + var url = ele.getValue(); + var service = "SERVICE=WMS"; + var request = "REQUEST=GetCapabilities"; + url = urlAppend(url, service); + url = urlAppend(url, request); + + store = new GeoExt.data.WMSCapabilitiesStore({ + url: url + }); + store.load(); + + grid.destroy(); + grid = new Ext.grid.GridPanel({ + id: 'wmsgrid', + collapsible: false, + split: false, + border: true, + // TODO: autoHeight might cause trouble + autoHeight: true, + overflow: 'auto', + store: store, + cm: new Ext.grid.ColumnModel([ + { + header: '<bean:message key="gnviewer.mapclient.wms.load.grid.name"/>', + dataIndex: 'name', + sortable: true + }, + { + id: 'title', + header: '<bean:message key="gnviewer.mapclient.wms.load.grid.title"/>', + dataIndex: 'title', + sortable: true + }]), + renderTo: 'capgrid', + bbar: [{ + text: '<bean:message key="gnviewer.mapclient.wms.load.addlayer"/>', + handler: addLayer + }] + }); +} + + +function editFeature(e) { + var feature = e.feature; + + // TODO SET FEATURE ATTRIBUTES + //feature.attributes['lawa'] = 999; + //feature.attributes['lawa_id'] = 999; + //feature.attributes['w_gwk_lawa'] = 999; + //feature.attributes['w_wrrl'] = 999; + //feature.attributes['length_fee'] = 999; +} + +function updateControls() { + var controls = panel.controls; + + controls.remove(drawPointControl); + controls.remove(drawPathControl); + controls.remove(drawPolygonControl); + + panel.destroy(); + panel = new OpenLayers.Control.Panel(); + panel.addControls(controls); + + if (points.getVisibility()) + panel.addControls(drawPointControl); + if (lines.getVisibility()) + panel.addControls(drawPathControl); + if (polygons.getVisibility()) + panel.addControls(drawPolygonControl); + + map.addControl(panel); +}