                 lyrXML.@displaylevels = tiledLyr.displayLevels.join();
             }
         }
+        else if (layer is CSVLayer)
+        {
+            var csvLyr:CSVLayer = layer as CSVLayer;
+            lyrXML = <layer label={label}
+                    type="csv"
+                    visible={csvLyr.visible}
+                    alpha={csvLyr.alpha}
+                    url={csvLyr.url}
+                    longitudefieldname={csvLyr.longitudeFieldName}
+                    latitudefieldname={csvLyr.latitudeFieldName}/>;
+            if (csvLyr.columnDelimiter != ",")
+            {
+                lyrXML.@columndelimiter = csvLyr.columnDelimiter;
+            }
+            if (csvLyr.sourceFields)
+            {
+                var fields:Array = [];
+                for each (var field:Field in csvLyr.sourceFields)
+                {
+                    fields.push(field.name + "|" + field.alias + "|" + field.type);
+                }
+                lyrXML.@sourcefields = fields.join();
+            }
+        }
         else if (layer is FeatureLayer && !(layer is CSVLayer))
         {
             var feaLyr:FeatureLayer = layer as FeatureLayer;

                lyrXML.@displaylevels = veLyr.displayLevels.join();
            }
        }
        else if (layer is KMLLayer)
        {
            var kmlLayer:KMLLayer = layer as KMLLayer;
            lyrXML = <layer label={label}
                    type="kml"
                    visible={kmlLayer.visible}
                    alpha={kmlLayer.alpha}
                    url={kmlLayer.url}/>;
        }
        else if (layer is WMSLayer)
        {

                        iseditable={feaLyr.isEditable}/>;
            }
        }
        else if (layer is GeoRSSLayer)
        {
            var geoRSSLayer:GeoRSSLayer = layer as GeoRSSLayer;
            lyrXML = <layer label={label}
                    type="georss"
                    visible={geoRSSLayer.visible}
                    alpha={geoRSSLayer.alpha}
                    url={geoRSSLayer.url}/>;
            if (geoRSSLayer.serviceURL)
            {
                lyrXML.@serviceurl = geoRSSLayer.serviceURL;
            }
            if (geoRSSLayer.pointSymbol)
            {
                lyrXML.appendChild(getPointSymbolXML(geoRSSLayer.pointSymbol));
            }
            if (geoRSSLayer.polylineSymbol)
            {
                lyrXML.appendChild(getLineSymbolXML(geoRSSLayer.polylineSymbol));
            }
            if (geoRSSLayer.polygonSymbol)
            {
                lyrXML.appendChild(getPolygonSymbolXML(geoRSSLayer.polygonSymbol));
            }
        }
        else if (layer is KMLLayer)
        {
            var kmlLayer:KMLLayer = layer as KMLLayer;
            lyrXML = <layer label={label}
                    type="kml"
                    visible={kmlLayer.visible}
                    alpha={kmlLayer.alpha}
                    url={kmlLayer.url}/>;
        }
        else if (layer is OpenStreetMapLayer)
        {
            var osmLyr:OpenStreetMapLayer = layer as OpenStreetMapLayer;
