Hi,
I want to rebind the informationlayer data automatically so if any data changed it will reflect on map. i am fetching informationlayer data from database.
and using DispatchTimer to rebind it. on my informationlayer there is tooltip also. problem is some time this tooltip displayed in wrong position like upperleft corner of the map instead of on the item location.
my xaml is :
and my code behind is
please help also tell which is the best way to refresh the information layer when ever the data is updated in database. i am using WCF basichttpbinded service.
Regards,
Syed Fahad Anwar
I want to rebind the informationlayer data automatically so if any data changed it will reflect on map. i am fetching informationlayer data from database.
and using DispatchTimer to rebind it. on my informationlayer there is tooltip also. problem is some time this tooltip displayed in wrong position like upperleft corner of the map instead of on the item location.
my xaml is :
<
UserControl
x:Class
=
"SitesMapp.MainPage"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadMap
Height
=
"auto"
HorizontalAlignment
=
"Left"
Margin
=
"12,12,0,0"
Center
=
"9.45, 7.46"
ZoomLevel
=
"6"
Name
=
"radMap1"
VerticalAlignment
=
"Top"
Width
=
"auto"
>
<
telerik:InformationLayer
x:Name
=
"informationLayer"
>
<
telerik:InformationLayer.ItemTemplate
>
<
DataTemplate
>
<
Grid
telerik:MapLayer.BaseZoomLevel
=
"{Binding BaseZoomLevel}"
telerik:MapLayer.Location
=
"{Binding Location}"
telerik:MapLayer.ZoomRange
=
"{Binding ZoomRange}"
>
<
telerik:MapLayer.HotSpot
>
<
telerik:HotSpot
X
=
"0.5"
Y
=
"0.5"
ElementName
=
"PART_Ellipse"
/>
</
telerik:MapLayer.HotSpot
>
<
Ellipse
x:Name
=
"PART_Ellipse"
Width
=
"20"
Height
=
"20"
Stroke
=
"Red"
StrokeThickness
=
"3"
Fill
=
"Transparent"
>
<
ToolTipService.ToolTip
>
<
ToolTip
Content
=
"{Binding Rating}"
/>
</
ToolTipService.ToolTip
>
</
Ellipse
>
</
Grid
>
</
DataTemplate
>
</
telerik:InformationLayer.ItemTemplate
>
</
telerik:InformationLayer
>
</
telerik:RadMap
>
</
Grid
>
</
UserControl
>
and my code behind is
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;
using System.Collections.ObjectModel;
using Telerik.Windows.Controls.Map;
using System.Threading;
using System.Windows.Threading;
namespace SitesMapp
{
public partial class MainPage : UserControl
{
PammsDataService.PammsDataServiceClient client = new PammsDataService.PammsDataServiceClient();
public MainPage()
{
InitializeComponent();
radMap1.Provider = new OpenStreetMapProvider();
radMap1.InitializeCompleted += new EventHandler(radMap1_InitializeCompleted);
DispatcherTimer t = new DispatcherTimer();
t.Interval = new TimeSpan( 0, 0, 1 );
t.Tick += new EventHandler(Rebind);
t.Start();
}
void radMap1_InitializeCompleted(object sender, EventArgs e)
{
//informationLayer.ItemsSource = GetMapData();
client.GetSitesInformationAsync();
client.GetSitesInformationCompleted += new EventHandler<
PammsDataService.GetSitesInformationCompletedEventArgs
>(client_GetSitesInformationCompleted);
}
void client_GetSitesInformationCompleted(object sender, PammsDataService.GetSitesInformationCompletedEventArgs e)
{
ObservableCollection<
MapItem
> data = new ObservableCollection<
MapItem
>();
ObservableCollection<
PammsDataService.Site
> sites = e.Result;
foreach (PammsDataService.Site site in sites)
{
MapItem mapItem = new MapItem(site.SiteName, new Location(site.Latitude, site.Longitude), 5, new ZoomRange(5, 12),site.Rating);
data.Add(mapItem);
}
Dispatcher.BeginInvoke(() =>
informationLayer.ItemsSource = data
);
//radMap1.UpdateLayout();
//informationLayer.UpdateLayout();
}
private void Rebind(object e , EventArgs args)
{
client.GetSitesInformationAsync();
client.GetSitesInformationCompleted += new EventHandler<
PammsDataService.GetSitesInformationCompletedEventArgs
>(client_GetSitesInformationCompleted);
}
private ObservableCollection<
MapItem
> GetMapData()
{
ObservableCollection<
MapItem
> data = new ObservableCollection<
MapItem
>();
//data.Add(new MapItem("Sofia", new Location(9.45, 7.46), 5, new ZoomRange(5, 12)));
//data.Add(new MapItem("Plovdiv", new Location(8.45, 7.46), 5, new ZoomRange(5, 12)));
//data.Add(new MapItem("Burgas", new Location(5.45, 7.46), 5, new ZoomRange(5, 12)));
//data.Add(new MapItem("Varna", new Location(4.45, 7.46), 5, new ZoomRange(5, 12)));
return data;
}
}
}
please help also tell which is the best way to refresh the information layer when ever the data is updated in database. i am using WCF basichttpbinded service.
Regards,
Syed Fahad Anwar