Setting the Active Aelection with .Net

meli-m meli-m at arcor.de
Tue Oct 10 09:55:15 EDT 2006


Based on the example in the Developer' Guide on page 45-48 I create an
aspx-file with following code to select a parcel by a given key.
Unfortunately nothing is selected in the map. So what's wrong with my code?
I am exspecially not sure about how the xml-file with the selection is
passed to the map. 



<%      Response.Charset = "utf-8";

        GetRequestParameters();
        mapName = "New Map";

        InitializeWebTier();

        MgUserInformation cred = new MgUserInformation(sessionId);
        MgSiteConnection site = new MgSiteConnection();
        site.Open(cred);

        MgFeatureService featureSrvc =
site.CreateService(MgServiceType.FeatureService) as MgFeatureService;
        MgResourceService resourceSrvc =
site.CreateService(MgServiceType.ResourceService) as MgResourceService;
        MgRenderingService renderingSrvc =
site.CreateService(MgServiceType.RenderingService) as MgRenderingService;

        MgMap map = new MgMap();
        map.Open(resourceSrvc, mapName);

        MgLayerCollection layers = map.GetLayers();
        string name = "ALK_Nutzungen";
        MgLayer layer = layers.GetItem(name);

        MgFeatureQueryOptions query = new MgFeatureQueryOptions();
        query.SetFilter("Key LIKE '3966/000 at 3970'");


        string featureClass = layer.GetFeatureClassName();
        
        MgResourceIdentifier featureSource = new
MgResourceIdentifier(layer.GetFeatureSourceId());
        MgFeatureReader features = featureSrvc.SelectFeatures(featureSource,
featureClass, query);

        MgSelection sel = new MgSelection(map);

        
        sel.AddFeatureIdInt32(layer, featureClass, 0);


        Response.AddHeader("Content-type", "text/xml");
        selectionXml = sel.ToXml();

%>

Additional I have a Javascript function: 

    function OnPageLoad()
    {
        parent.parent.SetSelectionXML(selectionXml);
    }


The xml-file looks like this:

 <?xml version="1.0" encoding="UTF-8" ?> 
- <FeatureSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="FeatureSet-1.0.0.xsd">
- <Layer id="b9410078-ffff-ffff-8000-00142ab4c581">
- <Class id="SDF_2_Schema:ALK_Nutzungen">
  <ID>AAAAAA==</ID> 
  </Class>
  </Layer>
  </FeatureSet>






Thanks in advance to all,


Melanie
-- 
View this message in context: http://www.nabble.com/Setting-the-Active-Aelection-with-.Net-tf2416837.html#a6736960
Sent from the OSGeo MapGuide mailing list archive at Nabble.com.





More information about the Mapguide-users mailing list