Mercurial > lada > lada-client
comparison app/view/panel/Map.js @ 796:7267bae1d43f
made window-panel recyclable, fwd openlayers events to ext
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Wed, 20 May 2015 14:19:12 +0200 |
parents | 477379250512 |
children | 1e7095533038 |
comparison
equal
deleted
inserted
replaced
795:255568e97c96 | 796:7267bae1d43f |
---|---|
30 /** | 30 /** |
31 * @private | 31 * @private |
32 * Initialize the map panel. | 32 * Initialize the map panel. |
33 */ | 33 */ |
34 initComponent: function() { | 34 initComponent: function() { |
35 var id = this.record ? this.record.get('id') : Math.floor(Math.random() * 100); | 35 var id = Ext.id(); |
36 this.layers = [ | 36 this.layers = [ |
37 new OpenLayers.Layer.WMS( | 37 new OpenLayers.Layer.WMS( |
38 'Standard' + id, | 38 'Standard' + id, |
39 'http://osm.intevation.de/cgi-bin/standard.fcgi?', | 39 'http://osm.intevation.de/cgi-bin/standard.fcgi?', |
40 { | 40 { |
58 this.map.addControl(keyControl); | 58 this.map.addControl(keyControl); |
59 keyControl.activate(); | 59 keyControl.activate(); |
60 this.bodyStyle = {background: '#fff'}; | 60 this.bodyStyle = {background: '#fff'}; |
61 this.initData(); | 61 this.initData(); |
62 this.tbar = Ext.create('Lada.view.widget.MapToolbar'); | 62 this.tbar = Ext.create('Lada.view.widget.MapToolbar'); |
63 this.addEvents('featureselected'); | |
63 this.callParent(arguments); | 64 this.callParent(arguments); |
64 }, | 65 }, |
65 | 66 |
66 initData: function() { | 67 initData: function() { |
67 var me = this; | 68 var me = this; |
90 }) | 91 }) |
91 }) | 92 }) |
92 }); | 93 }); |
93 this.featureLayer.addFeatures(this.locationFeatures); | 94 this.featureLayer.addFeatures(this.locationFeatures); |
94 this.map.addLayer(this.featureLayer); | 95 this.map.addLayer(this.featureLayer); |
96 | |
95 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, { | 97 this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, { |
96 clickout: false, | 98 clickout: false, |
97 toggle: false, | 99 toggle: false, |
98 multiple: false, | 100 multiple: false, |
99 hover: false, | 101 hover: false, |
100 onSelect: me.selectedFeature, | 102 onSelect: me.selectedFeature, |
101 scope: me | 103 scope: me |
102 }); | 104 }); |
103 this.map.addControl(this.selectControl); | 105 this.map.addControl(this.selectControl); |
104 this.selectControl.activate(); | 106 this.selectControl.activate(); |
105 }, | |
106 | |
107 selectedFeature: function(feature) { | |
108 if (feature.attributes.id && | |
109 feature.attributes.id !== '') { | |
110 var record = Ext.data.StoreManager.get('locations').getById(feature.attributes.id); | |
111 this.up('window').down('locationform').setRecord(record); | |
112 this.up('window').down('locationform').setReadOnly(true); | |
113 this.up('window').down('ortform').down('combobox').setValue(record.id); | |
114 } | |
115 else { | |
116 this.up('window').down('locationform').setRecord(this.locationRecord); | |
117 this.up('window').down('locationform').setReadOnly(false); | |
118 } | |
119 }, | 107 }, |
120 | 108 |
121 selectFeature: function(id) { | 109 selectFeature: function(id) { |
122 var feature = this.featureLayer.getFeaturesByAttribute('id', id); | 110 var feature = this.featureLayer.getFeaturesByAttribute('id', id); |
123 this.map.setCenter( | 111 this.map.setCenter( |
151 * @private | 139 * @private |
152 * Override to display and update the map view in the panel. | 140 * Override to display and update the map view in the panel. |
153 */ | 141 */ |
154 afterRender: function() { | 142 afterRender: function() { |
155 this.superclass.afterRender.apply(this, arguments); | 143 this.superclass.afterRender.apply(this, arguments); |
144 | |
156 this.map.render(this.body.dom); | 145 this.map.render(this.body.dom); |
157 this.map.addControl(new OpenLayers.Control.Navigation()); | 146 this.map.addControl(new OpenLayers.Control.Navigation()); |
158 this.map.addControl(new OpenLayers.Control.PanZoomBar()); | 147 this.map.addControl(new OpenLayers.Control.PanZoomBar()); |
159 this.map.addControl(new OpenLayers.Control.ScaleLine()); | 148 this.map.addControl(new OpenLayers.Control.ScaleLine()); |
160 if (this.record) { | 149 }, |
161 this.selectFeature(this.record.get('ort')); | 150 |
162 } | 151 /** |
163 else { | 152 * Forward OpenlayersEvent to EXT |
164 this.map.zoomToMaxExtent(); | 153 */ |
165 } | 154 selectedFeature: function() { |
155 this.fireEvent('featureselected', this, arguments); | |
166 }, | 156 }, |
167 | 157 |
168 beforeDestroy: function() { | 158 beforeDestroy: function() { |
169 if (this.map) { | 159 if (this.map) { |
170 this.map.destroy(); | 160 this.map.destroy(); |