2010-10-01 133 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