<div>and i have the same prob with inserting polygone in layerand this time even with mapguide Studio i don't see the polygone in layer , this is my code i give it you may be it will help you see my error :</div>
<div>As cordinates i pass </div>
<div>
<div> </div>
<div> Dim x() As Double = {0, 2, 2, 0, 0}<br> Dim y() As Double = {0, 0, 2, 2, 0}</div>
<div>just for testing and for constituting polygone i do that: (as i've show you in my code)</div>
<div> </div>
<div> </div>
<div> <br> Dim poly As MgPolygon<br> Dim geomfactory As MgGeometryFactory = New MgGeometryFactory()<br> Dim coordcol As MgCoordinateCollection = New MgCoordinateCollection()<br> Dim j As Integer<br>
For j = 0 To 4<br> Dim coord As MgCoordinate = geomfactory.CreateCoordinateXY(a(j), b(j))<br> coordcol.Add(coord)<br> j = j + 1<br> <br> Next<br> Dim outring As MgLinearRing = geomfactory.CreateLinearRing(coordcol)<br>
poly = geomfactory.CreatePolygon(outring, Nothing)<br> </div>
<div> Dim agf As MgAgfReaderWriter = New MgAgfReaderWriter()<br> <br> properties.Add(New MgGeometryProperty("GEOM", agf.Write(poly)))</div>
<div> </div>
<div> </div>
<div>another prob that i have that i can't see the layer i add after refreshing map (conntained in <iframe>)for saying layer i use mapguide studio where i see the layer wich doesn't contain the polygon, may be pro in type of geometry i give or another, i'll give all complete code it will help you see my error and help me if you can, i've spent a lot of time at that but i don't see my error and why even i add layer in map i don't see it and when i see it using mapguide studio it doesn't contain polygone i insert.i have even tested to insert polygone with text shape (("POLYGON XY ((0 0, 2 0, 2 2, 0 2, 0 0))" in function makeLine2() as you see)but it doesn't run too.i don't know what do, please help me if you can do it. Thanks a lot in advance.</div>
<div> </div>
<div> </div>
<div><%@ Page Language="VB" AutoEventWireup="true" CodeFile="essai.aspx.vb" <br>Inherits="essai" %><br><%@ Import Namespace="System" %><br><%@ Import Namespace="System.IO" %><br>
<%@ Import Namespace="System.Collections.Specialized" %><br><%@ Import Namespace="OSGeo.MapGuide" %><br><%@ Import Namespace="System.Text" %><br><%@ Import Namespace="System.Globalization" %></div>
<div> </div>
<div><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <br>"<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"></div>
<div> </div>
<div><html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>" ><br><head id="Head1" runat="server"><br> <title>selection</title><br> <br>
</head><br><body></div>
<div><br /><br> <%<br> <br> <br> Dim sessionid1 As String<br> Dim siteConnection As MgSiteConnection<br> Dim resourceSrvc As MgResourceService<br> Dim myLayerName As String = "line9"<br>
Dim mapname As String = "Sheboygan"<br> Dim map As MgMap<br> Dim featureSrvc As MgFeatureService<br> Dim myLayer As MgLayer<br> </div>
<div> Dim configPath As String = "C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\webconfig.ini"<br> MapGuideApi.MgInitializeWebTier(configPath)<br> Dim site1 As MgSite = New MgSite()<br>
Dim userInfo As MgUserInformation = New MgUserInformation("Administrator", "admin")<br> siteConnection = New MgSiteConnection()<br> siteConnection.Open(userInfo)<br> site1 = siteConnection.GetSite()<br>
sessionid1 = site1.CreateSession()<br> userInfo.SetMgSessionId(sessionid1)</div>
<div> resourceSrvc = siteConnection.CreateService(MgServiceType.ResourceService)<br> featureSrvc = siteConnection.CreateService(MgServiceType.FeatureService)</div>
<div> <br> Response.Charset = "utf-8"<br> Dim layerDef As String = "Library://Samples/Sheboygan/Layers/" + myLayerName + ".LayerDefinition"<br> Dim layerDefId As MgResourceIdentifier = New MgResourceIdentifier(layerDef)<br>
Dim dataSource As String = "Library://Samples/Sheboygan/Data/" + myLayerName + ".FeatureSource"<br> Dim dataSourceId As MgResourceIdentifier = New MgResourceIdentifier(dataSource)<br> Dim resourceID2 As MgResourceIdentifier = New MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition")<br>
<br> map = New MgMap(siteConnection)<br> map.Create(resourceSrvc, resourceID2, mapname)<br> <br> map.Save()<br> map.Open(resourceSrvc, mapname)</div>
<div> Dim myClassDef As MgClassDefinition</div>
<div> If (DoesLayerExist(myLayerName, map) = False) Then<br> </div>
<div> '//create Feature Source<br> myClassDef = New MgClassDefinition()<br> myClassDef.SetName("line9")<br> 'myClassDef.SetDescription(myLayerName + " Feature Source")<br>
'myClassDef.SetDefaultGeometryPropertyName("SHPGEOM")</div>
<div> 'Set KEY Property<br> Dim prop As MgDataPropertyDefinition = New MgDataPropertyDefinition("KEY")<br> prop.SetDataType(MgPropertyType.Int32)<br> prop.SetAutoGeneration(True)<br>
prop.SetReadOnly(True)<br> prop.SetNullable(False)<br> myClassDef.GetProperties().Add(prop)<br> myClassDef.GetIdentityProperties().Add(prop)</div>
<div> 'Set ID Property<br> prop = New MgDataPropertyDefinition("ID")<br> prop.SetDataType(MgPropertyType.Int32)<br> myClassDef.GetProperties().Add(prop)<br> <br> <br>
'et geometry property<br> Dim geomProp As MgGeometricPropertyDefinition = New MgGeometricPropertyDefinition("GEOM")<br> geomProp.SetGeometryTypes(MgFeatureGeometricType.Surface)<br> geomProp.SetHasElevation(False)<br>
geomProp.SetHasMeasure(False)<br> geomProp.SetSpatialContextAssociation("LL84")<br> myClassDef.GetProperties().Add(geomProp)<br> 'myClassDef.SetDefaultGeometryPropertyName("SHPGEOM")</div>
<div> 'Create the schema<br> Dim schema As MgFeatureSchema = New MgFeatureSchema()<br> schema.SetName("SHP_Shema")<br> schema.GetClasses().Add(myClassDef)<br> </div>
<div> Dim sdfParams As MgCreateSdfParams = New MgCreateSdfParams("MGA-56 (GDA94 /MGA zone 56)", map.GetMapSRS(), schema)</div>
<div> featureSrvc.CreateFeatureSource(dataSourceId, sdfParams)</div>
<div><br> <br> <br> Dim content As MgByteSource = New MgByteSource("C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\createpoint\LayerDefinition.xml")<br> resourceSrvc.SetResource(layerDefId, content.GetReader(), Nothing)</div>
<div> myLayer = New MgLayer(layerDefId, resourceSrvc)<br> myLayer.SetName(myLayerName)<br> myLayer.SetLegendLabel(myLayerName)<br> myLayer.SetDisplayInLegend(True)<br> myLayer.SetSelectable(False)<br>
map.GetLayers().Insert(0, myLayer)<br> 'map.GetLayers().Add(myLayer) <br> myLayer.ForceRefresh()<br> map.Save(resourceSrvc)<br> <br> <br> <br> End If<br> <br>
<br> Dim insertFeatures2 As MgInsertFeatures = New MgInsertFeatures(myLayerName, makeLine())<br> <br> Dim commands As MgFeatureCommandCollection = New MgFeatureCommandCollection()<br> <br> commands.Add(insertFeatures2)<br>
<br> myLayer.UpdateFeatures(commands)<br> <br> <br> <br> <br> <br> <br> <br> </div>
<div> <br> </div>
<div> <br> <br> %></div>
<div><div id="viewer"><br> <iframe id="carte" width="800" height="300" frameborder="0" scrolling="no" src="<a href="http://localhost/mapguide2008/mapviewerajax/?SESSION=<%=sessionid1">http://localhost/mapguide2008/mapviewerajax/?SESSION=<%=sessionid1</a> %>&WEBLAYOUT=Library%3a%2f%2fSamples%2fSheboygan%2fLayouts%2fSheboyganAsp.WebLayout" name="fenetre"></iframe><br>
</div><br> <br /><br> <div> <br><input type="button" value="zoom" name="zoom" onclick="zoom()"/><br></div><br><br /><br><div> <br><input type="button" value="rafraichir" name="calque" onclick="testcalque();"/><br>
</div></div>
<div><br></body><br><script type="text/javascript"></div>
<div> var str2;<br> var str;<br> <br> <br> function zoom()<br> {<br> carte.GetMapFrame().ZoomToView(-87.7116768,43.7766789973,5000,true);<br> <br> }<br> function testcalque()<br> {<br>
//carte.GetMapFrame().GetLayers(true,true);<br> //carte.GetScriptFrame().location.href = "essai.aspx";<br> frames['fenetre'].location.reload();<br> carte.GetMapFrame().Refresh();<br> //carte.ExecuteMapAction(20); <br>
//carte.GetMapFrame().ExecuteMapAction(1); <br> //carte.GetTaskFrame().location.href = "essai.aspx" <br> //carte.GetScriptFrame().location.href = "essai.aspx" </div>
<div> //carte.GetMapFrame().ExecuteMapAction(20);</div>
<div><br> //carte.GetMapFrame().ExecuteMapAction(20); </div>
<div> }<br> <br> <br></script></div>
<div><br><script runat="server"><br> <br> Public Function makeLine() As MgPropertyCollection<br> <br> Dim x() As Double = {0, 2, 2, 0, 0}<br> Dim y() As Double = {0, 0, 2, 2, 0}<br>
<br> Dim poly As MgPolygon<br> Dim geomfactory As MgGeometryFactory = New MgGeometryFactory()<br> Dim coordcol As MgCoordinateCollection = New MgCoordinateCollection()<br> Dim j As Integer<br> For j = 0 To 4<br>
Dim coord As MgCoordinate = geomfactory.CreateCoordinateXY(x(j), y(j))<br> coordcol.Add(coord)<br> j = j + 1<br> <br> Next<br> Dim outring As MgLinearRing = geomfactory.CreateLinearRing(coordcol)<br>
poly = geomfactory.CreatePolygon(outring, Nothing)<br> </div>
<div> Dim agf As MgAgfReaderWriter = New MgAgfReaderWriter()<br> <br> properties.Add(New MgGeometryProperty("GEOM", agf.Write(poly)))<br> </div>
<div> <br> return properties<br> <br> End Function<br> Public Function makeLine2() As MgPropertyCollection</div>
<div> Dim PropertyCollection2 As MgPropertyCollection = New MgPropertyCollection()<br> Dim nameProperty2 As MgInt32Property = New MgInt32Property("ID", 1)<br> PropertyCollection2.Add(nameProperty2)</div>
<div> Dim wktReaderWriter2 As MgWktReaderWriter = New MgWktReaderWriter()<br> Dim agfReaderWriter2 As MgAgfReaderWriter = New MgAgfReaderWriter()</div>
<div> Dim geometry2 As MgPolygon = wktReaderWriter2.Read("POLYGON XY ((0 0, 2 0, 2 2, 0 2, 0 0))")<br> <br> <br> Dim geometryByteReader2 As MgByteReader = agfReaderWriter2.Write(geometry2)<br>
Dim geometryProperty2 As MgGeometryProperty = New MgGeometryProperty("GEOM", geometryByteReader2)<br> PropertyCollection2.Add(geometryProperty2)<br> Return PropertyCollection2<br> End Function<br>
</div>
<div> <br> Function DoesLayerExist(ByVal LayerName As String, ByVal Map As MgMap) As Boolean</div>
<div> Dim layers As MgLayerCollection = Map.GetLayers()<br> Return (layers.Contains(LayerName))<br> End Function<br> <br> <br> </div>
<div> <br></script></div>
<div> </div>
<div> </div>
<div> <br></html><br></div>
<div> </div>
<div><br><br> </div>
<div class="gmail_quote">2009/5/11 javed shaikh <span dir="ltr"><<a href="mailto:jaspune@hotmail.com">jaspune@hotmail.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Wakrim<br> <br>Could you tell me what is the error?<br> <br>You were code is technically correct, if you can tell me what is the error i can help you.<br> <br>Before that make sure you are passing corrrect cordinates (last co ordinate is same as first) you are passing correct layer scheme and inserting in correct session.<br>
<br>J<br> <br>> From: <a href="mailto:wakrimsaloua.wakrim@gmail.com" target="_blank">wakrimsaloua.wakrim@gmail.com</a><br>> To: <a href="mailto:jaspune@hotmail.com" target="_blank">jaspune@hotmail.com</a><br>> Subject: please help me if you can<br>
> Date: Sat, 9 May 2009 04:13:56 -0700<br>> <br>> hi, i've the same prob that you have, but i can't resolve it, i use this code for drawning polygon ,but it doesn't draw it, please correct it me if you have time to do it, this is my mail: <a href="mailto:wakrimsaloua.wakrim@gmail.com" target="_blank">wakrimsaloua.wakrim@gmail.com</a>, this is my code:<br>
> <br>> If (DoesLayerExist(myLayerName, map) = False) Then<br>> <br>> <br>> '//create Feature Source<br>> Dim myClassDef As MgClassDefinition = New MgClassDefinition()<br>> myClassDef.SetName("saloua3")<br>
> 'myClassDef.SetDescription(myLayerName + " Feature Source")<br>> myClassDef.SetDefaultGeometryPropertyName("SHPGEOM")<br>> <br>> 'Set KEY Property<br>> Dim prop As MgDataPropertyDefinition = New MgDataPropertyDefinition("KEY")<br>
> prop.SetDataType(MgPropertyType.Int32)<br>> prop.SetAutoGeneration(True)<br>> prop.SetReadOnly(True)<br>> prop.SetNullable(False)<br>> myClassDef.GetProperties().Add(prop)<br>> myClassDef.GetIdentityProperties().Add(prop)<br>
> <br>> 'Set ID Property<br>> prop = New MgDataPropertyDefinition("ID")<br>> prop.SetDataType(MgPropertyType.Int32)<br>> myClassDef.GetProperties().Add(prop)<br>> <br>> 'add poly<br>
> <br>> Dim poly As MgPolygon<br>> Dim geomfactory As MgGeometryFactory = New MgGeometryFactory()<br>> Dim coordcol As MgCoordinateCollection = New MgCoordinateCollection()<br>> Dim j As Integer<br>> For j = 0 To 3<br>
> Dim coord As MgCoordinate = geomfactory.CreateCoordinateXY(x(j), y(j))<br>> coordcol.Add(coord)<br>> <br>> Next<br>> Dim outring As MgLinearRing = geomfactory.CreateLinearRing(coordcol)<br>> poly = geomfactory.CreatePolygon(outring, Nothing)<br>
> Dim agf As MgAgfReaderWriter = New MgAgfReaderWriter()<br>> <br>> 'Dim geom As MgByteReader = geometryReaderWriter.Write(poly)<br>> properties = New MgPropertyCollection()<br>> properties.Add(New MgGeometryProperty("GEOM", agf.Write(poly)))<br>
> <br>> 'et geometry property<br>> Dim geomProp As MgGeometricPropertyDefinition = New MgGeometricPropertyDefinition("SHPGEOM")<br>> geomProp.SetGeometryTypes(MgFeatureGeometricType.Curve)<br>> geomProp.SetHasElevation(False)<br>
> geomProp.SetHasMeasure(False)<br>> geomProp.SetSpatialContextAssociation("LL84")<br>> myClassDef.GetProperties().Add(geomProp)<br>> myClassDef.SetDefaultGeometryPropertyName("SHPGEOM")<br>
> <br>> 'Create the schema<br>> Dim schema As MgFeatureSchema = New MgFeatureSchema()<br>> schema.SetName("SHP_Shema")<br>> schema.GetClasses().Add(myClassDef)<br>> <br>> <br>> Dim sdfParams As MgCreateSdfParams = New MgCreateSdfParams("MGA-56 (GDA94 /MGA zone 56)", map.GetMapSRS(), schema)<br>
> <br>> featureSrvc.CreateFeatureSource(dataSourceId, sdfParams)<br>> <br>> <br>> 'Dim layerDefContent As MgByteReader = BuildLayerDefinitionContent(dataSource, "SHP_Shema:linetestvb4", "", "5", "F000F")<br>
> 'resourceSrvc.SetResource(layerDefId, layerDefContent, nothing)<br>> <br>> Dim content As MgByteSource = New MgByteSource("C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\testvb\LayerDefinition.xml")<br>
> resourceSrvc.SetResource(layerDefId, content.GetReader(), Nothing)<br>> <br>> Dim myLayer As MgLayer = New MgLayer(layerDefId, resourceSrvc)<br>> myLayer.SetName(myLayerName)<br>> myLayer.SetLegendLabel("legend" + myLayerName)<br>
> myLayer.SetDisplayInLegend(True)<br>> myLayer.SetSelectable(True)<br>> map.GetLayers().Insert(0, myLayer)<br>> 'map.GetLayers().Add(myLayer) <br>> myLayer.ForceRefresh()<br>> map.Save(resourceSrvc)<br>
> Dim insertFeatures As MgInsertFeatures = New MgInsertFeatures(myLayerName, properties)<br>> Dim commands As MgFeatureCommandCollection = New MgFeatureCommandCollection()<br>> commands.Add(insertFeatures)<br>> Dim commandIndex As Integer = commands.IndexOf(insertFeatures)<br>
> <br>> Dim insertResults As MgPropertyCollection<br>> <br>> insertResults = featureSrvc.UpdateFeatures(dataSourceId, commands, False)<br>> End If<br><br><br><br></div></blockquote></div></div>
<div class="gmail_quote">2009/5/11 saloua wakrim <span dir="ltr"><<a href="mailto:wakrimsaloua.wakrim@gmail.com">wakrimsaloua.wakrim@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>thanks a lot for your replay,yes, i'm sure, i've tried another code and with mapguide studio i see the layer that i add, it contains the line wich i insert, but on iframe (where the map is displayed) i don't see the layer and even in mapguide studio with the layers belonging to the map, i don't see the layer (it's not added), this is my complete code:</div>
<div> </div>
<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">="VB"</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.vb"</font><font size="2">
<p></p></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>
<p> </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">
<p></p></font><font color="#0000ff" size="2">
<p>"<a 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 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">
<p></p></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">>
<p></p></font><font size="2">
<p></p>
<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">/>
<p></p></font><font size="2">
<p><%</p>
<p></p></font><font size="2">
<p></p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> x0 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"100"
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> y0 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"100"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> x1 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"120"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> y1 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"120"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> sessionid1 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> siteConnection </font><font color="#0000ff" size="2">As</font><font size="2"> MgSiteConnection
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> resourceSrvc </font><font color="#0000ff" size="2">As</font><font size="2"> MgResourceService
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> myLayerName </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"line6"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> mapname </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"Sheboygan"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> map </font><font color="#0000ff" size="2">As</font><font size="2"> MgMap
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> featureSrvc </font><font color="#0000ff" size="2">As</font><font size="2"> MgFeatureService
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> myLayer </font><font color="#0000ff" size="2">As</font><font size="2"> MgLayer
<p></p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> configPath </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\webconfig.ini"
<p></p></font><font size="2">
<p>MapGuideApi.MgInitializeWebTier(configPath)</p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> site1 </font><font color="#0000ff" size="2">As</font><font size="2"> MgSite = </font><font color="#0000ff" size="2">New</font><font size="2"> MgSite()
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> userInfo </font><font color="#0000ff" size="2">As</font><font size="2"> MgUserInformation = </font><font color="#0000ff" size="2">New</font><font size="2"> MgUserInformation(</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"> MgSiteConnection()
<p>siteConnection.Open(userInfo)</p>
<p>site1 = siteConnection.GetSite()</p>
<p>sessionid1 = site1.CreateSession()</p>
<p>userInfo.SetMgSessionId(sessionid1)</p>
<p>resourceSrvc = siteConnection.CreateService(MgServiceType.ResourceService)</p>
<p>featureSrvc = siteConnection.CreateService(MgServiceType.FeatureService)</p>
<p></p>
<p>Response.Charset = </p></font><font color="#800000" size="2">"utf-8"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> layerDef </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"Library://Samples/Sheboygan/Layers/"</font><font size="2"> + myLayerName + </font><font color="#800000" size="2">".LayerDefinition"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> layerDefId </font><font color="#0000ff" size="2">As</font><font size="2"> MgResourceIdentifier = </font><font color="#0000ff" size="2">New</font><font size="2"> MgResourceIdentifier(layerDef)
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> dataSource </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = </font><font color="#800000" size="2">"Library://Samples/Sheboygan/Data/"</font><font size="2"> + myLayerName + </font><font color="#800000" size="2">".FeatureSource"
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> dataSourceId </font><font color="#0000ff" size="2">As</font><font size="2"> MgResourceIdentifier = </font><font color="#0000ff" size="2">New</font><font size="2"> MgResourceIdentifier(dataSource)
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> resourceID2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgResourceIdentifier = </font><font color="#0000ff" size="2">New</font><font size="2"> MgResourceIdentifier(</font><font color="#800000" size="2">"Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition"</font><font size="2">)
<p></p>
<p>map = </p></font><font color="#0000ff" size="2">New</font><font size="2"> MgMap(siteConnection)
<p>map.Create(resourceSrvc, resourceID2, mapname)</p>
<p></p>
<p>map.Save()</p>
<p>map.Open(resourceSrvc, mapname)</p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> myClassDef </font><font color="#0000ff" size="2">As</font><font size="2"> MgClassDefinition
<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">) </font><font color="#0000ff" size="2">Then
<p></p></font><font size="2">
<p></p>
<p></p></font><font color="#008000" size="2">'//create Feature Source
<p></p></font><font size="2">
<p>myClassDef = </p></font><font color="#0000ff" size="2">New</font><font size="2"> MgClassDefinition()
<p>myClassDef.SetName(</p></font><font color="#800000" size="2">"line6"</font><font size="2">)
<p></p></font><font color="#008000" size="2">'myClassDef.SetDescription(myLayerName + " Feature Source")
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">'myClassDef.SetDefaultGeometryPropertyName("SHPGEOM")
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">'Set KEY Property
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> prop </font><font color="#0000ff" size="2">As</font><font size="2"> MgDataPropertyDefinition = </font><font color="#0000ff" size="2">New</font><font size="2"> MgDataPropertyDefinition(</font><font color="#800000" size="2">"KEY"</font><font size="2">)
<div class="im">
<p>prop.SetDataType(MgPropertyType.Int32)</p>
<p>prop.SetAutoGeneration(</p></div></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
<p></p></font>
<div class="im"><font size="2">
<p>prop = </p></font><font color="#0000ff" size="2">New</font><font size="2"> MgDataPropertyDefinition(</font><font color="#800000" size="2">"ID"</font><font size="2">)
<p>prop.SetDataType(MgPropertyType.Int32)</p>
<p>myClassDef.GetProperties().Add(prop)</p>
<p></p>
<p></p>
<p></p></font></div><font color="#008000" size="2">'et geometry property
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> geomProp </font><font color="#0000ff" size="2">As</font><font size="2"> MgGeometricPropertyDefinition = </font><font color="#0000ff" size="2">New</font><font size="2"> MgGeometricPropertyDefinition(</font><font color="#800000" size="2">"SHPGEOM"</font><font size="2">)
<p>geomProp.SetGeometryTypes(MgFeatureGeometricType.Point)</p>
<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></font><font size="2">
<p></p></font><font color="#008000" size="2">'Create the schema
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> schema </font><font color="#0000ff" size="2">As</font><font size="2"> MgFeatureSchema = </font><font color="#0000ff" size="2">New</font><font size="2"> MgFeatureSchema()
<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="#0000ff" size="2">Dim</font><font size="2"> sdfParams </font><font color="#0000ff" size="2">As</font><font size="2"> MgCreateSdfParams = </font><font color="#0000ff" size="2">New</font><font size="2"> MgCreateSdfParams(</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>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> content </font><font color="#0000ff" size="2">As</font><font size="2"> MgByteSource = </font><font color="#0000ff" size="2">New</font><font size="2"> MgByteSource(</font><font color="#800000" size="2">"C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\createpoint\LayerDefinition.xml"</font><font size="2">)
<div class="im">
<p>resourceSrvc.SetResource(layerDefId, content.GetReader(), </p></div></font><font color="#0000ff" size="2">Nothing</font><font size="2">)
<p>myLayer = </p></font><font color="#0000ff" size="2">New</font><font size="2"> MgLayer(layerDefId, resourceSrvc)
<p>myLayer.SetName(myLayerName)</p>
<p>myLayer.SetLegendLabel(myLayerName)</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">False</font><font size="2">)
<div class="im">
<p>map.GetLayers().Insert(0, myLayer)</p>
<p></p></div></font><font color="#008000" size="2">'map.GetLayers().Add(myLayer)
<p></p></font>
<div class="im"><font size="2">
<p>myLayer.ForceRefresh()</p></font><font size="2">
<p></p>
<p>map.Save(resourceSrvc)</p>
<p></p>
<p></p>
<p></p>
<p></p></font></div><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If
<p></p></font><font size="2">
<p></p>
<p></p>
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">Dim insertFeatures2 As MgInsertFeatures = New MgInsertFeatures(myLayerName, makeLine2("1", x0, y0, x1, y1))
<p></p></font><font size="2">
<p></p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> commands </font><font color="#0000ff" size="2">As</font><font size="2"> MgFeatureCommandCollection = </font><font color="#0000ff" size="2">New</font><font size="2"> MgFeatureCommandCollection()
<p></p></font><font color="#008000" size="2">commands.Add(insertFeatures2)
<p></p></font><font size="2">
<p></p>
<p>myLayer.UpdateFeatures(commands)</p>
<p></p>
<p></p></font><font color="#008000" size="2">
<p></p></font><font size="2">
<p></p></font><font size="2">
<p></p>
<p></p></font><font color="#008000" size="2">
<p></p></font><font size="2">
<p></p>
<p></p>
<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">
<p></p></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 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">>
<p></p></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">>
<p></p></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">/>
<p></p></font><font size="2"> </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">script</font><font size="2"> </font><font color="#ff0000" size="2">type</font><font color="#0000ff" size="2">="text/javascript">
<p></p></font><font size="2"><font size="2">
<p></p></font><font color="#0000ff" size="2">function</font><font size="2"> refresh()
<p>{</p>
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().GetLayers(true,true);
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetScriptFrame().location.href = "essai.aspx";
<p></p></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);
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().ExecuteMapAction(1);
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetTaskFrame().location.href = "essai.aspx"
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetScriptFrame().location.href = "essai.aspx"
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().ExecuteMapAction(20);
<p> </p>
<p></p></font><font size="2">
<p></p></font><font color="#008000" size="2">//carte.GetMapFrame().ExecuteMapAction(20);
<p></p></font><font size="2">
<p>}</p>
<p></p></font></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">
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">
<p></p></font><font size="2"><font color="#0000ff" size="2">
<p>Public</p></font><font size="2"></font><font color="#0000ff" size="2">Function</font><font size="2"> makeLine2(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> Name </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> x0 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> y0 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> x1 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> y1 </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">) </font><font color="#0000ff" size="2">As</font><font size="2"> MgPropertyCollection
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> PropertyCollection2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgPropertyCollection = </font><font color="#0000ff" size="2">New</font><font size="2"> MgPropertyCollection()
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> nameProperty2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgInt32Property = </font><font color="#0000ff" size="2">New</font><font size="2"> MgInt32Property(</font><font color="#800000" size="2">"ID"</font><font size="2">, 1)
<p>PropertyCollection2.Add(nameProperty2)</p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> wktReaderWriter2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgWktReaderWriter = </font><font color="#0000ff" size="2">New</font><font size="2"> MgWktReaderWriter()
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> agfReaderWriter2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgAgfReaderWriter = </font><font color="#0000ff" size="2">New</font><font size="2"> MgAgfReaderWriter()
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> geometry2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgGeometry = wktReaderWriter2.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">)
<p></p>
<p></p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> geometryByteReader2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgByteReader = agfReaderWriter2.Write(geometry2)
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> geometryProperty2 </font><font color="#0000ff" size="2">As</font><font size="2"> MgGeometryProperty = </font><font color="#0000ff" size="2">New</font><font size="2"> MgGeometryProperty(</font><font color="#800000" size="2">"SHPGEOM"</font><font size="2">, geometryByteReader2)
<p>PropertyCollection2.Add(geometryProperty2)</p>
<p></p></font><font color="#0000ff" size="2">Return</font><font size="2"> PropertyCollection2
<p></p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Function</font>
<p></p>
<p></p>
<p></p></font><font color="#0000ff" size="2">Function</font><font size="2"> DoesLayerExist(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> LayerName </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> Map </font><font color="#0000ff" size="2">As</font><font size="2"> MgMap) </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Boolean
<p></p></font><font size="2">
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> layers </font><font color="#0000ff" size="2">As</font><font size="2"> MgLayerCollection = Map.GetLayers()
<p></p></font><font color="#0000ff" size="2">Return</font><font size="2"> (layers.Contains(LayerName))
<p></p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Function
<p></p></font><font size="2">
<p></p>
<p></p></font><font color="#0000ff" size="2">Function</font><font size="2"> LoadTemplate2(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> filePath </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2">) </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String
<p></p></font><font size="2">
<p></p>
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> sr </font><font color="#0000ff" size="2">As</font><font size="2"> StreamReader = File.OpenText(filePath)
<p></p></font><font color="#0000ff" size="2">Dim</font><font size="2"> template </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">String</font><font size="2"> = sr.ReadToEnd()
<p></p></font><font color="#0000ff" size="2">Return</font><font size="2"> template
<p></p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Function
<p> </p>
<p></p></font><font size="2">
<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>
<p></p></font><font size="2">
<p></p>
<p></p></font><font color="#0000ff" size="2">
<p></</p></font><font color="#800000" size="2">html</font><font color="#0000ff" size="2">>
<p></p></font>
<div class="im"> <br> <br>
<hr width="90%" size="4">
<br>_______________________________________________<br>mapguide-users mailing list<br><a href="mailto:mapguide-users@lists.osgeo.org" target="_blank">mapguide-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a><br>
</div></div>
<div>
<div></div>
<div class="h5">
<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>_______________________________________________<br>mapguide-users mailing list<br><a href="mailto:mapguide-users@lists.osgeo.org" target="_blank">mapguide-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a><br><br></blockquote></div><br></div></div></blockquote></div><br>