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

RADMAP control for WPF always sets ZoomLevel to 1 when using SetView()

3 Answers 124 Views
Map
This is a migrated thread and some comments may be shown as answers.
Padmanabhan
Top achievements
Rank 1
Padmanabhan asked on 01 Feb 2011, 07:07 PM
Hi,

   I'm using RADMap control for WPF to plot the pins based on set of Lats and Longs. But, i need the Optimum Zoomlevel to display in Map. For this i use Setview() method of the rad map. By doing this i always get the Zoomlevel to 1. But, when i click on the button event, the Zoomlevel is setting correctly even if the debug says Zoomlevel =1. Please find my below code and let me know how should i proceed.

MainWindow.xaml
==============
 <Window x:Class="RadMapControlStudy.MainWindow"
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Title="MainWindow" Height="600" Width="600" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Grid>
<telerik:RadMap Height="500" HorizontalAlignment="Left" Margin="3,0,0,0" Name="radMap1" VerticalAlignment="Top" Width="500">
<telerik:InformationLayer x:Name="layer">
</telerik:InformationLayer>
</telerik:RadMap>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="503,282,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
</Grid>
</
Window>

MainWindow.xaml.cs
==================
namespace RadMapControlStudy 
{
 public partial class MainWindow : Window
{
    Location lc1 = new Location(28.066600, -82.381600); //Some LatLong
    
Location lc2 = new Location(28.066890, -82.381876); //Some LatLong

 

 public MainWindow()
{
    InitializeComponent();
    radMap1.Provider = n
ew BingMapProvider(MapMode.Road, true, "KeyValue"); 
    layer.Items.Add(lc1);
    layer.Items.Add(lc2);

    LocationRect
lr = new LocationRect(lc1, lc2); 
    
radMap1.SetView(lr);
}

private void button1_Click(object sender, RoutedEventArgs e) //Zoom seems to be working fine when you click the button
{
    
LocationRect lr1 = new LocationRect(lc1,lc2); 
    radMap1.SetView(lr1);

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 04 Feb 2011, 10:24 AM
Hi Padmanabhan,

The RadMap.SetView method can't be used before the map control and map provider complete intialization process. I.e. you can't use it in the window constructor. If you need to setup view port when you application starts, then it is better to do it in the window Loaded event handler. For example:

Location lc1 = new Location(28.066600, -82.381600); //Some LatLong
Location lc2 = new Location(28.066890, -82.381876); //Some LatLong 
  
public MainWindow()
{
    InitializeComponent();
  
    layer.Items.Add(lc1);
    layer.Items.Add(lc2);
  
    this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
}
  
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    LocationRect lr = new LocationRect(lc1, lc2);
    this.radMap1.SetView(lr);
}


Kind regards,
Andrey Murzov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Padmanabhan
Top achievements
Rank 1
answered on 04 Feb 2011, 10:58 PM
Thanks, Andrey. That Worked. I have another Question here. I need to get a tooltip for the pushpins. For that, I went through one of PointStyling (http://www.telerik.com/community/forums/wpf/map/how-to-change-balloon-color-and-get-tooltip-info.aspx) solution you provided in another forum. Also, I'm not sure where the small pushpin object is coming from as i don't see any ImageSource being set in the solution you provided.

Now the issue: I'm creating a ToolTip object which is a Table with rows and columns in runtime and assigning the same to ToolTip property. But it is giving me nothing when i do a mouseover on the Pin. Please see the code:
xaml
===
<telerik:InformationLayer Name="techLayer">
                <telerik:InformationLayer.ItemTemplate>
                    <DataTemplate>
                        <telerik:Pushpin telerik:MapLayer.Location="{Binding Location}"
                                         Background="{Binding Background}"
                                         ToolTip="{Binding ToolTip1}"
                                         Tag="{Binding Tag}"/>
                    </DataTemplate>
                </telerik:InformationLayer.ItemTemplate>
</telerik:InformationLayer>

xaml.cs
======
for (int j = 0; j < datarow.Length; j++)
                {
                    poi = new PointOfInterest();
                    Double TechLatitude = datarow[j]["latitude"]
                    Double TechLongitude = datarow[j]["Longitude"]
                    poi.Location = new Location(TechLatitude, TechLongitude);
                    poi.Background = new SolidColorBrush(Colors.Blue);
                    poi.ToolTip1 = new System.Windows.Controls.ToolTip();               
                    ToolTip objToolTip = CreateToolTipGrid(); //Returns Tooltip object
                    poi.ToolTip1.ToolTip = objToolTip;
                    poiCollection.Add(poi);
                }

I even tried to register ToolTipOpeningEvent and the mouseover that pin did not fire the event

Regards!!
Paddy
0
Padmanabhan
Top achievements
Rank 1
answered on 05 Feb 2011, 12:49 AM
NeverMind Andrey. I figured it out. Thanks for all your help.

Regards!!
Paddy
Tags
Map
Asked by
Padmanabhan
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Padmanabhan
Top achievements
Rank 1
Share this question
or