iPhone Simulator providing location results
I am using iOS SDK 4.2 and followed this tutorial: http://mobileorchard.com/hello-there-a-corelocation-tutorial/, and got some GPS logs happening on the console using both iPhone and iPad.
Then I ran it on the simulator to test other features and the CoreLocation logs were hitting the locationManager:didFailWithError: method which is fair because the MacBookPro (OSX 10.6.6) has no开发者_如何学C GPS functionality... or so I thought.
This morning I tested it on the iPad again at work instead of at home and now testing on the iPhone simulator without any device connected the simulator is providing my location results of my office (No I don't work in Cupertino) and the horizontal accuracy is varying between 45-56m each time and only giving two samples at most (presumably because my notebook isn't moving).
Now I have fully closed XCode and the simulator and deleted the app from the simulator and performed a clean and rebuild and still getting my current coordinate. I can also replicate it without internet access incase the simulator was being tricky with some sort of GeoIP.
Where is the simulator getting my location from?
I thought perhaps maybe the simulator stored some GPS location data when I used the iPad this morning but with no device connected and clean starting everything it is providing varying results eg +/- 0.000001 of a degree variations.
From your MacBook's IP address or, if it's on WiFi, the stored location of your WiFi network. Since it's so accurate for you, it's the WiFi, since the IP address method generally narrows it only to a city, or at best, part of a city.
Skyhook provides geolocation information for most of the WiFi networks in the US and some other parts of the world, info that Apple subscribes to.
Edited to add
Apparently Apple ditched Skyhook last April and now uses its own database, but the system is the same. Much like Google got in hot water for in Germany, someone drives around with a computer looking for WiFi networks and recording their location.
精彩评论