2012-08-02 49 views
0

我正在尝试在我的应用程序应用程序的图形层上绘制路线,而我不知道这是正确的做法还是另一个如何做到这一点?我在哪里试图使用NSArray和ArgGIS来绘制地图,我有问题。在'MapViewController *'类型的对象上未找到属性'jsonData'

*编辑我试图改变的NSArray回JSON字符串,并尝试使用ArcGIS与JSON字符串

这它来画是我做了什么:

NSArray *BusRoute=[jsonResult objectForKey:@"BusRoute"]; 
int i; 
int count = [BusRoute count]; 
for (i = 0; i < count; i++) 
{ 
    NSDictionary *dic = [BusRoute objectAtIndex: i]; 
    NSString *Duration = [dic valueForKey:@"Duration"]; 
    //---PATH--- 
    NSArray *PATH = [dic valueForKey:@"PATH"]; 
    NSLog(@"PATH = %@", PATH); 
    self.path = PATH; 
} 
NSError *writeError = nil; 
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:path options:NSJSONWritingPrettyPrinted error:&writeError]; 
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 
    NSLog(@"JSON Output: %@", jsonString); 
if (self.jsonString) { 
     // symbolize the returned route graphic 
     self.jsonString.routeGraphic.symbol = [self routeSymbol]; 

     // add the route graphic to the graphic's layer 
     [self._graphicsLayer addGraphic:self.jsonString.routeGraphic]; 

     // tell the graphics layer to redraw 
     [self._graphicsLayer dataChanged]; 
    } 

*为JSON输出串

JSON Output: [ 
    [ 
    "38909,35576;38872,35589;38861,35593;38848,35597;38697,35650;38695,35651;38695,35651;38609,35681;38583,35689;38553,35697;38508,35700;38476...;29560,40043" 
    ] 
] 

这是我必须在地图上绘制的路径的一部分:

PATH = (( "38909,35576;38872,35589;38861,35593;38848,35597;38697,35650;38695,35651;38695,35651;38609,35681;38583,35689;38553,35697;38508,35700;38476,35696;38476,35696;....)) 

此行self.jsonData.routeGraphic.symbol = [self routeSymbol];我得到一个错误Property 'Property 'jsonData' not found on object of type 'MapViewController *'

应该怎么做什么来解决?请帮助


*怎样绘制使用NSArray和使用ArcGIS路径的线?

+0

有没有一种方法可以在图形图层上使用'NSArray'和'ArcGIS'绘制路径? – sihao 2012-08-06 01:23:14

+0

重新编辑整个qn – sihao 2012-08-08 09:35:47

回答

0

routeGraphic属性与NSArray类没有任何关联。 NSArray是集合。

你的代码有点奇怪。

什么是routeGrphic ???

是不是忘了下面的代码?

YourObject *object = [path objectAtIndex:index]; 
object.routeGraphic.symbol = [self routeSymbol]; 
+0

'YourObject * object = [path objectAtIndex:index];'这是在for循环,它是'NSArray * PATH = [dic valueForKey:@“PATH”]; '我把它传递给'路径'。 routeGraphic使用来自ArcGIS软件包 – sihao 2012-08-02 06:49:04

+0

添加了我编辑的代码 – sihao 2012-08-02 06:55:28

相关问题