<div>i want create temporary layer too wich contains polygone this is what i do, idon't see layer after refreshing map (on iframe) and when i use mapguide studio for see the layer i find layer but it doesn'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("GEOM", agf.Write(poly)))</div>
<div> </div>
<div> 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/8 adnanc <span dir="ltr"><<a href="mailto:adnan.chughtai@keynetix.com">adnan.chughtai@keynetix.com</a>></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'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>