[Commits] r1628 - in sandbox/cmoullet/ux/LayerManager: examples ux/data ux/widgets

commits at geoext.org commits at geoext.org
Tue Dec 29 07:40:54 CET 2009


Author: cmoullet
Date: 2009-12-29 07:40:54 +0100 (Tue, 29 Dec 2009)
New Revision: 1628

Modified:
   sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
   sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
   sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js
Log:
Add Import KML function and dataimported event

Modified: sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js	2009-12-29 05:26:50 UTC (rev 1627)
+++ sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js	2009-12-29 06:40:54 UTC (rev 1628)
@@ -41,7 +41,6 @@
     });
 
 
-
     var sundials = new OpenLayers.Layer.Vector("KML", {
         projection: map.displayProjection,
         strategies: [new OpenLayers.Strategy.Fixed()],
@@ -63,6 +62,14 @@
         }
     });
 
+    toolbar.push({
+        text: 'Import KML',
+        enableToggle: false,
+        handler: function() {
+            GeoExt.ux.data.Import.KMLImport(map, sundials);
+        }
+    });
+
     var mapStore = new GeoExt.data.LayerStore({
         map: map,
         layers: [bluemarble,sundials]

Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Import.js	2009-12-29 05:26:50 UTC (rev 1627)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Import.js	2009-12-29 06:40:54 UTC (rev 1628)
@@ -33,4 +33,29 @@
     }
 
     layer.addFeatures(importFeatures);
+};
+
+GeoExt.ux.data.Import.KMLImport = function(map, layer) {
+    GeoExt.ux.data.Export.format = 'KML';
+    var importPanel = new GeoExt.ux.LayerManagerImportPanel({
+        map: map,
+        defaultFormat: 'KML',
+        layer: layer
+    });
+    importPanel.on('dataimported', function(panel, format, filecontent, features) {
+        alert(OpenLayers.i18n("KML data sucessfully imported in layer: " + panel.layer.name + " !"));
+        importWindow.close();
+    });
+    var importWindow = new Ext.Window({
+        id: 'importwindow',
+        modal: true,
+        title: OpenLayers.i18n('Import KML'),
+        height: 135,
+        width: 275,
+        items: [
+            importPanel
+        ]
+    });
+    importWindow.show();
+
 };
\ No newline at end of file

Modified: sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js	2009-12-29 05:26:50 UTC (rev 1627)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js	2009-12-29 06:40:54 UTC (rev 1628)
@@ -12,6 +12,7 @@
     border: false,
     formatCombo: null,
     defaultFormat: 'KML',
+    layer: null,
 
     initComponent: function() {
 
@@ -116,10 +117,12 @@
                                             if (objFSO.FileExists(document.getElementById('fileselector').value)) {
                                                 filecontent = objFSO.OpenTextFile(document.getElementById('fileselector').value, 1).ReadAll();
                                             }
-                                            GeoExt.ux.data.Import(this.map,null,this.formatCombo.getValue(),filecontent,null);
+                                            GeoExt.ux.data.Import(this.map,this.layer,this.formatCombo.getValue(),filecontent,null);
+                                            this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent,null);
                                         } else if (Ext.isGecko) {
                                             filecontent = document.getElementById('fileselector').files.item(0).getAsText('UTF-8');
-                                            GeoExt.ux.data.Import(this.map,null,this.formatCombo.getValue(),filecontent,null);
+                                            GeoExt.ux.data.Import(this.map,this.layer,this.formatCombo.getValue(),filecontent,null);
+                                            this.fireEvent('dataimported', this, this.formatCombo.getValue(), filecontent,null);                                            
                                         } else {
                                             alert('Your browser is not supported. Patch welcome !');
                                         }
@@ -133,6 +136,7 @@
                 ]
             }
         ];
+        this.addEvents('dataimported');
         GeoExt.ux.LayerManagerImportPanel.superclass.initComponent.call(this);
     },
     onRender: function(container, position) {



More information about the Commits mailing list