ArcGIS Engine calls the ArcGIS Server service

Source: Internet
Author: User

You first need to add two references:

Using ESRI. Arcgis.gisclient;
Using ESRI. Arcgis.datasourcesraster;

        <summary>//ArcGIS Server service is invoked///</summary>//<param NA Me= "Sender" ></param>//<param name= "E" ></param> private void symbol varies with scale toolstripmenui Tem_click (object sender, EventArgs e) {//Get service object name Iagsserverobjectname Pserverobjectname = G            Etmapserver ("Http://services.arcgisonline.com/ArcGIS/services", "esri_imagery_world_2d", false);            Iname pName = (iname) pserverobjectname;            Access Map Service Iagsserverobject Pserverobject = (iagsserverobject) pname.open ();            Imapserver pmapserver = (imapserver) pserverobject; ESRI. ArcGIS.Carto.IMapServerLayer Pmapserverlayer = new ESRI.            ArcGIS.Carto.MapServerLayerClass ();            Connection Map Service Pmapserverlayer.serverconnect (Pserverobjectname, pmapserver.defaultmapname);            Add Data layer Axmapcontrol1.addlayer (Pmapserverlayer as ILayer); Axmapcontrol1.refreSH (); }///<summary>///Get a map service, return to Iagsserverobjectname///</summary>//<param Name= "Phostorurl" ></param>//<param name= "Pservicename" ></param>//<param name= " Pislan "></param>///<returns></returns> public iagsserverobjectname getmapserver (strin G Phostorurl, String pservicename, bool Pislan) {//Set connection properties Ipropertyset Ppropertyset = new Pr            Opertysetclass ();            if (Pislan) Ppropertyset.setproperty ("Machine", phostorurl);            else ppropertyset.setproperty ("url", Phostorurl);            Open 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.            Iagsenumserverobjectname pserverobjectnames = pconnection.serverobjectnames;            Pserverobjectnames.reset ();            Iagsserverobjectname serverobjectname = Pserverobjectnames.next (); while (serverobjectname! = null) {if ((ServerObjectName.Name.ToLower () = = Pservicename.tolower (                ) && (Serverobjectname.type = = "MapServer")) {break;            } serverobjectname = Pserverobjectnames.next ();        }//Returns the object return serverobjectname; }

  

ArcGIS Engine calls the ArcGIS Server service

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.