Searching for Map Layer by Identifier

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example implements search of map area by identifier and changing of timeline index by means of the MapObject.chart property.

Source Code

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

// Get object for working with map layer
MapLayer *layer = [[m_view layers] objectAtIndex:0];
// Save link to map in the "chart" property
[layer setChart:m_view];
// Call by link a method of the "map" object that moves timeline slider
[[[layer chart] timeAxis] setIndex:1];
// Create a tooltip for layer
layer.tooltip = [MapTooltip new];
// Get array of map areas in this layer
NSArray *shapes = [layer allShapes];
// Search in array of areas
for (MapShape *shape in shapes) {
    // Compare current area identifier with the specified one
    if([shape.ID isEqual:@"RU"] == YES)
    {
        // Create an object for working with a tooltip
        MapTooltip *tip = [MapTooltip new];
        // Display a tooltip
        tip.visibility = YES;
        // Set tooltip text
        tip.text = @"Russian Federation";
        // Set tooltip font
        tip.font = [UIFont fontWithName:@"Arial" size:18];
        // Set tooltip background color
        tip.background = [SolidColorBrush solidColorBrushWithColor:[UIColor whiteColor]];
        // Set tooltip border color
        tip.borderColor = [UIColor blackColor];
        // Set tooltip border thickness
        tip.borderThickness = 1.0;
        // Set rounding radius for tooltip angles
        tip.borderRadius = 10.0;
        // Pass area tooltip object
        shape.tooltip = tip;
    }
}

After executing the example the map timeline index value is equal to 1.  A tooltip is displayed for the area found by the specified identifier:

See also:

Examples of Component Use