5

My map shows current location with blue dot.. Of course, when I move, blue dot moves.. I just want to keep blue dot center of the map all the time, making map's moving instead like Google map navigator..

I searched a lot but couldn't find the way...

progrmr
  • 75,956
  • 16
  • 112
  • 147
MomentH
  • 1,979
  • 5
  • 22
  • 24

3 Answers3

8

In your map view delegate, do this:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    [mapView setCenterCoordinate:userLocation.location.coordinate animated:YES];
}
Daniel Dickison
  • 21,832
  • 13
  • 69
  • 89
1

Try using mapView.userTrackingMode = MKUserTrackingModeFollow;, you'll get smoother panning than using the location manager manually.

In addition note that there is a ready-made button for managing the various tracking states: MKUserTrackingBarButtonItem.

Gregory Cosmo Haun
  • 1,499
  • 17
  • 25
-1

The easiest way would be to create a new UIView on top of your map's view with a blue dot and only move the map's view.

Luis
  • 1,282
  • 1
  • 11
  • 25
  • There's no need to move the map's view; instead, you change the region displayed on the map. And if you do that correctly there's no need for a separate view for the position indicator. – Caleb Sep 18 '11 at 13:47
  • Sure, as far as he is using a mapview (and we don't know it yet) – Luis Sep 18 '11 at 14:03