开发者

Using core location on iphone simulator

开发者 https://www.devze.com 2023-01-12 04:26 出处:网络
I am developing an GPS based app. So I was wondering how could I simulate location on iphone simulator?

I am developing an GPS based app. So I was wondering how could I simulate location on iphone simulator? I dow开发者_如何学Gonloaded an sample app locateMe. This app does not work on simulator. Does simulator not support location api?

Any help would be appreciated.


Update: Xcode 4.2 with iOS 5 supports GPS positioning.

Select the Simulator -> Debug -> Location -> Custom Location...

Previous Version

No the simulator does not support it. So for GPS you have to install the application in the device to check it.

Simulator is gonna give you longitude and latitude as the address of Cupertino Where the headquaters of apple is.

So you have to use device only.

Happy Coding


According to the documentation, when using the simulator:

"The relocation reported by the CoreLocation framework in the simulator is fixed at the following coordinates (accuracy 100 meters), which correspond to 1 Infinite Loop, Cupertino, CA 95014.

Latitude: 37.3317 North Longitude: 122.0307 West"

So, in practical terms, you should be able to build the app but you'll be unlikely to do anything useful with it.


You might wanna check out my FTLocationSimulator at http://github.com/futuretap/FTLocationSimulator

It reads a KML file generated by Google Earth to provide faked location updates. It also updates the blue userLocation dot in a MKMapView with the simulated location updates.


In Xcode 4.2 we can simulate . There is a location symbol on the debug area (while you run the app). There are some predefined locations . Also we can add new GPX files


The solution was to subclass CLLocationManager and define a new delegate @protocol, called DLocationManagerDelegate.

It is designed to be a simple drop-in replacement for CLLocationManagerDelegate that compiles down to a very thin layer when deployed on an actual device.

When running on the device it will return data as normal using CoreLocation, but in the simulator it will read latitude and longitude from a text file (defined in the DLocationManager.h file).

I hope this helps, the implementation is on the simple side and you have to startUpdatingLocation and stopUpdatingLocation to update the display.

http://code.google.com/p/dlocation/

0

精彩评论

暂无评论...
验证码 换一张
取 消