某些引脚有时不会出现在MKMapView上......为什么?

时间:2012-07-24 23:00:07

标签: ios annotations mkmapview

所以我有以下代码,分割街道,城镇,州,国家,zip并创建一个AddressAnnotation,一个我从注释扩展的类。

有时所有的针脚都会出现在地图上,有时它找不到某些地方,虽然它每次都是完全相同地址的集合。谷歌地图有时可以找到一个地方,但不是所有时间都有原因吗?

我的代码中有什么内容吗?

谢谢, [R

for (int i=0; i < [places count]-1; ++i) {

    NSArray *arrayPlace = [[places objectAtIndex:i] componentsSeparatedByString:@"***"];

    AddressAnnotation *addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:
                                        [self getLocationFromAddressString:
                                         [NSString stringWithFormat:
                                          @"%@ %@ %@ %@ %@ %@",
                                          [arrayPlace objectAtIndex:3],
                                          [arrayPlace objectAtIndex:4],
                                          [arrayPlace objectAtIndex:5],
                                          [arrayPlace objectAtIndex:6],
                                          [arrayPlace objectAtIndex:7],
                                          [arrayPlace objectAtIndex:8]]]];




    [addAnnotation setWebsite:[arrayPlace objectAtIndex:2]];
    [addAnnotation setTitle:[arrayPlace objectAtIndex:0]];
    [addAnnotation setSubtitle:[arrayPlace objectAtIndex:1]];


    [mapView addAnnotation:addAnnotation];
}

2 个答案:

答案 0 :(得分:0)

这不应该是第一行吗?

for (int i=0; i < [places count]; i++) {

或更好:

for (NSArray *arrayPlace in places) {

答案 1 :(得分:0)

尝试记录您正在生成的地址字符串。如果它们总是相同,那么请查看getLocationFromAddressString并查看它返回的坐标是否始终相同。如果没有,则该功能有问题。我一直在寻找这个功能,但谷歌只是让我回到StackOverflow。这是你自己的功能还是你用过这个问题的那个? MKMapView with address

相关问题