简体   繁体   English

Iphone CLLocationCoordinate2D

[英]Iphone CLLocationCoordinate2D

I am new at iphone and I have a problem. 我是iphone的新手,我有一个问题。

I have this code 我有这个代码

for (int i=0; i<2; i++) {
    Datos *datos = (Datos *)[arr_datos objectAtIndex:i];
    CLLocationCoordinate2D coord;
    AnnotationItem *annotationItem = [[AnnotationItem alloc] init];
    coord.latitude =[datos.latitud doubleValue];
    coord.longitude = [datos.longitud doubleValue];

    NSLog(@"coord %f",coord.longitude);
    NSLog(@"coord %f",coord.latitude);
    [annotationItem setCoordinate:coord];
    //[annotationItem setEstacion:estacion];

    [mapView_ addAnnotation:annotationItem];
    [annotationItem release];

}

The problem that it doesn't done anything 它没有做任何事情的问题

But if i change the coord.latitude=40.444 and coord.longitude=-3.700; 但如果我改变了coord.latitude=40.444coord.longitude=-3.700;

this gives me what I want, but I don't want this, because I have an array with many latitudes and longitudes. 这给了我想要的东西,但我不想要这个,因为我有一个有许多纬度和经度的阵列。 Can anyone help me with this? 谁能帮我这个? when i put coord.longitude=[datos.longitude floatValue]; 当我把coord.longitude=[datos.longitude floatValue]; , it doesn't work? ,它不起作用?

I'm using Xcode 3.2.2 我正在使用Xcode 3.2.2

Thanks and forgive me english. 谢谢,原谅我英语。

The problem is that i had change the values, I was putting wrong values. 问题是我改变了价值观,我提出了错误的价值观。 Only I have to do is change the 只有我要做的就是改变

coord.latitude =[datos.longitud doubleValue]; 
coord.longitude = [datos.latitud doubleValue]; 

thank everyone for your time. 谢谢大家的时间。

It seems like Datos is an object you defined since i couldn't find it in the SDK. 似乎Datos是您定义的对象,因为我在SDK中找不到它。 Given that it could be a few different things: 鉴于它可能是一些不同的东西:

  • Either that arr_datos does not have the correct (or any) data inside of it arr_datos中没有正确的(或任何)数据
  • It could be that the Datos object is incorrectly handling data passed into it and not storing it correctly. 可能是Datos对象错误地处理传递给它的数据而没有正确存储它。

Place a breakpoint in Xcode and verify that arr_datos has the information you think inside of it and that the datos object is correctly storing information. 在Xcode中放置一个断点,并验证arr_datos是否包含您认为的信息以及datos对象是否正确存储信息。

CLLocationCoordinate2D is not an object so declare it like: CLLocationCoordinate2D不是一个对象,因此声明如下:

 CLLocationCoordinate2D coord;

BTW, you should be getting warnings about CLLocationCoordinate2D *coord - can you check your compiler logs? 顺便说一句,您应该收到有关CLLocationCoordinate2D *coord警告 - 您能检查一下您的编译器日志吗?

[suggestion1] [suggestion1]

NSLog(@"datos.lon %@", datos.longitud);
NSLog(@"datos.lat %@", datos.latitud);

[/suggestion1] [/ suggestion1]

[suggestion2] [suggestion2]

Note too that you can iterate through all of your datos_arr with the following: 另请注意,您可以使用以下内容遍历所有datos_arr:

for(Datos *datos in datos_arry) {
    NSLog(.....);
}

[/suggestion2] [/ suggestion2]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM