Autodesk 15606-011408-9300 Developer Guide - Page 166
DWG Filtering Application Example Code, Selection Changed Function (selChanged)
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 166 highlights
DWG Filtering Application Example Code This example illustrates some basic tasks an application can perform when working with DWG data. It primarily focuses on setting DWG filters and getting DWG data, but it can easily be modified to change other Autodesk MapGuide map layer properties, such as the DWG file, the DWG data source, and so on. In this example, DWG processing is performed on a map with a single Autodesk MapGuide map layer called Floor Plan. Processing is performed by two functions: selChanged() and showProperties(). The operational flow of these functions is described in the following sections. To see the full source code for this example, choose Help ➤ Contents ➤ Examples Advanced ➤ Filter DWG Layers in the Autodesk MapGuide Viewer API Help. When the application loads, click the view source link in the right frame. Selection Changed Function (selChanged) The following are excerpts from the selChanged() function. This function is called when a user selects or deselects one or more DWG filters from a list box displayed on the map page. This function sets the layer filter of the DWG map layer to layers selected by the user. The basic operational flow of this function is as follows: 1 Use the getMap function, the current map is assigned to the variable map. 2 Use the map.getMapLayer method to get the map's single map layer named Floor Plan. Assign the map layer to a variable called mapLayer. 3 Get the DWG data source object for the layer by first getting the layer setup using mapLayer.getLayerSetup, and then using the layer setup to get the DWG data sources object of the layer using mapLayerSetup.getDwgDataSources. 4 Use map.createObject("MGCollection")to create a collection object called mapDwgLayerFilters. This object will hold filters selected by the user from the filters list box. 5 Iterate through list box selections and add each to the collection object mapDwgLayerFilters. 6 Create a comma-delimited string named filterList containing selected filters. Note that the setLayerFilter method used next expects a comma-delimited string of filters. 166 | Chapter 7 Applications