comparison app/view/panel/Map.js @ 1307:152fca74a839

Fixed Map layer display of selected Ort
author Maximilian Krambach <mkrambach@intevation.de>
date Thu, 02 Feb 2017 15:46:05 +0100
parents bfdc00c24baf
children cba4e0b0e336
comparison
equal deleted inserted replaced
1306:c86fd6976264 1307:152fca74a839
60 this.map = new OpenLayers.Map('map_' + id, { 60 this.map = new OpenLayers.Map('map_' + id, {
61 controls: [], 61 controls: [],
62 tileManager: null, 62 tileManager: null,
63 zoomMethod: null, 63 zoomMethod: null,
64 // initializing with view centered on germany 64 // initializing with view centered on germany
65 center: new OpenLayers.LonLat(1160000,6694000), 65 center: new OpenLayers.LonLat(1160000,6694000)
66 }); 66 });
67 this.map.setOptions(this.mapOptions); 67 this.map.setOptions(this.mapOptions);
68 this.map.addLayers(this.layers); 68 this.map.addLayers(this.layers);
69 this.map.zoomTo(6); 69 this.map.zoomTo(6);
70 var keyControl = new OpenLayers.Control.KeyboardDefaults(); 70 var keyControl = new OpenLayers.Control.KeyboardDefaults();
100 this.map.setCenter( 100 this.map.setCenter(
101 new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y)); 101 new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y));
102 this.map.zoomTo(12); 102 this.map.zoomTo(12);
103 if (this.selectedFeatureLayer) { 103 if (this.selectedFeatureLayer) {
104 this.selectControl.unselectAll(); 104 this.selectControl.unselectAll();
105 var prev = this.selectedFeatureLayer.features[0];
106 if (prev){
107 this.featureLayer.addFeatures([prev.clone()]);
108 }
105 this.selectedFeatureLayer.removeAllFeatures(); 109 this.selectedFeatureLayer.removeAllFeatures();
106 this.selectedFeatureLayer.addFeatures(feature); 110 this.selectedFeatureLayer.addFeatures(feature.clone());
111 this.featureLayer.removeFeatures([feature]);
112 this.selectedFeatureLayer.refresh({force: true});
113 this.featureLayer.refresh({force: true});
107 } else { 114 } else {
108 this.selectControl.unselectAll(); 115 this.selectControl.unselectAll();
109 this.selectControl.select(feature); 116 this.selectControl.select(feature);
110 } 117 }
111 }, 118 },
135 var me = this; 142 var me = this;
136 locationFeatures = []; 143 locationFeatures = [];
137 144
138 // Iterate the Store and create features from it 145 // Iterate the Store and create features from it
139 for (var i = 0; i < locationStore.count(); i++) { 146 for (var i = 0; i < locationStore.count(); i++) {
140 locationFeatures.push(new OpenLayers.Feature.Vector( 147 var feature = new OpenLayers.Feature.Vector(
141 new OpenLayers.Geometry.Point( 148 new OpenLayers.Geometry.Point(
142 locationStore.getAt(i).get('longitude'), 149 locationStore.getAt(i).get('longitude'),
143 locationStore.getAt(i).get('latitude') 150 locationStore.getAt(i).get('latitude')
144 ), 151 ),
145 { 152 {
146 id: locationStore.getAt(i).get('id'), 153 id: locationStore.getAt(i).get('id'),
147 bez: locationStore.getAt(i).get('ortId') 154 bez: locationStore.getAt(i).get('ortId')
148 } 155 }
149 )); 156 );
157 feature.geometry.transform(new OpenLayers.Projection('EPSG:4326'),
158 new OpenLayers.Projection('EPSG:3857'));
159 locationFeatures.push(feature);
150 } 160 }
151 161
152 // Create a new Feature Layer and add it to the map 162 // Create a new Feature Layer and add it to the map
153 if (!this.featureLayer) { 163 if (!this.featureLayer) {
154 this.featureLayer = new OpenLayers.Layer.Vector( 'alle Messpunkte', { 164 this.featureLayer = new OpenLayers.Layer.Vector( 'alle Messpunkte', {
169 labelAlign: 'rt', 179 labelAlign: 'rt',
170 fontColor: 'blue', 180 fontColor: 'blue',
171 fontWeight: 'bold' 181 fontWeight: 'bold'
172 }) 182 })
173 }), 183 }),
174 projection: new OpenLayers.Projection('EPSG:3857'), 184 projection: new OpenLayers.Projection('EPSG:3857')
175 preFeatureInsert: function(feature) {
176 feature.geometry.transform(new OpenLayers.Projection('EPSG:4326'),
177 new OpenLayers.Projection('EPSG:3857'));
178 }
179 }); 185 });
180 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, { 186 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
181 clickout: false, 187 clickout: false,
182 toggle: false, 188 toggle: false,
183 multiple: false, 189 multiple: false,
190 this.selectControl.activate(); 196 this.selectControl.activate();
191 } 197 }
192 this.featureLayer.removeAllFeatures(); 198 this.featureLayer.removeAllFeatures();
193 this.featureLayer.addFeatures(locationFeatures); 199 this.featureLayer.addFeatures(locationFeatures);
194 this.map.addLayer(this.featureLayer); 200 this.map.addLayer(this.featureLayer);
195 this.featureLayer.setZIndex(500);
196 }, 201 },
197 202
198 /** 203 /**
199 * @private 204 * @private
200 * Override to display and update the map view in the panel. 205 * Override to display and update the map view in the panel.
211 /** 216 /**
212 * Forward OpenlayersEvent to EXT 217 * Forward OpenlayersEvent to EXT
213 */ 218 */
214 selectedFeature: function(feature) { 219 selectedFeature: function(feature) {
215 this.fireEvent('featureselected', this, arguments); 220 this.fireEvent('featureselected', this, arguments);
221 this.featureLayer.refresh({force: true});
222 if (this.selectedFeatureLayer) {
223 this.selectedFeatureLayer.refresh({force: true});
224
225 }
216 }, 226 },
217 227
218 beforeDestroy: function() { 228 beforeDestroy: function() {
219 if (this.map) { 229 if (this.map) {
220 this.map.destroy(); 230 this.map.destroy();

http://lada.wald.intevation.org