Community
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
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