CoreLocation City Name

Discussion in 'iOS Programming' started by DSchwartz88, Jul 25, 2008.

  1. DSchwartz88 macrumors 6502

    May 18, 2006
    Hey All,

    In my application i want to use the CoreLocation framework to append a the users current location to a string (which will be sent out as a POST to php, but thats not imporant). When using CoreLocation im noticing that you really only get Lat and Long co-ordinates back. In the twitteriffic app, and some others i notice it will give you city names and not lat and long lines, how would i ask CoreLocation to give me back a city name, or how do i take my lat long co-ordinates and translate them into a city name.

  2. Flyncode macrumors newbie

    Sep 5, 2007
    If another application is doing a city lookup, it's going to be a function that that app is performing, or one of its services. I don't seem any ability in CoreLocation to get the city name, which is to be expected.

    If you want to perform it yourself, you're going to have to dive into Geographic Information Systems (GIS for short), where you compare the Lat/Lon you get from CoreLocation to a set of polygons loaded from a file, seeing which polygons the point is inside of. Then comes a myrid of questions: how will the information about the city polygon be stored and how will you load it? How are you going to do the search (there are pre-prepared algorithms you could use)? How expansive of a city search are you going to be doing?

    There's no quick-and-easy way to do it, really, at least from the app perspective. You may be able to find a web service that would do the search for you, and return the city name. If you can find that, then you'd be golden. Short of that, you'd have to put infrastructure in place.

    Hope this helps.
  3. xsmasher macrumors regular


    Jul 18, 2008
    How to find city name

    Last time I looked for city data, I found these data sets - you could put them in a database (on a server) and query them to find a list of nearest cities. (There's no "city limits" data here, just a single point for each city center.)

    Geonames data
    files for each country, plus "all"

    Data pulled from Wikipedia
    Geocoordinates from Wikipedia for Google Earth
    found on

Share This Page