Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is iphone Simulator capable of showing heading and latitude , longitude?

I am using iphone simulator 4.2 and try to display or NSLog Heading and other Location services attributes e.g. Latitude, Longitude, altitude, horizontalAccuracy, VerticalAccuracy, speed. but its not showing the correct parameters and Incase of Heading its actually not firing the event. as its execute CLLocation code

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
    [self.delegate locationUpdate:newLocation];
}

and not executing CLHeading code

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
    [self.delegate headingUpdate:newHeading];
}

and when I put breakpoint on these both codes it never touch CLHeading code. I am updating location and heading in init.

- (id) init{
if (self!=nil) {
    self.locationManager  = [[[CLLocationManager alloc] init] autorelease];
    self.locationManager.delegate = self;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    self.locationManager.distanceFilter = kCLDistanceFilterNone;
    [self.locationManager startUpdatingLocation];
    [self.locationManager startUpdatingHeading];
}
return self;
}

The problem is that I do not know that is due to simulator or there is any problem in code?

please help.

like image 835
Azhar Avatar asked Aug 03 '11 06:08

Azhar


People also ask

How do I turn on location on iPhone simulator?

in iOS Simulator menu, go to Features -> Location -> Custom Location. There you can set the latitude and longitude and test the app accordingly. This works with mapkit and also with CLLocationManager. Save this answer.

How do you simulate a location in Simulation?

Click the location on the map you want to simulate, and then press the lowercase L key. A dialog will appear with the message, “Simulated Location Set”. After a short time, the simulated location you set in the Editor will appear as a pink dot in the Android Emulator. Click anywhere on the map, and press Shift+L.

How do I change orientation in iOS simulator?

iOS Simulator - You can rotate the simulator under the Hardware menu with the Rotate Left or Rotate Right option.

How do I change my current location in Simulation?

Change location when the application is runningStart running ⇧ F10 or debugging ⇧ F9 the application. Select a desired location from the list that opens. This location will be simulated on your device, but won't be saved in the list. If you want to add custom locations to the list, use GPX files.


2 Answers

CLLocationManager needs additional hardware and hence wont work on simulator. However you can test that using the method described in this other SO question.

From the documentation:

Some location services require the presence of specific hardware on the given device. For example, heading information is available only for devices that contain a hardware compass. This class defines several methods that you can use to determine which services are currently available.

like image 53
Praveen S Avatar answered Sep 23 '22 21:09

Praveen S


This answer can be updated for anyone using Xcode 4.2. It is still in beta status, but if you are a paid developer you will have access to it. Also, if you are a paid developer, there are some good videos from WWDC 2011 that explain how to use the simulator for location simulation.

WWDC 2011

See What's New in Core Location and Testing Your Location-Aware App Without Leaving Your Chair

**Note: Please note again that only paid developers have access to these videos

like image 43
Bill Burgess Avatar answered Sep 21 '22 21:09

Bill Burgess