views:

180

answers:

1

Does anyone know how to display more than one location on a map Using Database?

I am trying to drop Multiple Pins on google Map with the help of database but just able to drop last pin

+1  A: 
Below is the funtion 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; 
    }

well I run loop perfectly on array 5 times but its pass the last value to second function

awaiting for you reply

STUPID PROGRAMMER
You don't change the value of kBridgeAnnotionIndex. All your BridgePin are inserted in the same index !Where are you calling the method coordinate ?
MathieuF
well i m defining bridgeannotionindex like this enum{ kBridgeAnnotationIndex}; and calling - (IBAction)cityAction:(id)sender{ [self.mapView addAnnotation:[self.mapAnnotations objectAtIndex:kCityAnnotationIndex]];} can you please correct my code
STUPID PROGRAMMER
Try change to change kBridgeAnnotationIndex with i. But it's difficult whithout more code.
MathieuF
well i already but pins are overlapping on each other but it drops pin 20 time on same coordinate i m sick of this honestly :(
STUPID PROGRAMMER