comparison app/view/panel/Map.js @ 1051:981339d774b8

merged stammdatengrids to default.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 01 Mar 2016 14:12:39 +0100
parents 1bd4c0709bd6
children 65ea1c2a8c98
comparison
equal deleted inserted replaced
1048:eacf25f071c0 1051:981339d774b8
12 * It uses OpenLayers to display the map 12 * It uses OpenLayers to display the map
13 */ 13 */
14 Ext.define('Lada.view.panel.Map', { 14 Ext.define('Lada.view.panel.Map', {
15 extend: 'Ext.panel.Panel', 15 extend: 'Ext.panel.Panel',
16 alias: 'widget.map', 16 alias: 'widget.map',
17 name: 'map',
17 18
18 record: null, 19 record: null,
19 locationRecord: null, 20 locationRecord: null,
21 externalOrteStore: false,
22 /*
23 * if externalOrteStore is true, the mappanel will not load the orte
24 * store on it's own; it expects an already loaded store instead
25 */
20 26
21 /** 27 /**
22 * @cfg 28 * @cfg
23 * OpenLayers map options. 29 * OpenLayers map options.
24 */ 30 */
60 var keyControl = new OpenLayers.Control.KeyboardDefaults(); 66 var keyControl = new OpenLayers.Control.KeyboardDefaults();
61 this.map.addControl(keyControl); 67 this.map.addControl(keyControl);
62 keyControl.activate(); 68 keyControl.activate();
63 this.bodyStyle = {background: '#fff'}; 69 this.bodyStyle = {background: '#fff'};
64 this.initData(); 70 this.initData();
65 this.tbar = Ext.create('Lada.view.widget.MapToolbar');
66 this.addEvents('featureselected'); 71 this.addEvents('featureselected');
67 this.callParent(arguments); 72 this.callParent(arguments);
68 }, 73 },
69 74
70 /** 75 /**
71 * Initialise the Data and Create an 76 * Initialise the Data and Create an
72 * Array of OpenLayers.Layer objects. 77 * Array of OpenLayers.Layer objects.
73 */ 78 */
74 initData: function() { 79 initData: function() {
75 var me = this; 80 var me = this;
76 this.locationFeatures = []; 81
77 this.locationStore = Ext.data.StoreManager.get('locations'); 82 if (!this.externalOrteStore) {
78 for (var i = 0; i < this.locationStore.count(); i++) { 83 this.locationStore = Ext.data.StoreManager.get('orte');
79 this.locationFeatures.push(new OpenLayers.Feature.Vector( 84 this.addLocations(locationStore);
80 new OpenLayers.Geometry.Point( 85 }
81 this.locationStore.getAt(i).get('longitude'), 86 },
82 this.locationStore.getAt(i).get('latitude') 87
83 ), 88 selectFeature: function(model, record) {
84 { 89 var feature = this.featureLayer.getFeaturesByAttribute('id', record.get('id'));
85 id: this.locationStore.getAt(i).get('id'),
86 bez: this.locationStore.getAt(i).get('bezeichnung')
87 }
88 ));
89 }
90 this.featureLayer = new OpenLayers.Layer.Vector('vector_' + this.map.name, {
91 styleMap: new OpenLayers.StyleMap({
92 'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({
93 externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png',
94 graphicOpacity: 1,
95 pointRadius: 10,
96 label: '${bez}',
97 labelAlign: 'rt',
98 fontColor: 'green',
99 fontWeight: 'bold'
100 }, OpenLayers.Feature.Vector.style['default'])),
101 'select': new OpenLayers.Style({
102 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
103 pointRadius: 15,
104 label: '${bez}',
105 labelAlign: 'rt',
106 fontColor: 'blue',
107 fontWeight: 'bold'
108 })
109 })
110 });
111 this.featureLayer.addFeatures(this.locationFeatures);
112 this.map.addLayer(this.featureLayer);
113
114 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
115 clickout: false,
116 toggle: false,
117 multiple: false,
118 hover: false,
119 onSelect: me.selectedFeature,
120 scope: me
121 });
122 this.map.addControl(this.selectControl);
123 this.selectControl.activate();
124 },
125
126 selectFeature: function(id) {
127 var feature = this.featureLayer.getFeaturesByAttribute('id', id);
128 this.map.setCenter( 90 this.map.setCenter(
129 new OpenLayers.LonLat(feature[0].geometry.x, feature[0].geometry.y)); 91 new OpenLayers.LonLat(feature[0].geometry.x, feature[0].geometry.y));
130 this.map.zoomToScale(this.mapOptions.scales[5]); 92 this.map.zoomToScale(this.mapOptions.scales[5]);
131 this.selectControl.unselectAll(); 93 this.selectControl.unselectAll();
132 this.selectControl.select(feature[0]); 94 this.selectControl.select(feature[0]);
149 this.drawPoint.deactivate(); 111 this.drawPoint.deactivate();
150 this.selectControl.unselectAll(); 112 this.selectControl.unselectAll();
151 this.selectControl.select(features.feature); 113 this.selectControl.select(features.feature);
152 }, 114 },
153 115
116 addLocations: function(locationStore) {
117 var me = this;
118 locationFeatures = [];
119
120 // Iterate the Store and create features from it
121 for (var i = 0; i < locationStore.count(); i++) {
122 locationFeatures.push(new OpenLayers.Feature.Vector(
123 new OpenLayers.Geometry.Point(
124 locationStore.getAt(i).get('longitude'),
125 locationStore.getAt(i).get('latitude')
126 ),
127 {
128 id: locationStore.getAt(i).get('id'),
129 bez: locationStore.getAt(i).get('ortId')
130 }
131 ));
132 }
133
134 // Create a new Feature Layer and add it to the map
135 if (!this.featureLayer) {
136 this.featureLayer = new OpenLayers.Layer.Vector('vector_' + this.map.name, {
137 styleMap: new OpenLayers.StyleMap({
138 'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({
139 externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png',
140 graphicOpacity: 1,
141 pointRadius: 10,
142 label: '${bez}',
143 labelAlign: 'rt',
144 fontColor: 'green',
145 fontWeight: 'bold'
146 }, OpenLayers.Feature.Vector.style['default'])),
147 'select': new OpenLayers.Style({
148 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
149 pointRadius: 15,
150 label: '${bez}',
151 labelAlign: 'rt',
152 fontColor: 'blue',
153 fontWeight: 'bold'
154 })
155 })
156 });
157 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
158 clickout: false,
159 toggle: false,
160 multiple: false,
161 hover: false,
162 onSelect: me.selectedFeature,
163 scope: me
164 });
165 this.map.addControl(this.selectControl);
166 this.selectControl.activate();
167 }
168 this.featureLayer.removeAllFeatures();
169 this.featureLayer.addFeatures(locationFeatures);
170 this.map.addLayer(this.featureLayer);
171
172 },
173
174
154 /** 175 /**
155 * @private 176 * @private
156 * Override to display and update the map view in the panel. 177 * Override to display and update the map view in the panel.
157 */ 178 */
158 afterRender: function() { 179 afterRender: function() {

http://lada.wald.intevation.org