Autodesk MapGuide Enterprise Developer
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Set Active Selection From MapFrame
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
286 Views, 1 Replies
02-25-2013 11:00 PM
hi everyone;
I added some code to mapFrame file to set active selection. Bu It doesnt work
map.Create(resourceSrvc, resId, mapName);
//create an empty selection object and store it in the session repository
MgSelection sel;
string layerId = "";
string classId = "";
StringBuilder selectionXml = new StringBuilder();
MgLayerCollection layers = map.GetLayers();
foreach (MgLayerBase layer in layers)
{
if (layer.GetName() == "Parcels")
{
layerId = layer.GetObjectId();
classId = layer.FeatureClassName;
selectionXml.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><FeatureSet><Layer id=\"");
selectionXml.Append(layerId);
selectionXml.Append("\"><Class id=\"");
selectionXml.Append(classId);
selectionXml.Append("\"><ID>");
selectionXml.Append("LDMAAA==");
selectionXml.Append("</ID>");
selectionXml.Append("</Class>");
selectionXml.Append("</Layer>");
selectionXml.Append("</FeatureSet>");
break;
}
}
sel = new MgSelection(map,selectionXml.ToString());
sel.Save(resourceSrvc, mapName);I got an Xml String with GetSelectionXml which I select with mouse, And I write the same xml file into mapFrame,
But I cant select the same parcel why it didnt work ?
good works
Re: Set Active Selection From MapFrame
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-03-2013 04:48 PM in reply to:
AliKara1
For dumping a MgSelection out to XML, just call:
MgSelection sel = ... String selectionXml = sel.ToXml();
For initializing a MgSelection, if you use this constructor:
MgSelection(MgMap map, String xmlSelectionString)
Your MgSelection will be initialized with the selection based on the XML string you feed into it, eliminating the need to construct this XML fragment yourself.
You should never have to manually construct this selection XML yourself.
- Jackie
