Unexpected behavior for current location


#1

I’ve implemented all of the chapter 5 code and my app runs in the simulator (I can’t run it on my iPhone yet because I don’t have the necessary credentials yet). However, it doesn’t behave as I’d expect. On launch, it zooms to the “current location”, but that is Apple HQ with a blue dot! When I enter a location name, only then does it ask to use my current location, zoom to my true current location and display a red annotation dot there.

Is this expected? Is it just because I’m running in the simulator?


#2

I got the same results on the simulator and it did fine when I put it on the iPhone.


#3

I got set up with my certificate and provisioning credentials today so I was able to finally test on my iPhone, and sure enough all was well there. Guess this is an example of how the simulator isn’t perfect!


#4

djhoward, if you used the location hack that Joe wrote for those of us using the simulator (see http://forums.bignerdranch.com/viewtopic.php?f=79&t=2069) then the app worked by displaying Apple HQ.

The simulator is running on a laptop or desktop and those do not have the same GPS hardware and location services for cell towers as the iPhone (see Page 80 where the book is discussing the distanceFilter property). Thus, he had to “hardcode” coordinate values into the app to force it to see a location and thus allow the app to work when running on the simulator.

If you ran the app from the beginning on an iOS device (iPhone/iPad) then I don’t think you needed the extra code. It is helpful to note that the authors did put a note in the Introduction that stating getting fully credentialed by Apple was best because you test the app on a device. I’m only on Chapter 5 and I’ve run into two problems not being able to use my device (taking a screenshot and the location hack). I’m thinking it is time to start the ball rolling on a full Dev license!


#5

Has anyone else had this issue with the simulator: The Apple Campus shows up fine when the app is launched. When I type something in to modify the annotation, the map reloads into a blue screen and a pin pops up (but no actual map). If I click the pin, it has the proper annotation, but still no map. I can’t understand why it is doing this, or is this mainly due to the simulator?


#6

No issue here, but I’m on Xcode 4.0.2, Snow Leopard 10.6.8, iOS SDK 4.3.


#7

I will go home tonight and try to type something in the location box. My current issue is that when I open the app on simulator the blue dot shows up fine on the map yet it won’t zoom in at all. the map opens up to Europe and Asia and completely disregards the code to zoom in. I need to recheck my code.


#8

This is due to the hackLocationFix: workaround’s hard-coded coordinates. That blue is actually somewhere in the middle of North Atlantic, zoomed to 250-meters. If you set the region distance to something huge (say, 2500000 meters) you can see that. I decided to pick some other longitude/latitude coordinates as the hard-coded values in hackLocationFix:.

Hopefully the underlying bug causing the need for that workaround will be addressed sooner than later.


#9

Yup, sorry, I just threw in some random numbers for the coordinates. It apparently drops you in the Atlantic off the coast of Canada.

I hope you brought your wetsuit.


#10

Mac OS X 10.7.1 Xcode 4.1 iOS Simulator

Thanks for this. Thought I had made a mistake. Yes I was using the Hacklocation fix.

I changed the values to Latitude:33.758616 longitude:-84.363863 so as to make wetsuits unnecessary, but you might want a credit card instead. You’ll need it to pay for the class, or at least to buy Mr. Conway or Mr. Hillegass a beer.