Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example retrieves information about Apple map bubble.
Bubble identifier.
Name.
Displayed bubble name.
Bubble size, and also minimum and maximum size.
Bubble fill brush.
Bubble location coordinates.
It is required to add the following file to the base example Displaying of Express Report:
CustomMapDataBubbleViewController.h/.mm. Class implementing a protocol for working with Apple map data source.
Executing the example requires to create a class implementing a protocol for working with Apple map data source, and also to add a class header file into source code of the ViewController class (see the Displaying of Express Report section). The it is required to place the following code in the body of the executeExample method of the ViewController class:
// Get express report controller MAExpressAnalysisReportViewController *contr = (MAExpressAnalysisReportViewController *)m_controller; // Get express report delegate EAReportDelegateImpl *delegate = [contr delegate]; // Get map data source MapDataViewDatasource *dataSource = (MapDataViewDatasource *)[delegate mapDatasource]; // Create an Apple map controller CustomMapDataBubbleViewController *bubbleViewController = [[CustomMapDataBubbleViewController alloc] initWithDatasource: dataSource]; // Get identifiers of Apple map bubbles NSArray *allShapeIds = [bubbleViewController allShapeIDs]; NSLog(@"Number of map bubbles: %d", [allShapeIds count]); NSLog(@"Minimum radius of map bubbles: %f", [bubbleViewController minSize]); NSLog(@"Maximum radius of map bubbles: %f", [bubbleViewController maxSize]); if ([allShapeIds count] > 0) { // Get identifier of the first map bubble NSString *shapeId = [allShapeIds objectAtIndex: 0]; MapShape *mapShape = [bubbleViewController shapeWithID: shapeId]; NSLog(@"Bubble identifier: %@", [mapShape ID]); // Get bubble name NSString *shapeName = [bubbleViewController nameWithID: shapeId]; NSLog(@"Bubble name: %@", shapeName); [bubbleViewController setValue:[NSNumber numberWithInt:0] forKey:@"m_index"]; // Get displayed bubble name NSString *shapeCaption = [bubbleViewController captionWithID: shapeId]; NSLog(@"Displayed name of map bubble: %@", shapeCaption); // Get bubble coordinates by identifier CLLocationCoordinate2D location = [bubbleViewController locationWithID: shapeId]; NSLog(@"Latitude corresponding to bubble: %f", location.latitude); NSLog(@"Longitude corresponding to bubble: %f", location.longitude); // Get bubble fill brush Brush *brush = [bubbleViewController brushWithID: shapeId]; // Determine brush color as a hexadecimal string const CGFloat *colorComponents = CGColorGetComponents([[brush mainColor] CGColor]); CGFloat r = colorComponents[0]; CGFloat g = colorComponents[1]; CGFloat b = colorComponents[2]; NSString *hexString=[NSString stringWithFormat:@"%02X%02X%02X", (int)(r * 255), (int)(g * 255), (int)(b * 255)]; NSLog(@"Bubble fill color: %@", hexString); // Get bubble size double size = [bubbleViewController sizeWithID: shapeId]; NSLog(@"Bubble size: %f", size); } else { NSLog(@"No bubbles on map"); }
After executing the example the development environment console displays information about the first Apple map bubble:
Number of map bubbles: 42
Minimum radius of map bubbles: 0.000000
Maximum radius of map bubbles: 0.000000
Bubble identifier: GL
Bubble name: Greenland
Displayed name of map bubble: Greenland
GDP per capita growth (annual %)
Latitude corresponding to bubble: 76.126060
Longitude corresponding to bubble: -42.246990
Bubble fill color: F0F0F0
Bubble size: 20.000000
See also: