如何从谷歌地图的标记在ios中的dictionay?

在我的应用程序中,我已经做了JSONparsing,我得到了一个字典的forms的坐标,我想使用坐标angd在地图上绘制它,
我有使用这个

SBJsonParser *jsonParser = [SBJsonParser new]; NSArray *jsonData = (NSArray *) [jsonParser objectWithString:outputData error:nil]; for(int i=0;i<[jsonData count];i++) { NSDictionary *dict=(NSDictionary *)[jsonData objectAtIndex:i]; Nslog(@"%@",dict); double la=[[dict objectForKey:@"latitude"] doubleValue]; double lo=[[dict objectForKey:@"longitude"] doubleValue]; CLLocation * loca=[[CLLocation alloc]initWithLatitude:la longitude:lo]; CLLocationCoordinate2D coordi=loca.coordinate; marker=[GMSMarker markerWithPosition:coordi]; marker.snippet = @"Hello World"; marker.animated = YES; marker.map = mapView; } 

它被打印为

 [{"driver_id":"Tn1234sunil@gmail.com","username":"sunil","latitude":"0.000000000000000", "longitude":"0.000000000000000"}, {"driver_id":"ma12marii@yahoo.com","username":"mari","latitude":"13.040720500000000", "longitude":"80.243139600000000"}, {"driver_id":"45sabala@gmail.com","username":"balaji","latitude":"0.000000000000000", "longitude":"0.000000000000000"} 

然后,在我的日志中,它被打印为

 2014-01-04 10:55:48.121 MyTaxi[608:12e03] latitude : 0.000000 2014-01-04 10:55:48.121 MyTaxi[608:12e03] longitude : 0.000000 2014-01-04 10:55:48.122 MyTaxi[608:12e03] latitude : 13.040721 2014-01-04 10:55:48.122 MyTaxi[608:12e03] longitude : 80.243140 2014-01-04 10:55:48.122 MyTaxi[608:12e03] latitude : 0.000000 2014-01-04 10:55:48.123 MyTaxi[608:12e03] longitude : 0.000000 

但是,这不能正常工作

 Does any body have an idea how to plot these points to the google maps 

尝试这一个这可能是有帮助的只是创build一个for循环到你的计数,增加它…

 NSDictionary *dict=(NSDictionary *)[jsonData objectAtIndex:i]; double la=[[dict valueForKey:@"latitude"] doubleValue]; double lo=[[dict valueForKey:@"longitude"] doubleValue]; NSMutableArray * latArray=[[NSMutableArray alloc]init]; NSMutableArray * longArray=[[NSMutableArray alloc]init]; [latArray addObject:[NSNumber numberWithDouble:la]]; [longArray addObject:[NSNumber numberWithDouble:lo]]; CLLocation * loca=[[CLLocation alloc]initWithLatitude:[[latArray objectAtIndex:i]doubleValue] longitude:[[longArray objectAtIndex:i]doubleValue]]; CLLocationCoordinate2D coordi=loca.coordinate; GMSMarker *marker= [[GMSMarker alloc] init]; marker=[GMSMarker markerWithPosition:coordi]; marker.position = CLLocationCoordinate2DMake([[latArray objectAtIndex:i]doubleValue], [[longArray objectAtIndex:i]doubleValue]); marker.snippet = @"Hello World"; marker.animated = YES; marker.map = mapView; 

我想,你必须在循环中分配标记,现在你只创build一个标记,

 for(int i=0;i<[jsonData count];i++) { NSDictionary *dict=(NSDictionary *)[jsonData objectAtIndex:i]; double la=[dict valueForKey:@"latitude" doubleValue]; double lo=[dict valueForKey:@"longitude" doubleValue]; CLLocation * loca=[[CLLocation alloc]initWithLatitude:la longitude:lo]; CLLocationCoordinate2D coordi=loca.coordinate; GMSMarker *marker= [[GMSMarker alloc] init]; marker=[GMSMarker markerWithPosition:coordi]; marker.snippet = @"Hello World"; marker.animated = YES; marker.map = mapView; ..... }