【问题标题】:Property 'jsonData' not found on object of type 'MapViewController *'在“MapViewController *”类型的对象上找不到属性“jsonData”
【发布时间】:2012-07-31 02:25:52
【问题描述】:

我正在尝试在我的应用程序的图形层上绘制路线,但我不知道这是正确的方法,还是有其他方法?我在哪里尝试使用 NSArray 和 ArgGIS 来绘制地图,我遇到了问题。

*edit 我尝试将 NSArray 改回 JSON 字符串并尝试使用带有 JSON 字符串的 ArcGIS 来绘制它

这就是我所做的:

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 绘制路径线?

【问题讨论】:

  • 有没有办法可以使用NSArrayArcGIS 在图形层上绘制路径?

标签: iphone objective-c ios xcode4.3 arcgis


【解决方案1】:

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

你的代码有点奇怪。

什么是routeGrphic???

你是不是忘记了下面的类似代码?

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

【讨论】:

  • YourObject *object = [path objectAtIndex:index]; 这是在 NSArray *PATH = [dic valueForKey:@"PATH"]; 的 for 循环中,我将它传递给 path。 routeGraphic 是从 ArcGIS 包中使用的
猜你喜欢
  • 2014-04-27
  • 2012-03-04
  • 1970-01-01
  • 2023-03-22
  • 2019-06-25
  • 2021-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多