IOS移動端如何擷取ArcGIS Server的服務列表

來源:互聯網
上載者:User

1、應用需求

ArcGIS Server伺服器增加、刪除服務,移動端能動態擷取服務列表;

2、移動端解決方案

2.1、擷取伺服器端服務列表URL地址

(1)開啟ArcGIS Server服務類別目錄

(2)點擊rest得到服務列表URL

(3)點擊rest可以看到服務列表的json串,這個url就是我們擷取服務列表的url

2.2 IOS讀取方法

(1)非同步呼叫服務

//服務URL

NSURL* url = [NSURL URLWithString:@"http://192.168.0.1/arcgis/rest/services?f=pjson"];
//self.currentJsonOp是 AGSJSONRequestOperation 對象self.currentJsonOp = [[[AGSJSONRequestOperation alloc]initWithURL:url]autorelease];

self.currentJsonOp.target = self;
self.currentJsonOp.action = @selector(operation:didSucceedWithResponse:);
self.currentJsonOp.errorAction = @selector(operation:didFailWithError:);
//self.queue 是 NSOperationQueue 對象
//Add operation to the queue to execute in
the background
[self.queue addOperation:self.currentJsonOp];

(2)處理調用結果,得到服務名稱
//成功處理,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,[servicesArraycount]);
for (int i=0; i<[servicesArraycount];i++)
{
NSDictionary *services=[servicesArrayobjectAtIndex:i];
//NSLog(@"%@", services);
NSString *name=[servicesobjectForKey:@"name"];
NSString *type=[servicesobjectForKey:@"type"];
NSLog(@"%@,%@",name,type);
}
}
}
//處理失敗,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];
}

這樣就動態得到了地圖服務的URL列表

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.