Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements executing the following operations:
A tooltip for area parent layer is set.
A constant value of color scale is set for map area visual elements.
The development environment console displays map area name, center point coordinates obtained from Prognoz Platform 9 attributes, and also area center geographic coordinates.
A new map area center is set.
Executing the example requires to place the following code in the body of the mapChart:touchDownInShape: method of the ViewController class (see the Creating a Map with a Timeline section):
// Compare selected area identifier with the specified one
if([shape.ID isEqual:@"RU"] == YES)
{
// Create an object for working with a tooltip
MapTooltip *tooltip = [MapTooltip new];
// Set tooltip text
tooltip.text =@"Novaya Zemlya";
// Set tooltip text color
tooltip.borderColor = [UIColor blackColor];
// Set tooltip for parent layer
[[shape parentLayer] setTooltip:tooltip];
// Pass tooltip of area parent layer
[shape setTooltip:[[shape parentLayer] tooltip]];
// Get array of area visual elements
NSArray *visuals = [shape visuals];
// Parse visual elements in cycle
for(MapAreaVisual *visual in visuals)
{
/* Determine whether map area background fill parameters
do not depend on data source */
[[visual background] setIsDependent:NO];
/* Set visual element fill parameters,
used if there is not scale binding */
[[visual background] setValue:[SolidColorBrush solidColorBrushWithColor:[UIColor colorWithHex:@"86b7fb"]]];
// Redraw map
[m_view invalidate];
}
// Get area name
NSString *title = [shape title];
// Get area center point retrieved from Prognoz Platform 9 attributes
CGPoint centerPoint = [shape centerPoint];
// Get geographic coordinates of area center
CLLocationCoordinate2D centerPointCoordinate = [shape centerPointCoordinate];
// Display obtained values in the development environment console
NSLog(@"Area name: %@",title);
NSLog(@"Area center coordinates obtained from Prognoz Platform 9 attributes: (%f,%f)",centerPoint.x,centerPoint.y);
NSLog(@"Area geographic center:");
NSLog(@"Latitude: %f", centerPointCoordinate.latitude);
NSLog(@"Longitude: %f", centerPointCoordinate.longitude);
// Determine the point that determines area center
CGPoint center = {0.25, 0.35};
// Set new area center point
[shape setCenter:center];
// Get the rectangle that limits the area
CGRect rect = [shape bounds];
// Zoom and scroll the screen to the obtained rectangle
[mapChart zoomToRect: rect];
}
Then manually press the map layer area with the RU identifier. As a result, the map is zoomed and scrolled to this area. Fill color for all areas is changed for blue. A tooltip is also displayed in the new center point of the specified area:
The development environment console displays map area name, center point coordinates obtained from Prognoz Platform 9 attributes, and also area center geographic coordinates:
Area name: Russian Federation
Area center coordinates obtained from Prognoz Platform 9 attributes: (744.861206,180.082138)
Area geographic center:
Latitude: 69.423810
Longitude: 103.997054
See also: