简体   繁体   中英

store latitude and longitude in ios address book

Can latitude and longitude be added to a record in an iOS address book?

My app wants to display nearby contacts on a map. I know how to get the latitude/longitude from an address. I do not know how to save them so I can avoid repeated lookups

Yes, you can add a latitude-and-longitude address to a contact in your iOS address book. It takes one extra step to view the map pin from that address, but it works.

Open an existing or new Contact, and create a new address. Under Street, put in the latitude and longitude, with a comma between but no blank space. Leave everything else empty: city, state, and so on. It will force you to pick a country, so either just leave the default, or if you want, you can select the country that corresponds to the coordinates, though it really doesn't matter.

For example, you could enter:

• Street: 48.8582,2.2945
• Country: France (or any country)

(For locations South of the equator or East of the Greenwich meridian, add a minus sign: eg, -17.53655,-149.56832).

Save the address.

To go to the location in Apple maps, open the Contact and click the latitude/longitude address. This will take you to Apple maps. Don't wait for the map to come up, because if you wait the pin will be dead center in whatever country is listed. Instead, while it's thinking, just go to the address bar at the top and edit out the country so that only the lat/long is left and hit Search. This time, the pin will go directly to the correct latitude/longitude location. If you want Google maps, just copy/paste the lat/long into Google maps.

The example shown above should put you right at the Eiffel Tower. Bon voyage!

In iPhone native address book it's not possible to store. But you can do one thing, you can store info of the user in SQLite database in your app along with lat lon and if you want some synchronization functionality then you can create web-service which will update your SQLite database as per your logic.

Hope this will help you.

All the best !!!

I am not sure but this may be not possible to add latitude and longitude value to ABPeoplePickerNavigationController . but if you want to find distance between two Contact then you can find it from contacts's address or add your latitude and longitude value into database and use 2 option of mine .

There are two way for find location by address

1) How to get street address from ABPeoplePickerNavigationController

2) use reverseGeocodeLocation and also check this my answer CLLocationManager not getting City name this is helpful for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM