Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smooth following of user's location in MKMapView

I would like to follow user's blue dot same way Google Maps do it. It means when the location is changing then the map (or it's center) should smoothly follow it. But when I use standard way with delegate:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    [map setCenterCoordinate:map.userLocation.coordinate animated:YES];
}

or keyvalue observer on mapview.userLocation then move of the map is quite "choppy", it quickly "jumps" to new location even if I use animated parameter.

In addition I think that the blue dot itself doesn't move so smoothly as in native Google Maps app and often jumps to new location instead of moving there.

Thanks for any help.

like image 932
JakubM Avatar asked Feb 17 '11 15:02

JakubM


1 Answers

'hi Jak

I've tried to solve this as well but it looks like MKMapView might be using some fancy stuff between updates to predict the next position and make the movement smoother.

If you look at the way they handle the compass they are doing a lot of filtering as the raw compass data is not terribly steady so they make it really slick and smooth.

Also, notice when tracking you can zoom but not pan. I've failed to replicate this functionality in my app even with scrolling turned off, it still scrolls when you are zooming if you pan your fingers around.

I guess they don't expose everything just to keep ahead of us :) D

like image 129
d0n13 Avatar answered Oct 19 '22 03:10

d0n13