Working With the Active Selection

Whenever a selection is changed by the Viewer, the selection information is sent to the Web server so the map can be re-generated.

To retrieve and manipulate the active selection for a map:

  1. Create an MgSelection object for the map. Initialize it to the active selection.
  2. Retrieve selected layers from the MgSelection object.
  3. For each layer, retrieve selected feature classes. There will normally be one feature class for the layer, so you can use the MgSelection::GetClass() method instead of the MgSelection::GetClasses() method.
  4. Call MgSelection::GenerateFilter() to create a selection filter that contains the selected features in the class.
  5. Call MgFeatureService::SelectFeatures() to create an MgFeatureReader object for the selected features.
  6. Process the MgFeatureReader object, retrieving each selected feature.