2014-10-03 27 views
0

我的计算有点问题。计算mapcenter,以便移动注释(gps)仍然保持在屏幕上的可见视图中

我想要的是应用程序的用户在地图可见区域的某处放置移动的地图注记。虽然注释位置正在改变(GPS单位),但地图应该移动,但引脚始终保持在屏幕上的该点。

我试图从this stackoverflow answer

使用效果和

-(CLLocationDistance) calcluateDistance:(CLLocationCoordinate2D)annotationLocation{ 

CLLocation *annotationPosition = [[[CLLocation alloc]initWithLatitude:annotationLocation.latitude longitude:annotationLocation.longitude]autorelease]; 
CLLocation *centrePosition = [[CLLocation alloc]initWithLatitude:self.mapView.centerCoordinate.latitude longitude:self.mapView.centerCoordinate.longitude]; 
CLLocationDistance distance = [centrePosition distanceFromLocation:trackerPosition]; 
return distance; 

}

导致扔成果转化为this stackoverflow anser

自己是不是真正的工作。我知道我的解释是不是superclear所以请问我,如果有不清楚的地方:)

五月感谢

回答

0

一个与你正在使用的方法的问题是,距离不告诉你方向,即40米开外,但其它是40米还是西?这可能是有用的,以你

一个功能是[MapView的convertPoint:annotationPoint toCoordinateFromView:MapView类]

如果相对于地图视图在注释应该留下来,保存这个值,然后用[我们的观点图mapView convertPoint:annotationPoint toCoordinateFromView:mapView]来计算地图视图中的坐标。

希望它有帮助。

相关问题