Ajay_Kumar
Ajay_Kumar

Reputation: 1387

How will get current location in iphone

I am making google map integration in iphone. I have to show current location showing in map. How will i get current location ?

Thanks

Upvotes: 1

Views: 10154

Answers (4)

Simon
Simon

Reputation: 31

I think the question has been answered -

CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate];  
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);

place this in the viewdidappear:animated

then you should find that you have the right location. Doing it any sooner and the location won't be set yet and you'll probably end up in the ocean :)

Upvotes: 3

Rams
Rams

Reputation: 1751

CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate];  
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);

Upvotes: 5

The short answer is to write code like mapview.showsUserLocation = YES;, where mapview is your UIMapView class object.

Upvotes: 1

Related Questions