Git Product home page Git Product logo

ftlocationsimulator's Introduction

FTLocationSimulator

FTLocationSimulator allows simulating Core Location in the iPhone simulator on the desktop. It sends fake Core Location updates taken from a KML file that describes a predefined route.

Besides the simulated Core Location updates, it also updates the blue userLocation view on MapKit views.

The sample project shows how to integrate FTLocationSimulator into an existing app, in this case Apple's "Breadcrumb" sample application.

Integration Steps

In a nutshell, these are the necessary steps:

  1. Add the FTLocationSimulator directory to your project

  2. Add -licucore to "Other Linker flags" in the project/target settings (this is needed for RegExKitLite)

  3. #ifdef all occurences of "CLLocationManager" like the following:

     #ifdef FAKE_CORE_LOCATION
         self.locationManager = [[[FTLocationSimulator alloc] init] autorelease];
     #else
         self.locationManager = [[[CLLocationManager alloc] init] autorelease];
     #endif
    

    Only the alloc/init call has to be ifdef'ed. All further occurences of your locationManager object don't need to be changed since FTLocationSimulator uses the same interface as CLLocationManager.

  4. #include "FTLocationSimulator.h" where necessary.

  5. If you're using MapKit, set the mapView property with your MKMapView and set it to nil if you're done with the map. Then, put the following into your MKMapViewDelegate:

     - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
     	if ([annotation isMemberOfClass:[MKUserLocation class]]) {
     #ifdef FAKE_CORE_LOCATION
     		return self.locationManager.fakeUserLocationView;
     #else
     		return nil;
     #endif
     	}
     	// Your code for regular annotation views
     }
    
  6. Adjust FAKE_CORE_LOCATION_UPDATE_INTERVAL in FTLocationSimulator.h if the location updates are too fast.

  7. Change the fakeLocations.kml if needed (currently, it includes a route from Cupertino to San Francisco). To create a new fakeLocations.kml, use Google Earth and create a route. Send the route via email and take the "Route.kmz" file out of the draft mail. The kmz format is zipped kml. So unzip that file using "unzip Route.kml" on the command line.

    The parser is not a generic KML parser but is only able to parse these specific Google Earth KML files.

Implemented methods and properties

From CLLocationManager:

  • delegate
  • location (for polling updates)
  • distanceFilter
  • -startUpdatingLocations
  • -stopUpdatingLocations

CLLocationManagerDelegate:

  • -locationManager:didUpdateToLocation:fromLocation: (is sent by FTLocationSimulator)

CLLocation objects:

  • coordinate
  • location
  • timestamp

Known Issues

  • In Google's KML files the distance between waypoints varies. For straight roads it's larger than for curvy roads. FTLocationSimulator does not consider this difference, so the speed on the KML route varies.
  • The faked userLocation view does not incorporate the GPS halo animation.
  • heading, course, altitude, speed and accuracy are not implemented (some of them might be technically possible)

Collaboration

We're happy if someone wants to contribute to the project or work on some of the issues. Just fork the project and send us a pull request.

Have fun!

-Ortwin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.