|
|
MapGuide API Extensions v5.0 |
Clip API ControlThe Clip API Control is an ActiveX component that extends the capability of the MapGuide Viewer API by enabling the development of applications that download vector and attribute data to the client's devices. The Control provides a set of public methods that enable the developer to:
When authoring maps, general or password access must be granted to the vertices of the layers which are to be eligible for output; refer to the layer's Security tab. If password access is granted, then the user will be prompted to enter the appropriate password when an object from the layer is selected for evaluation. This control requires the MapGuide SDF Component Toolkit DLL (sdfcomtk.dll) to be registered on the client's computer. The client must download the Toolkit from the Autodesk website (www.mapguide.com), install the Toolkit, and register the DLL by entering the following command in the Windows Run menu: C:\Windows\System\Regsvr32.exe C:\Program Files\Autodesk\SdfComTk4\Bin\sdfcomtk.dll Alternatively, you could permit the user to download the DLL from your website. Ensure that the version of the control that you use matches the version of the SDF Component Toolkit. The control appears as a clickable button:
The button may be sized through the BoxWidth and BoxHeight parameters while the label is set through the ButtonLabel parameter. Clicking on the button pulls up the Clip Api About Dialog:
The names of files that are currently opened are displayed in the dialog; this feature is commonly used for debugging purposes. An option is provided for closing a file; however, a warning is issued indicating that behaviour of the application may become unpredictable if a file is closed. The closing of files is provided for those applications that require the user to close the file, or when an error has occurred and the application is unable to close the file. The control provides two methods to open output files on the client's devices. The first method (saveFileDlg) calls presents the standard Windows File Selection dialog box, enabling the client to define the output filename. The second method (saveAsFile) allows an application to open a file without requesting a user-supplied filename, allowing the programmer to develop applications that open layer-specific files. The client is provided with an option to be notified when a file is opened if the file was not specified by the user through the standard Windows File Selection dialog. This option, which can only be set by the client, helps to prevent potential malicious damage through unauthorized file modification. If the client has requested to be notified and a saveAsFile call is made, then the following window is presented, defining the file that is about to be opened:
Loading the ControlInstructions for implementing the control on web pages are provided with the Toolkit documentation.
Parameters
Downloading Data to FilesOutput files are opened through the saveAsFile() and saveFileDlg() methods by designating a File Number:
When an SDF file is opened, an SIF file is also opened as well as an optional KIF file. After the SDF file has been opened, its header must be output with the writeSdfFileHeader() method before any objects can be written to it; this applies to files opened in either 'create' and 'append' modes. When an SHP file is opened for output, corresponding SHX and DBF files are opened as well. The header of SHP files, output via writeShpFileHeader(), requires specification of the type of objects to place in the file, as well as the extents of the file. Shapefiles may only contain one type of object; attempting to write an object not of the type specified in the SHP file's header will lead to unpredictable results and possible system lockup. For SDF and SHP files, it is important to bear in mind the types of coordinates that are being sent to the Control's methods. The application must always send coordinates to the Control in a consistent fashion, either in Mapping Coordinate System (MCS) units or in latitude/longitude. The application may be set up to output the coordinates in either MCS or latitude/longitude by setting the CoordConv parameter when the file header is output:
A variety of methods are provided for writing objects to SDF and SHP files:
The saving of the keys of objects that are written to the output file may be toggled on/off via setSaveKeys(). The switch should be toggled on prior to opening the output file, and toggeled off after closing the output file. The number of keys may be retrieved by getSavedKeyCount() in order to establish a loop so that the individual keys may be obtained through getSavedKey. The keys may then be passed to the server in order to download selected attributes from a database, which may then be written out to a text file. The keys remain saved until they are released through a call to freeSavedKeys(). The output of ASCII files is rather straightforward: the method writeTextRecord() outputs a user-supplied string to the text file, followed by a carriage return (x0D) and line feed (x0A). Before closing the text file, the number of objects output to the file may be obtained via a call to getNumberOfObjectsOutput().
MethodsA complete list of the public methods is provided with the Toolkit documentation. |
|||
| © 2002, Hunter GIS |