Geolocation in Iphone Application - iphone

I am a newbee to Iphone App Development and struggling with my first application.
I have a database with few address in it. All I have to do is get the current location and pick the closest three address from the database and of-course have to show the current location and the selected three nearest address on a map with directions on them.
I had a look at the Xcode frameworks LocateMe, CurrentAddress and MKReverseGeocoder Class Reference.
But then not sure how to co-ordinate this all together in an orderly manner.
Any suggestions/assistance would be greatly appreciated.
Thanks

You should provide lat/lon with your addresses in your database, so do the geocoding of the addresses before.
You have a location manager (CLLocationManager) which takes care of your current position, and with each location (CLLocation) you can calculate the distance (distanceFormLocation:). Now you only need to sort your database with this and pick the first three items.
Hmm?

Related

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: e.g., -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.

iOS Find Other Nearby Devices (GPS locations)

I have an app that allows a user to transmit their location to a server. What I am trying to do is have the user press a button that will send a push notification to anyone with the app within lets say a 3 mile radius. Can someone give me an overview of how I can accomplish this.
The only way I could think of doing this is publishing the gps coords to a server. Then when the user presses "Send notif" a message gets sent to the server, then the server does some complex proximity search based upon the location and then returns the values to the user.
My problem is, I have no server-side experience and have no idea how to program a GPS search algorithm on the server.
Is there a way for me to do what I want without having to write code on a server? I am able to use Parse to store the GPS coordinates. I'd like to keep my server code to simply storing and retrieving values and handle everything else client side.
Thoughts?
Each device should send their GPS coordinates to the server periodically. I think you already have this step. The next step is to find devices that are near each other. This is fairly simple.
Distance Between Two Latitude and Longitude Points
However, if you have millions of devices, it will be a problem of scale if you compare each update to all the other devices. You might bucket the devices to a certain area. For example, you might bucket the updates into 100 square mile areas. When an update comes in you need to only compare to those devies in that bucket plus adjacent buckets if they are near the edge. This is just top of the head analysis but hopefully it will point you in the right direction.
If you really want to put all the load on the client (iOS) side:
Query the server for IDs and locations of all possible recipients for the push notification
Store ID and Location in custom object and put those in a NSArray or a NSSet
Then
//otherUsers is the NSArray or NSSet with custom objects
//currentLocation is the users current location
for(MYCustomUser * otherUser in otherUsers) {
if([currentLocation distanceFromLocation:[otherUser location]] < 4829) { //4828 == 3 Miles in Meters, so 4829 is 3 Miles + one Meter
//send msg to server to perform push notf. to user
}
}
Done...
you should put this in a NSOperationQueue so that is can run in background an is not blocking the device
But as bbarnhart said... it's not very wise to put all this on a device.

Plotting User Locations On A Map in an iPhone App

How can I receive and store user location data so that I can add it to a map?
Have been studying MapKit and the UserLocation code from Apple. What I want to do is get all user's locations and plot on a map - a worldmap with dots showing the combined user base locations - like several apps we've all seen. NOT looking for code, need to do my own work, just if someone could share how they would tackle this..Thanks! Do I gather the user location somehow - add to a plist and .... Not sure...
You should look at the Core Location APIs as well as map kit, you can find a way to get user locations there. Store the results in an array, with a plist to save them if you want, and put annotations on your map to show all locations.
If I'm understanding your question correctly, you're going to need to build a couple web services:
1) that the assorted clients can send their location data TO, and that will then store it in a database. Then
2) when any user needs to open the map view, they'll request the full set of data so that you can then use that data to plot the points

Getting nearby locations

I want to get nearby cities from current location depending upon distance, e.g, cities in radius of 100km,200km etc using the gps of iphone. How can i determine these cties as gps only gives the details of the current location.
Thanks in advance
You need to have a database of the cities in your program, with their coordinates.
You'll read the coordinates of the iphone from the GPS, and then find the x closest cities to you by simple math (see this answer for an example)
You will have to have a custom list of cities and their respective locations and work it out yourself, or potentially use something like google local api, but I don't know if you could reliably return cities through it.

I'm trying to understand the concept of pulling information off the web and into an app Please!

Generally speaking, how does an app like "Around Me" acquire the information it displays?
For example: the restaurants that show up in a list that are near me with the address and distance (I think I get the distance piece) where is this information extracted from? Is it Google or something?
I'm not asking how to implement this (that's over my head!) just get an idea of how it occurs.
Thanks StackOverFlow people.
I haven't seen that specific app, but most such apps either have an embedded database of locations or they dynamically query a server back-end (e.g. using HTTP) to fetch a set of locations near you. They know where you are because the app has access to location services to find out your geographic location.
The iPhone has a GPS unit which gives you your latitude and longitude, which it then sends to a backend server (Say Google Maps) and queries it for, in your case a restaurant. The server responds with a set of locations around you.