4

Is there any good code which implements auto scrolling of MKMapView when dragging pin?

The effect I'm trying to achieve is a map scrolling when I drag the pin and reach edges of the map. When I move pin out of the edges I expect scrolling to stop and when I drop it, map shell move until pin reaches center of the screen.

I know how to center map on chosen location, but I'm not really have an idea how to scroll it while dragging pin.

It would really help if someone could just direct me to a logic of the way how to implement it.

Misha
  • 5,260
  • 6
  • 35
  • 63
  • I understand what you're looking for, but I think you've got a couple of close votes because some people don't. You should expand your question with more info. I'd love to find something like this too. – nevan king May 13 '12 at 10:47
  • I've updated the question by your suggestion. – Misha May 13 '12 at 12:17

1 Answers1

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];
karthika
  • 4,085
  • 3
  • 21
  • 23