4

是否有任何好的代码可以在拖动 pin 时实现 MKMapView 的自动滚动?

我想要达到的效果是当我拖动图钉并到达地图边缘时地图滚动。当我将 pin 移出边缘时,我希望滚动停止,当我放下它时,map shell 会移动,直到 pin 到达屏幕中心。

我知道如何在所选位置上居中地图,但我真的不知道如何在拖动图钉时滚动它。

如果有人可以指导我了解如何实现它的逻辑,那将真的很有帮助。

4

1 回答 1

0
MKMapRect mapRect = [self.mapView visibleMapRect];

CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(42.777126,-76.113281);

MKMapPoint point = MKMapPointForCoordinate(coordinate);
mapRect.origin.x = point.x - mapRect.size.width * 0.3;
mapRect.origin.y = point.y - mapRect.size.height * 0.70;

[self.mapView setVisibleMapRect:mapRect animated:YES];
于 2013-04-23T06:15:28.807 回答