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 4091116
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:19:31+00:00 2026-05-20T19:19:31+00:00

i am building an iphone app and i am looking for an idea how

  • 0

i am building an iphone app and i am looking for an idea how to get objects close to my position. the objects have an address listed in my database. now i am interested to show the objects that are close to mine on the map. how do i get that property? at first i thought of floyd-warshall but is there an better solution than coding that myself?

  • 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-20T19:19:32+00:00Added an answer on May 20, 2026 at 7:19 pm

    The first thing you’ll need to do is get Lat Long positions in your database instead of Addresses. There is a tool that google provides that does this. There is also a manual approach.

    Then you can use the Haversine formula to work out if it is within a certain radius of your location.

    Here is a example. You can cycle through your objects(‘s location) on the map and see how far away they are from you.

    -(CGFloat) getDistance :(CGFloat)objLatitude :(CGFloat)objLongitude :(CGFloat)currentLocationLatitude :(CGFloat)currentLocationLongitude
    {
        CGFloat earthRadius = 6371;
    
        CGFloat deltaLat = deg2rad(currentLocationLatitude - objLatitude);
        CGFloat deltaLong = deg2rad(objLongitude - currentLocationLongitude);
    
        CGFloat a = sin(deltaLat/2) * sin(deltaLat/2) +
            cos(deg2rad(objLatitude)) * cos(deg2rad((double)currentLocationLatitude)) * 
            sin(deltaLong/2) * sin(deltaLong/2);
    
        CGFloat c = 2 * atan2(sqrt(a), sqrt(1 - a));
        CGFloat d = earthRadius * c;
    
        d = round(d, 4); // round to 4dp
        d = d * 1000; // convert from km to m
        d = d * 0.621371192; // convert from km to miles
    
        return d; // m
    }
    

    You could amend this method to return TRUE if it is within a specific distance and FALSE if it does not:

    -(BOOL) doesObjFallWithinMyRadius :(CGFloat)objLatitude :(CGFloat)objLongitude :(CGFloat)currentLocationLatitude :(CGFloat)currentLocationLongitude :(CGFloat)distanceLimit
    {
        CGFloat earthRadius = 6371;
    
        CGFloat deltaLat = deg2rad(currentLocationLatitude - objLatitude);
        CGFloat deltaLong = deg2rad(objLongitude - currentLocationLongitude);
    
        CGFloat a = sin(deltaLat/2) * sin(deltaLat/2) +
            cos(deg2rad(objLatitude)) * cos(deg2rad((double)currentLocationLatitude)) * 
            sin(deltaLong/2) * sin(deltaLong/2);
    
        CGFloat c = 2 * atan2(sqrt(a), sqrt(1 - a));
        CGFloat d = earthRadius * c;
    
        d = round(d, 4); // round to 4dp
        d = d * 1000; // convert from km to m
        d = d * 0.621371192; // convert from km to miles
    
        if(d < distanceLimit) return TRUE;
        else return FALSE;
    }
    

    To find out your current location you will need to use the CLLocationManager which is part of the iOS SDK.

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

Sidebar

Related Questions

We are looking at building a cross-platform mobile app for iPhone, Android, etc. In
I have a question regarding iphone development. i am building an app for iphone
I am building an iPhone app. Currently when I close the app and relaunch
I am building an iphone app that reads a phone number from the address
I'm building an iPhone app, with the following structure: I have the MainViewController which
I'm looking to start building an iPhone app and I was wondering if it
I am now building an iPhone app and it involves core data. One of
I finally succeeded in building my first iPhone app but now I am pulling
I'm building an iphone app, and i have my first view call a second
I'm building an iPhone app, and my app copies a bunch of resources to

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.