posted by: Ralf Rottmann | posted @ Sunday, September 07, 2008 8:58 PM | View blog reactions

As many if not all of my readers know approved iPhone developers are under a heavy NDA. This prevents public code discussions and step-by-step tutorials. One of the applications I'm currently working on heavily depends on the current user's location. When I started diving into creating location based applications I naively assumed that iPhone's Core Location Framework would provide me with a rich API for getting country, city and street information. Well, that's not the case.

At the end of the day all Core Location Framework gives you are latitude and longitude as a 2D coordinate. The rest is up to you.

So in case you want to create a location based application you've got to do the reverse geocoding yourself. There are many free web services out there which provide you with the latitude and longitude information if you input an address. That's not what we need. We do need it vice versa. Therefore the term is coined reverse geocoding.

Even without the ability to go into code level discussions here, these hints might shorten your journey:

  • For Europe I'm using the free geolocation web services at http://www.geonames.org/. You don't have to register, get an App Id or anything like that. Just use it and feel happy.
  • For reverse geocoding the findNearbyPostalCodes method is just fine.
  • Here's what I do
    • Use Core Location to get latitude and longitude
    • Use GeoNames REST API to get the postal code
    • Use NSXML parser to asynchronously parse the GeoNames resulting XML document
    • Use the <name> element's content to resolve the user's current city

Finally here is a nice overview of all the web services GeoNames offers.

Last note: iPhone Simulator always resolves to Cupertino (so GeoNames works fine for NA cities, too).

comments
boruiezg stated:
# boruiezg
boruiezg
posted on 10/19/2008 9:37 PM
sildenafil stated:
# sildenafil
sildenafil
posted on 10/21/2008 11:16 PM
hnioaobf stated:
# hnioaobf
hnioaobf
posted on 10/22/2008 7:40 PM
mdfdhjhx stated:
# mdfdhjhx
mdfdhjhx
posted on 10/22/2008 7:40 PM
pnvkjmbj stated:
# pnvkjmbj
pnvkjmbj
posted on 10/22/2008 7:40 PM
cipro stated:
# cipro
cipro
posted on 10/23/2008 1:13 PM
allopurinol stated:
# allopurinol
allopurinol
posted on 10/23/2008 1:14 PM
viagra stated:
# viagra
viagra
posted on 10/23/2008 2:35 PM
iahhhwta stated:
# iahhhwta
iahhhwta
posted on 10/23/2008 9:24 PM
pezfrmxu stated:
# pezfrmxu
pezfrmxu
posted on 10/23/2008 9:24 PM
bfpajspy stated:
# bfpajspy
bfpajspy
posted on 10/23/2008 9:24 PM
mgfcywhh stated:
# mgfcywhh
mgfcywhh
posted on 10/24/2008 3:04 PM
gcftazsl stated:
# gcftazsl
gcftazsl
posted on 10/24/2008 3:04 PM
zbiascty stated:
# zbiascty
zbiascty
posted on 10/24/2008 3:04 PM
generic zyrtec stated:
# generic zyrtec
generic zyrtec
posted on 10/25/2008 9:20 AM
paxil stated:
# paxil
paxil
posted on 10/25/2008 9:20 AM
ifuaexty stated:
# ifuaexty
ifuaexty
posted on 10/25/2008 4:47 PM
cheap propecia stated:
# cheap propecia
cheap propecia
posted on 10/27/2008 10:33 AM
sertraline stated:
# sertraline
sertraline
posted on 10/27/2008 12:28 PM
order valium stated:
# order valium
order valium
posted on 10/27/2008 12:28 PM
generic vicodin stated:
# generic vicodin
generic vicodin
posted on 10/27/2008 12:28 PM
jeiqkjhr stated:
# jeiqkjhr
jeiqkjhr
posted on 10/27/2008 7:07 PM
pzabzxly stated:
# pzabzxly
pzabzxly
posted on 10/27/2008 7:07 PM
vlwlzkto stated:
# vlwlzkto
vlwlzkto
posted on 10/27/2008 7:07 PM
posocxgy stated:
# posocxgy
posocxgy
posted on 10/28/2008 8:13 AM
kjzvqgbi stated:
# kjzvqgbi
kjzvqgbi
posted on 10/28/2008 8:13 AM
jhezeodw stated:
# jhezeodw
jhezeodw
posted on 10/28/2008 8:13 AM
ikfwdnlu stated:
# ikfwdnlu
ikfwdnlu
posted on 10/28/2008 8:13 AM
ruaxpqgs stated:
# ruaxpqgs
ruaxpqgs
posted on 10/29/2008 10:47 PM
unjkajkl stated:
# unjkajkl
unjkajkl
posted on 10/29/2008 10:47 PM
aetjbhqy stated:
# aetjbhqy
aetjbhqy
posted on 10/29/2008 10:47 PM
ecrqpcjt stated:
# ecrqpcjt
ecrqpcjt
posted on 10/29/2008 10:48 PM
tjninigq stated:
# tjninigq
tjninigq
posted on 11/9/2008 2:15 PM
sgzgcfez stated:
# sgzgcfez
sgzgcfez
posted on 12/1/2008 3:49 AM
post your comment
Title *
Name *
Email
Url
Comment *  
Please add 3 and 7 and type the answer here: