Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set Active Selection From MapFrame

1 REPLY 1
Reply
Message 1 of 2
AliKara1
759 Views, 1 Reply

Set Active Selection From MapFrame

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

1 REPLY 1
Message 2 of 2
jackie.ng
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report