繁体   English   中英

ios MapKit,遵循路径

[英]ios MapKit, following a path

我的地图上有路径渲染。 我有一系列航路点,并且正在模拟通过它们的运动。

更改显示区域时,Apple的实现似乎将我转换为CGPoint时的坐标为floorf。 这会导致非常抖动的外观,而不是平滑的外观。

反正有解决这个问题的方法吗?

[m_mapView setRegion: MKCoordinateRegionMake(coord, MKCoordinateSpanMake(0, 0))];

然后,地图尝试以该给定点为中心。 但是,该点可能未通过以下功能进行像素对齐。

CGPoint point = [m_mapView convertCoordinate:coord toPointToView:m_mapView];

因此,mapview会放下中心点的结果,以对齐基础地图的所有像素。

我使视图大于屏幕,以解决偏移并避免裁剪。

我模拟了沿路线移动的点,并使用注释将其放置,然后以每秒30帧的速度在该点居中。

假设坐标是移动点的位置。

[m_mapView setCenterCoordinate: coord];

CGPoint p = [m_mapView convertCoordinate:m_mapView.centerCoordinate toPointToView:m_mapView];
CGPoint p1 = [m_mapView convertCoordinate:coord toPointToView:m_mapView];

CGPoint offset = CGPointMake(p.x - p1.x, p.y - p1.y);
CGRect frame = CGRectInset(CGRectMake(0.0f, 0.0f, 1024.0f, 1024.0f), -50.0f, -50.0f);
frame.origin.x+= offset.x;
frame.origin.y+= offset.y;
[m_mapView setFrame: frame];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM