Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example shows zoom and scroll of map to the specified map layer area, and also old and changed coordinates of map top left corner and zoom coefficient are determined.
Executing the example requires to place the following code instead of the contents of the mapChart:touchDownInShape: method of the ViewController class (see the Creating a Map with a Timeline section):
// Get map visible area CGRect visibleRect = [mapChart visibleRect]; NSLog(@"Old coordinates of top left corner of visible area: (%f, %f)", visibleRect.origin.x, visibleRect.origin.y); /* Zoom and scroll for displaying of specified map layer area */ [mapChart zoomToShape: shape]; // Display a tooltip for map layer area [m_view showPopupInShape: shape]; // Get map visible area visibleRect = [mapChart visibleRect]; NSLog(@"New coordinates of top left corner of visible area: (%f, %f)", visibleRect.origin.x, visibleRect.origin.y); NSLog(@"Zoom coefficient: %f", [mapChart zoom]);
Then manually press the map layer area with the RU identifier. As a result, the map is zoomed, and scrolled to this area, and a tooltip is also displayed for this area:
The development environment console displays old and new coordinates of top left corner of visible area, and also zoom coefficient:
Old coordinates of top left corner of visible area: (0.000000, -241.210678)
New coordinates of top left corner of visible area: (506.336517, -88.003075)
Zoom coefficient: 0.784064
The identical result (except for displaying information to the development environment console) is obtained on executing the following code:
// Get coordinates and size of map layer area CGRect shapeRect = [shape bounds]; /* Zoom and scroll for displaying of specified map layer area without animation playback */ [mapChart zoomToRect:shapeRect]; // Redraw map layer area [mapChart invalidateRect:shapeRect]; // Display a tooltip for map layer area [mapChart showPopupInShape:shape];
The identical result but including zoom animation playback and map scroll is obtained on executing the following script:
// Get map layer area coordinates and size CGRect shapeRect = [shape bounds]; /* Zoom and scroll for displaying of specified map layer area with animation playback */ [mapChart zoomToRect:shapeRect animated:YES]; // Redraw map layer area [mapChart invalidateRect:shapeRect]; // Display a tooltip for map layer area [mapChart showPopupInShape:shape];
See also: