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

annsそれが解析されたxml要素を持つ配列であると仮定します。

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 に答える