how to determine current location from GPS in iphone - iphone

I needed to implement the positioning functionality in my next app. I got a few questions regarding the development.
1) I found the tutorial and implemented the positioning thing.. but is it possible to simulate my code with iphone simulator or is it necessary to use the device for this purpose. while googling i read on some forum that 4.2 SIM supports GPS apps simulation though it will give Apple's headquarter's location every time but in my case the CLLocationManager's didFailWithError delegate gets called. any help with that!!
2) After determining the position, longitude and latitude, how to determine the exact area name and other information from it?
Thanks in advance for your invaluable time and feedbacks.

CLLocationManager will in fact return the location of the network the simulator is using. It's MapKit that will think the current location is in Cupertino at Apple's headquarters. That you get two different locations from the calls often causes confusion.
You can get information about a given latitude and longitude by using the MKReverseGeocoder. It will attempt to give you a full address, but you can use whatever portion of it you'd like (just the country, or city and state/province, whatever).

Related

iphone gps accuracy, can it trigger an event based on location?

I have an issue that i am having trouble to solve. We are about to develop an iphone locative application that would take you around the city with audio that would be played based on the location. I was wondering, do you know how accurate the iphone GPS will be? In terms of actual distance. I am reading 250 m on line but it looks a lot. Plus the gps in the iphone finds my location more precisley than 250 m. I know it is a generic question, but mabe you guys can give me a feedback about it, i am quite desperate and exausted. what we would live to do is, every 70-80 m, put a pin on a map with an audio file, when the user crossed the pin it would trigger an event that is the audio file. I just would love to know how accurate the gps could be so that i can start designing the experience.
Thanks a lot
I've seen iPhone's GPS as accurate as 3m (at least that's what it said on my device when testing).
There is also a new API since iOS 4.0 that you might be interested in that will enable you to set a region for the device to monitor and it will automatically generate a callback when the user crosses the virtual fenceline depending on how accurate you need that to be. This is particularly useful when the app is sent to the background since you can simply monitor the user's location using CLLocation when the app is in the foreground:
- (void)startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy
You can get up to 5 meters accuracy. Within the core location framework there is a property - horizontalAccurracy - that you can read at runtime to get the accuracy for a given moment
The accuracy is anywhere from 5-25m.

current location without using gps

hai
Can we know current location without using gps? Is it possible?
The iPhone SDK has a framework that automatically utilizes the proper mechanism for determining location based on how accurate the result needs to be. Apple has a good article discussing these different methods of locating a device.
Also, here is a good starting point for learning about programming with Location Services.
Furthermore, you can dive right into the CoreLocation framework documentation and learn about everything you can do using Location Services on iOS.
Yes, CoreLocation can triangulate your position via nearby cell phone towers, but the position won't be as accurate as with GPS. Also, it can get your location via nearby WLANs, but this is even less reliable.
Core Location does what you want (by using Wi-Fi triangulation). Check out the documentation of CLLocationManager
Try this
map.showsUserLocation = YES;
map is my MKMapView Object.
Well thats kind of a very broad and very general question. If you are talking cell phones you can use three tower triangulation which is good when you are hitting three towers all at once, but if you are only hitting one the error can be up to a few kilometers.
Now if you are talking internet accessing devices (ie something with an IP address) again things get dicey. If you are using a stationary access point you will get a close approximation using nearest known Hubs with the IP range the device is in. Mobile devices with IPs are really hard to pinpoint.
More links
http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial
http://www.icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/
and step by step guide.
http://gigaom.com/apple/iphone-dev-sessions-finding-your-way-with-mapkit/
To add to #Jenifer's answer
showsUserLocation
Discussion
This property does not indicate
whether the user’s position is
actually visible on the map, only
whether the map view is allowed to
display it. To determine whether the
user’s position is visible, use the
userLocationVisible property. The
default value of this property is NO.
Setting this property to YES causes
the map view to use the Core Location
framework to find the current
location. As long as this property is
YES, the map view continues to track
the user’s location and update it
periodically.
Core Location Framework
The Core Location framework lets you
determine the current location or
heading associated with a device. The
framework uses the available hardware
to determine the user’s position and
heading. You use the classes and
protocols in this framework to
configure and schedule the delivery of
location and heading events. You can
also use it to define geographic
regions and monitor when the user
crosses the boundaries of those
regions.
If you want to know How does the Core Location do this
It actually uses several mechanisms.
GPS
Cell Tower Triangulation
Wifi Hotspot cataloging
Randomly assuming you are in Cupertino
There are tradeoffs based on speed, precision, and available hardware. A first Gen iPad will only have the 3 option available while the iPhone simulator makes use of the last mechanism.
You can observe the difference in these systems in the map application where it initially guesses based on the cell tower, then refines the guess via GPS.
Only options #3 requires a data connection.
And for the humor impaired including #4 was not totally serious although it is functionally correct. (I think they simulate the GPS reporting that location rather than just hard coding it, but I haven't checked.)
From How does CoreLocation locate the device?
The iPod Touch does something like this. It doesn't have a GPS chip, but instead uses the available WiFi networks in the area to get a rough idea of where you're located.

Problem with geolocation on iPhone

I have developed a simple program for current user location following this tutorial :
http://www.youtube.com/watch?v=qNMNRAbIDoU
However when I build and run, the map is shown but the cuppertino location (apple headquarters) is not located on the map.
I heard that the problem may be that apple didn't recognize my wifi or something like that, is this possible, and if so, should I keep my code and suppose it to be true and so wait to test it on device later? Thanks in advance
Make sure you watch to the end of the tutorial as he makes a mistake on the method name, which he corrects, to be honest it doesn't look like a very good tutorial, I'd find another.
In Simulator, the blue dot will always pinpoint the Mothership.
However, mapView.userLocation.coordinate will in fact return your current location coordinate (based on Wifi, so be sure it's on).
Note, though, in pre-4.0, mapView.userLocation.coordinate is returns the coordinates for the Mothership.
Once you start testing on your device the blue dot will appear correctly in your MKMapView. Be sure to test your app on a device when using CLLocation and MKMapView, especially if you rely on the users location for anything. Well, always be sure to test your app on a device :)

best method to find location in indoors iphone

I am trying to find the location of user using corelocation framework in my app ,
but
it doesn't showing good results , can anyone please tell me how can i get location accurately in indoors ?
thanks in advance
regards
I am not sure, about the exact physical environment but if wifi access points are available then you can use sdk available from skyhook wireless or navision to locate your current position in case the accuracy of the gps position is not good.
This is not a failsafe approach, but may work better in areas where data is available about wireless ap.
In the general case, you can't get an accurate location indoors using Core Location. (What's wrong with your question is in assuming that you can, before asking how to do the impossible.)
You might get lucky if you are under to a tent roof that is paper thin or near a large window below lots of wide open sky, or happen to be between 3 or more nearby wifi access points whose locations are all accurately and precisely registered with whichever wifi database(s) Apple is using.

GPS or triangulation when setting user position on map?

I have been programming an app using the mapkit and the SDK 3.0. Everything works allright except for one detail. I have noticed that when displaying the userlocation I get different user positions on the map dependent of the current network. I have read about this problem and understand that it is common? In my WLAN is the user position correctly displayed. When using the 3G net (T-mobile) the position is some 100 meters away from my actual position. I understand this has to do with the celluar phone net using triangulation and in WLAN is the GPS or WiFi hotspot used. So, to my question. Is there a way to go around this? My app shows positions in a town and also the distance to those positions. It is very obvious and also missleading if the position is false because of the short distances. Is there a way (in code) to set which method to be used for getting the user postion? I have tested all other apps on my iPhone using maps and the problem seem to be the same by all of them. (If someone wants to test my app it is in the app store for free under car2go also other comments are of course interesting)
Thanks in advance!
-loop-
Core Location provides information about the vertical and horizontal accuracy of the location that it is reporting. One should use that accuracy to report to the user if the location is suspect. Google maps does this by increasing the size of the blue circle around the location marker. There are other ways to indicate to the user that the location is suspect, alert boxes, not showing the location if it falls outside of some predetermined accuracy, etc.
See: http://developer.apple.com/iphone/library/documentation/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html#//apple_ref/occ/instp/CLLocation/horizontalAccuracy
Use an alternate source for your location? Portable GPS units would do the trick.
The real question is how can you correct the data being specified by the 3G triangulation. I wonder if you can do a differential to correct for the 3G's location errors.
1) In a given city, calibrate the 3G location errors by plotting the city. This could be corrected by the 3G networks at any time, so you'd have to have a way to verify and re-calibrate.
2) Calibrate the 3G network's location using a known location - a 3G location along with a GPS location. Take that as a differential that can be applied to other 3G locations. This assumes a consistent offset in the triangulation calculation which probably isn't the reality.
3) Wait for the 3G networks to fix it and do nothing in the meantime.
4) Provide the 3G network provider with error information in their triangulation and see if it is a priority for them.
I can't think of any other viable options...
Perhaps you can use CoreLocation directly. CLLocationManager gives you CLLocation objects than include their accuracy. If you get an accuracy below 50 meters, it the location probably came from GPS.