Developer's Guide - MapGuide Open Source - OSGeo
Developer's Guide - MapGuide Open Source - OSGeo
Developer's Guide - MapGuide Open Source - OSGeo
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
4 Initialize the MgSelection object with the list of features passed to the<br />
page.<br />
5 Retrieve selected layers from the MgSelection object.<br />
6 For each layer, retrieve selected feature classes. There will normally be<br />
one feature class for the layer, so you can use the<br />
MgSelection::GetClass() method instead of the<br />
MgSelection::GetClasses() method.<br />
7 Call MgSelection::GenerateFilter() to create a selection filter that<br />
contains the selected features in the class.<br />
8 Call MgFeatureService::SelectFeatures() to create an MgFeatureReader<br />
object for the selected features.<br />
9 Process the MgFeatureReader object, retrieving each selected feature.<br />
Example: Listing Selected Parcels (AJAX Viewer)<br />
To run the following example, view a map created with the sample data. Using<br />
one of the selection tools, select one or more parcels.<br />
NOTE The sample code below is not complete. You must perform standard<br />
initialization steps and exception trapping.<br />
The example creates a Resource Service connection to open the map and a<br />
Feature Service connection to read the feature information. In addition, you<br />
will require an MgFeatureQueryOptions object for creating the list of features.<br />
The MgSelection object contains selection information for a given map. It<br />
can either contain the current selection or a selection created from XML data.<br />
For this example, create the object with the current map selection.<br />
Get the list of layers and iterate through them. When the $layers collection<br />
is empty, there are no features selected.<br />
Working With the Active Selection | 47