tim@987: <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
tim@987: function handleMeasurements(event) {
tim@987: var geometry = event.geometry;
tim@987: var units = event.units;
tim@987: var order = event.order;
tim@987: var measure = event.measure;
tim@987: var element = document.getElementById('measurements');
tim@987:
tim@987: var out = "";
tim@987: if(order == 1) {
tim@987: out += "L\u00e4nge: " + measure.toFixed(3) + " " + units;
tim@987: } else {
tim@987: out += "Fl\u00e4che: " + measure.toFixed(3) + " " + units + "2";
tim@987: }
tim@987:
tim@987: element.innerHTML=out;
tim@987: };
tim@987:
tim@987:
tim@987:
tim@987: function readWMC(merge) {
tim@987: var layers = mapPanel.layers;
tim@987: map = mapPanel.map;
tim@987:
tim@987: var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});
tim@987: var text = document.getElementById("wmc").value;
tim@987:
tim@987: merge = true;
tim@987: if(merge) {
tim@987: try {
tim@987: map = format.read(text, {map: map});
tim@987: } catch(err) {
tim@987: document.getElementById("wmc").value = err;
tim@987: }
tim@987: } else {
tim@987: map.destroy();
tim@987: try {
tim@987: var jsonFormat = new OpenLayers.Format.JSON();
tim@987: var mapOptions = jsonFormat.read();
tim@987: map = format.read(text, {map: mapOptions});
tim@987: } catch(err) {
tim@987: document.getElementById("wmc").value = err;
tim@987: }
tim@987: }
tim@987:
tim@987: // create MapPanel
tim@987: mapPanel = new GeoExt.MapPanel({
tim@987: border: true,
tim@987: title: "Karte",
tim@987: region: "center",
tim@987: map: map,
tim@987: zoom: 1,
tim@987: layers: map.layers
tim@987: });
tim@987: }
tim@987:
tim@987:
tim@987: function writeWMC(merge) {
tim@987: var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});
tim@987:
tim@987: try {
tim@987: var text = format.write(map);
tim@987: document.getElementById("wmc").value = text;
tim@987: } catch(err) {
tim@987: document.getElementById("wmc").value = err;
tim@987: }
tim@987: }
tim@987:
tim@987:
tim@987:
tim@987: function toggleGetFeatureInfo(evt) {
tim@987: if (infoActive) {
tim@987: infoControls.click.deactivate();
tim@987: infoActive = false;
tim@987: }
tim@987: else {
tim@987: infoControls.click.activate();
tim@987: infoActive = true;
tim@987: }
tim@987: }
tim@987:
tim@987:
tim@987: function showInfo(evt) {
tim@987: }
tim@987:
tim@987:
tim@987: function addLayer() {
tim@989: var records = grid.getSelectionModel().getSelections();
tim@989: for (rec in records){
tim@989:
tim@989: var record = records[rec];
tim@989: // TODO: Look for something better than object
tim@989: if (typeof record == "object"){
tim@987: var copy = record.copy();
tim@987: copy.set("layer", record.get("layer"));
tim@987: copy.get("layer").mergeNewParams({
tim@987: format: "image/png",
tim@987: transparent: true
tim@987: });
tim@989: copy.singletile = true;
tim@987: mapPanel.layers.add(copy);
tim@989: }
tim@989: }
tim@989:
tim@987: }
tim@987:
tim@987:
tim@987: // this is just copied from OpenLayers.Util
tim@987: function urlAppend(url, paramStr) {
tim@987: var newUrl = url;
tim@987: if(paramStr) {
tim@987: var parts = (url + " ").split(/[?&]/);
tim@987: newUrl += (parts.pop() === " " ?
tim@987: paramStr :
tim@987: parts.length ? "&" + paramStr : "?" + paramStr);
tim@987: }
tim@987: return newUrl;
tim@987: }
tim@987:
tim@989: function showWarning(){
tim@989: if (store.data.length == 0){
tim@989: Ext.MessageBox.alert("", '', grid);
tim@989: return;
tim@989: }
tim@989: }
tim@989:
tim@987:
tim@987: function updateCapabilities() {
tim@987: var ele = Ext.Element.get('capfield');
tim@987:
tim@987: var url = ele.getValue();
tim@987: var service = "SERVICE=WMS";
tim@987: var request = "REQUEST=GetCapabilities";
tim@987: url = urlAppend(url, service);
tim@987: url = urlAppend(url, request);
tim@987:
tim@987: store = new GeoExt.data.WMSCapabilitiesStore({
tim@987: url: url
tim@987: });
tim@989: store.load({
tim@989: callback: showWarning
tim@989: });
tim@989:
tim@987: grid.destroy();
tim@987: grid = new Ext.grid.GridPanel({
tim@987: id: 'wmsgrid',
tim@987: collapsible: false,
tim@987: split: false,
tim@987: border: true,
tim@987: // TODO: autoHeight might cause trouble
tim@987: autoHeight: true,
tim@987: overflow: 'auto',
tim@987: store: store,
tim@987: cm: new Ext.grid.ColumnModel([
tim@987: {
tim@987: header: '',
tim@987: dataIndex: 'name',
tim@987: sortable: true
tim@987: },
tim@987: {
tim@987: id: 'title',
tim@987: header: '',
tim@987: dataIndex: 'title',
tim@987: sortable: true
tim@987: }]),
tim@987: renderTo: 'capgrid',
tim@987: bbar: [{
tim@987: text: '',
tim@987: handler: addLayer
tim@987: }]
tim@987: });
tim@987: }
tim@987:
tim@987:
tim@987: function editFeature(e) {
tim@987: var feature = e.feature;
tim@987:
tim@987: // TODO SET FEATURE ATTRIBUTES
tim@987: //feature.attributes['lawa'] = 999;
tim@987: //feature.attributes['lawa_id'] = 999;
tim@987: //feature.attributes['w_gwk_lawa'] = 999;
tim@987: //feature.attributes['w_wrrl'] = 999;
tim@987: //feature.attributes['length_fee'] = 999;
tim@987: }
tim@987:
tim@987: function updateControls() {
tim@987: var controls = panel.controls;
tim@987:
tim@987: controls.remove(drawPointControl);
tim@987: controls.remove(drawPathControl);
tim@987: controls.remove(drawPolygonControl);
tim@987:
tim@987: panel.destroy();
tim@987: panel = new OpenLayers.Control.Panel();
tim@987: panel.addControls(controls);
tim@987:
tim@987: if (points.getVisibility())
tim@987: panel.addControls(drawPointControl);
tim@987: if (lines.getVisibility())
tim@987: panel.addControls(drawPathControl);
tim@987: if (polygons.getVisibility())
tim@987: panel.addControls(drawPolygonControl);
tim@987:
tim@987: map.addControl(panel);
tim@987: }