我是ios
字段中的新成員,現在我正在嘗試執行基於MKMapView
的iPhone應用程序。從Google地圖Web網絡服務我以JSON
輸出格式獲取數據。如何從JSON輸出數據中解碼路線點?
- (void)update {
self.responseData=[NSMutableData data];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://maps.googleapis.com/maps/api/directions/json?origin=Ernakulam&destination=Kanyakumari&mode=driving&sensor=false"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
[self.responseData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[self.responseData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
[connection release];
self.responseData =nil;
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSLog(@"connection established");
[connection release];
NSString *responseString=[[NSString alloc]initWithData:self.responseData encoding:NSUTF8StringEncoding];
self.responseData=nil;
NSLog(@" OUTPUT JSON DATA^^^^^^^^^^^^^^^^%@",responseString);
}
我得到了輸出已在JSON
格式。現在我想繪製這兩個位置之間的路線。母豬如何分離出JSON
輸出數據的所有緯度和經度點。
看看我的答案 – Hiren 2012-04-11 06:25:02