Description: class implementing a protocol for working with Apple map data source.
#import <Foundation/Foundation.h> #import <MobileAnalysis/MAMapDataBubbleViewController.h> #import "MapDataViewDatasource.h" #import <MobileAnalysis/MobileClientMapDataSource.h> @interface CustomMapDataBubbleViewController : MAMapDataBubbleViewController { MapDataViewDatasource *m_mapDataSource; // Map data source NSNumber *m_metricDimension; // Metric dimension NSNumber *m_metric; // Data source metric NSNumber *m_metricNoPivot; // Metric, to which data table does not correspond } // Returns name of the metric, to which data table does not correspond -(NSString *)metricNoPivotName; @end
#import "CustomMapDataBubbleViewController.h" #import <MobileAnalysis/MapShape.h> @implementation CustomMapDataBubbleViewController -(id)init { m_mapDataSource = [self mapDatasource]; return self; } // Refreshes source data - (void)refresh { MapDataViewDatasource *dataSource = [self mapDatasource]; [dataSource updateData]; NSLog(@"Data is refreshed"); } // Sets metric, to which data table does not correspond - (void)setMetricNoPivot:(NSNumber *)metric { m_metricNoPivot = metric; } // Returns name of the metric, to which data table does not correspond -(NSString *)metricNoPivotName { [self setMetric: m_metricNoPivot]; NSString *metricName = [self metricsName]; return metricName; } // Sets data source metric key -(void)setMetric:(NSNumber *)metric { m_metric = metric; } // Returns data source metric key -(NSNumber *) metric { return m_metric; } // Returns metric name -(NSString *)metricsName { // Get data source metric dictionary NSDictionary *metrics = [self metrics]; NSString *metricName = [metrics valueForKey: [[self metric] stringValue]]; return metricName; } // Returns data source metric dictionary -(NSDictionary *)metrics { NSDictionary *metrics; MapDataViewDatasource *dataSource = [self mapDatasource]; NSArray *values = @[[dataSource colorMetricName], [dataSource sizeMetricName], [dataSource heightMetricName]]; NSArray *keys = @[[NSString stringWithFormat: @"%lld", [dataSource colorMetricKey]], [NSString stringWithFormat: @"%lld", [dataSource sizeMetricKey]], [NSString stringWithFormat: @"%lld", [dataSource heightMetricKey]]]; metrics = [NSDictionary dictionaryWithObjects:values forKeys: keys]; return metrics; } // Returns metric dimension key -(NSNumber *)metricDimension { return m_metricDimension; } // Sets metric dimension key -(void)setMetricDimension:(NSNumber *)metricDimension { m_metricDimension = metricDimension; } // Returns dictionary of metric dimension keys -(NSDictionary *)metricDimensions { MapDataViewDatasource *dataSource = [self mapDatasource]; return [dataSource metricsDimensionsKeys]; } // Returns array of bubble identifiers on map - (MapShape *)shapeWithID:(NSString *)ID { // Create a map layer area MapShape *mapShape = [[MapShape new] autorelease]; [mapShape setID: ID]; [mapShape setBackground: [self brushWithID: ID]]; return mapShape; } @end
See also: