Retrieving Selected-Feature Information

If feature selection was performed by the user, via mouse modes with isSynchronous = TRUE, the client can obtain the index of the view in which the user made the selection, via getRespondingViewIndex. If feature selection was performed by the user, via mouse modes with isSynchronous = FALSE, the index of of the responding view is passed as an argument to the client-side method.  The client can obtain the ViewAPI instance corresponding to the index via ViewMngrAPI.getViewWithIndex.  If feature selection was performed by the client directly via ViewAPI.selectFeature, the client already has the the view.  Once the client has the responding view, it can identify the selected feature as follows:

  1. Obtain the corresponding MapAPI instance, via ViewAPI.getMapAPI.
  2. Obtain a list of the unique IDs of the selected features, via MapAPI.getSelectedFeatures.

The approach is demonstrated by the following Visual C++ code snippet:

  1. IMapAPI mapAPI;

  2. mapAPI.m_lpDispatch = vwAPI.getMapAPI();

  3. CString featureIds = mapAPI.getSelectedFeatures();

Additional information may then be obtained about a selected feature, using MapAPI.querySelectionByName or MapAPI.querySelectionByIndex.  If either of these returns the empty string, i.e. "", no feature has been selected.