Why is the MKMapView's userLocation property rubbish … for a while?

孤者浪人 提交于 2019-12-01 21:52:01

I'm assuming it hasn't finished finding the user location - it has to work this out and it may take a while.

Instead of using it in viewDidLoad use THIS delegate method:

- (void)mapView:(MKMapView *)myMapView didUpdateUserLocation:(MKUserLocation *)userLocation;

You will need to set your mapview delegate to self. :)

Same is often true of Core Location. You'll get the last location lingering it its buffer, sometimes, or a super-broad throw-the-dart-at-the-map kind of location...

Best bet is to check the .horizontalAccuracy property of the location object and toss any that are too vague. It's good practice to just chuck the first one too.

for didUpdateUserLocation to be called you have to have... mapView.showsUserLocation = TRUE;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!