开发者

MapView does not track user location

The map view does not seem to track my location. If the current location is moving off the visible area of the map, the map view does not pan automatically.

I dragged and dropped a map view on a view and set "Shows User Location" property to true in the IB.

When my view controller loads, I set the map view's region as follows

- (void)viewDidLoad {
    [super viewDidLoad];

    MKCoordinateRegion region;
    region.center = aCoordinate;
    region.span = MKCoordinateSpanMake(0.0625, 0.0625);

    [mapView setRegion:region animated:YES];
}

I also have the following method which sets the current location as the center of the map.

- (void)panToCurrentLocation:(id)sender
{
    [mapView setCenterCoordinate:mapView.userLocation.coordinate animated:YES];

    mapView.showsUserLocation = YES;
}

The map view is still not tracking my lo开发者_StackOverflow社区cation as I move. The map view does not pan, if the current location is moving out of the visible area. After sometime, the current location is moved off the screen because the map view did not pan automatically.

I need the map view to pan automatically as I move.


Are you calling that panToCurrentLocation: method from the MKMapViewDelegate's mapView:didUpdateUserLocation: method? Did you check to be sure it actually is being called when the user location is updated?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜