title: iOS Route-Me: Add User Location Marker
body: <p>I have been trying to add the following things to a Route-Me app.</p>
  
  <ul>
  <li>Add a marker at the starting location</li>
  <li>Move the map to the user location</li>
  <li>Move the marker to that new location</li>
  </ul>
  
  <p>I am using the basic example from MapBox ios example, as my maps are from an offline mbtiles store.</p>
  
  <p>This is my header file:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  #import "RMMapView.h"
  #import "RMMarker.h"
  #import "RMMapViewDelegate.h"
  #import "RMMarkerManager.h"
  #import "CoreLocation/CoreLocation.h"
  
  @interface MBTiles_ExampleViewController : UIViewController
  {
      RMMapView *mapView;
  }
  
  @property (nonatomic, retain) IBOutlet RMMapView *mapView;
  @property (nonatomic, retain) CLLocationManager *locationManager;
  @property (nonatomic, retain) CLLocation *currentLocation;
  @property (nonatomic, retain) RMMarkerManager *markerManager;
  @property (nonatomic, retain) RMMarker *locationMarker;
  
  @end
  </code></pre>
  
  <p>And this is my implementation file:</p>
  
  <pre><code>#define kStartingLat   30.0f
  #define kStartingLon  -10.0f
  #define kStartingZoom   1.5f
  
  #import "MBTiles_ExampleViewController.h"
  
  #import "RMMBTilesTileSource.h"
  #import "RMMapContents.h"
  #import "RMMarker.h"
  
  #import "RMMarkerManager.h"
  #import "CoreLocation/CoreLocation.h"
  
  
  @implementation MBTiles_ExampleViewController
  
  @synthesize mapView;
  @synthesize currentLocation;
  @synthesize locationManager;
  @synthesize markerManager;
  @synthesize locationMarker;
  
  
  
  (void)viewDidLoad
  {
      CLLocationCoordinate2D startingPoint;
  
      startingPoint.latitude  = kStartingLat;
      startingPoint.longitude = kStartingLon;
  
      NSURL *tilesURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"control-room-0.2.0" ofType:@"mbtiles"]];
  
      RMMBTilesTileSource *source = [[[RMMBTilesTileSource alloc] initWithTileSetURL:tilesURL] autorelease];
  
      [[[RMMapContents alloc] initWithView:self.mapView 
                                tilesource:source
                              centerLatLon:startingPoint
                                 zoomLevel:kStartingZoom
                              maxZoomLevel:[source maxZoom]
                              minZoomLevel:[source minZoom]
                           backgroundImage:nil] autorelease];
  
      mapView.enableRotate = NO;
      mapView.deceleration = NO;
  
      mapView.backgroundColor = [UIColor blackColor];
  
      mapView.contents.zoom = kStartingZoom;
  
      if (nil == locationManager)
          locationManager = [[CLLocationManager alloc] init];
      locationManager.delegate = self;
  
      locationManager.desiredAccuracy = kCLLocationAccuracyBest;
  
      [locationManager startUpdatingLocation];
  
  
      UIImage *iconImage = [UIImage imageNamed:@"marker.png"];
  
      locationMarker = [[RMMarker alloc] initWithUIImage: iconImage];
  
  
  
      [markerManager addMarker: locationMarker AtLatLong: startingPoint];  
  
  }
  
  (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
  {
      [mapView moveToLatLong:newLocation.coordinate];
  
      RMLatLong newCoords = {newLocation.coordinate.latitude, newLocation.coordinate.longitude};
  
      if (nil != markerManager)
         [markerManager moveMarker:locationMarker AtLatLon: newCoords];
  
  }
  
  (void)dealloc
  {
      [mapView release];
  
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>The marker.png has been added to my resources folder.</p>
  
  <p>So my questions</p>
  
  <ol>
  <li>Why is my starting marker not showing?</li>
  <li>I am using xcode on SnowLeopard, so can the simulator actually find my location? As the map does not move.</li>
  </ol>
  
  <p>Any help would be great as I have tried so many code snippets and tutorials but none have ended up working.</p>