Use ArcGIS Engine to develop a fat client browser program for ArcGIS Server

Source: Internet
Author: User

Summary: Two new products are added in the family of ArcGIS 9: ArcGIS Engine and ArcGIS Server. Their respective strong development capabilities in the C/S field and B/S field have attracted much attention since their launch. Among them, ArcGIS Server has attracted the attention of all ArcGIS users thanks to its excellent redevelopment capabilities.

ArcGIS Engine and Server)

In the family of ArcGIS 9, two new products were added: ArcGIS Engine and ArcGIS Server. Their respective strong development capabilities in the C/S field and B/S field have attracted much attention since their launch. Among them, ArcGIS Server has attracted the attention of all ArcGIS users thanks to its excellent redevelopment capabilities.

So what is ArcGIS Server? ArcGIS Server provides a platform for developing centralized GIS applications. These applications can provide geographic information services over the network. ArcGIS Server is a powerful B/S Development Tool Based on ArcObjects. It provides online map publishing and online map browsing functions as easily as ArcIMS does, and provides online map analysis and map editing functions as ArcMap does. The latter is the problem that has plagued ArcIMS developers for a long time and the advantages of server.

There are many kinds of ArcGIS Server users, from the most common IE browser (thin client) to large ArcGIS desktop applications (fat client ). These two clients are very powerful and can complete all kinds of work from data browsing to simple map editing. However, the most powerful is the ArcGIS desktop application or the fat client developed using the engine. This type of client can not only complete all the functions that thin clients can complete across the network, but also fully display the online editing function of ArcGIS Server, this makes full use of the functions of the server platform.

Today we will discuss how to use ArcGIS Engine to develop a fat client that can connect to ArcGIS Server over a network and implement complex online editing functions.

Connect the engine client to an instance of the server map service

In order to give everyone more confidence to start our work, I will first use the engine to develop an instance with the above features: ESRI China (Beijing) Training Center Server fat client.

On the tab on the right, you can see that we can connect to the map service published by the server in two ways: Lan and Internet. These two methods basically solve all the network types we encounter in our daily work. Further, we can see that by specifying the address of the server (such as V9 in the LAN or http: // 202.111.113.201 in the Internet ), we can connect to the server service at any location and display its content. In the map server and data frame ComboBox, we can see that the Service published by the server has been split and can be selected. Finally, we can clearly see all the content published in the server service in the map display area at the bottom.

How are these seemingly incredible processes implemented?

First, split the application. This application is composed of the following controls (only list the main ones ):

Name

Control Type

Functions

Expressconnect

Commandbutton

Provides all the connection code to help the engine client connect to the server

Picture1

Picturebox

Displays the content in the Map Service published by the server.

Cbomapserver

ComboBox

Split to display all server objects in the corresponding address

Cbodataframe

ComboBox

Split to display all map objects in each server objects

Cbobookmark

ComboBox

Obtain all bookmarks of the server map service.

We can see that the engine application can connect to the remote server map service mainly because of the functions implemented by the code called in the connector connect. Let's take a look at how the code works (the code description is added to the code comment ).

Private sub branch connect_click ()

Set m_pmapserver = nothing 'if the user is interacting with another server map service during connection, release the server objects
'Prepare to connect to the server map service. First, create a propertyset object, as we often do when we connect to SDE.

Dim pconnectionprops as ipropertyset

Set pconnectionprops = new propertyset

If optlan. value = true then', if the user wants to connect to the server in the LAN, obtain the machine name.

Pconnectionprops. setproperty "machine", txtserver. Text

Else

Pconnectionprops. setproperty "url", txtserver. text' if the user wants to connect to the server on the internet, obtain the URL address

End if

Use an iagsserverconnectionfactory interface to create an instance of agsserverconnectionfactory and connect it to the server map service.

Dim pagsserverconfactory as iagsserverconnectionfactory

Set pagsserverconfactory = new agsserverconnectionfactory

Set m_pagsserverconnection = pagsserverconfactory. Open (pconnectionprops, 0)
'Connection successful
'Get all map server objects in this connection

Dim pagssobjs as iagsenumserverobjectname

Set pagssobjs = m_pagsserverconnection.serverobjectnames

Dim pagssobj as iagsserverobjectname

Set pagssobj = pagssobjs. Next

Do until pagssobj is nothing

If pagssobj. type = "mapserver" then

Cbomapserver. additem pagssobj. Name

Set pagssobj = pagssobjs. Next

End if

Loop

End sub

So far, we have successfully connected to a remote server map service and obtained all its map servers. This is what you see on the software interface. You will surely notice that the ComboBox of the map server is already in the optional status, but nothing is displayed in the map. Why? In fact, we only need to add a function called "Draw map" to solve this problem.

In essence, when ArcGIS Server publishes the map service over the Internet, it essentially sends the current image of the map service. Therefore, we only need to obtain the map service accurately. At this time, the status information of the images that have been images can be displayed in the picturebox.

Next let's take a look at how this code shows the map.

Private function drawmap (pmapdescriptoin as imapdescription, pmapserver as imapserver)

Dim it as iimagetype, idisp as iimagedisplay

Dim PID as iimagedescription' first, set the image description to the image output of the map service.

Set it = new imagetype 'create a new imagetype and set it to JPG

It. format = esriimageformat. esriimagejpg

It. returntype = esriimagereturntype. esriimagereturnmimedata

Set idisp = new imagedisplay

Idisp. Height = 400

Idisp. width = 500

Idisp. deviceresolution = 150 'sets the image display size and device resolution.

Set pid = new imagedescription

PID. Display = idisp

PID. type = it' generate a new imagedescription object and accept the previous settings 'imagedisplay and imagetype.

In this case, we have a JPG file with the size of '2017*400, and the device resolution is 500.

Dim PMI as iimageresult

Set PMI = pmapserver. exportmapimage (pmapdescriptoin, pid)
'Add the content in pmapserver to imageresult.

Dim B () as byte 'converts the MIME data type to an image.

B () = PMI. mimedata

Dim pmemblb as imemoryblobstreamvariant

Set pmemblb = new memoryblobstream

Pmemblb. importfromvariant B

Dim ppersist as ipersiststream, hbitmap as long, ppicture as ipicturedisp

Dim PIC as picdesc, PPIC as ipicture, iid_idispatch as guid

With iid_idispatch

. Data1 = & h20400

. Data4 (0) = & hc0

. Data4 (7) = & h46

End with 'sets the guid to the guid of the idispatch interface.

With PIC

. Size = Len (PIC)

. Type = vbpictypebitmap

. Hbmp = hbitmap

. Hpal = 0

End with 'create a picture structure to store the passed image object

Dim result as long 'create a new image object

Result = olecreatepictureindirect (PIC, iid_idispatch, true, PPIC)

Set ppersist = PPIC
Ppersist. Load pmemblb

Picture1.picture = PPIC
Picture1.refresh

End Function

Then, after refreshing picturebox, we can see the complete server map service content.

More advanced functions

Through a series of code operations just now, we have learned how to use the engine to develop a client and connect to the server map service at any location. By operating picturebox, we successfully display the content in the map service on our client. (Just like what we often do on thin clients ).

But this is just the beginning of our work. The biggest difference between a client developed by the engine and a thin client is that it is built based on ArcObjects at the underlying layer, therefore, our client can not only view data, but also further process the server map service on the remote client. As we have seen above, we have successfully obtained the map server through the connection. Then, as long as we develop this idea further, we can get more commonly used maps, layers, and more information in our daily development. Finally, ArcGIS Server becomes a powerful remote server and database of the engine client. Although large-scale data is stored on the other side of the Internet, advanced geographic information operations such as data analysis and editing can still be smoothly performed on our clients.

In addition, ArcGIS Server gives us more advanced development methods. Including:

* Asp.net Web Application Development (development of server websites)

* Development of pooled and non-pooled user interaction modes (Online Editing of webpage Mode)

* Expand the development of Web controls for the ADF (development of Web application controls)

* Expand the development of web templates for the ADF

* ArcGIS Server Web Servics development and so on (Web Servics)

These advanced development directions not only give full play to the functions of ArcGIS Server, but also make your B/S development methods rich and vital. These advanced development methods will be included in the ArcGIS Server Application Development tutorial at ESRI China (Beijing) Training Center.

 

Original article: http://www.gissky.net/Article/107.htm

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.