0

我的计算有点问题。

我想要的是让应用程序的用户在地图可见区域的某处放置一个移动的地图注释。当注释位置发生变化(gps 单位)时,地图应该移动,但大头针始终停留在屏幕上的那个点。

我正在尝试使用此 stackoverflow 答案的结果

结果来自

-(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;

}

并将结果扔到这个 stackoverflow 分析器中

某些东西并没有真正起作用。我知道我的解释不是很清楚,所以如果有什么不清楚的地方请问我:)

可能会感谢

4

1 回答 1

0

您使用的方法的一个问题是距离不能告诉您方向,即 40 米远,但它是 40 米还是西边?

一个可能对您有用的功能是 [mapView convertPoint:annotationPoint toCoordinateFromView:mapView]

如果你计算出我们相对于地图视图的点,注释应该保留,存储这个值,并使用 [mapView convertPoint:annotationPoint toCoordinateFromView:mapView] 来计算地图视图中的坐标。

希望能帮助到你。

于 2014-10-03T13:56:12.687 回答