我正在尝试在我的应用程序的图形层上绘制路线,但我不知道这是正确的方法,还是有其他方法可以做到?我在哪里尝试使用 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 绘制路径线?