[Commits] r1622 - in sandbox/cmoullet/ux/LayerManager: examples ux/data ux/widgets
commits at geoext.org
commits at geoext.org
Mon Dec 28 13:40:55 CET 2009
Author: cmoullet
Date: 2009-12-28 13:40:55 +0100 (Mon, 28 Dec 2009)
New Revision: 1622
Modified:
sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html
sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js
sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js
Log:
First import functions. No style...
Modified: sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html 2009-12-28 12:08:01 UTC (rev 1621)
+++ sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.html 2009-12-28 12:40:55 UTC (rev 1622)
@@ -12,6 +12,7 @@
<script type="text/javascript" src="../ux/utils/flash.js"></script>
<script type="text/javascript" src="../ux/data/FormatStore.js"></script>
<script type="text/javascript" src="../ux/data/Export.js"></script>
+ <script type="text/javascript" src="../ux/data/Import.js"></script>
<script type="text/javascript" src="../ux/widgets/LayerManagerExportPanel.js"></script>
<script type="text/javascript" src="../ux/widgets/LayerManagerImportPanel.js"></script>
<script type="text/javascript" src="../ux/widgets/LayerManagerWindow.js"></script>
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2009-12-28 12:08:01 UTC (rev 1621)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2009-12-28 12:40:55 UTC (rev 1622)
@@ -41,16 +41,16 @@
}
if (format == 'KML') {
- var kmlWriter = new OpenLayers.Format.KML(GeoExt.ux.data.formats.getFormatExportConfig(format));
+ var kmlWriter = new OpenLayers.Format.KML(GeoExt.ux.data.formats.getFormatConfig(format));
return kmlWriter.write(exportFeatures);
} else if (format == 'GeoJSON') {
- var geojsonWriter = new OpenLayers.Format.GeoJSON(GeoExt.ux.data.formats.getFormatExportConfig(format));
+ var geojsonWriter = new OpenLayers.Format.GeoJSON(GeoExt.ux.data.formats.getFormatConfig(format));
return geojsonWriter.write(exportFeatures);
} else if (format == 'GeoRSS') {
- var georssWriter = new OpenLayers.Format.GeoRSS(GeoExt.ux.data.formats.getFormatExportConfig(format));
+ var georssWriter = new OpenLayers.Format.GeoRSS(GeoExt.ux.data.formats.getFormatConfig(format));
return georssWriter.write(exportFeatures);
} else if (format == 'GML') {
- var gmlWriter = new OpenLayers.Format.GML(GeoExt.ux.data.formats.getFormatExportConfig(format));
+ var gmlWriter = new OpenLayers.Format.GML(GeoExt.ux.data.formats.getFormatConfig(format));
return gmlWriter.write(exportFeatures);
} else {
return 'Format ' + format + ' not supported. Patch welcome !';
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js 2009-12-28 12:08:01 UTC (rev 1621)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/FormatStore.js 2009-12-28 12:40:55 UTC (rev 1622)
@@ -9,13 +9,13 @@
Ext.namespace("GeoExt.ux.data");
GeoExt.ux.data.formats = [
- ['KML', 'OpenLayers.Format.KML', '{extractStyles: true}'],
+ ['KML', 'OpenLayers.Format.KML', '{extractStyles: true,extractAttributes: true}'],
['GeoJSON', 'OpenLayers.Format.GeoJSON', '{}'],
['GeoRSS', 'OpenLayers.Format.GeoRSS', '{}'],
['GML', 'OpenLayers.Format.GML', '{}']
];
-GeoExt.ux.data.formats.getFormatExportConfig = function(format) {
+GeoExt.ux.data.formats.getFormatConfig = function(format) {
for (var i = 0; i < GeoExt.ux.data.formats.length; i++) {
if (GeoExt.ux.data.formats[i][0] === format) {
return GeoExt.ux.data.formats[i][2];
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Import.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Import.js 2009-12-28 12:08:01 UTC (rev 1621)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Import.js 2009-12-28 12:40:55 UTC (rev 1622)
@@ -14,10 +14,10 @@
var importFeatures = [];
if (format && filecontent) {
- importFeatures = features;
if (format == 'KML') {
- var kmlReader = new OpenLayers.Format.KML();
- }else {
+ var kmlReader = new OpenLayers.Format.KML(GeoExt.ux.data.formats.getFormatConfig(format));
+ importFeatures = kmlReader.read(filecontent);
+ } else {
return 'Format ' + format + ' not supported. Patch welcome !';
}
}
@@ -25,4 +25,12 @@
if (features) {
importFeatures = features;
}
+ if (!layer) {
+ layer = new OpenLayers.Layer.Vector("Import", {
+ projection: map.displayProjection
+ });
+ map.addLayer(layer);
+ }
+
+ layer.addFeatures(importFeatures);
};
\ 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-28 12:08:01 UTC (rev 1621)
+++ sandbox/cmoullet/ux/LayerManager/ux/widgets/LayerManagerImportPanel.js 2009-12-28 12:40:55 UTC (rev 1622)
@@ -103,7 +103,26 @@
if (document.getElementById('fileselector').value == "") {
alert(OpenLayers.i18n('Select a file to import'));
} else {
- document.getElementById('fileselector').files.item(0).getAsText('UTF-8')
+ var filecontent;
+ if (Ext.isIE) {
+ try {
+ var objFSO = new ActiveXObject("Scripting.FileSystemObject");
+ }
+ catch (e)
+ {
+ alert('Dear IE user. Add this site in the list of trusted site and activate the ActiveX. ' + e.description);
+ return;
+ }
+ 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);
+ } 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);
+ } else {
+ alert('Your browser is not supported. Patch welcome !');
+ }
//alert(document.getElementById('fileselector').value);
}
},
More information about the Commits
mailing list