This is a migrated thread and some comments may be shown as answers.

Map Background

1 Answer 104 Views
Map
This is a migrated thread and some comments may be shown as answers.
Santiago Dávila
Top achievements
Rank 1
Santiago Dávila asked on 24 Feb 2010, 11:54 AM
Please

I would like to change the background color of the map in an empty provider mode application. How can I change the gray background for a black for example.

Thanks in advance


Santiago

1 Answer, 1 is accepted

Sort by
0
Accepted
Sia
Telerik team
answered on 01 Mar 2010, 07:48 AM
Hi Santiago Dávila,

After our Q1 2010 release, scheduled for the week of March 8th, you will just need to set the RadMap's Background property to the desired color with the following code behind:
this.RadMap1.Background = new SolidColorBrush(Colors.Red);

Currently you need to retemplate the Map control.

Here is the XAML needed:
<UserControl x:Class="MapApplication.MainPage"
    xmlns:map="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.DataVisualization"
    xmlns:maps="clr-namespace:Telerik.Windows.Controls.Map;assembly=Telerik.Windows.Controls.DataVisualization"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    <UserControl.Resources>    
        <Style TargetType="maps:TileLayer" x:Key="CustomTileLayer">
            <Setter Property="Background" Value="Red" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="maps:TileLayer">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <Grid x:Name="PART_TileGrid" />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
 
        <Style TargetType="map:RadMap" x:Key="CustomMap">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="map:RadMap">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" MinHeight="200" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
 
                            <maps:TileLayer Style="{StaticResource CustomTileLayer}" x:Name="PART_TileLayer" Grid.RowSpan="2" />
                            <maps:MouseControl x:Name="PART_MouseControl" Grid.RowSpan="2" />
                            <ItemsPresenter Grid.RowSpan="2" />
 
                            <maps:MapNavigation x:Name="PART_MapNavigation"
                                        Width="100"
                                        Margin="0,0,0,10"
                                        Visibility="Collapsed"
                                        VerticalAlignment="Stretch"
                                        HorizontalAlignment="Left" />
 
                            <maps:MapCommandBar x:Name="PART_MapCommandBar"
                                            Grid.RowSpan="2"
                                            Margin="110,10,0,0"
                                            Visibility="Collapsed"
                                            VerticalAlignment="Top"
                                            HorizontalAlignment="Left" />
 
                            <maps:MapScale x:Name="PART_MapScale"
                                       Grid.RowSpan="2"
                                       Height="20"
                                       Margin="0,0,20,20"
                                       Visibility="Collapsed"
                                       DistanceUnit="{TemplateBinding DistanceUnit}"
                                       VerticalAlignment="Bottom"
                                       HorizontalAlignment="Right" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <Grid />
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <map:RadMap x:Name="RadMap1" />
    </Grid>
</UserControl>

In your code behind you need to set your new Style to the RadMap control:
this.RadMap1.Style = this.Resources["CustomMap"] as Style;

Hope this helps!

Sincerely yours,
Sia
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Map
Asked by
Santiago Dávila
Top achievements
Rank 1
Answers by
Sia
Telerik team
Share this question
or