Using MAPX to create user customization tools in VB

Source: Internet
Author: User
Tags constant

This paper describes how to use MAPX to create a user-defined map tool in VB, detailing the entire creation process and the key methods used in creating custom tools.

1. Foreword

With the development of GIS, many GIS (geographic information System) software has appeared at home and abroad, in which MAPX is the ActiveX control product of MapInfo company. Because it is a standard control based on Windows operating systems, MapX4.0 supports most of the standard visual development environments, such as: Visualbasic,delphi,powerbuilder,visualc++ and other object-oriented languages, You can also use Lotus script to embed MapX4.0 in Lotus Notes.

Although MapX4.0 provides a number of standard tools that can be used directly, in many cases these standard tools do not meet the actual needs, which requires custom mapping tools to specify what functionality the tool can accomplish, such as drawing an ellipse tool, ruler tools (measuring line length), and so on. Below, the author through a specific example to introduce VB in the use of MapX4.0 control to make a map of custom tools.

MAPX Programming under 2.VB environment

The use of MapX4.0 to create user-defined tools is divided into the following three steps:

2.1 Creating Custom Tools

This example creates a drawing ellipse tool. First, declaring the global constant Miaddellipsetool = 1,1 represents the tool for drawing ellipses. Then, create the drawing ellipse tool in the main form.

Key approach (create custom tools):

OBJECT. Createcustomtool (Toolnumber, Type, Cursor, [Shiftcursor], [Ctrlcursor], [infotips])

Object: Map object;

Toolnumber (tool number) is the creation of the miaddellipsetool representing the drawing ellipse tool;

Type (Types): Describes the behavior of the tool, which takes a tooltypeconstants (tool type constant) value. In this example, the tool is to press the left mouse button to the left mouse button in the process of drawing an ellipse. In this case, the mitooltypepoint is taken;

Cursor (pointer shape): The shape that the tool displays on a map when you use the tool, taking values from cursorconstants (pointer constants). This example uses the Microsscursor, then when the tool is selected, the tool will be displayed on the map as a cross fork shape;

Shiftcursor, Ctrlcursor: These two parameters are optional, and by default, the SHIFT key and the CTRL key do not work;

Infotips (tooltip): Boolean type. If you want to display a ToolTip, you need to set this argument to True, and the default value is False.

Actual encoding:

Public Const miAddEllipseTool = 1 '定制的加椭圆工具
Public RectX1 As Double '新加椭圆(所需的矩形)的点1的X(经纬度)坐标
Public RectY1 As Double '新加椭圆(所需的矩形)的点1的Y(经纬度)坐标
Public RectX2 As Double '新加椭圆(所需的矩形)的点2的X(经纬度)坐标
Public RectY2 As Double '新加椭圆(所需的矩形)的点2的Y(经纬度)坐标
Private Sub Form_Load() '创建定制工具
Map1.CreateCustomTool miAddEllipseTool, _
miToolTypePoint, miCrossCursor
End Sub

The tool created at this time does not have any functionality and the tool has the appropriate functionality to be implemented in the second step.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.