[mapguide-users] Selecting features on the server

Gunter Becker gunter.becker at csogis.de
Thu Apr 8 09:06:38 EDT 2010

Hi everyone,

I'm dealing with selecting features serverside and then dislpay the seletion
on the map. First of all let me say that I have a solution that works but
I'm wondering about the client side code to display the selection.

If the current selection (before adding new features) has one or more
features then it is sufficient to just refresh the map to show the new
selection. But if no feature is in the selection before adding new features
then selection has no result afterwards, although the features were added to
the selection.

The solution that works for me is to pass the "SelectionXml" from
selection.ToXml()-methode and use the Ajax-Viewer method "SetSelectionXML".
But this seems to me like a double- (or even multiple-) roundtrip to the
server. I don't like it! Is it because of the architecture of the

Maybe I have forgotten something in my serverside code to deal with an empty
selection before adding features. Has anyone find a solution for this!

Thanks, Gunter

Here is my code

    // set queryoptions
    MgFeatureQueryOptions queryOptions = new MgFeatureQueryOptions();
    queryOptions.SetFilter("SDFKEY IN ('" + attrString + "')")

    // select features
    MgFeatureReader featureReader =
featureService.SelectFeatures(featureSource, featureClassName,

    // get current selection
    MgMap map = csoMgr.GetCurrentMgMap();
    MgLayerBase layer = map.GetLayers().GetItem("parcels");
    MgSelection sel = new MgSelection(map);
    sel.Open(resourceService, csoMgr.MapName);

    // change selection and save 
    sel.AddFeatures(layer, featureReader, 0);
    sel.Save(resourceService, csoMgr.MapName);

View this message in context: http://n2.nabble.com/Selecting-features-on-the-server-tp4870900p4870900.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

More information about the mapguide-users mailing list