Mapx development Zheng Jun, based on .NET platform, Chen Zhengyang
Zheng Jun, Chen Zhengyang
(School of Information Physics Engineering, Central South University, Changsha 410083, China)
Abstract: Developing a MAPX component on the .NET platform is a newer issue. The meaning of developing MAPX on the .NET platform is briefly expounded; introducing the basic steps of the MAPX and the .NET platform binding; explore the specific method of developing MAPX; and use instance code to explain, while paying attention to the development process The problem has been studied and provides a solution to the problem. It is initially solved the problem of developing MAPX on the .NET platform, laying the foundation for the next in-depth study.
Key words: .NET platform; MAPX; development
CLC number: P208 Document identification code: b Article number: 1001-358X (2004) 03-0007-04
Mapx is an ActiveX component that MapInfo provides a powerful map analysis feature to users. Although MAPX component development technology has matured, MAPX development is also a new topic on the .NET platform. In this paper, it is a preliminary discussion on the development of MAPX on the .NET platform.
1. The meaning of the combination of Mapx and .NET platform
Visual Basic .NET (refermstriction VB.NET) is a powerful information from Microsoft to users.
One of the four programming languages of the map analyzer function, which is a simple upgrade of Visual Basic 6.0, but a quality change. Compared with VB6.0, VB.NET has a large change in grammar or the framework structure, which is also greatly enhanced, completes from the initial console application, Windows application to web applications. Various different requirements is a language that is a true face-to-object, a historic leap. The introduction of VB.NET makes it possible with Java. In terms of GIS secondary development, since VB.NET is Microsoft products, it is more convenient and quick to use than Java in a Windows operating system. VB.NET has broad application prospects, and will be accepted by more and more people, VB.NET replaces VB for GIS secondary development, is a general trend. Therefore, the development of MAPX on the .NET platform is a topic worth studying.
2. Binds of the MAPX control and .NET platform
Using MAPX in VB.NET is not complicated, as in VB, you can display a map in the application without writing a line of code. After installing MAPX, start VB.NET, select the "File | Add Items" command in the integrated development environment, open the New Project dialog, create an application called MapX, project automatically generates Form1 form At this time, select the "Tools | Add / Remove Toolbox" command (as shown in Figure 1).
Select "COM Components" in the custom toolbox appear, tick on the "MapXfo Mapx V4" option, click the "OK" button (as shown in Figure 2), then a new control appears on the toolbox, this
The new control is the MAPX control. This way, you can use the MAPX control in VB.NET.
3. MAPX development on the .NET platform
Map controls are used to display a map. Therefore, you want to display a map, first you need to add a map control in the form. You can add a map control in the form by double-clicking on the map control on the toolbox, and adjust the size and location of the map control appropriately as needed. You can also select the map control first, then press and hold the left mouse button in the form and drag the mouse to specify the location and size of the map control. When adding a map control in the form, a US map is displayed by default, the Geoset default properties of the map control Mapx are United States, as shown in Figure 3. After adding the MAPX control, developers can modify the properties and methods of MAPX controls like other objects, call various functions. In Mapx, a standard map tool is provided, which can easily develop convenient and easy-to-use geographic information systems, without having to fully rely on developers from developers for each map operation. Mapx has built-in standard map tools, mainly divided into two categories: First, the object creation tool is used to create map elements; the other is the selection tool. When using the tool for use, you can match the function key Shift and Ctrl. They include: (1) Tools that change map scale and map navigation: Zoom tool, reduce tools, panning tools, and center tools.
(2) The annotation tool that is labeled by clicking the map element.
(3) Select the selection tool collection of map elements in different ways. The specific development method is: activate a standard tool in the proper position, set the CurrentTool property to a certain constant, or use the value directly. For example, in the form, the MAPX control is an Axmap1 object, when an enlargement is required:
Axmap1.currentTool = Mapxlib.ToolConstants.Mizoomintool
or:
Axmap1.currenttool = 1003
The running program will see that this mouse light is changed to a magnifying glass. The method set by other tools is the same. In the specific implementation, some toolbars are often provided, with a standard operating tool above, to facilitate user operating maps, such as providing zoomed, narrowing, translation, and selecting these four common tools buttons, can be in the command of the button. Written as:
'Map Zoom Tool Private Sub Button3_Click (Byval As System.Eventargs) Handles Button3.Click AxMap1.currentTool = Mapxlib.ToolConstants.MizoMintool
End Sub
'Map Reduce Tool
Private sub Button4_click (Byval Sender As System.Object, byval as system.eventargs) Handles Button4.click
Axmap1.currenttool = Mapxlib.ToolConstants.MizoomouthTool
End Sub
'Map panning tool
Private sub button1_click (byval sender as system.object, byval as system.eventargs) Handles Button1.click
Axmap1.currentTool = Mapxlib.ToolConstants.Mipantool
End Sub
'Map Selection Tool
PRIVATE SUB button7_click (Byval As System.EventArgs) Handles Button7.click
Axmap1.currentTool = Mapxlib.ToolConstants.MisElectrtool
End Sub
For general applications, the standard tools provided by MAPX are sufficient. At this point, the application and development of MAPX on the .NET platform is realized. For general applications, the standard tools provided by MAPX are sufficient. At this point, the application and development of MAPX on the .NET platform is realized.
4. Several questions that should be paid attention to
The integrated development environment of VB.NET is complicated than VB, although the basic idea of VB.NET and VB development MAPX is substantially the same, the syntax and architecture of the two have a large difference, can't use VB development Mapx's experience, especially source code, and can not be utilized.
4.1 Adding a MAPX control correctly
To develop MAPX in the .NET platform, you first have to install the MAPX package correctly, otherwise, "MapInfo Mapx V4" option cannot be found in "COM Components". Just follow the MAPX installation guide to install it by step. However, it should be noted that with the release of MapX4.0, MapInfo changed the copyright control method - using the method of computer system numbers. In addition to purchasing the MAPX software itself, users should purchase software licenses separately for each computer that wants to install MAPX, otherwise, the software will not use it normally. Second, to properly add the MAPX control to the toolbox of the VB.NET integration development environment, you are using the programmers who are used to VB, and open the dialog in the Project | Parts command, select the MapInfo Mapx V4 control, but Without "Projects | Parts" commands in VB.NET, you want to use "Tools |
Plus / Remove Toolbox NE command Opens the dialog.
4.2 rationally use MAPX standard tools
In order to create new primitives in the map, or modify existing primitives, you need a map editing function. MAPX standard tools provide MIADDPOINT, TOOLMIADDLINE, TOOLMIADDPOLYLINETOOL, MIADDREGONTOOL four add tools, which are added, add line, add line, and add zone tools. For adding tools, MAPX specifies that the image will be added in the InsertionLayer layer.
Therefore, you need to set the InsertionLayer layer before the addition of the layer, and set it to editable. Methods as below:
Private Sub MenuItem132_Click (ByVal sender As Systeme.Object, ByVal e As System.EventArgs) Handles MenuItem132.Click AxMap1.Layers.LayersDlg () (1) AxMap1.Layers.InsertionLayer = AxMap1.Layers.Item (1) (2)
End Sub
(1) Represents: Open the layer dialog box, set the current layer to edit in the Layer dialog; (2) indicates that the InsertionLayer layer is set to the current layer.
(1) Represents: Open the layer dialog box, set the current layer to edit in the Layer dialog; (2) indicates that the InsertionLayer layer is set to the current layer.
4.3 About Changing the initial interface
When adding a MAPX control in the form, the default is the US map, so the initial interface is an US map when the application is running. How to change the initial interface to a map you need? First, place the map (extension .GST) to the MAPS folder of the MAPX installation path, for example: D: / Program Files / MapInfo Mapx 4.0 / Maps. Second, click the right mouse button in the form MAPX control and select "Properties", which appears in the middle map attribute page shown in Figure 4.
Click the General tab in the dialog, find the geoset option, select the desired map, and modify the bottom Title content, change the map of the initial interface to the map you need.
references:
[1] Liu Guang. Geographic Information System - Component Development [M]. Beijing: China Electric Press, 2003
[2] Rui. Develop geographic information systems with MAPX [M]. Beijing: Tsinghua University Press, 2003
[3] Li Shengle. Secondary Development Example of MapInfo Geographic Information System [M] Beijing: Electronic Industry Press, 2004
[4] Li Lianying.Mapx-based GIS application development [M] Wuhan: Wuhan University Press, 2003
[5] Wang Xingjing. VisualBasic .NET application programming 150 cases [M] Beijing: Electronic Industry Press, 2003
[6] Ge Xiaodong. VB.NET Programming Example and Skills Collection [M] Beijing: China Science and Technology Press, 2003
About the author: Zheng Jun (1972-), male, Hunan Changsha people, master's degree in Central South University. Research direction: mapology and geographic information system.