我已经成功地从xml文件中获取了注释:
double realLatitude = [[[anns objectAtIndex:i] objectForKey:@"Latitude"] doubleValue];
double realLongitude = [[[anns objectAtIndex:i] objectForKey:@"Longitude"] doubleValue];
MyAnnotation *myAnnotation = [[MyAnnotation alloc] init];
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = realLatitude;
theCoordinate.longitude = realLongitude;
myAnnotation.coordinate=CLLocationCoordinate2DMake(realLatitude,realLongitude);
xml文件如下所示:
<key>Latitude</key>
<string>60.490275</string>
<key>Longitude</key>
<string>22.255962</string>
但现在我有一个大的坐标列表,如下所示:
<key>Coordinates</key>
<string>27.864849695000,70.080733147000</string>
我需要改变我的代码是什么?谢谢!
答案 0 :(得分:1)
假设anns
是包含已解析xml
元素的数组:
NSString *coordinates = [[anns objectAtIndex:i] objectForKey:@"Coordinates"];
double realLatitude = [[[coordinates componentsSeparatedByString:@","] objectAtIndex:0] doubleValue];
double realLongitude = [[[coordinates componentsSeparatedByString:@","] objectAtIndex:1] doubleValue];