I am trying to get Altitude of my location in my application. But every time I try altitude
property of CLLocation
object I am getting 0.00
See Android - Get Altitude By Longitude and Latitude? there is an Android solution but it is easily adaptable to iOS.
The answer is to use the USGS Elevation Query Web Service
From the top answer there, basically you just send an HTML Web request to:
http://gisdata.usgs.gov/xmlwebservices2/elevation_service.asmx/getElevation?X_Value=" +
String.valueOf(longitude) +
"&Y_Value=" + String.valueOf(latitude)
+ "&Elevation_Units=METERS&Source_Layer=-1&Elevation_Only=true";
Then you can parse out the response text from between the <double>...</double>
tags
Edit: It looks like you might be trying to get elevation outside the United States.
Google Maps API does provide an Elevation service and documentation at https://developers.google.com/maps/documentation/javascript/elevation
To answer your original question: GPS will always be used if you set desiredAccuracy to Best or BestForNavigation, and distanceFilter to kCLDistanceFilterNone when configuring the CLLocationManager. You will then also get altitude values in the CLLocation event.
However, it takes a short while before the GPS has "locked in" to enough satelites to be able to report the altitude. During that time it will report CLLocation events without altitude values. Therefore, you should ignore the first couple of events until the verticalAccuracy value is good enough for you. Also, check the timestamp, because sometimes the first CLLocation event is an old one.