2010-10-01 66 views
1

有谁知道如何在地图上显示多个位置使用数据库?iPhone上的多个注释在Mapkit上

我试图删除多个引脚上的谷歌地图与数据库的帮助,但只是能够最后销下降

+0

我想我知道。但没有看到你的代码,它是不可能找到你的错误... – Vladimir 2010-10-01 07:50:17

+0

只是回应弗拉基米尔的请求 - 请张贴您的代码。 – dannywartnaby 2010-10-01 08:16:55

回答

2
Below is the function which i m using to fill array with the help of Database 


RecipieAppDelegate *appDelegate = (RecipieAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    [appDelegate getallrecords]; 
    self.namesArray=appDelegate.rs; 
    ///filling array with database 
     for (int i=0; i<namesArray.count; i++) { 
     Food *product = (Food *)[self.namesArray objectAtIndex:i]; 
     NSLog(@"%d",i); 
     appDelegate.mylatitude=product.Latitude; 
     appDelegate.mylongitude=product.Longitude; 
    /// this function is use to call the class which is use to drop pin on map 
    BridgeAnnotation *BridgePin = [[BridgeAnnotation alloc] init]; 
    [self.mapAnnotations insertObject:BridgePin atIndex:kBridgeAnnotationIndex]; 
    [BridgePin release]; 

    } 


/////CLASS BRIDGE ANNOTATION below is the function getting cordinate from above function n droping pin  
    - (CLLocationCoordinate2D)coordinate; 
    { 
     RecipieAppDelegate *appDelegate = (RecipieAppDelegate *)[[UIApplication sharedApplication] delegate]; 
     Food *product; 
     CLLocationCoordinate2D theCoordinate; 
    // theCoordinate.latitude = 37.810000; 
    // theCoordinate.longitude = -122.477989; 
     theCoordinate.latitude = [appDelegate.mylatitude doubleValue]; 
     NSLog(@"%f", theCoordinate.latitude); 
     theCoordinate.longitude = [appDelegate.mylongitude doubleValue]; 
     NSLog(@"%f", theCoordinate.longitude); 
     return theCoordinate; 
    } 

好,我完全在阵列5次运行循环,但其传递的最后一个值,以第二功能

等待你回复

+0

您不会更改kBridgeAnnotionIndex的值。您的所有BridgePin都插入到相同的索引中! 你在哪里调用方法坐标? – MathieuF 2010-10-01 11:54:36

+0

以及我定义bridgeannotionindex像这样enum { kBridgeAnnotationIndex }; (IBAction)cityAction:(id)sender { [self.mapView addAnnotation:[self.mapAnnotations objectAtIndex:kCityAnnotationIndex]]; } 您能否请我改正我的代码 – 2010-10-01 18:04:04

+0

尝试改变以更改kBridgeAnnotationIndex与我。但是如果没有更多的代码就很困难。 – MathieuF 2010-10-06 21:22:12