首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

IOS移动端怎么获取ArcGIS Server的服务列表

2012-09-19 
IOS移动端如何获取ArcGIS Server的服务列表1、应用需求ArcGIS Server服务器增加、删除服务,移动端能动态的获

IOS移动端如何获取ArcGIS Server的服务列表

1、应用需求

ArcGIS Server服务器增加、删除服务,移动端能动态的获取服务列表;

2、移动端解决方法

2.1、获取服务器端服务列表URL地址

(1)打开ArcGIS Server服务目录

IOS移动端怎么获取ArcGIS Server的服务列表

(2)点击rest得到服务列表URL

IOS移动端怎么获取ArcGIS Server的服务列表

(3)点击rest可以看到服务列表的json串,这个url就是我们获取服务列表的url

IOS移动端怎么获取ArcGIS Server的服务列表

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列表

IOS移动端怎么获取ArcGIS Server的服务列表

热点排行