Mercurial > lada > lada-client
diff 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 |
line wrap: on
line diff
--- a/app/view/panel/Map.js Mon May 18 17:04:32 2015 +0200 +++ b/app/view/panel/Map.js Wed May 20 14:19:12 2015 +0200 @@ -32,7 +32,7 @@ * Initialize the map panel. */ initComponent: function() { - var id = this.record ? this.record.get('id') : Math.floor(Math.random() * 100); + var id = Ext.id(); this.layers = [ new OpenLayers.Layer.WMS( 'Standard' + id, @@ -60,6 +60,7 @@ this.bodyStyle = {background: '#fff'}; this.initData(); this.tbar = Ext.create('Lada.view.widget.MapToolbar'); + this.addEvents('featureselected'); this.callParent(arguments); }, @@ -92,6 +93,7 @@ }); this.featureLayer.addFeatures(this.locationFeatures); this.map.addLayer(this.featureLayer); + this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, { clickout: false, toggle: false, @@ -104,20 +106,6 @@ this.selectControl.activate(); }, - selectedFeature: function(feature) { - if (feature.attributes.id && - feature.attributes.id !== '') { - var record = Ext.data.StoreManager.get('locations').getById(feature.attributes.id); - this.up('window').down('locationform').setRecord(record); - this.up('window').down('locationform').setReadOnly(true); - this.up('window').down('ortform').down('combobox').setValue(record.id); - } - else { - this.up('window').down('locationform').setRecord(this.locationRecord); - this.up('window').down('locationform').setReadOnly(false); - } - }, - selectFeature: function(id) { var feature = this.featureLayer.getFeaturesByAttribute('id', id); this.map.setCenter( @@ -153,16 +141,18 @@ */ afterRender: function() { this.superclass.afterRender.apply(this, arguments); + this.map.render(this.body.dom); this.map.addControl(new OpenLayers.Control.Navigation()); this.map.addControl(new OpenLayers.Control.PanZoomBar()); this.map.addControl(new OpenLayers.Control.ScaleLine()); - if (this.record) { - this.selectFeature(this.record.get('ort')); - } - else { - this.map.zoomToMaxExtent(); - } + }, + + /** + * Forward OpenlayersEvent to EXT + */ + selectedFeature: function() { + this.fireEvent('featureselected', this, arguments); }, beforeDestroy: function() {