<div id="mb_0">
<div>i try to draw line so i create feature source and layer wich contains line and add it to the map, this is my code, it doesn&#39;t give me error baut when i run it i don&#39;t see the layer in map:</div>
<div> </div>
<div> </div>
<div><font size="2">
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Page</font><font size="2"> </font><font color="#ff0000" size="2">Language</font><font color="#0000ff" size="2">=&quot;C#&quot;</font><font size="2"> </font><font color="#ff0000" size="2">AutoEventWireup</font><font color="#0000ff" size="2">=&quot;true&quot;</font><font size="2"> </font><font color="#ff0000" size="2">CodeFile</font><font color="#0000ff" size="2">=&quot;essai.aspx.cs&quot;</font><font size="2"> </font><font color="#ff0000" size="2">
<p>Inherits</p></font><font color="#0000ff" size="2">=&quot;essai&quot;</font><font size="2"> %&gt; 
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Import</font><font size="2"> </font><font color="#ff0000" size="2">Namespace</font><font color="#0000ff" size="2">=&quot;System&quot;</font><font size="2"> %&gt; 
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Import</font><font size="2"> </font><font color="#ff0000" size="2">Namespace</font><font color="#0000ff" size="2">=&quot;System.IO&quot;</font><font size="2"> %&gt; 
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Import</font><font size="2"> </font><font color="#ff0000" size="2">Namespace</font><font color="#0000ff" size="2">=&quot;System.Collections.Specialized&quot;</font><font size="2"> %&gt; 
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Import</font><font size="2"> </font><font color="#ff0000" size="2">Namespace</font><font color="#0000ff" size="2">=&quot;OSGeo.MapGuide&quot;</font><font size="2"> %&gt; 
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Import</font><font size="2"> </font><font color="#ff0000" size="2">Namespace</font><font color="#0000ff" size="2">=&quot;System.Text&quot;</font><font size="2"> %&gt; 
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Import</font><font size="2"> </font><font color="#ff0000" size="2">Namespace</font><font color="#0000ff" size="2">=&quot;System.Globalization&quot;</font><font size="2"> %&gt; 
<p>&lt;%</p></font><font color="#0000ff" size="2">@</font><font size="2"> </font><font color="#800000" size="2">Import</font><font size="2"> </font><font color="#ff0000" size="2">Namespace</font><font color="#0000ff" size="2">=&quot;OSGeo.MapGuide.Schema.LayerDefinition&quot;</font><font size="2">%&gt;;</font><font color="#008000" size="2"> 
<p>&lt;!-- #Include File=&quot;C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\mapviewernet\common.aspx--&gt;</p>
<p> </p></font><font color="#0000ff" size="2">
<p>&lt;!</p></font><font color="#800000" size="2">DOCTYPE</font><font size="2"> </font><font color="#ff0000" size="2">html</font><font size="2"> </font><font color="#ff0000" size="2">PUBLIC</font><font size="2"> </font><font color="#0000ff" size="2">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</font><font size="2"> </font><font color="#0000ff" size="2">
<p>&quot;<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&quot;&gt;</p>
<p> </p>
<p> </p>
<p>&lt;</p></font><font color="#800000" size="2">html</font><font size="2"> </font><font color="#ff0000" size="2">xmlns</font><font color="#0000ff" size="2">=&quot;<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.w3.org/1999/xhtml" target="_blank">http://www.w3.org/1999/xhtml</a>&quot;</font><font size="2"> </font><font color="#0000ff" size="2">&gt; 
<p>&lt;</p></font><font color="#800000" size="2">head</font><font size="2"> </font><font color="#ff0000" size="2">id</font><font color="#0000ff" size="2">=&quot;Head1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;&gt;</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">title</font><font color="#0000ff" size="2">&gt;</font><font size="2">selection</font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">title</font><font color="#0000ff" size="2">&gt;</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2">
<p>&lt;/</p></font><font color="#800000" size="2">head</font><font color="#0000ff" size="2">&gt; 
<p>&lt;</p></font><font color="#800000" size="2">body</font><font color="#0000ff" size="2">&gt; 
<p>&lt;</p></font><font color="#800000" size="2">br</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</font><font size="2"> 
<p>&lt;%</p>
<p></p>
<p></p></font><font color="#008080" size="2">String</font><font size="2"> x0 = </font><font color="#800000" size="2">&quot;100&quot;</font><font size="2">; 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> y0 = </font><font color="#800000" size="2">&quot;100&quot;</font><font size="2">; 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> x1 = </font><font color="#800000" size="2">&quot;109&quot;</font><font size="2">; 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> y1 = </font><font color="#800000" size="2">&quot;109&quot;</font><font size="2">; 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> sessionid1; 
<p></p></font><font color="#008080" size="2">MgSiteConnection</font><font size="2"> siteConnection; 
<p></p></font><font color="#008080" size="2">MgResourceService</font><font size="2"> resourceSrvc; 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> myLayerName = </font><font color="#800000" size="2">&quot;linetest&quot;</font><font size="2">; 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> mapname = </font><font color="#800000" size="2">&quot;Sheboygan&quot;</font><font size="2">; 
<p></p></font><font color="#008080" size="2">MgMap</font><font size="2"> map; 
<p></p></font><font color="#008080" size="2">MgFeatureService</font><font size="2"> featureSrvc; 
<p> </p>
<p></p></font><font color="#008080" size="2">String</font><font size="2"> configPath = </font><font color="#800000" size="2">&quot;C:\\Program Files\\Autodesk\\MapGuideEnterprise2008\\WebServerExtensions\\www\\webconfig.ini&quot;</font><font size="2">; 
<p></p></font><font color="#008080" size="2">MapGuideApi</font><font size="2">.MgInitializeWebTier(configPath); 
<p></p></font><font color="#008080" size="2">MgSite</font><font size="2"> site1 = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgSite</font><font size="2">(); 
<p></p></font><font color="#008080" size="2">MgUserInformation</font><font size="2"> userInfo = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgUserInformation</font><font size="2">(</font><font color="#800000" size="2">&quot;Administrator&quot;</font><font size="2">, </font><font color="#800000" size="2">&quot;admin&quot;</font><font size="2">); 
<p>siteConnection = </p></font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgSiteConnection</font><font size="2">(); 
<p>siteConnection.Open(userInfo);</p>
<p>site1 = siteConnection.GetSite();</p>
<p>sessionid1 = site1.CreateSession();</p>
<p>userInfo.SetMgSessionId(sessionid1);</p>
<p>resourceSrvc = (</p></font><font color="#008080" size="2">MgResourceService</font><font size="2">)siteConnection.CreateService(</font><font color="#008080" size="2">MgServiceType</font><font size="2">.ResourceService) </font><font color="#0000ff" size="2">as</font><font size="2"> </font><font color="#008080" size="2">MgResourceService</font><font size="2">; 
<p>featureSrvc = siteConnection.CreateService(</p></font><font color="#008080" size="2">MgServiceType</font><font size="2">.FeatureService) </font><font color="#0000ff" size="2">as</font><font size="2"> </font><font color="#008080" size="2">MgFeatureService</font><font size="2">; 
<p></p></font><font color="#008080" size="2">MgResourceIdentifier</font><font size="2"> resourceID = </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://Samples/Sheboygan/Maps/Sheboygan.MapDefinition&quot;</font><font size="2">); 
<p>map = </p></font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgMap</font><font size="2">(siteConnection); 
<p>map.Create(resourceSrvc, resourceID, mapname);</p>
<p></p></font><font color="#008000" size="2">//MgResourceIdentifier mapStateId = new MgResourceIdentifier(&quot;Session:&quot; + sessionid1 + &quot;//&quot; + mapname + &quot;.&quot; + MgResourceType.Map);</font><font size="2"> 
<p>map.Save();</p>
<p>map.Open(resourceSrvc, mapname);</p>
<p>Response.Charset = </p></font><font color="#800000" size="2">&quot;utf-8&quot;</font><font size="2">; 
<p></p></font><font color="#008000" size="2">//String x0 = &quot;100&quot;;</font><font size="2"> 
<p></p></font><font color="#008000" size="2">//String y0 = &quot;100&quot;;</font><font size="2"> 
<p></p></font><font color="#008000" size="2">//String x1 = &quot;109&quot;;</font><font size="2"> 
<p></p></font><font color="#008000" size="2">//String y1 = &quot;109&quot;;</font><font size="2"> 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> layerDef = </font><font color="#800000" size="2">&quot;Library://Samples/Sheboygan/Layers/&quot;</font><font size="2"> + myLayerName + </font><font color="#800000" size="2">&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">(layerDef); 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> dataSource = </font><font color="#800000" size="2">&quot;Library://Samples/Sheboygan/Data/&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="#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></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(</p></font><font color="#800000" size="2">&quot;linetest&quot;</font><font size="2">); 
<p></p></font><font color="#008000" size="2">//myClassDef.SetDescription(myLayerName + &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="#008000" size="2">//Set KEY Property</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>prop.SetNullable(</p></font><font color="#0000ff" size="2">false</font><font size="2">); 
<p>myClassDef.GetProperties().Add(prop);</p>
<p>myClassDef.GetIdentityProperties().Add(prop);</p>
<p></p></font><font color="#008000" size="2">//Set ID Property</font><font size="2"> 
<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="#008000" size="2">//Set geometry property</font><font size="2"> 
<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>geomProp.SetHasElevation(</p></font><font color="#0000ff" size="2">false</font><font size="2">); 
<p>geomProp.SetHasMeasure(</p></font><font color="#0000ff" size="2">false</font><font size="2">); 
<p>geomProp.SetSpatialContextAssociation(</p></font><font color="#800000" size="2">&quot;LL84&quot;</font><font size="2">); 
<p>myClassDef.GetProperties().Add(geomProp);</p>
<p>myClassDef.SetDefaultGeometryPropertyName(</p></font><font color="#800000" size="2">&quot;SHPGEOM&quot;</font><font size="2">); 
<p></p></font><font color="#008000" size="2">//Create the schema</font><font size="2"> 
<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">(); 
<p>schema.SetName(</p></font><font color="#800000" size="2">&quot;SHP_Shema&quot;</font><font size="2">); 
<p>schema.GetClasses().Add(myClassDef);</p>
<p> </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="#008000" size="2">//layerDef = &quot;Session:&quot; + sessionid1 + &quot;//&quot; + myLayerName + &quot;.LayerDefinition&quot;; 
<p> </p></font><font size="2">
<p></p></font><font color="#008080" size="2">MgByteReader</font><font size="2"> layerDefContent = BuildLayerDefinitionContent(dataSource, </font><font color="#800000" size="2">&quot;SHP_Shema:linetest&quot;</font><font size="2">, </font><font color="#800000" size="2">&quot;&quot;</font><font size="2">, </font><font color="#800000" size="2">&quot;5&quot;</font><font size="2">, </font><font color="#800000" size="2">&quot;F000F&quot;</font><font size="2">); 
<p>resourceSrvc.SetResource(layerDefId, layerDefContent, </p></font><font color="#0000ff" size="2">null</font><font size="2">); 
<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">(layerDefId, resourceSrvc); 
<p>myLayer.SetName(myLayerName);</p>
<p>myLayer.SetLegendLabel(</p></font><font color="#800000" size="2">&quot;legend&quot;</font><font size="2"> + myLayerName); 
<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>map.GetLayers().Insert(0, myLayer);</p>
<p></p></font><font color="#008000" size="2">//map.GetLayers().Add(myLayer); </font><font size="2">
<p>myLayer.ForceRefresh();</p>
<p>map.Save(resourceSrvc); </p>
<p>}</p>
<p></p></font><font color="#008000" size="2">// Save the map back to the session repository</font><font size="2"> 
<p></p></font><font color="#008000" size="2">/*String sessionIdName = &quot;Session:&quot; + sessionid1 + &quot;//&quot; + mapname + &quot;.Map&quot;; 
<p>MgResourceIdentifier sessionResourceID = new MgResourceIdentifier(sessionIdName);</p>
<p>sessionResourceID.Validate();</p>
<p>map.Save(resourceSrvc, sessionResourceID);</p>
<p>//Response.Write(map.GetLayers().GetItem(&quot;layertest&quot;).GetName());</p>
<p>//Response.Write(map.GetLayers().GetItem(&quot;Redline2&quot;).GetLayerDefinition().ToString());</p>
<p> </p>
<p> </p>
<p>//</p>
<p>//myLayer.SetVisible(true);</p>
<p> </p>
<p>//}*/</p></font><font size="2">
<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>
<p></p>
<p></p>
<p></p>
<p>%&gt;</p></font><font color="#0000ff" size="2">
<p>&lt;</p></font><font color="#800000" size="2">div</font><font size="2"> </font><font color="#ff0000" size="2">id</font><font color="#0000ff" size="2">=&quot;viewer&quot;&gt;</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">iframe</font><font size="2"> </font><font color="#ff0000" size="2">id</font><font color="#0000ff" size="2">=&quot;carte&quot;</font><font size="2"> </font><font color="#ff0000" size="2">width</font><font color="#0000ff" size="2">=&quot;800&quot;</font><font size="2"> </font><font color="#ff0000" size="2">height</font><font color="#0000ff" size="2">=&quot;300&quot;</font><font size="2"> </font><font color="#ff0000" size="2">frameborder</font><font color="#0000ff" size="2">=&quot;0&quot;</font><font size="2"> </font><font color="#ff0000" size="2">scrolling</font><font color="#0000ff" size="2">=&quot;no&quot;</font><font size="2"> </font><font color="#ff0000" size="2">src</font><font color="#0000ff" size="2">=&quot;<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://localhost/mapguide2008/mapviewerajax/?SESSION=" target="_blank">http://localhost/mapguide2008/mapviewerajax/?SESSION=</a></font><font size="2">&lt;%=sessionid1 %&gt;</font><font color="#0000ff" size="2">&amp;WEBLAYOUT=Library%3a%2f%2fSamples%2fSheboygan%2fLayouts%2fSheboyganAsp.WebLayout&quot;</font><font size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">=&quot;fenetre&quot;&gt;&lt;/</font><font color="#800000" size="2">iframe</font><font color="#0000ff" size="2">&gt;</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">&gt;</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">br</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">&gt;</font><font size="2"> </font><font color="#0000ff" size="2">
<p>&lt;</p></font><font color="#800000" size="2">input</font><font size="2"> </font><font color="#ff0000" size="2">type</font><font color="#0000ff" size="2">=&quot;button&quot;</font><font size="2"> </font><font color="#ff0000" size="2">value</font><font color="#0000ff" size="2">=&quot;zoom&quot;</font><font size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">=&quot;zoom&quot;</font><font size="2"> </font><font color="#ff0000" size="2">onclick</font><font color="#0000ff" size="2">=&quot;zoom()&quot;/&gt; 
<p>&lt;/</p></font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">&gt; 
<p>&lt;</p></font><font color="#800000" size="2">br</font><font size="2"> </font><font color="#0000ff" size="2">/&gt; 
<p>&lt;</p></font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">&gt;</font><font size="2"> </font><font color="#0000ff" size="2">
<p>&lt;</p></font><font color="#800000" size="2">input</font><font size="2"> </font><font color="#ff0000" size="2">type</font><font color="#0000ff" size="2">=&quot;button&quot;</font><font size="2"> </font><font color="#ff0000" size="2">value</font><font color="#0000ff" size="2">=&quot;rafraichir&quot;</font><font size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">=&quot;calque&quot;</font><font size="2"> </font><font color="#ff0000" size="2">onclick</font><font color="#0000ff" size="2">=&quot;testcalque();&quot;/&gt; 
<p>&lt;/</p></font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">&gt; 
<p> </p>
<p>&lt;/</p></font><font color="#800000" size="2">body</font><font color="#0000ff" size="2">&gt; 
<p>&lt;</p></font><font color="#800000" size="2">script</font><font size="2"> </font><font color="#ff0000" size="2">type</font><font color="#0000ff" size="2">=&quot;text/javascript&quot;&gt;</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2">var</font><font size="2"> str2; 
<p></p></font><font color="#0000ff" size="2">var</font><font size="2"> str; 
<p></p>
<p></p>
<p></p></font><font color="#0000ff" size="2">function</font><font size="2"> zoom() 
<p>{</p>
<p>carte.GetMapFrame().ZoomToView(-87.7116768,43.7766789973,5000,</p></font><font color="#0000ff" size="2">true</font><font size="2">); 
<p></p>
<p>}</p>
<p></p></font><font color="#0000ff" size="2">function</font><font size="2"> testcalque() 
<p>{</p>
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().GetLayers(true,true);</font><font size="2"> 
<p></p></font><font color="#008000" size="2">//carte.GetScriptFrame().location.href = &quot;essai.aspx&quot;;</font><font size="2"> 
<p>frames[</p></font><font color="#800000" size="2">&#39;fenetre&#39;</font><font size="2">].location.reload(); 
<p>carte.GetMapFrame().Refresh();</p>
<p></p></font><font color="#008000" size="2">//carte.ExecuteMapAction(20); </font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().ExecuteMapAction(1); </font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetTaskFrame().location.href = &quot;essai.aspx&quot; </font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetScriptFrame().location.href = &quot;essai.aspx&quot; </font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().ExecuteMapAction(20); 
<p> </p></font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().ExecuteMapAction(20); </font><font size="2">
<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; 
<p> </p>
<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">MgPropertyCollection</font><font size="2"> makeLine(</font><font color="#008080" size="2">String</font><font size="2"> Name, </font><font color="#008080" size="2">String</font><font size="2"> x0, </font><font color="#008080" size="2">String</font><font size="2"> y0, </font><font color="#008080" size="2">String</font><font size="2"> x1,</font><font color="#008080" size="2">String</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>
<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></p></font><font color="#0000ff" size="2">return</font><font size="2"> (layers.Contains(LayerName)); 
<p>}</p>
<p></p>
<p></p></font><font color="#008080" size="2">String</font><font size="2"> LoadTemplate2(</font><font color="#008080" size="2">String</font><font size="2"> filePath) 
<p>{</p>
<p></p></font><font color="#008080" size="2">StreamReader</font><font size="2"> sr = </font><font color="#008080" size="2">File</font><font size="2">.OpenText(filePath); 
<p></p></font><font color="#008080" size="2">String</font><font size="2"> template = sr.ReadToEnd(); 
<p></p></font><font color="#0000ff" size="2">return</font><font size="2"> template; 
<p>}</p>
<p> </p></font><font color="#008080" size="2">
<p>MgByteReader</p></font><font size="2">BuildLayerDefinitionContent(</font><font color="#008080" size="2">String</font><font size="2"> ResourceId, </font><font color="#008080" size="2">String</font><font size="2"> FeatureName, </font><font color="#008080" size="2">String</font><font size="2"> ToolTip, </font><font color="#008080" size="2">String</font><font size="2"> Thickness, </font><font color="#008080" size="2">String</font><font size="2"> LineColor) 
<p>{</p>
<p></p></font><font color="#008080" size="2">String</font><font size="2"> layerTempl = LoadTemplate2(</font><font color="#800000" size="2">&quot;C:\\Program Files\\Autodesk\\MapGuideEnterprise2008\\WebServerExtensions\\www\\viewerfiles\\linelayerdef.templ&quot;</font><font size="2">); 
<p></p>
<p></p></font><font color="#008080" size="2">String</font><font size="2">[] vals = { 
<p>ResourceId,</p>
<p>FeatureName,</p>
<p></p></font><font color="#800000" size="2">&quot;SHPGEOM&quot;</font><font size="2">, 
<p>ToolTip,</p>
<p>Thickness,</p>
<p>LineColor</p>
<p>};</p>
<p>layerTempl = Substitute(layerTempl, vals);</p>
<p></p></font><font color="#0000ff" size="2">byte</font><font size="2">[] bytes = </font><font color="#008080" size="2">Encoding</font><font size="2">.UTF8.GetBytes(layerTempl); 
<p></p></font><font color="#008080" size="2">MgByteSource</font><font size="2"> src = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgByteSource</font><font size="2">(bytes, bytes.Length); 
<p></p></font><font color="#0000ff" size="2">return</font><font size="2"> src.GetReader(); 
<p>}</p>
<p></p></font><font color="#0000ff" size="2">void</font><font size="2"> add_layer_group(</font><font color="#008080" size="2">MgLayer</font><font size="2"> layer, </font><font color="#008080" size="2">String</font><font size="2"> layergroupname, </font><font color="#008080" size="2">MgMap</font><font size="2"> map) 
<p>{</p>
<p></p></font><font color="#008080" size="2">MgLayerGroupCollection</font><font size="2"> group = map.GetLayerGroups(); 
<p></p></font><font color="#008080" size="2">MgLayerGroup</font><font size="2"> grouplayer = group.GetItem(layergroupname); 
<p>layer.SetGroup(grouplayer);</p>
<p>map.Save();</p>
<p>} </p>
<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; 
<p> </p>
<p> </p>
<p> </p>
<p> </p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">
<p>&lt;/</p></font><font color="#800000" size="2">html</font><font color="#0000ff" size="2">&gt;</font></div></div>