This question is locked. New answers and comments are not allowed.
Hi,
I have A RadDocking window with two RadSplitContainers. Each RadSplitContainer has one RadPaneGroup with one RadPane in it.
One RadPane has a TreeView and the other has a RadMap.
The TreeView has some TreeNodes.I have a RadContextMenu created on each node, with a "Zoom to Location" RadMenuItem. When I click this RadMenuItem, I can retrieve the "Latitude" and "Longitude" of a Location from the node, and I want the Map in another RadPane to zoom to that Location automatically to zoom level 6 (Am using 3 zoom levels for the map 5,6 and 7). How can this be achieved?
Am using Silverlight 5 with MVVM pattern.
Thanks in Advance,
Viddy.
I have A RadDocking window with two RadSplitContainers. Each RadSplitContainer has one RadPaneGroup with one RadPane in it.
One RadPane has a TreeView and the other has a RadMap.
The TreeView has some TreeNodes.I have a RadContextMenu created on each node, with a "Zoom to Location" RadMenuItem. When I click this RadMenuItem, I can retrieve the "Latitude" and "Longitude" of a Location from the node, and I want the Map in another RadPane to zoom to that Location automatically to zoom level 6 (Am using 3 zoom levels for the map 5,6 and 7). How can this be achieved?
Am using Silverlight 5 with MVVM pattern.
Thanks in Advance,
Viddy.
4 Answers, 1 is accepted
0
Hello Vidyadhar,
You should use Center and ZoomLevel properties of the RadMap control (see details here http://www.telerik.com/help/silverlight/radmap-features-navigation.html).
All the best,
You should use Center and ZoomLevel properties of the RadMap control (see details here http://www.telerik.com/help/silverlight/radmap-features-navigation.html).
All the best,
Andrey Murzov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Vidyadhar
Top achievements
Rank 1
answered on 22 Mar 2012, 08:34 PM
Hi Andrey,
Thanks for the reply.
I did try setting those properties, but no luck. Couldn't get the map to Zoom in or change its Center. Please have a look at the code below and let me know where am I going wrong. Am using my own custom MapProvider, am not sure if that has to do anything with it. Am attaching my MapProvider code, just in case.
XAML:
<telerik:RadMap Name="RadMap1" ZoomLevel="{Binding Path=CurrentZoomLevel,Mode=TwoWay}" MinZoomLevel="{Binding Path=MinZoomLevel,Mode=TwoWay}" MaxZoomLevel="{Binding Path=MaxZoomLevel,Mode=TwoWay}"
GeoBoundsNW="55.7,-131.0" GeoBoundsSE="27.2,-90.4" MouseClickMode="None"
Provider="{Binding Path=MyRadMapProvider,Mode=TwoWay}" Center="{Binding Path=MyRadMapCenter,Mode=TwoWay}" InitializeCompleted="RadMap1_InitializeCompleted" />
ViewModel Properties:
private int _zoomLevel;
public int CurrentZoomLevel
{
get { return _zoomLevel; }
set
{
_zoomLevel = value;
NotifyPropertyChanged(m => m.CurrentZoomLevel);
}
}
private int _minZoomLevel;
public int MinZoomLevel
{
get { return _minZoomLevel; }
set
{
_minZoomLevel = value;
NotifyPropertyChanged(m => m.MinZoomLevel);
}
}
private int _maxZoomLevel;
public int MaxZoomLevel
{
get { return _maxZoomLevel; }
set
{
_maxZoomLevel = value;
NotifyPropertyChanged(m => m.MaxZoomLevel);
}
}
In Consturctor of my ViewModel:
MyRadMapCenter = new Location(41.4, -109.5);
MyRadMapProvider.GeoBounds = new LocationRect(new Location(55.7, -131.6), new Location(27.0, -90.0));
CurrentZoomLevel = 5;
MinZoomLevel = 5;
MaxZoomLevel = 7;
On a MenuItemClick Event am calling a method called Zoomtolocation:
private void ZoomToLocation(double lat, double longi)
{
//MessageBox.Show("This will zoom the map to the location");
CurrentZoomLevel = 7;
MyRadMapCenter = new Location(35.353, -123.553);
//NotifyPropertyChanged(m => m.CurrentZoomLevel);
//NotifyPropertyChanged(m=>m.MyRadMapCenter);
}
Thanks for the reply.
I did try setting those properties, but no luck. Couldn't get the map to Zoom in or change its Center. Please have a look at the code below and let me know where am I going wrong. Am using my own custom MapProvider, am not sure if that has to do anything with it. Am attaching my MapProvider code, just in case.
XAML:
<telerik:RadMap Name="RadMap1" ZoomLevel="{Binding Path=CurrentZoomLevel,Mode=TwoWay}" MinZoomLevel="{Binding Path=MinZoomLevel,Mode=TwoWay}" MaxZoomLevel="{Binding Path=MaxZoomLevel,Mode=TwoWay}"
GeoBoundsNW="55.7,-131.0" GeoBoundsSE="27.2,-90.4" MouseClickMode="None"
Provider="{Binding Path=MyRadMapProvider,Mode=TwoWay}" Center="{Binding Path=MyRadMapCenter,Mode=TwoWay}" InitializeCompleted="RadMap1_InitializeCompleted" />
ViewModel Properties:
private int _zoomLevel;
public int CurrentZoomLevel
{
get { return _zoomLevel; }
set
{
_zoomLevel = value;
NotifyPropertyChanged(m => m.CurrentZoomLevel);
}
}
private int _minZoomLevel;
public int MinZoomLevel
{
get { return _minZoomLevel; }
set
{
_minZoomLevel = value;
NotifyPropertyChanged(m => m.MinZoomLevel);
}
}
private int _maxZoomLevel;
public int MaxZoomLevel
{
get { return _maxZoomLevel; }
set
{
_maxZoomLevel = value;
NotifyPropertyChanged(m => m.MaxZoomLevel);
}
}
In Consturctor of my ViewModel:
MyRadMapCenter = new Location(41.4, -109.5);
MyRadMapProvider.GeoBounds = new LocationRect(new Location(55.7, -131.6), new Location(27.0, -90.0));
CurrentZoomLevel = 5;
MinZoomLevel = 5;
MaxZoomLevel = 7;
On a MenuItemClick Event am calling a method called Zoomtolocation:
private void ZoomToLocation(double lat, double longi)
{
//MessageBox.Show("This will zoom the map to the location");
CurrentZoomLevel = 7;
MyRadMapCenter = new Location(35.353, -123.553);
//NotifyPropertyChanged(m => m.CurrentZoomLevel);
//NotifyPropertyChanged(m=>m.MyRadMapCenter);
}
0
Hi Vidyadhar,
It is hard to say what is wrong with your application having just the code snippet you provided. I created a simple application which do similar things (zoom to center) but using the OpenStreet map provider. Everything works as expected. Please compare it with your own and let me know if there's anything else I can help you with.
All the best,
It is hard to say what is wrong with your application having just the code snippet you provided. I created a simple application which do similar things (zoom to center) but using the OpenStreet map provider. Everything works as expected. Please compare it with your own and let me know if there's anything else I can help you with.
All the best,
Andrey Murzov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Vidyadhar
Top achievements
Rank 1
answered on 23 Mar 2012, 07:57 PM
Hey Andrey,
It worked. It was a data binding issue. When I fixed the DataContext, it started working.
Thank You,
Viddy.
It worked. It was a data binding issue. When I fixed the DataContext, it started working.
Thank You,
Viddy.