Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6385597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:55:10+00:00 2026-05-25T02:55:10+00:00

i am working on an app that viewing pins on a map the app

  • 0

i am working on an app that viewing pins on a map

the app is reading the pins from an SQLite data base using this code:

- (void) readDB
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDir = [paths objectAtIndex:0];

    NSString *filename = @"places.db";
    NSString *filedocPath = [docDir stringByAppendingPathComponent:filename];

    BOOL success;
    NSFileManager *fileManager = [NSFileManager defaultManager];
    success = [fileManager fileExistsAtPath:filedocPath];

    if(success == NO)
    {
        NSString *configPathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:filename];

        [fileManager copyItemAtPath:configPathFromApp toPath:filedocPath error:nil];
        [fileManager release];
    }

    FMDatabase* db = [FMDatabase databaseWithPath:filedocPath];
    if (![db open]) {
        NSLog(@"Could not open db.");
        return;
    }

    // kind of experimentalish.
    [db setShouldCacheStatements:YES];


/*read*/
    for(int i = 0; i <colNum; i++)
    {
        [poi_Infos addObject:[[NSMutableArray alloc] init]];
    }

    NSString *queryString=[NSString stringWithFormat:@"select Category as %@,* from Places",categoryName];
    FMResultSet *rs = [db executeQuery:queryString];
    while ([rs next])
    {
        // just print out what we've got in a number of formats.
        [ [poi_Infos objectAtIndex:0] addObject:[rs stringForColumn:@"Company Name"]];
        [ [poi_Infos objectAtIndex:1] addObject:[NSNumber numberWithDouble:[[rs stringForColumn:@"Latitude"] doubleValue]] ];
        [ [poi_Infos objectAtIndex:2] addObject:[NSNumber numberWithDouble:[[rs stringForColumn:@"Longitude"] doubleValue]] ];
    }
    [rs close];  

    [db close];

    //NSLog(@"%@,%@", [[poi_Infos objectAtIndex:0] objectAtIndex:0],[[poi_Infos objectAtIndex:1] objectAtIndex:0]);

}

- (void) displayLocalPOI
{
    CLLocationCoordinate2D CurrentLocation;

    CurrentLocation=map.userLocation.coordinate;



    //set the radius in km so that you will get the nearest location in that radius

    double radius=localSearchRadius;


    int num = [[poi_Infos objectAtIndex:0] count];
    for(int i = 0; i < num; i++)
    {
        double y = [[[poi_Infos objectAtIndex:1] objectAtIndex:i] doubleValue];
        double x = [[[poi_Infos objectAtIndex:2] objectAtIndex:i] doubleValue];

        if(y>=CurrentLocation.latitude-(radius/111)&&y<=CurrentLocation.latitude+(radius/111))
        {
            if(x>=CurrentLocation.longitude-(radius/111)&&x<=CurrentLocation.longitude+(radius/111))
            {

                CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(
                                                                          (CLLocationDegrees)y, 
                                                                          (CLLocationDegrees)x);

                NSString *title = [[poi_Infos objectAtIndex:1] objectAtIndex:i];

                UserAnnotation *userAnnotation = [[UserAnnotation alloc] initWithCoordinate:coord];
                userAnnotation.title = title;
                [self.mapAnnotations addObject:userAnnotation];

                [userAnnotation release];
            }
        }



    }



}

as i have more than 10,000 pints, the app work very slowly.

My question is:

1- is there any way to make the process faster? like select only pins in the nearest location in a radius before handling them? please provide a code.

2- how can i drop more pins if i zoom out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:55:11+00:00Added an answer on May 25, 2026 at 2:55 am

    First of all, get from SQL database values what you need at current moment. I don’t think what you can view all 10000 points at once after app started. So make selection for specific region by objects latitude and longitude. And when user drag map, update your data model with pins from SQL which visible at current moment.

    Add annotation as batch through addAnnotations: this may add some speed to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an app that is reading it's data from a customized RSS
I'm working on an app that plays audio continuously using the waveOut... API from
I`m working on an app that does reading and handling specific URIs from NFC
So I'm working on app that involves leveraging user profile data from FB. But
I'm working on an app that needs to accept a RegEx from the user,
I'm working on an app that will be using https, but we wanted to
I'm working on an app that sends raw data to zebra printer and print
I'm currently working on an app that is being created using Ironspeed Designer. It's
Using Visual Studio 2008 and VB.Net: I have a working web app that uses
I'm working on an app that has a status menu and from that menu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.