Multiple Annotations On Mapkit for iPhone

匆匆过客 提交于 2019-12-24 11:48:02

问题


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:


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; 
    }

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

awaiting for you reply



来源:https://stackoverflow.com/questions/3837237/multiple-annotations-on-mapkit-for-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!