How can I get GPS location in Iphone

Can you tell me, how can I get GPS location in iPhone.

Thanks.

-------------Problems Reply------------

Implement CLLocationManagerDelegate and write this function and call this in viewDidLoad Method of your viewController.

-(void)startLocationManager
{
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation];
}

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D coordinate = [newLocation coordinate];
double dblLatitude = coordinate.latitude;
double dblLongitude = coordinate.longitude;
}

If you are using CLLocationmanager, make sure you check to see if location Service is enabled first. I would do this to get the current location:

if ([CLLocationManager locationServicesEnabled])
{
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];

CLLocationCoordinate2D *currentLocation = locationManager.location;

[locationManager stopUpdatingLocation];
[locationManager release];
}

If you are using mapView, you could get current location using:

[mapView setShowsUserLocation:YES];
CLLocationCoordinate2D *currentLocation = mapView.userLocation.coordinate;

You use CoreLocation framework. Here you can get sample code http://mobileorchard.com/hello-there-a-corelocation-tutorial/

Category:iphone Views:0 Time:2011-08-01

Related post

  • Question regarding GPS/Location in iPhone 2011-04-11

    Currently I'm doing an location app in iPhone but my question is.... What is the service does iPhone using? According to Apple Developer Manual "The framework uses information obtained from the built-in cellular, Wi-Fi, or GPS hardware to triangulate

  • How to read GPS coordinates on iPhone or Nokia e73 through java application (phone connected to laptop with cable)? 2010-11-20

    Can I read the iPhone's file system from java application? My iPhone 3G is connected to laptop by cable and I want that my java code knows in every moment whats the GPS location of iPhone. That data must be stored in some "string" on iPhone don't you

  • How to display Dropdown info sorted by GPS location in Objective C on the iPhone 2009-05-12

    Is there an easy way to display a sorted dropdown list on the iPhone by "closest to current location"? I.e. if I have a list of cities with their GPS locations, can I quickly sort a dropdown to show you city selections in order of closest to you? Wil

  • iPhone GPS (location) API link required 2009-08-27

    I am new to iPhone Application... I want to use GPS API in my iPhone Application, for getting current location of iPhone.. Can any one plz post some links for GPS API for iPhone ? Thanks.. --------------Solutions------------- Look at Core Location fr

  • How to find State location from iphone GPS? 2009-11-23

    I'm trying to add to my program that locates the person in GPS but sets a value to the State that person is in so example: GPS Locates person from his/her iphone then returns the state they are in so say its California then the state variable gets se

  • Different between GPS and Core Locator in iphone? 2010-12-22

    I'd like know what is difference between GPA and core locator in iphone. Also Whether internet needed for GPS? --------------Solutions------------- I think this sentence best sums it up, but I would add the MapKit Framework to the mix Apple Documenta

  • Can I get the Iphone/Android GPS location using the Corona SDK? 2011-06-13

    Can I get the Iphone/Android GPS location using the Corona SDK? I want to build an app and I am considering Corona, however I am unsure about whether it can access native features of the iphone and android. I'm a bit confused as: http://www.anscamobi

  • is it possible to continuously track gps location in phonegap app(iphone) in background(means when app is not running) 2012-01-25

    I am working on an iphone app which needs to pop up a notification when the user reaches some particular place. I am developing the app in phonegap. A function is available in phonegap to track gps location continuously i.e. "geolocation.watchPositio

  • send current location on iPhone GPS at specific time 2011-02-18

    So I would like to obtain my current GPS location and send it at a specific time in a day to a web service. How can I do this? Is there a way to automatically turn on the current location GPS service? --------------Solutions------------- You can run

  • How to create GPS Compass based on user Location in iPhone 2011-08-04

    Can we create GPS Compass in iPhone as shown in Compass Application Video using code? I want to create the GPS compass in my app, as shown in this video. I do not need code but want to get reference about that. Please help me to solve my problem. Tha

  • Is there any API which can detect GPS location is changed in the iPhone native application? 2011-10-02

    I want to show gps coordinates in the Label, is there any default API which can observe/detect that GPS location is changed,so we that I should be able to take and show new GPS location in the label. --------------Solutions------------- You should ta

  • Is it possible to detect a mobile browser's GPS location? 2009-04-17

    I am making a web site targeted at mobile phones and would like to get the user's current GPS latitude/longitude when they visit my default page so I can show them results in their area. Is this possible using ASP.NET? See Also Get position data from

  • GPS Location takes a few seconds to be retrieved 2009-09-06

    I have written an iPhone app that uses the iPhone's relative GPS location. I have a button in the user interface that does reverse geolocation (pulls the street name bases on the lat and long). The only problem is that the location object as retrieve

  • how to get GPS Coordinates in iphone using Objective C 2009-11-24

    i want to get the GPS coordinates from iphone and send these GPS coordinates to web service. This web service, will take my GPS Coordinates and send me the location of the nearest ATM, from the current location. now i want to do this in 2 phases. Fir

  • get gps location from mobile phone 2010-02-18

    I would like to know What is the best way to get the gps locations off multiple phones on to a googlemaps on a website. I just downloaded googlemaps with latitude on my phone. Is it only possible to query your own location with the public location ba

  • How to get the current location of iPhone through code? 2010-03-16

    How do you get the current location of iPhone through code? I need to track the location using GPS. --------------Solutions------------- You're looking for the "CoreLocation" API. Here's a tutorial There is (as always for core functionality) comprehe

  • How to Get GPS location from the web browser 2010-04-05

    I am developing a mobile based web-site, there I have integrated google maps, I need to fill the 'From' field of google maps dynamically. Is it possible to get the 'GPS' location from web-browser and fill it up in the 'From' field of a google map dyn

  • How to test location based iPhone application during development? 2010-06-02

    I am currently developing a location based iPhone application. Is there any way to test the app other than taking the iPhone to different places? Thanks --------------Solutions------------- Yes, you can. Try this: http://www.vimov.com/isimulate/ (...

  • How GPS works in iPhone? 2010-06-11

    I am using a iPhone 3g. I am in India(I got it in India). I just tried to check my location using the Google Maps. My location was spotted when I had sim in my phone. But when I took out the SIM from iPhone, I did not get my location. I tried the sam

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.089 (s). 11 q(s)