0

我已经成功地从 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>

我需要改变我的代码工作吗?谢谢!

4

1 回答 1

1

Assuming that anns is the array with the parsed xml elements:

NSString *coordinates = [[anns objectAtIndex:i] objectForKey:@"Coordinates"];
double realLatitude = [[[coordinates componentsSeparatedByString:@","] objectAtIndex:0] doubleValue];
double realLongitude = [[[coordinates componentsSeparatedByString:@","] objectAtIndex:1] doubleValue];
于 2012-05-21T15:41:44.827 回答