Experience of developing Web GIS using ArcGIS Server (III)

Source: Internet
Author: User
Tags polyline
In (2), we analyzed the HTML code, and basically figured out how. Net ADF encapsulates client interaction and how the client interacts with the server. Next, let's take a look at the development method on the server side. It is actually a simple practice. If you can learn about the implementation of AGS when developing Web GIS using other jobs, you will surely be inspired by some tips on encapsulating the client, server, and interaction between the two, how to encapsulate common functions without interfering with function expansion.

Let's get started with our new experience.
As we have already mentioned in (1),. Net ADF provides a series of templates that encapsulate some common functions based on different needs. Our development generally starts with these templates. If you are familiar with the programs generated by these templates, you do not need these templates. However, if you are a newbie, start with the template to avoid many detours.

First, start Visual Studio 2003 and create a new project. In the create dialog box, you can see the ArcGIS Server projects item in "project type". Select the language Visual C #, seven templates are available in the template list on the right. Each template can be used to create an application for different purposes, as shown in:

We will first create a map viewer web application, that is, a map browsing program. The analysis will show how the Map Browsing program is implemented and how to expand its functions.
After a map viewer web application is created, the interface is shown in. As you can see,. Net creates an Asp.net web project for us. The project consists of three pages: default. aspx, errorpage. aspx, and identify. aspx. Here, default. aspx is the main interface, errorpage. aspx is used to display error information, and identify is used to display the result of the query operation. Next we will mainly analyze the page default. aspx.

The upper part of this webpage is a banner. The following section consists of seven Asp.net components. These seven components are:
1. Map component: Map component. There are two key attributes: Host and serverobject. I don't need to say it, but I also know what it means.
2. TOC component: Table of contents ). A key attribute, buddycontrol, is associated with the map component.
3. toolbar component: tool bar component. A key property, buddycontrols, indicates that multiple map components or pagelayout components can be bound.
4. overviewmap component: the navigation chart component. There are three key attributes: Host, serverobject, and buddycontrol.
5. impersonation component: Authentication component. There is a key attribute, identity, used to design how to log on to the server and have operation permissions.
6. northarrow component: pointing to the North
7. scalebar component: the scale component, which has a key property: buddycontrol. The barfont attribute seems to have a bug. How can it be set to be ineffective? The font size is always small. I don't know why. Which of my friends can help me to see what's going on?

Among the seven components, the map component is obviously the most important, because it is responsible for Map Display and interaction with users. Let's take a look at some events of the map component. Only mapchanged events contain code. A closer look is the Code related to view (MAP scope) saving. Where can the map component interact with users and the server-side processing code, such as scaling a map?

Let's take a look at the toolbar component, which contains seven buttons: Zoom in, zoom out, pan, full graph, previous view, next view, and click. Click its toolbaritems attribute to check that the definition of the toolbar button is included here.
There are two types of toolbar buttons: tool and command.
Tool: tool button. Indicates that the user needs to interact with the map before executing a function not immediately after clicking it. Therefore, you need to save its status. At the same time, the corresponding client code (JavaScript) and server code are required. Zoom in, zoom out, pan, and click are of this type.
Command: command button. Perform an operation immediately without user interaction, so no storage status is required. Full graph, previous view, and next view belong to this type.
In the toolbaritems custom interface, select identify and check its attributes, including the following:
1. Appearance images group: Define the image displayed by the button. These settings are converted into HTML code.
2. Appearance text group: There are two subitems. Text indicates the text displayed in the button, that is, the button can be composed of two parts: Image and text. Tooltip, that is, the prompt information displayed when you place the cursor over the button.
3. client-side action group: this group has only one attribute, namely, clienttoolaction. Here is the JavaScript code that interacts with the client. The content is ID (). Open defaut. aspx and view the HTML. You can see the ID function content. The interaction here is relatively simple, and the interaction is complicated. For example, if you need to pull a box during amplification, how to encapsulate it? Originally, cient-side action is actually only an onmousedown execution function in Javascript. Where can I find the onmousemove and omnouseup required by the pull box? Actually, it's just a little trick. Can I assign values to onmousemove and onmouseup dynamically in onmousedown? In fact, this is what. Net ADF encapsulates zoomin and other operations.
The client-side action property has a drop-down option that contains dragimage, dragrectangle, point, line, polyline, polygon, circle, oval, none, custom. Needless to explain, I believe everyone understands that the toolbar component encapsulates various types of client operations. Where are the JavaScript code used to interact with the client? (2) I have already introduced it. I will omit it here.
4. General group. It includes three attributes: Disabled, name, and showloading.
5. server-side action group: it has two attributes: servertoolactionassembly and servertoolactionclass, which define the functions to be executed on the server. In. Net ADF, each closed server operation is implemented by a class. servertoolactionassembly indicates the program set in which the class is located, and servertoolactionclass is the name of the class. Select ESRI. ArcGIS. server. webcontrols in servertoolactionassembly. We can clearly see that this program defines four types: mapcenterat, mappan, mapzoomin, and mapzoomout. Event, we can also define our own processing class, as long as the ESRI. ArcGIS. server. webcontrols. Tools. imapservertoolaction interface is implemented.

About expansion:
1. client interaction: client-side action group. The ADF encapsulates operations such as dragimage, dragrectangle, point, line, polyline, polygon, circle, and oval, I believe that most of our applications can be handled. If not, do not forget that there is another custom. Select it and write JavaScript on your own. Remember the JavaScript code of onmousedown. In the code after interaction, if you need to return to the server, remember to execute the _ dopostback function.
2. server-side function implementation: server-side action group. The map component provides an event for each behavior encapsulated by the client, indicating that the code in the event is executed immediately after the client interaction is complete. These events include oval, line, point, and polygon. If the client operation is self-written JavaScript and finally submitted to the server, you can process your own operations in page_load.

The toolbar buttons of the tool type are introduced above. The command type is much simpler. You can select fullextent to check that its attributes are less client-side action group and server-side action group. Its implementation code is directly included in the commandclick event of the toolbar component. Let's see it by yourself.
Other components are not introduced.
  
I believe that you have used it. net ADF Web GIS development has a general understanding, but also basic understanding.. In the next section, I will introduce how to expand functions.

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.