Creating Map Margins

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example implements executing the following operations:

Source Code

Executing the example requires to place the following code instead of the viewDidAppear: method of the ViewController class (see the Creating a Map with a Timeline section):

[super viewDidAppear:animated];
// Set new component size
struct CGRect frame;
frame = CGRectMake(0, 0, 395, 510);
[m_view setFrame:frame];
// Sets gray color border
[[m_view layer] setBorderColor: [[UIColor colorWithRed:0.75 green:0.75 blue:0.75 alpha:1] CGColor]];
[[m_view layer] setBorderWidth: 1.0f];
// Set map margin values
Thickness mapMargin = {0};
mapMargin.top = 8;
mapMargin.left = 8;
//Set background color
m_view.backgroundColor= [UIColor lightGrayColor];
// Set map margin
[m_view setMargin: mapMargin];
// Set timeline index value
[m_view setIndex:2];
//Set timeline value
[[m_view timeAxis] setIndex: [m_view index]];
// Set legend background fill parameters
UIColor *backgroundColor = [UIColor colorWithIntRed:210 green:220 blue:235 alpha:255];
[m_view.legend setBackground:[SolidColorBrush solidColorBrushWithColor:backgroundColor]];
// Set legend background transparency
[m_view.legend setOpacity:0.5];
// Get coordinate value on X axis for top left  corner of legend
double left = [m_view.legend left];
// Get coordinate value on Y axis for top left corner of legend
double top = [m_view.legend top];
// Get legend width value
double width = [m_view.legend width];
// Get legend height value
double height = [m_view.legend height];
// Display obtained values to the development environment console
NSLog(@"X axis coordinate for top left corner of legend: %f", left);
NSLog(@"Y axis coordinate for top left corner of legend: %f", top);
NSLog(@"Legend width: %f", width);
NSLog(@"Legend height: %f", height);

It is also required to replace the contents of the  mapChart:touchDownInShape: method of the ViewController class (see the Creating a Map with a Timeline section) with the following code:

// Set map title margin
Thickness captionThickness = {0};
captionThickness.top = 10;
captionThickness.right = 250;
// Set new values of title margin
[[m_view caption] setMargin:captionThickness];
// display new values of title margins
[m_view alignCaption];
// Hide timeline
[[m_view timeAxis] setOptimizedOut:YES];

After executing the example the top and left map margins are equal to 8 pixels, the timeline value is equal to 2, A new color with the transparency 50% is set for legend background:

The development environment console displays values of height, width and top left corner coordinates of the legend:

X axis coordinate for top left corner of legend: 0.000000

Y axis coordinate for top left corner of legend: 0.000000

Legend width: 215.291977

Legend height: 74.650002

 

Then manually press any map layer area. As a result, the timeline is hidden. Value of the map title top margin is equal to 10 pixels, the right margin value is equal to 250 pixels:

See also:

Examples of Component Use