hi! i draw polygones in layer and i want know how can i return the id of polygone selected by user, if you have some ideas please suggest it me, i've trough to use getselection but i don't know if it's the good method or not!!<br>
<br>
<div class="gmail_quote">2009/5/11 Kenneth Skovhede, GEOGRAF A/S <span dir="ltr"><<a href="mailto:ks@geograf.dk">ks@geograf.dk</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div text="#000000" bgcolor="#ffffff">Yes, that looks right.<br><br>You must also refresh the map (refresh/pan/zoom/etc.) in the browser via javascript.<br><br>In addition to my other suggestions, you can also check the error log for messages.
<div>
<div></div>
<div class="h5"><br><pre cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre><br><br>saloua wakrim skrev:
<blockquote type="cite">
<div>hi! please i want know if this code is that what all i must do for adding new layer to map and see it in viewer frame or i must do some relation with the feature source i create in my code?? thanks on advance</div>
<div> </div>
<div><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">)
<p>map.GetLayers().Insert(0, myLayer)</p></font><font size="2">
<p>myLayer.ForceRefresh()</p></font><font size="2">map.Save(resourceSrvc)</font><br><br></div>
<div class="gmail_quote">2009/5/10 Kenneth Skovhede, GEOGRAF A/S <span dir="ltr"><<a href="mailto:ks@geograf.dk" target="_blank">ks@geograf.dk</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<div text="#000000" bgcolor="#ffffff">The code looks alright.<br>Do you refresh the map afterwards?<br>What is in the "insertResults" ? <br>(There can be a hidden error, due to a bug in MapGuide)<br>Are you sure that the LayerDefinition matches the FeatureSource?<br>
Try to create the FeatureSource and LayerDefinition in "Library://" instead,<br>so you can examine the layer from Studio/Maestro.<br><pre cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre><br><br>saloua wakrim skrev:
<blockquote type="cite">
<div>
<div>
<div>i try the following code for displaying layer wich contains line in map, so i digitize a line, create temporary feature for this line, create a layer wich contains it and add it to the map. it doesn't give me some error but i can see the line in the map (i can draw it). Please help me. the code is following:</div>
<div> </div>
<div> <font color="#008080" size="2">
<p>String</p></font><font size="2">dataSource = </font><font color="#800000" size="2">"Session:"</font><font size="2"> + sessionid1 + </font><font color="#800000" size="2">"//"</font><font size="2"> + myLayerName + </font><font color="#800000" size="2">".FeatureSource"</font><font size="2">; </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); </font><font color="#008080" size="2">MgFeatureService</font><font size="2"> featureSrvc = (</font><font color="#008080" size="2">MgFeatureService</font><font size="2">)siteConnection.CreateService(</font><font color="#008080" size="2">MgServiceType</font><font size="2">.FeatureService); </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 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(myLayerName);</p>
<p>myClassDef.SetDescription(myLayerName + </p></font><font color="#800000" size="2">" Feature Source"</font><font size="2">);
<p>myClassDef.SetDefaultGeometryPropertyName(</p></font><font color="#800000" size="2">"SHPGEOM"</font><font size="2">); </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>myClassDef.GetIdentityProperties().Add(prop);</p>
<p>myClassDef.GetProperties().Add(prop);</p>
<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></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>myClassDef.GetProperties().Add(geomProp);</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">(myLayerName + </font><font color="#800000" size="2">"Schema"</font><font size="2">, myLayerName + </font><font color="#800000" size="2">"SchemaDesc"</font><font size="2">);
<p>schema.GetClasses().Add(myClassDef);</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></font><font color="#008000" size="2">//create layer </font><font color="#008000" size="2">//String layerDef = "Session:" + sessionid1 + "//" + myLayerName + ".LayerDefinition";</font><font size="2"> </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">(</font><font color="#800000" size="2">"Library://essaicalque/Redline.LayerDefinition"</font><font size="2">);
<p> </p>
<p> </p></font><font color="#008080" size="2">MgByteSource</font><font size="2"> content = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#008080" size="2">MgByteSource</font><font size="2">(</font><font color="#800000" size="2">@"C:\Program Files\MapGuideOpenSource\WebServerExtensions\www\essaiselect2\Layerdef.xml"</font><font size="2">);
<p>resourceSrvc.SetResource(layerDefId, content.GetReader(), </p></font><font color="#0000ff" size="2">null</font><font size="2">); </font><font color="#008000" size="2">//code enlev‚ d'ici: ajouter layer resource … la carte</font><font size="2"> </font><font color="#008000" size="2">//il faut ajouter l'autre code: add layer resource to map</font><font size="2"> </font><font color="#008000" size="2">//DOMDocument domdoc = new DOMdocument();</font><font size="2"> </font><font color="#008080" size="2">MgLayer</font><font size="2"> result=add_layer_resource_to_map(layerDefId,resourceSrvc,myLayerName,myLayerName,map);
<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)); </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></font><font color="#0000ff" size="2">int</font><font size="2"> commandIndex = commands.IndexOf(insertFeatures); </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">); </font><font color="#008080" size="2">MgLayer</font><font size="2"> myLayer1 = map.GetLayers().GetItem(myLayerName) </font><font color="#0000ff" size="2">as</font><font size="2"> </font><font color="#008080" size="2">MgLayer</font><font size="2">;
<p>myLayer1.ForceRefresh();</p>
<p> </p></font><font color="#008000" size="2">//commands.Add(new MgInsertFeatures(myLayerName,makeLine("1", x0, y0, x1, y1)));
<p> </p></font><font size="2">
<p>map.Save(resourceSrvc); </p>
<p> </p><font color="#0000ff" size="2">
<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"> </font><font color="#008080" size="2">Boolean</font><font size="2"> result; </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">Double</font><font size="2"> x0, </font><font color="#008080" size="2">Double</font><font size="2"> y0, </font><font color="#008080" size="2">Double</font><font size="2"> x1, </font><font color="#008080" size="2">Double</font><font size="2"> y1)
<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">(); </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></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">(); </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">(); </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">; </font><font color="#008000" size="2">//MgGeometry geometry = wktReaderWriter.Read("LINESTRING(3 4,10 50,20 25)") as MgLineString; </font><font color="#008080" size="2">MgByteReader</font><font size="2"> geometryByteReader = agfReaderWriter.Write(geometry); </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></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></font><font color="#008080" size="2">MgLayerCollection</font><font size="2"> layers = Map.GetLayers();
<p>result = (layers.Contains(myLayerName));</p></font><font color="#0000ff" size="2">return</font><font size="2"> result;
<p>}</p></font><font color="#008080" size="2">MgLayer</font><font size="2"> add_layer_resource_to_map(</font><font color="#008080" size="2">MgResourceIdentifier</font><font size="2"> layerresourceid, </font><font color="#008080" size="2">MgResourceService</font><font size="2"> rs, </font><font color="#008080" size="2">String</font><font size="2"> layername, </font><font color="#008080" size="2">String</font><font size="2"> layerlegendlabel, </font><font color="#008080" size="2">MgMap</font><font size="2"> map)
<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">(layerresourceid, rs);
<p>myLayer.SetName(layername);</p>
<p>myLayer.SetLegendLabel(layerlegendlabel);</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">true</font><font size="2">);
<p> </p></font><font color="#0000ff" size="2">if</font><font size="2"> (!map.GetLayers().Contains(layername))
<p>{</p>
<p>map.GetLayers().Insert(0, myLayer);</p>
<p>}</p>
<p>myLayer.SetVisible(</p></font><font color="#0000ff" size="2">true</font><font size="2">);
<p>myLayer.ForceRefresh();</p>
<p>map.Save(resourceSrvc);</p></font><font color="#0000ff" size="2">return</font><font size="2"> myLayer;
<p>}</p></font><font color="#0000ff" size="2">
<p></</p></font><font color="#800000" size="2">script</font><font color="#0000ff" size="2">></font>
<p> </p>
<p> </p>
<p> </p></font></div></div></div><pre><hr width="90%" size="4">
_______________________________________________
mapguide-users mailing list
<a href="mailto:mapguide-users@lists.osgeo.org" target="_blank">mapguide-users@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
</pre></blockquote></div><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><pre><hr width="90%" size="4">
_______________________________________________
mapguide-users mailing list
<a href="mailto:mapguide-users@lists.osgeo.org" target="_blank">mapguide-users@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
</pre></blockquote></div></div></div><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>
<br></blockquote></div><br>