<div>i want create temporary layer too wich contains polygone this is what i do, idon&#39;t see layer after refreshing map (on iframe) and when i use mapguide studio for see the layer i find layer but it doesn&#39;t contain polygon i insert, pleaaase correct me my code if you can,i give it you:</div>

<div> </div>
<div>
<div>as cordinates i pass </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:  </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(&quot;GEOM&quot;, agf.Write(poly)))</div>
<div> </div>
<div> i can&#39;t see the layer i add after refreshing map (conntained in &lt;iframe&gt;)for saying layer i use mapguide studio where i see the layer wich doesn&#39;t contain the polygon, may be pro in type of geometry i give or another, i&#39;ll give all complete code it will help you see my error and help me if you can, i&#39;ve spent a lot of time at that but i don&#39;t see my error and why even i add layer in map i don&#39;t see it and when i see it using mapguide studio it doesn&#39;t contain polygone i insert.i have even tested to insert polygone with text shape ((&quot;POLYGON XY ((0 0, 2 0, 2 2, 0 2, 0 0))&quot; in function makeLine2() as you see)but it doesn&#39;t run too.i don&#39;t know what do, please help me if you can do it. Thanks a lot in advance.</div>

<div> </div>
<div> </div>
<div>&lt;%@ Page Language=&quot;VB&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;essai.aspx.vb&quot; <br>Inherits=&quot;essai&quot; %&gt;<br>&lt;%@ Import Namespace=&quot;System&quot; %&gt;<br>&lt;%@ Import Namespace=&quot;System.IO&quot; %&gt;<br>
&lt;%@ Import Namespace=&quot;System.Collections.Specialized&quot; %&gt;<br>&lt;%@ Import Namespace=&quot;OSGeo.MapGuide&quot; %&gt;<br>&lt;%@ Import Namespace=&quot;System.Text&quot; %&gt;<br>&lt;%@ Import Namespace=&quot;System.Globalization&quot; %&gt;</div>

<div> </div>
<div>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; <br>&quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&quot;&gt;</div>

<div> </div>
<div>&lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&quot; &gt;<br>&lt;head id=&quot;Head1&quot; runat=&quot;server&quot;&gt;<br>    &lt;title&gt;selection&lt;/title&gt;<br>   <br>
&lt;/head&gt;<br>&lt;body&gt;</div>
<div>&lt;br /&gt;<br> &lt;%<br>     <br>          <br>        Dim sessionid1 As String<br>     Dim siteConnection As MgSiteConnection<br>     Dim resourceSrvc As MgResourceService<br>     Dim myLayerName As String = &quot;line9&quot;<br>
     Dim mapname As String = &quot;Sheboygan&quot;<br>     Dim map As MgMap<br>     Dim featureSrvc As MgFeatureService<br>     Dim myLayer As MgLayer<br>     </div>
<div>     Dim configPath As String = &quot;C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\webconfig.ini&quot;<br>     MapGuideApi.MgInitializeWebTier(configPath)<br>     Dim site1 As MgSite = New MgSite()<br>
     Dim userInfo As MgUserInformation = New MgUserInformation(&quot;Administrator&quot;, &quot;admin&quot;)<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 = &quot;utf-8&quot;<br>     Dim layerDef As String = &quot;Library://Samples/Sheboygan/Layers/&quot; + myLayerName + &quot;.LayerDefinition&quot;<br>     Dim layerDefId As MgResourceIdentifier = New MgResourceIdentifier(layerDef)<br>
     Dim dataSource As String = &quot;Library://Samples/Sheboygan/Data/&quot; + myLayerName + &quot;.FeatureSource&quot;<br>     Dim dataSourceId As MgResourceIdentifier = New MgResourceIdentifier(dataSource)<br>     Dim resourceID2 As MgResourceIdentifier = New MgResourceIdentifier(&quot;Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition&quot;)<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>         &#39;//create Feature Source<br>         myClassDef = New MgClassDefinition()<br>         myClassDef.SetName(&quot;line9&quot;)<br>         &#39;myClassDef.SetDescription(myLayerName + &quot; Feature Source&quot;)<br>
         &#39;myClassDef.SetDefaultGeometryPropertyName(&quot;SHPGEOM&quot;)</div>
<div>         &#39;Set KEY Property<br>         Dim prop As MgDataPropertyDefinition = New MgDataPropertyDefinition(&quot;KEY&quot;)<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>         &#39;Set ID Property<br>         prop = New MgDataPropertyDefinition(&quot;ID&quot;)<br>         prop.SetDataType(MgPropertyType.Int32)<br>         myClassDef.GetProperties().Add(prop)<br>          <br>        <br>
         &#39;et geometry property<br>         Dim geomProp As MgGeometricPropertyDefinition = New MgGeometricPropertyDefinition(&quot;GEOM&quot;)<br>         geomProp.SetGeometryTypes(MgFeatureGeometricType.Surface)<br>         geomProp.SetHasElevation(False)<br>
         geomProp.SetHasMeasure(False)<br>         geomProp.SetSpatialContextAssociation(&quot;LL84&quot;)<br>         myClassDef.GetProperties().Add(geomProp)<br>         &#39;myClassDef.SetDefaultGeometryPropertyName(&quot;SHPGEOM&quot;)</div>

<div>         &#39;Create the schema<br>         Dim schema As MgFeatureSchema = New MgFeatureSchema()<br>         schema.SetName(&quot;SHP_Shema&quot;)<br>         schema.GetClasses().Add(myClassDef)<br>     </div>
<div>         Dim sdfParams As MgCreateSdfParams = New MgCreateSdfParams(&quot;MGA-56 (GDA94 /MGA zone 56)&quot;, map.GetMapSRS(), schema)</div>
<div>         featureSrvc.CreateFeatureSource(dataSourceId, sdfParams)</div>
<div><br>        <br>         <br>         Dim content As MgByteSource = New MgByteSource(&quot;C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\createpoint\LayerDefinition.xml&quot;)<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>         &#39;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> %&gt;</div>
<div>&lt;div id=&quot;viewer&quot;&gt;<br> &lt;iframe id=&quot;carte&quot; width=&quot;800&quot; height=&quot;300&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;<a href="http://localhost/mapguide2008/mapviewerajax/?SESSION=&lt;%=sessionid1">http://localhost/mapguide2008/mapviewerajax/?SESSION=&lt;%=sessionid1</a> %&gt;&amp;WEBLAYOUT=Library%3a%2f%2fSamples%2fSheboygan%2fLayouts%2fSheboyganAsp.WebLayout&quot; name=&quot;fenetre&quot;&gt;&lt;/iframe&gt;<br>
 &lt;/div&gt;<br> &lt;br /&gt;<br> &lt;div&gt; <br>&lt;input type=&quot;button&quot; value=&quot;zoom&quot; name=&quot;zoom&quot; onclick=&quot;zoom()&quot;/&gt;<br>&lt;/div&gt;<br>&lt;br /&gt;<br>&lt;div&gt; <br>&lt;input type=&quot;button&quot; value=&quot;rafraichir&quot; name=&quot;calque&quot; onclick=&quot;testcalque();&quot;/&gt;<br>
&lt;/div&gt;</div>
<div><br>&lt;/body&gt;<br>&lt;script type=&quot;text/javascript&quot;&gt;</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 = &quot;essai.aspx&quot;;<br>   frames[&#39;fenetre&#39;].location.reload();<br>    carte.GetMapFrame().Refresh();<br>    //carte.ExecuteMapAction(20); <br>
    //carte.GetMapFrame().ExecuteMapAction(1); <br>    //carte.GetTaskFrame().location.href = &quot;essai.aspx&quot; <br>    //carte.GetScriptFrame().location.href = &quot;essai.aspx&quot; </div>
<div>    //carte.GetMapFrame().ExecuteMapAction(20);</div>
<div><br>    //carte.GetMapFrame().ExecuteMapAction(20); </div>
<div>    }<br>     <br>    <br>&lt;/script&gt;</div>
<div><br>&lt;script runat=&quot;server&quot;&gt;<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(&quot;GEOM&quot;, 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(&quot;ID&quot;, 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(&quot;POLYGON XY ((0 0, 2 0, 2 2, 0 2, 0 0))&quot;)<br>    <br>    <br>        Dim geometryByteReader2 As MgByteReader = agfReaderWriter2.Write(geometry2)<br>
        Dim geometryProperty2 As MgGeometryProperty = New MgGeometryProperty(&quot;GEOM&quot;, 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>&lt;/script&gt;</div>
<div> </div>
<div> </div>
<div> <br>&lt;/html&gt;<br></div>
<div> </div>
<div><br><br> </div>
<div class="gmail_quote">2009/5/11 javed shaikh <span dir="ltr">&lt;<a href="mailto:jaspune@hotmail.com">jaspune@hotmail.com</a>&gt;</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>&gt; From: <a href="mailto:wakrimsaloua.wakrim@gmail.com" target="_blank">wakrimsaloua.wakrim@gmail.com</a><br>&gt; To: <a href="mailto:jaspune@hotmail.com" target="_blank">jaspune@hotmail.com</a><br>&gt; Subject: please help me if you can<br>
&gt; Date: Sat, 9 May 2009 04:13:56 -0700<br>&gt; <br>&gt; hi, i&#39;ve the same prob that you have, but i can&#39;t resolve it, i use this code for drawning polygon ,but it doesn&#39;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>
&gt; <br>&gt; If (DoesLayerExist(myLayerName, map) = False) Then<br>&gt; <br>&gt; <br>&gt; &#39;//create Feature Source<br>&gt; Dim myClassDef As MgClassDefinition = New MgClassDefinition()<br>&gt; myClassDef.SetName(&quot;saloua3&quot;)<br>
&gt; &#39;myClassDef.SetDescription(myLayerName + &quot; Feature Source&quot;)<br>&gt; myClassDef.SetDefaultGeometryPropertyName(&quot;SHPGEOM&quot;)<br>&gt; <br>&gt; &#39;Set KEY Property<br>&gt; Dim prop As MgDataPropertyDefinition = New MgDataPropertyDefinition(&quot;KEY&quot;)<br>
&gt; prop.SetDataType(MgPropertyType.Int32)<br>&gt; prop.SetAutoGeneration(True)<br>&gt; prop.SetReadOnly(True)<br>&gt; prop.SetNullable(False)<br>&gt; myClassDef.GetProperties().Add(prop)<br>&gt; myClassDef.GetIdentityProperties().Add(prop)<br>
&gt; <br>&gt; &#39;Set ID Property<br>&gt; prop = New MgDataPropertyDefinition(&quot;ID&quot;)<br>&gt; prop.SetDataType(MgPropertyType.Int32)<br>&gt; myClassDef.GetProperties().Add(prop)<br>&gt; <br>&gt; &#39;add poly<br>
&gt; <br>&gt; Dim poly As MgPolygon<br>&gt; Dim geomfactory As MgGeometryFactory = New MgGeometryFactory()<br>&gt; Dim coordcol As MgCoordinateCollection = New MgCoordinateCollection()<br>&gt; Dim j As Integer<br>&gt; For j = 0 To 3<br>
&gt; Dim coord As MgCoordinate = geomfactory.CreateCoordinateXY(x(j), y(j))<br>&gt; coordcol.Add(coord)<br>&gt; <br>&gt; Next<br>&gt; Dim outring As MgLinearRing = geomfactory.CreateLinearRing(coordcol)<br>&gt; poly = geomfactory.CreatePolygon(outring, Nothing)<br>
&gt; Dim agf As MgAgfReaderWriter = New MgAgfReaderWriter()<br>&gt; <br>&gt; &#39;Dim geom As MgByteReader = geometryReaderWriter.Write(poly)<br>&gt; properties = New MgPropertyCollection()<br>&gt; properties.Add(New MgGeometryProperty(&quot;GEOM&quot;, agf.Write(poly)))<br>
&gt; <br>&gt; &#39;et geometry property<br>&gt; Dim geomProp As MgGeometricPropertyDefinition = New MgGeometricPropertyDefinition(&quot;SHPGEOM&quot;)<br>&gt; geomProp.SetGeometryTypes(MgFeatureGeometricType.Curve)<br>&gt; geomProp.SetHasElevation(False)<br>
&gt; geomProp.SetHasMeasure(False)<br>&gt; geomProp.SetSpatialContextAssociation(&quot;LL84&quot;)<br>&gt; myClassDef.GetProperties().Add(geomProp)<br>&gt; myClassDef.SetDefaultGeometryPropertyName(&quot;SHPGEOM&quot;)<br>
&gt; <br>&gt; &#39;Create the schema<br>&gt; Dim schema As MgFeatureSchema = New MgFeatureSchema()<br>&gt; schema.SetName(&quot;SHP_Shema&quot;)<br>&gt; schema.GetClasses().Add(myClassDef)<br>&gt; <br>&gt; <br>&gt; Dim sdfParams As MgCreateSdfParams = New MgCreateSdfParams(&quot;MGA-56 (GDA94 /MGA zone 56)&quot;, map.GetMapSRS(), schema)<br>
&gt; <br>&gt; featureSrvc.CreateFeatureSource(dataSourceId, sdfParams)<br>&gt; <br>&gt; <br>&gt; &#39;Dim layerDefContent As MgByteReader = BuildLayerDefinitionContent(dataSource, &quot;SHP_Shema:linetestvb4&quot;, &quot;&quot;, &quot;5&quot;, &quot;F000F&quot;)<br>
&gt; &#39;resourceSrvc.SetResource(layerDefId, layerDefContent, nothing)<br>&gt; <br>&gt; Dim content As MgByteSource = New MgByteSource(&quot;C:\Program Files\Autodesk\MapGuideEnterprise2008\WebServerExtensions\www\testvb\LayerDefinition.xml&quot;)<br>
&gt; resourceSrvc.SetResource(layerDefId, content.GetReader(), Nothing)<br>&gt; <br>&gt; Dim myLayer As MgLayer = New MgLayer(layerDefId, resourceSrvc)<br>&gt; myLayer.SetName(myLayerName)<br>&gt; myLayer.SetLegendLabel(&quot;legend&quot; + myLayerName)<br>
&gt; myLayer.SetDisplayInLegend(True)<br>&gt; myLayer.SetSelectable(True)<br>&gt; map.GetLayers().Insert(0, myLayer)<br>&gt; &#39;map.GetLayers().Add(myLayer) <br>&gt; myLayer.ForceRefresh()<br>&gt; map.Save(resourceSrvc)<br>
&gt; Dim insertFeatures As MgInsertFeatures = New MgInsertFeatures(myLayerName, properties)<br>&gt; Dim commands As MgFeatureCommandCollection = New MgFeatureCommandCollection()<br>&gt; commands.Add(insertFeatures)<br>&gt; Dim commandIndex As Integer = commands.IndexOf(insertFeatures)<br>
&gt; <br>&gt; Dim insertResults As MgPropertyCollection<br>&gt; <br>&gt; insertResults = featureSrvc.UpdateFeatures(dataSourceId, commands, False)<br>&gt; End If<br><br><br><br></div></blockquote></div></div>
<div class="gmail_quote">2009/5/8 adnanc <span dir="ltr">&lt;<a href="mailto:adnan.chughtai@keynetix.com">adnan.chughtai@keynetix.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>Hello all,<br><br>I&#39;ve created a temporary map layer in the session, which appears fine on the<br>
map, however it is added as the top most layer.  I believe this is the<br>default behaviour.<br><br>Any ideas as to how I can modify its draw order priority? Modify the<br>MapDefinition document?<br><br>Regards,<br><br>Adnan<br>
<font color="#888888">--<br>View this message in context: <a href="http://n2.nabble.com/Changing-Draw-Order-Priority-of-a-Temporary-Layer-tp2845838p2845838.html" target="_blank">http://n2.nabble.com/Changing-Draw-Order-Priority-of-a-Temporary-Layer-tp2845838p2845838.html</a><br>
Sent from the MapGuide Users mailing list archive at Nabble.com.<br><br>_______________________________________________<br>mapguide-users mailing list<br><a href="mailto:mapguide-users@lists.osgeo.org">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></font></blockquote></div><br>