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

How to turn off MapCommandBar

3 Answers 81 Views
Map
This is a migrated thread and some comments may be shown as answers.
ewart
Top achievements
Rank 1
ewart asked on 20 Jan 2010, 09:07 AM
I don't want to display it.  I'd like to set

RadMap1.MapCommandBar.Visibility = System.Windows.

 

Visibility.Collapsed;

 

 

 


would have thought this should work inside the InitializeCompleted but it doesn't.  Where should I be doing it from?

 

 

 

private void RadMap1_InitializeCompleted(object sender, EventArgs e)   
{  
}   
 

 

 

 

 

 

 


Thanks
Ewart.

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 22 Jan 2010, 03:05 PM
Hello Ewart,

Thank you for the feedback.
The MapCommandBar could not be turned off separately in the RadMap CTP version. It will be available in the 2010 Q1 release. Also the MapCommandBar will be inaccessible from a code as well as others built-in controls since Q1.
Currently the RadMap control has only UseDefaultLayout property to turning on/off all UI controls (Command bar, Navigation and Scale). The standard way to show map control without the MapCommandBar is to setting the UseDefaultLayout to False and to add necessary map controls directly.
The sample XAML and C# code are below.
 
<Grid x:Name="LayoutRoot">
    <map:RadMap Name="RadMap1"
                ...
                UseDefaultLayout="False">
                ...
    </map:RadMap>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="4*" MinHeight="150" />
            <RowDefinition Height="5*" />
        </Grid.RowDefinitions>
    <maps:MapNavigation Name="customNavigation"
                        Width="100"
                        Margin="0,0,10,0"
                        VerticalAlignment="Stretch"
                        HorizontalAlignment="Left"/>
    <maps:MapScale Name="customScale"
                   Grid.Row="1"
                   Height="20"
                   Margin="0,0,20,20"
                   DistanceUnit="Mile"
                   VerticalAlignment="Bottom"
                   HorizontalAlignment="Right"/>
    </Grid>
</Grid>
private void RadMap1_InitializeCompleted(object sender, EventArgs e)
{
    this.InitializeMapControls();
  
    ...
}
  
private void InitializeMapControls()
{
    this.customNavigation.MapControl = this.RadMap1;
    this.customNavigation.Visibility = Visibility.Visible;
  
    this.customScale.MapControl = this.RadMap1;
    this.customScale.Visibility = Visibility.Visible;
}

Kind regards,
Andrey Murzov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
ewart
Top achievements
Rank 1
answered on 04 Mar 2010, 10:33 AM
has this changed in the Q1 2010 beta ?  I find in the code below the InitializeCompleted never fires and my map doesn't load at all.

<UserControl x:Class="Mapper.UI.TestPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    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" 
               
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="400">  
    <Grid x:Name="LayoutRoot">  
        <map:RadMap Name="RadMap1" InitializeCompleted="RadMap1_InitializeCompleted" 
                UseDefaultLayout="False">  
        </map:RadMap> 
        <Grid> 
            <Grid.RowDefinitions> 
                <RowDefinition Height="4*" MinHeight="150" /> 
                <RowDefinition Height="5*" /> 
            </Grid.RowDefinitions> 
            <maps:MapNavigation Name="customNavigation" 
                        Width="100" 
                        Margin="0,0,10,0" 
                        VerticalAlignment="Stretch" 
                        HorizontalAlignment="Left"/>  
            <maps:MapScale Name="customScale" 
                   Grid.Row="1" 
                   Height="20" 
                   Margin="0,0,20,20" 
                   DistanceUnit="Mile" 
                   VerticalAlignment="Bottom" 
                   HorizontalAlignment="Right"/>  
        </Grid> 
 
    </Grid> 
</UserControl> 
 

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Net;  
using System.Windows;  
using System.Windows.Controls;  
using System.Windows.Documents;  
using System.Windows.Input;  
using System.Windows.Media;  
using System.Windows.Media.Animation;  
using System.Windows.Shapes;  
 
namespace Mapper.UI  
{  
    public partial class TestPage : UserControl  
    {  
        public TestPage()  
        {  
            InitializeComponent();  
        }  
 
        private void RadMap1_InitializeCompleted(object sender, EventArgs e)  
        {  
            this.InitializeMapControls();  
        }  
 
        private void InitializeMapControls()  
        {  
            this.customNavigation.MapControl = this.RadMap1;  
            this.customNavigation.Visibility = Visibility.Visible;  
 
            this.customScale.MapControl = this.RadMap1;  
            this.customScale.Visibility = Visibility.Visible;  
        }  
 
    }  
}  
 


if I remove the UseDefaultLayout="False" then the map tries to load.   basically I need the best way (for Q1 2001 beta) of

1. hiding the mapcommandbar completely - is  "

radMap.MapCommandBarVisibility = System.Windows.

 

Visibility.Collapsed;" the easiest and best way? seems to work.

 


2. move the position of the scale.  not sure on this one.

regards
   ewart
0
Andrey
Telerik team
answered on 05 Mar 2010, 12:44 PM
Hi ewart,

I could not find the place where the map provider  is set for the map control. If you don’t do it then map control will never be initialized and you control’s will not be visible. I’ve extended your code a bit with initialization of the map provider and all things works just fine:
using System;   
using System.Collections.Generic;   
using System.Linq;   
using System.Net;   
using System.Windows;   
using System.Windows.Controls;   
using System.Windows.Documents;   
using System.Windows.Input;   
using System.Windows.Media;   
using System.Windows.Media.Animation;   
using System.Windows.Shapes;   
    
namespace Mapper.UI   
{   
    public partial class TestPage : UserControl   
    
   
        public TestPage()
        {
            InitializeComponent();
   
            this.Loaded += new RoutedEventHandler(TestPage_Loaded);
        }
   
        private void TestPage_Loaded(object sender, RoutedEventArgs e)
        {
            BingMapProvider provider = new BingMapProvider(MapMode.Aerial, true, "Your_Bing_Application_ID");
            this.RadMap1.Provider = provider;
        }
                    
        private void RadMap1_InitializeCompleted(object sender, EventArgs e)   
        {   
            this.InitializeMapControls();   
        }  
                  
        private void InitializeMapControls()
        {
            this.customNavigation.MapControl = this.radMap;
            this.customNavigation.Visibility = Visibility.Visible;
   
            this.customScale.MapControl = this.radMap;
            this.customScale.Visibility = Visibility.Visible;
            this.customScale.InvalidateMeasure();
        }   
    }
}

Greetings,
Andrey Murzov
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
ewart
Top achievements
Rank 1
Answers by
Andrey
Telerik team
ewart
Top achievements
Rank 1
Share this question
or