<div>i try the following code for displaying layer wich contains line in map, so i digitize a line, create temporary feature for this line, create a layer wich contains it and add it to the map. it doesn&#39;t give me some error but  i can see the line in the map (i can draw it). Please help me. the code is following:</div>

<div> </div>
<div> <font color="#008080" size="2"> 
<p>String</p></font><font size="2"> dataSource = </font><font color="#800000" size="2">&quot;Session:&quot;</font><font size="2"> + sessionid1 + </font><font color="#800000" size="2">&quot;//&quot;</font><font size="2"> + myLayerName + </font><font color="#800000" size="2">&quot;.FeatureSource&quot;</font><font size="2">;
<p></p></font><font color="#008080" size="2">MgResourceIdentifier</font><font size="2"> dataSourceId = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgResourceIdentifier</font><font size="2">(dataSource);
<p></p></font><font color="#008080" size="2">MgFeatureService</font><font size="2"> featureSrvc = (</font><font color="#008080" size="2">MgFeatureService</font><font size="2">)siteConnection.CreateService(</font><font color="#008080" size="2">MgServiceType</font><font size="2">.FeatureService);
<p></p></font><font color="#0000ff" size="2">if</font><font size="2"> (DoesLayerExist(myLayerName, map) == </font><font color="#0000ff" size="2">false</font><font size="2">)
<p>{</p>
<p> </p>
<p></p></font><font color="#008000" size="2">//create Feature Source </font><font size="2">
<p></p></font><font color="#008080" size="2">MgClassDefinition</font><font size="2"> myClassDef = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgClassDefinition</font><font size="2">();
<p>myClassDef.SetName(myLayerName);</p>
<p>myClassDef.SetDescription(myLayerName + </p></font><font color="#800000" size="2">&quot; Feature Source&quot;</font><font size="2">);
<p>myClassDef.SetDefaultGeometryPropertyName(</p></font><font color="#800000" size="2">&quot;SHPGEOM&quot;</font><font size="2">);
<p></p></font><font color="#008080" size="2">MgDataPropertyDefinition</font><font size="2"> prop = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgDataPropertyDefinition</font><font size="2">(</font><font color="#800000" size="2">&quot;KEY&quot;</font><font size="2">);
<p>prop.SetDataType(</p></font><font color="#008080" size="2">MgPropertyType</font><font size="2">.Int32);
<p>prop.SetAutoGeneration(</p></font><font color="#0000ff" size="2">true</font><font size="2">);
<p>prop.SetReadOnly(</p></font><font color="#0000ff" size="2">true</font><font size="2">);
<p>myClassDef.GetIdentityProperties().Add(prop);</p>
<p>myClassDef.GetProperties().Add(prop);</p>
<p>prop = </p></font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgDataPropertyDefinition</font><font size="2">(</font><font color="#800000" size="2">&quot;ID&quot;</font><font size="2">);
<p>prop.SetDataType(</p></font><font color="#008080" size="2">MgPropertyType</font><font size="2">.Int32);
<p>myClassDef.GetProperties().Add(prop);</p>
<p></p></font><font color="#008080" size="2">MgGeometricPropertyDefinition</font><font size="2"> geomProp = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgGeometricPropertyDefinition</font><font size="2">(</font><font color="#800000" size="2">&quot;SHPGEOM&quot;</font><font size="2">);
<p>geomProp.SetGeometryTypes(</p></font><font color="#008080" size="2">MgFeatureGeometricType</font><font size="2">.Curve);
<p>myClassDef.GetProperties().Add(geomProp);</p>
<p></p></font><font color="#008080" size="2">MgFeatureSchema</font><font size="2"> schema = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgFeatureSchema</font><font size="2">(myLayerName + </font><font color="#800000" size="2">&quot;Schema&quot;</font><font size="2">, myLayerName + </font><font color="#800000" size="2">&quot;SchemaDesc&quot;</font><font size="2">);
<p>schema.GetClasses().Add(myClassDef);</p>
<p></p></font><font color="#008080" size="2">MgCreateSdfParams</font><font size="2"> sdfParams = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgCreateSdfParams</font><font size="2">(</font><font color="#800000" size="2">&quot;MGA-56 (GDA94 / MGA zone 56)&quot;</font><font size="2">, map.GetMapSRS(), schema);
<p>featureSrvc.CreateFeatureSource(dataSourceId, sdfParams);</p>
<p> </p>
<p> </p>
<p></p></font><font color="#008000" size="2">//create layer </font><font size="2">
<p></p></font><font color="#008000" size="2">//String layerDef = &quot;Session:&quot; + sessionid1 + &quot;//&quot; + myLayerName + &quot;.LayerDefinition&quot;;</font><font size="2">
<p></p></font><font color="#008080" size="2">MgResourceIdentifier</font><font size="2"> layerDefId = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgResourceIdentifier</font><font size="2">(</font><font color="#800000" size="2">&quot;Library://essaicalque/Redline.LayerDefinition&quot;</font><font size="2">);
<p> </p>
<p> </p>
<p></p></font><font color="#008080" size="2">MgByteSource</font><font size="2"> content = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgByteSource</font><font size="2">(</font><font color="#800000" size="2">@&quot;C:\Program Files\MapGuideOpenSource\WebServerExtensions\www\essaiselect2\Layerdef.xml&quot;</font><font size="2">);
<p>resourceSrvc.SetResource(layerDefId, content.GetReader(), </p></font><font color="#0000ff" size="2">null</font><font size="2">);
<p></p>
<p></p>
<p></p></font><font color="#008000" size="2">//code enlev‚ d&#39;ici: ajouter layer resource … la carte</font><font size="2">
<p></p></font><font color="#008000" size="2">//il faut ajouter l&#39;autre code: add layer resource to map</font><font size="2">
<p></p></font><font color="#008000" size="2">//DOMDocument domdoc = new DOMdocument();</font><font size="2">
<p></p>
<p></p></font><font color="#008080" size="2">MgLayer</font><font size="2"> result=add_layer_resource_to_map(layerDefId,resourceSrvc,myLayerName,myLayerName,map); 
<p></p>
<p></p>
<p></p>
<p>}</p>
<p></p></font><font color="#008080" size="2">MgInsertFeatures</font><font size="2"> insertFeatures = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgInsertFeatures</font><font size="2">(myLayerName, makeLine(</font><font color="#800000" size="2">&quot;1&quot;</font><font size="2">, x0, y0, x1, y1));
<p></p></font><font color="#008080" size="2">MgFeatureCommandCollection</font><font size="2"> commands = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgFeatureCommandCollection</font><font size="2">();
<p>commands.Add(insertFeatures);</p>
<p></p></font><font color="#0000ff" size="2">int</font><font size="2"> commandIndex = commands.IndexOf(insertFeatures);
<p></p></font><font color="#008080" size="2">MgPropertyCollection</font><font size="2"> insertResults;
<p>insertResults = featureSrvc.UpdateFeatures(dataSourceId, commands, </p></font><font color="#0000ff" size="2">false</font><font size="2">);
<p></p></font><font color="#008080" size="2">MgLayer</font><font size="2"> myLayer1 = map.GetLayers().GetItem(myLayerName) </font><font color="#0000ff" size="2">as</font><font size="2"> </font><font color="#008080" size="2">MgLayer</font><font size="2">;
<p>myLayer1.ForceRefresh();</p>
<p> </p>
<p></p></font><font color="#008000" size="2">//commands.Add(new MgInsertFeatures(myLayerName,makeLine(&quot;1&quot;, x0, y0, x1, y1))); 
<p> </p></font><font size="2">
<p>map.Save(resourceSrvc); </p>
<p> </p><font color="#0000ff" size="2">
<p>&lt;</p></font><font color="#800000" size="2">script</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=server&gt;</font><font size="2">
<p></p>
<p></p></font><font color="#008080" size="2">Boolean</font><font size="2"> result;
<p></p>
<p></p></font><font color="#008080" size="2">MgPropertyCollection</font><font size="2"> makeLine(</font><font color="#008080" size="2">String</font><font size="2"> Name, </font><font color="#008080" size="2">Double</font><font size="2"> x0, </font><font color="#008080" size="2">Double</font><font size="2"> y0, </font><font color="#008080" size="2">Double</font><font size="2"> x1, </font><font color="#008080" size="2">Double</font><font size="2"> y1) 
<p>{ </p>
<p></p></font><font color="#008080" size="2">MgPropertyCollection</font><font size="2"> PropertyCollection = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgPropertyCollection</font><font size="2">(); 
<p></p></font><font color="#008080" size="2">MgInt32Property</font><font size="2"> nameProperty = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgInt32Property</font><font size="2">(</font><font color="#800000" size="2">&quot;ID&quot;</font><font size="2">, 1); 
<p>PropertyCollection.Add(nameProperty); </p>
<p></p></font><font color="#008080" size="2">MgWktReaderWriter</font><font size="2"> wktReaderWriter = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgWktReaderWriter</font><font size="2">(); 
<p></p></font><font color="#008080" size="2">MgAgfReaderWriter</font><font size="2"> agfReaderWriter = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgAgfReaderWriter</font><font size="2">(); 
<p></p></font><font color="#008080" size="2">MgGeometry</font><font size="2"> geometry = wktReaderWriter.Read(</font><font color="#800000" size="2">&quot;LINESTRING XY (&quot;</font><font size="2"> + x0 + </font><font color="#800000" size="2">&quot; &quot;</font><font size="2"> + y0 + </font><font color="#800000" size="2">&quot;,&quot;</font><font size="2"> + x1 + </font><font color="#800000" size="2">&quot; &quot;</font><font size="2"> + y1 + </font><font color="#800000" size="2">&quot;)&quot;</font><font size="2">) </font><font color="#0000ff" size="2">as</font><font size="2"> </font><font color="#008080" size="2">MgLineString</font><font size="2">; 
<p></p></font><font color="#008000" size="2">//MgGeometry geometry = wktReaderWriter.Read(&quot;LINESTRING(3 4,10 50,20 25)&quot;) as MgLineString; </font><font size="2">
<p></p>
<p></p>
<p></p></font><font color="#008080" size="2">MgByteReader</font><font size="2"> geometryByteReader = agfReaderWriter.Write(geometry); 
<p></p></font><font color="#008080" size="2">MgGeometryProperty</font><font size="2"> geometryProperty = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgGeometryProperty</font><font size="2">(</font><font color="#800000" size="2">&quot;SHPGEOM&quot;</font><font size="2">, geometryByteReader); 
<p>PropertyCollection.Add(geometryProperty); </p>
<p></p></font><font color="#0000ff" size="2">return</font><font size="2"> PropertyCollection; 
<p>} </p></font><font color="#008080" size="2">
<p>Boolean</p></font><font size="2"> DoesLayerExist(</font><font color="#008080" size="2">String</font><font size="2"> LayerName, </font><font color="#008080" size="2">MgMap</font><font size="2"> Map) 
<p>{ </p>
<p></p></font><font color="#008080" size="2">MgLayerCollection</font><font size="2"> layers = Map.GetLayers();
<p>result = (layers.Contains(myLayerName));</p>
<p></p></font><font color="#0000ff" size="2">return</font><font size="2"> result; 
<p>}</p>
<p></p></font><font color="#008080" size="2">MgLayer</font><font size="2"> add_layer_resource_to_map(</font><font color="#008080" size="2">MgResourceIdentifier</font><font size="2"> layerresourceid, </font><font color="#008080" size="2">MgResourceService</font><font size="2"> rs, </font><font color="#008080" size="2">String</font><font size="2"> layername, </font><font color="#008080" size="2">String</font><font size="2"> layerlegendlabel, </font><font color="#008080" size="2">MgMap</font><font size="2"> map)
<p>{</p>
<p></p></font><font color="#008080" size="2">MgLayer</font><font size="2"> myLayer = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgLayer</font><font size="2">(layerresourceid, rs);
<p>myLayer.SetName(layername);</p>
<p>myLayer.SetLegendLabel(layerlegendlabel);</p>
<p>myLayer.SetDisplayInLegend(</p></font><font color="#0000ff" size="2">true</font><font size="2">);
<p>myLayer.SetSelectable(</p></font><font color="#0000ff" size="2">true</font><font size="2">);
<p> </p>
<p></p></font><font color="#0000ff" size="2">if</font><font size="2"> (!map.GetLayers().Contains(layername))
<p>{</p>
<p></p>
<p>map.GetLayers().Insert(0, myLayer);</p>
<p>}</p>
<p>myLayer.SetVisible(</p></font><font color="#0000ff" size="2">true</font><font size="2">);
<p>myLayer.ForceRefresh();</p>
<p>map.Save(resourceSrvc);</p>
<p></p></font><font color="#0000ff" size="2">return</font><font size="2"> myLayer; 
<p>}</p>
<p></p>
<p></p></font><font color="#0000ff" size="2">
<p>&lt;/</p></font><font color="#800000" size="2">script</font><font color="#0000ff" size="2">&gt;</font>
<p> </p>
<p> </p>
<p> </p></font></div>