diff app/view/panel/Map.js @ 1021:1df6b6210b42 stammdatengrids

WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
author Dustin Demuth <dustin@intevation.de>
date Thu, 04 Feb 2016 16:31:46 +0100
parents 2b7bcb778f0a
children 1bd4c0709bd6
line wrap: on
line diff
--- a/app/view/panel/Map.js	Fri Jan 29 14:51:17 2016 +0100
+++ b/app/view/panel/Map.js	Thu Feb 04 16:31:46 2016 +0100
@@ -14,9 +14,15 @@
 Ext.define('Lada.view.panel.Map', {
     extend: 'Ext.panel.Panel',
     alias: 'widget.map',
+    name: 'map',
 
     record: null,
     locationRecord: null,
+    externalOrteStore: false,
+    /*
+     * if externalOrteStore is true, the mappanel will not load the orte
+     * store on it's own; it expects an already loaded store instead
+     */
 
     /**
      * @cfg
@@ -62,7 +68,6 @@
         keyControl.activate();
         this.bodyStyle = {background: '#fff'};
         this.initData();
-        this.tbar = Ext.create('Lada.view.widget.MapToolbar');
         this.addEvents('featureselected');
         this.callParent(arguments);
     },
@@ -73,54 +78,11 @@
      */
     initData: function() {
         var me = this;
-        this.locationFeatures = [];
-        this.locationStore = Ext.data.StoreManager.get('locations');
-        for (var i = 0; i < this.locationStore.count(); i++) {
-            this.locationFeatures.push(new OpenLayers.Feature.Vector(
-                new OpenLayers.Geometry.Point(
-                    this.locationStore.getAt(i).get('longitude'),
-                    this.locationStore.getAt(i).get('latitude')
-                ),
-                {
-                    id: this.locationStore.getAt(i).get('id'),
-                    bez: this.locationStore.getAt(i).get('bezeichnung')
-                }
-            ));
+
+        if (!this.externalOrteStore) {
+            this.locationStore = Ext.data.StoreManager.get('orte');
+            this.addLocations(locationStore);
         }
-        this.featureLayer = new OpenLayers.Layer.Vector('vector_' + this.map.name, {
-            styleMap: new OpenLayers.StyleMap({
-                'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({
-                    externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png',
-                    graphicOpacity: 1,
-                    pointRadius: 10,
-                    label: '${bez}',
-                    labelAlign: 'rt',
-                    fontColor: 'green',
-                    fontWeight: 'bold'
-                }, OpenLayers.Feature.Vector.style['default'])),
-                'select': new OpenLayers.Style({
-                    externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
-                    pointRadius: 15,
-                    label: '${bez}',
-                    labelAlign: 'rt',
-                    fontColor: 'blue',
-                    fontWeight: 'bold'
-                })
-            })
-        });
-        this.featureLayer.addFeatures(this.locationFeatures);
-        this.map.addLayer(this.featureLayer);
-
-        this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
-            clickout: false,
-            toggle: false,
-            multiple: false,
-            hover: false,
-            onSelect: me.selectedFeature,
-            scope: me
-        });
-        this.map.addControl(this.selectControl);
-        this.selectControl.activate();
     },
 
     selectFeature: function(id) {
@@ -151,6 +113,61 @@
         this.selectControl.select(features.feature);
     },
 
+    addLocations: function(locationStore) {
+        locationFeatures = [];
+
+        // Iterate the Store and create features from it
+        for (var i = 0; i < locationStore.count(); i++) {
+            locationFeatures.push(new OpenLayers.Feature.Vector(
+                new OpenLayers.Geometry.Point(
+                    locationStore.getAt(i).get('longitude'),
+                    locationStore.getAt(i).get('latitude')
+                ),
+                {
+                    id: locationStore.getAt(i).get('id'),
+                    bez:locationStore.getAt(i).get('kurztext')
+                }
+            ));
+        }
+
+        // Create a new Feature Layer and add it to the map
+        this.featureLayer = new OpenLayers.Layer.Vector('vector_' + this.map.name, {
+            styleMap: new OpenLayers.StyleMap({
+                'default': new OpenLayers.Style(OpenLayers.Util.applyDefaults({
+                    externalGraphic: 'resources/lib/OpenLayers/img/marker-green.png',
+                    graphicOpacity: 1,
+                    pointRadius: 10,
+                    label: '${bez}',
+                    labelAlign: 'rt',
+                    fontColor: 'green',
+                    fontWeight: 'bold'
+                }, OpenLayers.Feature.Vector.style['default'])),
+                'select': new OpenLayers.Style({
+                    externalGraphic: 'resources/lib/OpenLayers/img/marker-blue.png',
+                    pointRadius: 15,
+                    label: '${bez}',
+                    labelAlign: 'rt',
+                    fontColor: 'blue',
+                    fontWeight: 'bold'
+                })
+            })
+        });
+        this.featureLayer.addFeatures(locationFeatures);
+        this.map.addLayer(this.featureLayer);
+
+        this.selectControl = new OpenLayers.Control.SelectFeature(this.featureLayer, {
+            clickout: false,
+            toggle: false,
+            multiple: false,
+            hover: false,
+            onSelect: me.selectedFeature,
+            scope: me
+        });
+        this.map.addControl(this.selectControl);
+        this.selectControl.activate();
+    },
+
+
     /**
      * @private
      * Override to display and update the map view in the panel.

http://lada.wald.intevation.org