comparison gnv/src/main/webapp/scripts/olutils.jsp @ 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
children e3301755bd3c
comparison
equal deleted inserted replaced
986:d3e0f505f50c 987:42da41835b54
1 <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
2 function handleMeasurements(event) {
3 var geometry = event.geometry;
4 var units = event.units;
5 var order = event.order;
6 var measure = event.measure;
7 var element = document.getElementById('measurements');
8
9 var out = "";
10 if(order == 1) {
11 out += "L\u00e4nge: " + measure.toFixed(3) + " " + units;
12 } else {
13 out += "Fl\u00e4che: " + measure.toFixed(3) + " " + units + "<sup>2</sup>";
14 }
15
16 element.innerHTML=out;
17 };
18
19
20
21 function readWMC(merge) {
22 var layers = mapPanel.layers;
23 map = mapPanel.map;
24
25 var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});
26 var text = document.getElementById("wmc").value;
27
28 merge = true;
29 if(merge) {
30 try {
31 map = format.read(text, {map: map});
32 } catch(err) {
33 document.getElementById("wmc").value = err;
34 }
35 } else {
36 map.destroy();
37 try {
38 var jsonFormat = new OpenLayers.Format.JSON();
39 var mapOptions = jsonFormat.read();
40 map = format.read(text, {map: mapOptions});
41 } catch(err) {
42 document.getElementById("wmc").value = err;
43 }
44 }
45
46 // create MapPanel
47 mapPanel = new GeoExt.MapPanel({
48 border: true,
49 title: "Karte",
50 region: "center",
51 map: map,
52 zoom: 1,
53 layers: map.layers
54 });
55 }
56
57
58 function writeWMC(merge) {
59 var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});
60
61 try {
62 var text = format.write(map);
63 document.getElementById("wmc").value = text;
64 } catch(err) {
65 document.getElementById("wmc").value = err;
66 }
67 }
68
69
70
71 function toggleGetFeatureInfo(evt) {
72 if (infoActive) {
73 infoControls.click.deactivate();
74 infoActive = false;
75 }
76 else {
77 infoControls.click.activate();
78 infoActive = true;
79 }
80 }
81
82
83 function showInfo(evt) {
84 }
85
86
87 function addLayer() {
88 var record = grid.getSelectionModel().getSelected();
89
90 if (record) {
91 var copy = record.copy();
92 copy.set("layer", record.get("layer"));
93 copy.get("layer").mergeNewParams({
94 format: "image/png",
95 transparent: true
96 });
97
98 mapPanel.layers.add(copy);
99 mapPanel.map.zoomToExtent(OpenLayers.Bounds.fromArray(copy.get("llbbox")));
100 }
101 }
102
103
104 // this is just copied from OpenLayers.Util
105 function urlAppend(url, paramStr) {
106 var newUrl = url;
107 if(paramStr) {
108 var parts = (url + " ").split(/[?&]/);
109 newUrl += (parts.pop() === " " ?
110 paramStr :
111 parts.length ? "&" + paramStr : "?" + paramStr);
112 }
113 return newUrl;
114 }
115
116
117 function updateCapabilities() {
118 var ele = Ext.Element.get('capfield');
119
120 var url = ele.getValue();
121 var service = "SERVICE=WMS";
122 var request = "REQUEST=GetCapabilities";
123 url = urlAppend(url, service);
124 url = urlAppend(url, request);
125
126 store = new GeoExt.data.WMSCapabilitiesStore({
127 url: url
128 });
129 store.load();
130
131 grid.destroy();
132 grid = new Ext.grid.GridPanel({
133 id: 'wmsgrid',
134 collapsible: false,
135 split: false,
136 border: true,
137 // TODO: autoHeight might cause trouble
138 autoHeight: true,
139 overflow: 'auto',
140 store: store,
141 cm: new Ext.grid.ColumnModel([
142 {
143 header: '<bean:message key="gnviewer.mapclient.wms.load.grid.name"/>',
144 dataIndex: 'name',
145 sortable: true
146 },
147 {
148 id: 'title',
149 header: '<bean:message key="gnviewer.mapclient.wms.load.grid.title"/>',
150 dataIndex: 'title',
151 sortable: true
152 }]),
153 renderTo: 'capgrid',
154 bbar: [{
155 text: '<bean:message key="gnviewer.mapclient.wms.load.addlayer"/>',
156 handler: addLayer
157 }]
158 });
159 }
160
161
162 function editFeature(e) {
163 var feature = e.feature;
164
165 // TODO SET FEATURE ATTRIBUTES
166 //feature.attributes['lawa'] = 999;
167 //feature.attributes['lawa_id'] = 999;
168 //feature.attributes['w_gwk_lawa'] = 999;
169 //feature.attributes['w_wrrl'] = 999;
170 //feature.attributes['length_fee'] = 999;
171 }
172
173 function updateControls() {
174 var controls = panel.controls;
175
176 controls.remove(drawPointControl);
177 controls.remove(drawPathControl);
178 controls.remove(drawPolygonControl);
179
180 panel.destroy();
181 panel = new OpenLayers.Control.Panel();
182 panel.addControls(controls);
183
184 if (points.getVisibility())
185 panel.addControls(drawPointControl);
186 if (lines.getVisibility())
187 panel.addControls(drawPathControl);
188 if (polygons.getVisibility())
189 panel.addControls(drawPolygonControl);
190
191 map.addControl(panel);
192 }

http://dive4elements.wald.intevation.org