How does IOS Mobile get the service list of ArcGIS Server?

Source: Internet
Author: User

1. Application Requirements

The ArcGIS Server adds or deletes services, and the mobile end can dynamically obtain the service list;

2. Mobile Solutions

2.1 obtain the URL address of the server service list

(1) Open the ArcGIS Server Service Directory

(2) Click rest to get the service list URL

(3) Click rest to view the JSON string of the service list. This URL is the URL for getting the service list.

2.2 IOS reading Method

(1) asynchronous service call

// Service URL

Nsurl * URL = [Nsurl Urlwithstring: @ "http: // 192.168.0.1/ArcGIS/rest/services? F = pjson "];
// Self. currentjsonop is Agsjsonrequestoperation object Self. currentjsonop = [[Agsjsonrequestoperation Alloc] initwithurl: url] Autorelease];

Self.currentjsonop.tar get = Self;
Self. currentjsonop. Action = @ Selector (Operation: didsucceedwithresponse :);
Self. currentjsonop. erroraction = @ Selector (Operation: didfailwitherror :);
// Self. queue is the nsoperationqueue object
// Add Operation To The Queue To Execute In
The Background
[Self. Queue Addoperation: Self. currentjsonop];

(2) process the call result and obtain the service name.
// The WebService was invoked successfully.

- (Void) operation :( nsoperation *) OP Didsucceedwithresponse :( nsdictionary *) Weatherinfo {
// Print The Response To See What The JSON
Payload Looks Like.
Nslog (@ "% @", Weatherinfo );
Nslog (@ "Number Is % D ", weatherinfo. Count );
If ([weatherinfo Objectforkey: @ "services"]! = Nil ){
Nsarray * Servicesarray = [weatherinfo
Objectforkey: @ "services"];
Nslog (@ "% @, lenth Is % D ", Servicesarray, [servicesarray Count]);
For (Int I = 0; I <[servicesarray Count]; I ++)
{
Nsdictionary * Services = [servicesarray Objectatindex: I];
// Nslog (@ "% @", Services );
Nsstring * Name = [Services Objectforkey: @ "name"];
Nsstring * Type = [Services Objectforkey: @ "type"];
Nslog (@ "% @, % @", name, type );
}
}
}
// Processing failed, error encountered while invoking WebService. Alert user
- (Void) operation :( nsoperation *) OP Didfailwitherror :( nserror *) Error {
Self. mapview. callout. Hidden = Yes;
Uialertview * AV = [[Uialertview Alloc] Initwithtitle: @ "sorry"
Message: [Error Localizeddescription]
Delegate: Nil Cancelbuttontitle: @ "OK"
Otherbuttontitles: Nil] Autorelease];
[AV Show];
}

In this way, the URL list of the map service is obtained dynamically.

Related Article

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.