Find nearest place

Discussion in 'iOS Programming' started by OriginalJef, May 27, 2013.

  1. OriginalJef macrumors newbie

    Joined:
    Mar 1, 2013
    #1
    Hye,

    I'm searching for a way to see the closed shop, calculated on your current location. I'm a noob in programming for iOS and can't find a way to do it.
    The thing is that I have a table view controller with al the shops and I want to press the button it needs to filter the list and give only the nearest shop in the list.

    Sorry for the bad english.

    Pleas help,
    Original jef
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    What have you tried? What code have you written so far?
     
  3. xArtx macrumors 6502a

    Joined:
    Mar 30, 2012
    #3
    The short answer is measure the distance to all of them, and disqualify all but the closest.
    And how much have you searched this forum?
    The spoon fed solution is right here!
     
  4. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #4
    Create CLLocation objects for all your locations.

    Then get the current location, and create a CLLocation object for that too.

    Then use the CLLocation method distanceFromLocation to calculate the distance from the user's current location to each "shop" in your list of locations. Select the "shop" locations that are within your distance cutoff.

    When the user moves a significant distance from his current location (say 1/2 kilometer) you'll need to recalculate your distances.
     

Share This Page