Displaying 3D Map

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example displays data view as a 3D map, and also the following operations are executed:

Source Code

Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Displaying of Dashboard section):

// Get dashboard controller
MAExpressAnalysisReportViewController *contr = (MAExpressAnalysisReportViewController *)m_controller;
// Get express report delegate
EAReportDelegateImpl *delegate = [contr delegate];
// Get map data source
MapDataViewDatasource *dataSource = (MapDataViewDatasource *)[delegate mapDatasource];
// Get map topobase
NSData *topobase = [delegate mapTopobase];
// Create a map container
MAMapDataViewContainerController *mapContainer = [MAMapDataViewContainerController new];
// Create a 3D  map
MAMapData3DViewController *map3DViewController = [[MAMapData3DViewController alloc] initWithDatasource: nil];
// Set map data source
[map3DViewController setMapDatasource: dataSource];
// Set topobase data
[map3DViewController setTopobaseWithData:topobase];
// Set 3D map delegate
[map3DViewController setDelegate: mapContainer];
// Specify that map is loaded
[map3DViewController setTag: kViewModeMap];
[mapContainer setMainViewController: map3DViewController];
// Set map container delegate
[mapContainer setDelegate: contr];
// Specify that map container is loaded
[mapContainer setTag: kViewModeMap];
// Determine map settings
NSMutableDictionary *mapSettings = [NSMutableDictionary dictionary];
// Calculate indicator height by scale
[mapSettings setValue:kMapDepthModeScale forKey:kMapDepthMode];
// Set map settings
[map3DViewController setSettings: mapSettings];
// Create an Apple map
MAMapDataBubbleViewController *bubbleViewController = [[MAMapDataBubbleViewController alloc] initWithDatasource:(MapDataViewDatasource *)delegate.mapDatasource];
// Set Apple map delegate
[bubbleViewController setDelegate: mapContainer];
[bubbleViewController setTag: kViewModeMap];
// Set topobase data
[bubbleViewController setTopobaseWithData:delegate.mapBubbleTopobase];
[mapContainer setBubbleViewController: bubbleViewController];
BOOL isDepthEnable = [MAMapData3DViewController depthEnableState];
if (isDepthEnable) {
    NSLog(@"Map layer area height settings are available");
    } else {
    NSLog(@"Map layer area height settings are not available");
}
// Set colored map elements
[map3DViewController setStrokedShapes: [[mapContainer bubbleViewController] strokedShapes]];
NSLog(@"Number of colored map elements: %d", [[map3DViewController strokedShapes] count]);
// Delete all window subviews
NSArray *subviews = [self.parentViewController.view subviews];
for (UIView *subView in subviews) {
    [subView removeFromSuperview];
}
// Display controller view
[self.parentViewController.view addSubview: [map3DViewController view]];

After executing the example the 3D map data view is displayed:

The development environment console displays notification that map layer height settings are not specified, and the number of colored map elements:

Number of colored map elements: 1

See also:

Example of Component Use