CATEGORII DOCUMENTE |
Bulgara | Ceha slovaca | Croata | Engleza | Estona | Finlandeza | Franceza |
Germana | Italiana | Letona | Lituaniana | Maghiara | Olandeza | Poloneza |
Sarba | Slovena | Spaniola | Suedeza | Turca | Ucraineana |
ESRI MO 2.2 MO2 Helper Components
Usage Notes
1. Introduction
There are four helper component samples which are included with MapObjects 2.2. These consist of the Visual Basic source for 2 ActiveX controls and 2 ActiveX dll files, as well as a demonstration sample for each component. The components themselves may be used in conjunction with MapObjects2.2 to provide your application with a map legend and scalebar as well as various useful additional functions. The source is supplied in Visual Basic version 6.0 project files with one for each component. The four demonstration projects are also Visual Basic projects which give a simple example of how each of the components may be used.
Within the samples, although the source code is included, there are no compiled versions of the components themselves i.e. .ocx or .dll files. Therefore, the source may be compiled by developers themselves or, as in the demonstrator projects, simply referenced within a Visual Basic Project Group. This latter option may be very useful for stepping into the code while debugging. The source code for these components is supplied open so that developers may modify it to suit their own needs, it is also supplied un-supported.
[NB Although there are no compiled versions of the components included in the samples there are 2 helper component ocx files optionally installed with the other binary MapObjects files. These are MO21Legend.ocx and MO21Scalebar.ocx which are effectively the same as the Legend Component Sample and ScaleBar Component Sample source code except in name, version and guid. These are separate from the samples so that developers may make use of these components without there being a danger of other developers creating slightly different version of the same components, with the same name and guid. These compiled components are installed into the Common FilesESRI folder if the 'MapObjects Helper Components' option is selected during the install.]
The Helper Component Samples themselves are installed along with the other samples as follows:
Program filesesriMapObjects2SamplesSample MO2 Helper Components
LegendComponentSample
test.vbp [Legend Demo Project]
legend.vbg [Legend Project Group]
LegendSource
Samplelegend.vbp [Legend Source Project]
ScaleBarComponentSample
test.vbp [Scalebar Demo Project]
ScaleBar.vbg [ScaleBar Project Group]
ScaleBarSource
Scalebarcontrol.vbp [Legend Source Project]
CommonComponentSample
test.vbp [MO2Common Demo Project]
MO2Common.vbg [MO2Common Project Group]
CommonSource
MO2Common.vbp [MO2Common Source Project]
MoComponentSample
test.vbp [MO2MO Demo Project]
MO2MO.vbg [MO2MO Project Group]
MO2MOSource
MO2mo.vbp [MO2MO Source Project]
For a better understanding of the four component samples, please refer to the following sections which describe each component in turn.
2. General Description of Components
2.1 MO2MO
This component can be used to implement some commonly required functions in MapObjects, like zooming, measuring distances, or adding maptips. The major objects included within this component, are listed in Table 1.
Table 1. Major objects within MO2MO
Object Functions
AEDistance Measures the distance on the map (map units in decimal degrees)
AEDistance2 Measures the distance on the map (map units not in decimal degrees)
AEExtent Given MinX, MinY, MaxX & MaxY returns Width, Height, CenterX & CenterY
MapTip Set up map tips for a map layer
FancyLabels Draw a label with a shadowed box
MOFuncs Zoom in, Zoom out, Zoom to recordset, move by directions, and other functions.
MO2Common
This component can be used for implementing some common Windows functions. For example, popping up a file dialogue box, generating or unpacking a ZIP file, or setting the current the topmost window. The major objects implemented in this component are given in Table 2.
Table 2. Major objects within MO2Common
Object Functions
CommonDialogs Dialogs with functions such as 'File Save' or 'Printer Setup'
FileSysFuncs File system functions like delete a folder or delete a file
Shape Retrieve information from a shape file
Win32API Wrapped Windows 32 API functions eg. move a window to the top
ZipLibrary Wrapped DynaZIP components: used to generate or unpack zipfiles
MO2Legend
This component can be used for displaying a map legend. At the design time, this control can be added to the form along with a MapControl. By associating the legend with the map control, it can be used to display the legend for this map at runtime.
ScaleBar
This component can be used for displaying a scale bar for a map control. This control can be added to a form at design time. By associating it with a map control and setting up its properties either at design time or run time, it will display the scale dynamically for the map when the application is running.
3. Sample Applications - General Introduction
Each sample application can be loaded into the Visual Basic environment by using the VB project group file, e.g. MO2MO.vbg. In each sample application folder, there is a test.vbp file for demonstrating how the component may be used. To start the sample application, the VB project group file should be opened instead of test.vbp. After the application has been loaded, within the test.vbp, you can view and step into the source code for using the component as well as the source code for the component itself. This is possible because the group file references the component's Visual Basic source project (uncompiled) rather than a compiled file (i.e. ocx or dll file).
Table 3. Component and VB sample application file name
Component name Sample application name
MO2MO MO2MO.vbg
MO2Common MO2Common.vbg
MO2Legend MO2Legend.vbg
ScaleBar ScaleBar.vbg
3.1 MO2MO
This sample application shows how to use the moFuncs, AEDistance, and AEDistance2 objects provided by the MO2MO component. In this sample, the moFuncs is referenced to MO2MO.moFuncs, oDist is referenced to MO2MO.AEDistance, and oDist2 is referenced to MO2MO.AEDistances2. By using the moFuncs object, the zoom in and zoom out functions can be implemented by calling ZoomIn and ZoomOut method embedded within this object. This will reduce the amount of work required for these two functions. By using the oDist and oDist2 objects, the distance measuring function can be implemented without writing the code for actual measurement. These two objects will do the measurement.
For measuring distance, the oDist object is used when the map unit is decimal degrees and the oDist2 object is used when map unit is not decimal degrees. When measuring distance, the map unit should be selected correctly. Otherwise, the measuring will fail and the text message 'Unable to measure' will be displayed.
With these two objects, one of the four measuring units can be selected: feet, miles, meters, and kilometers. When measuring the distance, not only the dimension of latest segment will be reported, the accumulated distance will be reported as well.
Figure 1. MO2MO sample application interface
3.2 MO2Common
In this sample application, we can see how to use the commonDialogs, shape, and Win32API objects provided by MO2Common component. In the sample, oCDialog is referenced to mo2Common.CommonDialogs, oShp is referenced to mo2Common.Shape, and oW32 is referenced to mo2Common.Win32API. By using the oCDialog object, the function for Windows open and save dialogue boxes can be implemented without using Microsoft dialogue box control. By using the oShp object, the type for a shape file can be retrieved. By using oW32 object, the Window for displaying a BMP graphic will be set as the topmost window.
In the interface, click the 'Load Shape File' button will pop up file open dialogue box for loading a shape file. The 'Export BMP' button will pop up a file save dialogue box for saving exported BMP graphic files. After the BMP file is saved, a new window will be opened to display the exported BMP file. This window will be set on the top of the map window.
Figure 2. MO2Common sample application interface
3.3 MO2Legend
This sample application demonstrates how easy it is to add the legend to a MapObjects 2 application.
At design time, just add the legend control to the form. Then associate the map with the legend control using the setMapSource method of legend control:
Legend1.setMapSource Map1
To display a legend for each map layer, the LoadLegend method should be set as True:
Legend1.LoadLegend True
At run time, with the legend control, users can turn on or off the map layer by clicking the check box for each layer. Also the map layer sequence can be changed by dragging the box for each layer in the legend box up or down.
Figure 3. MO2Legend sample application interface
3.4 ScaleBar
This sample application demonstrates how to add the scale bar control to MapObjects.
Add the scalebar control to the form at design time. When loading the interface of the application at run time, the scale bar property can be set up by using the SUB RefreshScale.
When the application is running the scalebar can be made to reflect the current map scale by using RefreshScale. For scale units, four options are available: Miles, Feet, Meters, and Kilometers.
Figure 4. Scale bar sample application interface
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 2532
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved