annotate app/view/panel/Map.js @ 1279:291df0037835

Ortszuordnung window: create, change and display (wip)
author Maximilian Krambach <mkrambach@intevation.de>
date Wed, 18 Jan 2017 11:41:50 +0100
parents a792eecf1614
children 08085b7d1d0b
rev   line source
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
893
07dfcdf5b41f jsduck for grids and panels
Dustin Demuth <dustin@intevation.de>
parents: 879
diff changeset
8
07dfcdf5b41f jsduck for grids and panels
Dustin Demuth <dustin@intevation.de>
parents: 879
diff changeset
9
07dfcdf5b41f jsduck for grids and panels
Dustin Demuth <dustin@intevation.de>
parents: 879
diff changeset
10 /**
07dfcdf5b41f jsduck for grids and panels
Dustin Demuth <dustin@intevation.de>
parents: 879
diff changeset
11 * This is the MapPanel.
07dfcdf5b41f jsduck for grids and panels
Dustin Demuth <dustin@intevation.de>
parents: 879
diff changeset
12 * It uses OpenLayers to display the map
07dfcdf5b41f jsduck for grids and panels
Dustin Demuth <dustin@intevation.de>
parents: 879
diff changeset
13 */
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 Ext.define('Lada.view.panel.Map', {
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 extend: 'Ext.panel.Panel',
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 alias: 'widget.map',
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
17 name: 'map',
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
19 record: null,
638
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
20 locationRecord: null,
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
21 externalOrteStore: false,
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
22 /*
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
23 * if externalOrteStore is true, the mappanel will not load the orte
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
24 * store on it's own; it expects an already loaded store instead
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
25 */
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
26
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 /**
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 * @cfg
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 * OpenLayers map options.
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
30 * Please note that TMS zoom levels are roughly as this:
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
31 * 7 = 1:4000000 14 = 1:35000
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 */
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 mapOptions: {
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
34 maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
35 numZoomLevels: 15,
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
36 projection: 'EPSG:3857',
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
37 displayProjection: new OpenLayers.Projection('EPSG:4326')
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 },
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 /**
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 * @private
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 * Initialize the map panel.
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 */
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 initComponent: function() {
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
46 var id = Ext.id();
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
47 this.layers = [
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
48 new OpenLayers.Layer.TMS(
643
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 638
diff changeset
49 'Standard' + id,
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
50 'http://www.imis.bfs.de/mapcache/tms/',
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
51 {
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
52 layername: 'osm_bfs_google@GoogleMapsCompatible',
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
53 isBaseLayer: true,
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
54 displayInLayerSwitcher: false,
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
55 type: 'png',
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
56 visibility: true,
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
57 projection: 'EPSG:3857',
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
58 })
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
59 ];
643
477379250512 Open the ort create window on button click.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 638
diff changeset
60 this.map = new OpenLayers.Map('map_' + id, {
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 controls: [],
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 tileManager: null,
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
63 zoomMethod: null,
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
64 // initializing with view centered on germany
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
65 center: new OpenLayers.LonLat(1160000,6694000),
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
66 zoom: 7
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 });
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 this.map.setOptions(this.mapOptions);
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 this.map.addLayers(this.layers);
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 var keyControl = new OpenLayers.Control.KeyboardDefaults();
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 this.map.addControl(keyControl);
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 keyControl.activate();
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 this.bodyStyle = {background: '#fff'};
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
74 this.initData();
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
75 this.addEvents('featureselected');
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
76 this.callParent(arguments);
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
77 },
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
78
895
2b7bcb778f0a Jsduck debug
Dustin Demuth <dustin@intevation.de>
parents: 893
diff changeset
79 /**
2b7bcb778f0a Jsduck debug
Dustin Demuth <dustin@intevation.de>
parents: 893
diff changeset
80 * Initialise the Data and Create an
2b7bcb778f0a Jsduck debug
Dustin Demuth <dustin@intevation.de>
parents: 893
diff changeset
81 * Array of OpenLayers.Layer objects.
2b7bcb778f0a Jsduck debug
Dustin Demuth <dustin@intevation.de>
parents: 893
diff changeset
82 */
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
83 initData: function() {
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
84 var me = this;
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
85
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
86 if (!this.externalOrteStore) {
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
87 this.locationStore = Ext.data.StoreManager.get('orte');
1055
65ea1c2a8c98 Updated orte window in messprogramme to new orte model.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1051
diff changeset
88 this.addLocations(this.locationStore);
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
89 }
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
90 },
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
91
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
92 selectFeature: function(model, record) {
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1055
diff changeset
93 if (!record.get('id') || record.get('id') === '') {
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1055
diff changeset
94 return;
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1055
diff changeset
95 }
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
96 var feature = this.featureLayer.getFeaturesByAttribute('id', record.get('id'))[0];
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
97 this.map.setCenter(
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
98 new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y));
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
99 this.map.zoomTo(12);
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
100
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
101 if (this.selectedFeatureLayer) {
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
102 if (this.selectedFeatureLayer.features.lenght > 0) {
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
103 this.featureLayer.addFeatures(this.selectedFeatureLayer.features);
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
104 }
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
105 this.selectedFeatureLayer.addFeatures([feature]);
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
106 } else {
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
107 this.selectControl.select(feature);
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
108 }
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
109 //TODO: the text of new features is still drawn on top of the old feature's text
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 },
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111
638
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
112 activateDraw: function(record) {
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
113 this.locationRecord = record;
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
114 if (!this.drawPoint) {
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
115 this.drawPoint = new OpenLayers.Control.DrawFeature(this.featureLayer,
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
116 OpenLayers.Handler.Point);
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
117 this.map.addControl(this.drawPoint);
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
118 }
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
119 this.drawPoint.activate();
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
120 this.drawPoint.events.register('featureadded', this, this.featureAdded);
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
121 },
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
122
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
123 featureAdded: function(features) {
1263
26197c2d9362 Set values from which the server actually generates a geometry.
Tom Gottfried <tom@intevation.de>
parents: 1130
diff changeset
124 this.locationRecord.set('kdaId', 4);
26197c2d9362 Set values from which the server actually generates a geometry.
Tom Gottfried <tom@intevation.de>
parents: 1130
diff changeset
125 this.locationRecord.set('koordYExtern', features.feature.geometry.y);
26197c2d9362 Set values from which the server actually generates a geometry.
Tom Gottfried <tom@intevation.de>
parents: 1130
diff changeset
126 this.locationRecord.set('koordXExtern', features.feature.geometry.x);
638
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
127 this.drawPoint.deactivate();
1130
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1055
diff changeset
128 this.fireEvent('featureadded', this.locationRecord);
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1055
diff changeset
129 // this.selectControl.unselectAll();
e4952906634d Implemented insert, edit and delete for stammdaten.ort.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1055
diff changeset
130 // this.selectControl.select(features.feature);
638
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
131 },
d21048cbdbb3 Added controllers for map and location form and handle new locations.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 635
diff changeset
132
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
133 addLocations: function(locationStore) {
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
134 var me = this;
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
135 locationFeatures = [];
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
136
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
137 // Iterate the Store and create features from it
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
138 for (var i = 0; i < locationStore.count(); i++) {
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
139 locationFeatures.push(new OpenLayers.Feature.Vector(
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
140 new OpenLayers.Geometry.Point(
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
141 locationStore.getAt(i).get('longitude'),
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
142 locationStore.getAt(i).get('latitude')
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
143 ),
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
144 {
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
145 id: locationStore.getAt(i).get('id'),
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
146 bez: locationStore.getAt(i).get('ortId')
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
147 }
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
148 ));
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
149 }
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
150
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
151 // Create a new Feature Layer and add it to the map
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
152 if (!this.featureLayer) {
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
153 this.featureLayer = new OpenLayers.Layer.Vector( 'alle Messpunkte', {
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
154 styleMap: new OpenLayers.StyleMap({
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
155 'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
156 externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
157 graphicOpacity: 1,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
158 pointRadius: 10,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
159 label: '${bez}',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
160 labelAlign: 'rt',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
161 fontColor: 'green',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
162 fontWeight: 'bold'
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
163 }, OpenLayers.Feature.Vector.style['default'])),
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
164 'select': new OpenLayers.Style({
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
165 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
166 pointRadius: 15,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
167 label: '${bez}',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
168 labelAlign: 'rt',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
169 fontColor: 'blue',
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
170 fontWeight: 'bold'
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
171 })
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
172 }),
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
173 projection: new OpenLayers.Projection('EPSG:3857'),
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
174 preFeatureInsert: function(feature) {
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
175 feature.geometry.transform(new OpenLayers.Projection('EPSG:4326'),
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
176 new OpenLayers.Projection('EPSG:3857'));
1274
a792eecf1614 Updated Layout and Map for 'ortsbezug'-window. WIP!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1263
diff changeset
177 }
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
178 });
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
179 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
180 clickout: false,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
181 toggle: false,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
182 multiple: false,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
183 hover: false,
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
184 onSelect: me.selectedFeature,
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
185 layers: [me.featureLayer],
1049
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
186 scope: me
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
187 });
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
188 this.map.addControl(this.selectControl);
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
189 this.selectControl.activate();
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
190 }
1bd4c0709bd6 Working version of selectable 'ort' in map and grid.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1021
diff changeset
191 this.featureLayer.removeAllFeatures();
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
192 this.featureLayer.addFeatures(locationFeatures);
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
193 this.map.addLayer(this.featureLayer);
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
194 this.featureLayer.setZIndex(500);
1021
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
195 },
1df6b6210b42 WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
Dustin Demuth <dustin@intevation.de>
parents: 895
diff changeset
196
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
197 /**
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
198 * @private
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
199 * Override to display and update the map view in the panel.
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
200 */
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
201 afterRender: function() {
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
202 this.superclass.afterRender.apply(this, arguments);
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
203
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 this.map.render(this.body.dom);
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 this.map.addControl(new OpenLayers.Control.Navigation());
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 this.map.addControl(new OpenLayers.Control.PanZoomBar());
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207 this.map.addControl(new OpenLayers.Control.ScaleLine());
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
208 },
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
209
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
210 /**
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
211 * Forward OpenlayersEvent to EXT
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
212 */
1279
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
213 selectedFeature: function(feature) {
291df0037835 Ortszuordnung window: create, change and display (wip)
Maximilian Krambach <mkrambach@intevation.de>
parents: 1274
diff changeset
214 this.selectControl.unselectAll({except:feature});
796
7267bae1d43f made window-panel recyclable, fwd openlayers events to ext
Dustin Demuth <dustin@intevation.de>
parents: 643
diff changeset
215 this.fireEvent('featureselected', this, arguments);
614
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
216 },
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
217
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
218 beforeDestroy: function() {
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
219 if (this.map) {
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
220 this.map.destroy();
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
221 }
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
222 delete this.map;
04e380ce4d73 Load locations as layer on the map, set selections based on the selected 'ort'.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 605
diff changeset
223 this.callParent(arguments);
605
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 },
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 /**
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 * @private
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 * Override to resize the map and reposition the logo.
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 */
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 onResize: function() {
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 this.superclass.onResize.apply(this, arguments);
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 this.map.updateSize();
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233 }
c6994912a326 Added panel with OpenLayers map.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 });

http://lada.wald.intevation.org