Customize ArcGIS applications

Source: Internet
Author: User
Tags microsoft office com

ArcGISThe Foundation isArcObject, ArcObject is built based on the COM technology and is a development activity of all ArcGIS, such as the desktop version.DevelopmentIs the basis for server development. In general, application ArcGIS development includes the following aspects:

○ Set or customize ArcGIS applications, such as ArcMap;
○ Extended ArcGIS, such as developing your own Toolbox or adding a new data model;
○ Use ArcEngine to develop a fat clientApplicationProgram, for example, embedded in other programsGISFunction;
○ Use ArcGIS Server to create Web programs or Web services.

We have seen a lot about the relationship between AO and ArcGIS series in various documents. I will not talk about it here. The core of all products is AO. The difference between ArcGIS Engine and ArcGIS server is that the former provides medium-granularity controls for fat clients and servers, the latter development cannot use these controls.

Readers who have developed the application of ArcGIS can find that many controls under ArcEngine, such as Map and 3D display, exist in the system even if ArcEngine is not installed. We can speculate that, in ArcGIS 9. x, Desktop should also use these controls (need to confirm !).

This series of articles mainly introduces the development of ArcGIS Desktop.

Types of ArcGIS Desktop Development

○ Customize the layout and interface of ArcMap and ArcCatalog, including adding custom buttons and specifying corresponding macros;
○ Use VBA to create a solution;
○ Create ArcGIS extension;
○ Create an independent application (described later ).

Custom ArcGIS Desktop

Understanding Custom ArcGIS Desktop is similar to understanding the custom Word in Office. Taking ArcMap as an example, for a Map document (mxd), it includes the following parts: the data used (that is, the data used by the Map); the layout of the Map; the interface layout (custom) of the current program and the VBA project. For a template, there is a difference between a Normal Template and a map Template. The former affects the ArcMap program itself, that is, all open documents have a Normal template applied, the latter only affects the map that uses the template.

Therefore, the use of custom templates is the first layer of ArcGIS Desktop development. By combining the required interface elements and rescheduling them, you can form a custom program that meets the customer's needs, however, there is a lot of work that can be done by combining certain VBA code.

For example, a courier company can integrate interface elements related to map operations (scaling, movement, printing, etc.) and network analysis with custom tools, hiding other tools and interface elements can be better applied to actual work.

Apply VBA

Application VBA development solutions have many advantages, such as the absence of third-party development tools, being simple and easy to use, and the absence of familiarity with the AO structure, using VBA is easier to use than using other methods. For non-professional programmers, using VBA should be the first choice for ArcGIS Desktop development. For Professional Developers, using VBA is also a good way to learn and be familiar with AO.

VBA Project

VBA project is the carrier of VBA programs and codes in ArcGIS. It is stored together with a map template or map (mxd file. After the VBA editor is opened, there are two VBA projects: Normal and the files currently open. A vba project consists of the following types of objects:

○ ArcMap object
○ Process Module
○ Form Module
○ Category modules
○ Reference (reference to the Normal template)

For most development projects, you first need to use a custom interface, such as the create tool button. Then you can select this tool in the ArcMap object to create its event response process. For example, you can customize a button, UIButtonControl1, select UIButtonControl1 from the object selection list box in the ThisDocumnet code window, select Click in the event list box, and create uibuttoncontrol#click, you can write the code called after the button is clicked.

You can create a custom dialog box or window through the form, and the class module can create its own objects.

Compile ArcGIS Desktop Extension

Compile ArcGIS extension to complete the following tasks ():

○ Command: a button or menu, which is created through the ICommand, ITool, and IToolCommand interfaces;
○ Edit Task: a component that works with ArcMap Editor and must implement the IEditTask interface;
○ Table of Contents tab: a small window similar to the left-side data and layer view. It is created through the IContentsView interface;
○ Class extension: a custom object (feature), that is, a space object with its own attributes and rules, such as a traffic light object, a wire, or an electrical brake, which must implement interfaces such as IClassExtension.

Application plug-in architecture

For the development of ArcGIS Desktop, the most important core issue is to understand the running mechanism of the ArcGIS plug-in architecture. Below we will briefly introduce this problem.


 


The core of the plug-in architecture is that the application defines the interfaces that the plug-in follows, and then the custom components implement this interface. There are several key points:

First, how does the main application know to load the plug-in?

ArcGIS uses the Registry. Similar to MS Office, it creates a "component categories" entry in the registry. To load components by ArcGIS, you must register them, add an entry here. For the current majority. net programs and C or C ++ programs in the pre-COM era, this is done through the directory, by traversing the files in the directory, and then through the reflection mechanism (.. net.

The COM program, such as the VB environment, can load a component through CreatObject.

Second, plug-in Initialization

Initialization involves two aspects: on the one hand, the main program needs to create a variable, the type is the interface implemented by the plug-in, and then create the plug-in, and at the same time, call the plug-in Initialization code, such as Connect, input a reference (App) that requires the main program to be exposed to the plug-in ). COM programs or. net are implemented through events. The main program triggers an initialization event, which is implemented in the plug-in code. The runtime environment of the plug-in is initialized Based on the sent variables. For an environment like C or C ++, you can use function pointers and callback functions to achieve this.

The initialization process of the plug-in is the communication process between the plug-in and the main program. This bridge is the IApplication interface for ArcGIS.

Third, communication between plug-ins and Applications

In fact, the above is almost clear. For the main application, it is to create a plug-in object, obtain the current plug-in instance, and then control it. If the plug-in is a button, when the plug-in is initialized, a button object is created and the click Event of the bound button is handled by the corresponding process of the plug-in.

For plug-ins, the object instances such as the Application of the current Application are obtained by parameters of initialization events (such as OnCreat or Connect) during initialization, therefore, you can use these object instances to operate applications.

For some state changes of the application, you can define events and then respond to these events in the plug-in code.

Fourth, user interface

The compilation of Microsoft Office COM macro loading requires you to create user interface elements by calling the Commandbar and other objects of Office, which can be completely customized. For a program such as Photoshop, the plug-in program is completed using C or C ++, And the extension location is fixed at several fixed extension points. ArcGIS personally thinks that it is basically between the two.

Steps and methods for developing ArcGIS extension modules

After understanding the plug-in architecture of ArcGIS, the development is mainly based on familiarity with AO, using AO functions to develop specific applications, or extending functions not provided by AO.

The basic steps for developing an extension module are as follows:

(1) create a project and add a reference to AO;
(2) implement the required interface and add specific code;
(3) compile it as a DLL, register the COM component, and register it in the omponent categories of ArcGIS (you can also use the custom dialog box on the page to browse and locate the specific dll for registration );
(4) testing and debugging.

Currently, the extension development environment of ArcGIS Desktop includes the COM compatible environment (such as VB or VC), VB.net of. net 1.1, or C #.

Independent applications

A gis application must implement basic Map functions. Open the VB 6 or. net development environment and you can see that controls such as Map, PageLayout, Toc, and Toolbar installed with ArcGIS Desktop are available. Only the Map and PageLayout controls can be used (licensed) under Desktop. Some programs can also be developed using this method,ESRIWe recommend that you use ArcGIS Engine in an embedded or fat client.

Summary

Familiar with the basic idea of ArcGIS Desktop development and the idea of plug-in architecture of ArcGIS Desktop, applying ArcGIS Desktop development is no longer a very complicated task. The next major job is to familiarize yourself with AO. In addition to object-oriented knowledge, many principles and knowledge of GIS are also necessary.


Ps: I had to write this article more than two months ago, but I haven't written it for various reasons,3 sNewsThe revision finally came to an end. It took me half a day to write the article, hoping to finish the series.

 

ArcGISThe Foundation isArcObject, ArcObject is built based on the COM technology and is a development activity of all ArcGIS, such as the desktop version.DevelopmentIs the basis for server development. In general, application ArcGIS development includes the following aspects:

○ Set or customize ArcGIS applications, such as ArcMap;
○ Extended ArcGIS, such as developing your own Toolbox or adding a new data model;
○ Use ArcEngine to develop a fat clientApplicationProgram, for example, embedded in other programsGISFunction;
○ Use ArcGIS Server to create Web programs or Web services.

We have seen a lot about the relationship between AO and ArcGIS series in various documents. I will not talk about it here. The core of all products is AO. The difference between ArcGIS Engine and ArcGIS server is that the former provides medium-granularity controls for fat clients and servers, the latter development cannot use these controls.

Readers who have developed the application of ArcGIS can find that many controls under ArcEngine, such as Map and 3D display, exist in the system even if ArcEngine is not installed. We can speculate that, in ArcGIS 9. x, Desktop should also use these controls (need to confirm !).

This series of articles mainly introduces the development of ArcGIS Desktop.

Types of ArcGIS Desktop Development

○ Customize the layout and interface of ArcMap and ArcCatalog, including adding custom buttons and specifying corresponding macros;
○ Use VBA to create a solution;
○ Create ArcGIS extension;
○ Create an independent application (described later ).

Custom ArcGIS Desktop

Understanding Custom ArcGIS Desktop is similar to understanding the custom Word in Office. Taking ArcMap as an example, for a Map document (mxd), it includes the following parts: the data used (that is, the data used by the Map); the layout of the Map; the interface layout (custom) of the current program and the VBA project. For a template, there is a difference between a Normal Template and a map Template. The former affects the ArcMap program itself, that is, all open documents have a Normal template applied, the latter only affects the map that uses the template.

Therefore, the use of custom templates is the first layer of ArcGIS Desktop development. By combining the required interface elements and rescheduling them, you can form a custom program that meets the customer's needs, however, there is a lot of work that can be done by combining certain VBA code.

For example, a courier company can integrate interface elements related to map operations (scaling, movement, printing, etc.) and network analysis with custom tools, hiding other tools and interface elements can be better applied to actual work.

Apply VBA

Application VBA development solutions have many advantages, such as the absence of third-party development tools, being simple and easy to use, and the absence of familiarity with the AO structure, using VBA is easier to use than using other methods. For non-professional programmers, using VBA should be the first choice for ArcGIS Desktop development. For Professional Developers, using VBA is also a good way to learn and be familiar with AO.

VBA Project

VBA project is the carrier of VBA programs and codes in ArcGIS. It is stored together with a map template or map (mxd file. After the VBA editor is opened, there are two VBA projects: Normal and the files currently open. A vba project consists of the following types of objects:

○ ArcMap object
○ Process Module
○ Form Module
○ Category modules
○ Reference (reference to the Normal template)

For most development projects, you first need to use a custom interface, such as the create tool button. Then you can select this tool in the ArcMap object to create its event response process. For example, you can customize a button, UIButtonControl1, select UIButtonControl1 from the object selection list box in the ThisDocumnet code window, select Click in the event list box, and create uibuttoncontrol#click, you can write the code called after the button is clicked.

You can create a custom dialog box or window through the form, and the class module can create its own objects.

Compile ArcGIS Desktop Extension

Compile ArcGIS extension to complete the following tasks ():

○ Command: a button or menu, which is created through the ICommand, ITool, and IToolCommand interfaces;
○ Edit Task: a component that works with ArcMap Editor and must implement the IEditTask interface;
○ Table of Contents tab: a small window similar to the left-side data and layer view. It is created through the IContentsView interface;
○ Class extension: a custom object (feature), that is, a space object with its own attributes and rules, such as a traffic light object, a wire, or an electrical brake, which must implement interfaces such as IClassExtension.

Application plug-in architecture

For the development of ArcGIS Desktop, the most important core issue is to understand the running mechanism of the ArcGIS plug-in architecture. Below we will briefly introduce this problem.


 


The core of the plug-in architecture is that the application defines the interfaces that the plug-in follows, and then the custom components implement this interface. There are several key points:

First, how does the main application know to load the plug-in?

ArcGIS uses the Registry. Similar to MS Office, it creates a "component categories" entry in the registry. To load components by ArcGIS, you must register them, add an entry here. For the current majority. net programs and C or C ++ programs in the pre-COM era, this is done through the directory, by traversing the files in the directory, and then through the reflection mechanism (.. net.

The COM program, such as the VB environment, can load a component through CreatObject.

Second, plug-in Initialization

Initialization involves two aspects: on the one hand, the main program needs to create a variable, the type is the interface implemented by the plug-in, and then create the plug-in, and at the same time, call the plug-in Initialization code, such as Connect, input a reference (App) that requires the main program to be exposed to the plug-in ). COM programs or. net are implemented through events. The main program triggers an initialization event, which is implemented in the plug-in code. The runtime environment of the plug-in is initialized Based on the sent variables. For an environment like C or C ++, you can use function pointers and callback functions to achieve this.

The initialization process of the plug-in is the communication process between the plug-in and the main program. This bridge is the IApplication interface for ArcGIS.

Third, communication between plug-ins and Applications

In fact, the above is almost clear. For the main application, it is to create a plug-in object, obtain the current plug-in instance, and then control it. If the plug-in is a button, when the plug-in is initialized, a button object is created and the click Event of the bound button is handled by the corresponding process of the plug-in.

For plug-ins, the object instances such as the Application of the current Application are obtained by parameters of initialization events (such as OnCreat or Connect) during initialization, therefore, you can use these object instances to operate applications.

For some state changes of the application, you can define events and then respond to these events in the plug-in code.

Fourth, user interface

The compilation of Microsoft Office COM macro loading requires you to create user interface elements by calling the Commandbar and other objects of Office, which can be completely customized. For a program such as Photoshop, the plug-in program is completed using C or C ++, And the extension location is fixed at several fixed extension points. ArcGIS personally thinks that it is basically between the two.

Steps and methods for developing ArcGIS extension modules

After understanding the plug-in architecture of ArcGIS, the development is mainly based on familiarity with AO, using AO functions to develop specific applications, or extending functions not provided by AO.

The basic steps for developing an extension module are as follows:

(1) create a project and add a reference to AO;
(2) implement the required interface and add specific code;
(3) compile it as a DLL, register the COM component, and register it in the omponent categories of ArcGIS (you can also use the custom dialog box on the page to browse and locate the specific dll for registration );
(4) testing and debugging.

Currently, the extension development environment of ArcGIS Desktop includes the COM compatible environment (such as VB or VC), VB.net of. net 1.1, or C #.

Independent applications

A gis application must implement basic Map functions. Open the VB 6 or. net development environment and you can see that controls such as Map, PageLayout, Toc, and Toolbar installed with ArcGIS Desktop are available. Only the Map and PageLayout controls can be used (licensed) under Desktop. Some programs can also be developed using this method,ESRIWe recommend that you use ArcGIS Engine in an embedded or fat client.

Summary

Familiar with the basic idea of ArcGIS Desktop development and the idea of plug-in architecture of ArcGIS Desktop, applying ArcGIS Desktop development is no longer a very complicated task. The next major job is to familiarize yourself with AO. In addition to object-oriented knowledge, many principles and knowledge of GIS are also necessary.


Ps: I had to write this article more than two months ago, but I haven't written it for various reasons,3 sNewsThe revision finally came to an end. It took me half a day to write the article, hoping to finish the series.

 

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.