Working with Apple Map Data Source

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example displays operations with an Apple map data source. After starting the example the following operations are executed:

Required Files

It is required to add the following file to the base example Displaying of Express Report:

Source Code

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 a controller for working with Apple map data view
CustomMapDataBubbleViewController *bubbleViewController = [[CustomMapDataBubbleViewController alloc] initWithDatasource: dataSource];
// Update source data
[bubbleViewController refresh];
// Set metric that determines map element colors
[bubbleViewController setMetric: [NSNumber numberWithLongLong: [dataSource colorMetricKey]]];
NSLog(@"Name of metric that determines map bubble colors: %@", [bubbleViewController metricsName]);
// Get dictionary of metric dimension keys
NSDictionary *metricDimensions = [bubbleViewController metricDimensions];
for (int i = 0; i < [metricDimensions count]; i++) {
    NSNumber *key = [[metricDimensions allKeys] objectAtIndex: i];
    // Set metric dimension key
    [bubbleViewController setMetricDimension: key];
}
NSLog(@"Metric dimension key: %d", [[bubbleViewController metricDimension] intValue]);
// Set metric, to which data table does not correspond
[bubbleViewController setMetricNoPivot: [NSNumber numberWithLongLong: [dataSource heightMetricKey]]];
NSLog(@"Name of metric that determines map layer area height: %@", [bubbleViewController metricNoPivotName]);

After executing the example the development environment console displays notification about Apple map data source update, name of the metric that determines map bubble colors, metric dimension key, and name of the metric, to which data table does not correspond:

Data is updated

Name of the metric that determines map bubble colors: GDP per capita, PPP (constant 2005 international $)

Metric dimension key: 1557

Name of the metric that determines map layer area height: GDP per capita, PPP (constant 2005 international $)

See also:

Example of Component Use