comparison app/view/panel/Map.js @ 1049:1bd4c0709bd6 stammdatengrids

Working version of selectable 'ort' in map and grid.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 01 Mar 2016 11:50:39 +0100
parents 1df6b6210b42
children 981339d774b8
comparison
equal deleted inserted replaced
1028:2e7adc19b4fe 1049:1bd4c0709bd6
83 this.locationStore = Ext.data.StoreManager.get('orte'); 83 this.locationStore = Ext.data.StoreManager.get('orte');
84 this.addLocations(locationStore); 84 this.addLocations(locationStore);
85 } 85 }
86 }, 86 },
87 87
88 selectFeature: function(id) { 88 selectFeature: function(model, record) {
89 var feature = this.featureLayer.getFeaturesByAttribute('id', id); 89 var feature = this.featureLayer.getFeaturesByAttribute('id', record.get('id'));
90 this.map.setCenter( 90 this.map.setCenter(
91 new OpenLayers.LonLat(feature[0].geometry.x, feature[0].geometry.y)); 91 new OpenLayers.LonLat(feature[0].geometry.x, feature[0].geometry.y));
92 this.map.zoomToScale(this.mapOptions.scales[5]); 92 this.map.zoomToScale(this.mapOptions.scales[5]);
93 this.selectControl.unselectAll(); 93 this.selectControl.unselectAll();
94 this.selectControl.select(feature[0]); 94 this.selectControl.select(feature[0]);
112 this.selectControl.unselectAll(); 112 this.selectControl.unselectAll();
113 this.selectControl.select(features.feature); 113 this.selectControl.select(features.feature);
114 }, 114 },
115 115
116 addLocations: function(locationStore) { 116 addLocations: function(locationStore) {
117 console.log('add locations');
118 console.log(locationStore);
119 var me = this;
117 locationFeatures = []; 120 locationFeatures = [];
118 121
119 // Iterate the Store and create features from it 122 // Iterate the Store and create features from it
120 for (var i = 0; i < locationStore.count(); i++) { 123 for (var i = 0; i < locationStore.count(); i++) {
121 locationFeatures.push(new OpenLayers.Feature.Vector( 124 locationFeatures.push(new OpenLayers.Feature.Vector(
123 locationStore.getAt(i).get('longitude'), 126 locationStore.getAt(i).get('longitude'),
124 locationStore.getAt(i).get('latitude') 127 locationStore.getAt(i).get('latitude')
125 ), 128 ),
126 { 129 {
127 id: locationStore.getAt(i).get('id'), 130 id: locationStore.getAt(i).get('id'),
128 bez:locationStore.getAt(i).get('kurztext') 131 bez: locationStore.getAt(i).get('ortId')
129 } 132 }
130 )); 133 ));
131 } 134 console.log('add feature');
135 console.log(locationStore.getAt(i));
136 }
137 console.log(locationStore.count());
132 138
133 // Create a new Feature Layer and add it to the map 139 // Create a new Feature Layer and add it to the map
134 this.featureLayer = new OpenLayers.Layer.Vector('vector_' + this.map.name, { 140 if (!this.featureLayer) {
135 styleMap: new OpenLayers.StyleMap({ 141 this.featureLayer = new OpenLayers.Layer.Vector('vector_' + this.map.name, {
136 'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({ 142 styleMap: new OpenLayers.StyleMap({
137 externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png', 143 'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({
138 graphicOpacity: 1, 144 externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png',
139 pointRadius: 10, 145 graphicOpacity: 1,
140 label: '${bez}', 146 pointRadius: 10,
141 labelAlign: 'rt', 147 label: '${bez}',
142 fontColor: 'green', 148 labelAlign: 'rt',
143 fontWeight: 'bold' 149 fontColor: 'green',
144 }, OpenLayers.Feature.Vector.style['default'])), 150 fontWeight: 'bold'
145 'select': new OpenLayers.Style({ 151 }, OpenLayers.Feature.Vector.style['default'])),
146 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png', 152 'select': new OpenLayers.Style({
147 pointRadius: 15, 153 externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
148 label: '${bez}', 154 pointRadius: 15,
149 labelAlign: 'rt', 155 label: '${bez}',
150 fontColor: 'blue', 156 labelAlign: 'rt',
151 fontWeight: 'bold' 157 fontColor: 'blue',
158 fontWeight: 'bold'
159 })
152 }) 160 })
153 }) 161 });
154 }); 162 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
163 clickout: false,
164 toggle: false,
165 multiple: false,
166 hover: false,
167 onSelect: me.selectedFeature,
168 scope: me
169 });
170 this.map.addControl(this.selectControl);
171 this.selectControl.activate();
172 }
173 this.featureLayer.removeAllFeatures();
155 this.featureLayer.addFeatures(locationFeatures); 174 this.featureLayer.addFeatures(locationFeatures);
156 this.map.addLayer(this.featureLayer); 175 this.map.addLayer(this.featureLayer);
157 176
158 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
159 clickout: false,
160 toggle: false,
161 multiple: false,
162 hover: false,
163 onSelect: me.selectedFeature,
164 scope: me
165 });
166 this.map.addControl(this.selectControl);
167 this.selectControl.activate();
168 }, 177 },
169 178
170 179
171 /** 180 /**
172 * @private 181 * @private

http://lada.wald.intevation.org