<div><font size="2">
<p><%</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">="C#"</font><font size="2"> </font><font color="#ff0000" size="2">AutoEventWireup</font><font color="#0000ff" size="2">="true"</font><font size="2"> </font><font color="#ff0000" size="2">CodeFile</font><font color="#0000ff" size="2">="essai.aspx.cs"</font><font size="2"> </font><font color="#ff0000" size="2">
<p>Inherits</p></font><font color="#0000ff" size="2">="essai"</font><font size="2"> %>
<p><%</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">="System"</font><font size="2"> %>
<p><%</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">="System.IO"</font><font size="2"> %>
<p><%</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">="System.Collections.Specialized"</font><font size="2"> %>
<p><%</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">="OSGeo.MapGuide"</font><font size="2"> %>
<p><%</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">="System.Text"</font><font size="2"> %>
<p><%</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">="System.Globalization"</font><font size="2"> %>
<p><%</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">="OSGeo.MapGuide.Schema.LayerDefinition"</font><font size="2">%>;</font><font color="#008000" size="2">
<p><!-- #Include File="C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\mapviewernet\common.aspx--></p>
<p> </p></font><font color="#0000ff" size="2">
<p><!</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">"-//W3C//DTD XHTML 1.0 Transitional//EN"</font><font size="2"> </font><font color="#0000ff" size="2">
<p>"<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>"></p>
<p> </p>
<p> </p>
<p><</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">="<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>"</font><font size="2"> </font><font color="#0000ff" size="2">>
<p><</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">="Head1"</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">="server"></font><font size="2">
<p></p></font><font color="#0000ff" size="2"><</font><font color="#800000" size="2">title</font><font color="#0000ff" size="2">></font><font size="2">selection</font><font color="#0000ff" size="2"></</font><font color="#800000" size="2">title</font><font color="#0000ff" size="2">></font><font size="2">
<p></p></font><font color="#0000ff" size="2">
<p></</p></font><font color="#800000" size="2">head</font><font color="#0000ff" size="2">>
<p><</p></font><font color="#800000" size="2">body</font><font color="#0000ff" size="2">>
<p><</p></font><font color="#800000" size="2">br</font><font size="2"> </font><font color="#0000ff" size="2">/></font><font size="2">
<p><%</p>
<p></p>
<p></p></font><font color="#008080" size="2">String</font><font size="2"> x0 = </font><font color="#800000" size="2">"100"</font><font size="2">;
<p></p></font><font color="#008080" size="2">String</font><font size="2"> y0 = </font><font color="#800000" size="2">"100"</font><font size="2">;
<p></p></font><font color="#008080" size="2">String</font><font size="2"> x1 = </font><font color="#800000" size="2">"109"</font><font size="2">;
<p></p></font><font color="#008080" size="2">String</font><font size="2"> y1 = </font><font color="#800000" size="2">"109"</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">"linetest"</font><font size="2">;
<p></p></font><font color="#008080" size="2">String</font><font size="2"> mapname = </font><font color="#800000" size="2">"Sheboygan"</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">"C:\\Program Files\\Autodesk\\MapGuideEnterprise2008\\WebServerExtensions\\www\\webconfig.ini"</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">"Administrator"</font><font size="2">, </font><font color="#800000" size="2">"admin"</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">"Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition"</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("Session:" + sessionid1 + "//" + mapname + "." + 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">"utf-8"</font><font size="2">;
<p></p></font><font color="#008000" size="2">//String x0 = "100";</font><font size="2">
<p></p></font><font color="#008000" size="2">//String y0 = "100";</font><font size="2">
<p></p></font><font color="#008000" size="2">//String x1 = "109";</font><font size="2">
<p></p></font><font color="#008000" size="2">//String y1 = "109";</font><font size="2">
<p></p></font><font color="#008080" size="2">String</font><font size="2"> layerDef = </font><font color="#800000" size="2">"Library://Samples/Sheboygan/Layers/"</font><font size="2"> + myLayerName + </font><font color="#800000" size="2">".LayerDefinition"</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">"Library://Samples/Sheboygan/Data/"</font><font size="2"> + myLayerName + </font><font color="#800000" size="2">".FeatureSource"</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">"linetest"</font><font size="2">);
<p></p></font><font color="#008000" size="2">//myClassDef.SetDescription(myLayerName + " Feature Source");</font><font size="2">
<p>myClassDef.SetDefaultGeometryPropertyName(</p></font><font color="#800000" size="2">"SHPGEOM"</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">"KEY"</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">"ID"</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">"SHPGEOM"</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">"LL84"</font><font size="2">);
<p>myClassDef.GetProperties().Add(geomProp);</p>
<p>myClassDef.SetDefaultGeometryPropertyName(</p></font><font color="#800000" size="2">"SHPGEOM"</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">"SHP_Shema"</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">"MGA-56 (GDA94 /MGA zone 56)"</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 = "Session:" + sessionid1 + "//" + myLayerName +".LayerDefinition";</font><font size="2">
<p></p></font><font color="#008000" size="2">//layerDef = "Session:" + sessionid1 + "//" + myLayerName + ".LayerDefinition";
<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">"SHP_Shema:linetest"</font><font size="2">, </font><font color="#800000" size="2">""</font><font size="2">, </font><font color="#800000" size="2">"5"</font><font size="2">, </font><font color="#800000" size="2">"F000F"</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">"legend"</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 = "Session:" + sessionid1 + "//" + mapname + ".Map";
<p>MgResourceIdentifier sessionResourceID = new MgResourceIdentifier(sessionIdName);</p>
<p>sessionResourceID.Validate();</p>
<p>map.Save(resourceSrvc, sessionResourceID);</p>
<p>//Response.Write(map.GetLayers().GetItem("layertest").GetName());</p>
<p>//Response.Write(map.GetLayers().GetItem("Redline2").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">"1"</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>%></p></font><font color="#0000ff" size="2">
<p><</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">="viewer"></font><font size="2">
<p></p></font><font color="#0000ff" size="2"><</font><font color="#800000" size="2">iframe</font><font size="2"> </font><font color="#ff0000" size="2">id</font><font color="#0000ff" size="2">="carte"</font><font size="2"> </font><font color="#ff0000" size="2">width</font><font color="#0000ff" size="2">="800"</font><font size="2"> </font><font color="#ff0000" size="2">height</font><font color="#0000ff" size="2">="300"</font><font size="2"> </font><font color="#ff0000" size="2">frameborder</font><font color="#0000ff" size="2">="0"</font><font size="2"> </font><font color="#ff0000" size="2">scrolling</font><font color="#0000ff" size="2">="no"</font><font size="2"> </font><font color="#ff0000" size="2">src</font><font color="#0000ff" size="2">="<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"><%=sessionid1 %></font><font color="#0000ff" size="2">&WEBLAYOUT=Library%3a%2f%2fSamples%2fSheboygan%2fLayouts%2fSheboyganAsp.WebLayout"</font><font size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">="fenetre"></</font><font color="#800000" size="2">iframe</font><font color="#0000ff" size="2">></font><font size="2">
<p></p></font><font color="#0000ff" size="2"></</font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">></font><font size="2">
<p></p></font><font color="#0000ff" size="2"><</font><font color="#800000" size="2">br</font><font size="2"> </font><font color="#0000ff" size="2">/></font><font size="2">
<p></p></font><font color="#0000ff" size="2"><</font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">></font><font size="2"> </font><font color="#0000ff" size="2">
<p><</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">="button"</font><font size="2"> </font><font color="#ff0000" size="2">value</font><font color="#0000ff" size="2">="zoom"</font><font size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">="zoom"</font><font size="2"> </font><font color="#ff0000" size="2">onclick</font><font color="#0000ff" size="2">="zoom()"/>
<p></</p></font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">>
<p><</p></font><font color="#800000" size="2">br</font><font size="2"> </font><font color="#0000ff" size="2">/>
<p><</p></font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">></font><font size="2"> </font><font color="#0000ff" size="2">
<p><</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">="button"</font><font size="2"> </font><font color="#ff0000" size="2">value</font><font color="#0000ff" size="2">="rafraichir"</font><font size="2"> </font><font color="#ff0000" size="2">name</font><font color="#0000ff" size="2">="calque"</font><font size="2"> </font><font color="#ff0000" size="2">onclick</font><font color="#0000ff" size="2">="testcalque();"/>
<p></</p></font><font color="#800000" size="2">div</font><font color="#0000ff" size="2">>
<p> </p>
<p></</p></font><font color="#800000" size="2">body</font><font color="#0000ff" size="2">>
<p><</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">="text/javascript"></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 = "essai.aspx";</font><font size="2">
<p>frames[</p></font><font color="#800000" size="2">'fenetre'</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 = "essai.aspx" </font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetScriptFrame().location.href = "essai.aspx" </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></</p></font><font color="#800000" size="2">script</font><font color="#0000ff" size="2">>
<p> </p>
<p><</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></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">"ID"</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">"LINESTRING XY ("</font><font size="2"> + x0 + </font><font color="#800000" size="2">" "</font><font size="2">+ y0 + </font><font color="#800000" size="2">","</font><font size="2"> + x1 + </font><font color="#800000" size="2">" "</font><font size="2"> + y1 + </font><font color="#800000" size="2">")"</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">"SHPGEOM"</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">"C:\\Program Files\\Autodesk\\MapGuideEnterprise2008\\WebServerExtensions\\www\\viewerfiles\\linelayerdef.templ"</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">"SHPGEOM"</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></</p></font><font color="#800000" size="2">script</font><font color="#0000ff" size="2">>
<p> </p>
<p> </p>
<p> </p>
<p> </p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">
<p></</p></font><font color="#800000" size="2">html</font><font color="#0000ff" size="2">></font></div>