In C #, arcengine is used in winform to call the Services released by ArcGIS Server.

Source: Internet
Author: User

From: http://blog.sina.com.cn/s/blog_5d25ac4e0100yncl.html

 

The iagsserveroject interface and imapserver interface in AE are mainly used.
Private void getservertest_click (Object sender, eventargs E)
       {
  // Obtain the service object name

           Iagsserverobjectname pserverobjectname = fig ("http://services.arcgisonline.com/ArcGIS/services", "esri_imagery_world_2d", false );
           INAME pname = (INAME) pserverobjectname;
  // Access the map service
           Iagsserverobject pserverobject = (iagsserverobject) pname. open ();
           Imapserver pmapserver = (imapserver) pserverobject;
          
           ESRI. ArcGIS. Carto. imapserverlayer pmapserverlayer = new ESRI. ArcGIS. Carto. mapserverlayerclass ();
  // Connect to the map service

           Pmapserverlayer. serverconnect (pserverobjectname, pmapserver. defaultmapname );
  // Add a data layer

           Axmapcontrol1.addlayer (pmapserverlayer as ilayer );               

      Axmapcontrol1.refresh ();
       }

 

 

 Public iagsserverobjectname getmapserver (string phostorurl, string pservicename, bool pislan)
       {
         

           // Set Connection Properties
           Ipropertyset ppropertyset = new propertysetclass ();
           If (pislan)
               Ppropertyset. setproperty ("machine", phostorurl );
           Else
               Ppropertyset. setproperty ("url", phostorurl );

           // Open the connection

           IagsserverconnectionfactOry pfactory = new agsserverconnectionfactoRy ();
           // Type factorytype = type. gettypefromprogid (
           //  "Esrigisclient. agsserverconnectionfactoRy ");
           // IagsserverconnectionfactOry agsfactory = (iagsserverconnectionfactOry)
           //  Activator. createinstance (factorytype );
           Iagsserverconnection pconnection = pfactory. Open (ppropertyset, 0 );

           // Get the image server.
           IagsenumserverobjectnamePserverobjectnames = pconnection. serverobjectnames;
           Pserverobjectnames. Reset ();
           Iagsserverobjectname serverobjectname = pserverobjectnames. Next ();
           While (serverobjectname! = NULL)
           {
               If (serverobjectname. Name. tolower () = pservicename. tolower ())&&
                   (Serverobjectname. type = "mapserver "))
               {
                    
                   Break;
               }
               Serverobjectname = pserverobjectnames. Next ();
           }

           // Return object
           Return serverobjectname;
       }
Compiled in vs2008 + ae9.3

 

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.