This question is locked. New answers and comments are not allowed.
Hi,
I updated my project 2010 Q1 to 2011 Q1 than my all Information layer items location showns the same.
How can i fix it ?
You can see the example codes in the upper side.
I updated my project 2010 Q1 to 2011 Q1 than my all Information layer items location showns the same.
How can i fix it ?
You can see the example codes in the upper side.
<UserControl x:Class="Pergo.Silver.Views.ctrl.Map.Map"
xmlns:map="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.DataVisualization"
xmlns:mapNamespace="clr-namespace:Telerik.Windows.Controls.Map;assembly=Telerik.Windows.Controls.DataVisualization"
xmlns:example="Pergo.Silver.Views.ctrl.MapClass;assembly=Map"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<UserControl.Resources>
<DataTemplate x:Key="PointOfInterestTemplate">
<Grid x:Name="TopLevelGrid" Width="Auto" Height="Auto" telerik:MapLayer.Location="{Binding Path=Location}" >
<ToolTipService.ToolTip>
<ToolTip >
<ToolTip.Content>
<Grid x:Name="PopupGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" FontFamily="Tahoma" FontSize="12" FontWeight="Bold" Text="{Binding Path=TERMINAL}" Visibility="Collapsed"/>
<TextBlock Grid.Row="1" FontFamily="Tahoma" FontSize="12" FontWeight="Bold" Text="{Binding Path=SHORT_NAME}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="2" FontFamily="Tahoma" FontSize="12" FontWeight="Bold" Text="{Binding Path=LONG_NAME}" Visibility="{Binding Path=WaitOther}"/>
<StackPanel Grid.Row="3" Orientation="Horizontal" >
<Image x:Name="ISONLINEImage" Height="Auto" Width="Auto" Source="{Binding Path=ISONLINEImageSource}" Visibility="{Binding Path=WaitOther}"/>
<Image x:Name="SATELLITEImage" Height="Auto" Width="Auto" Source="{Binding Path=SATELLITEImageSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock x:Name="SATELLITELabel" VerticalAlignment="Center" Text="{Binding Path=SATELLITELabelSource}" Visibility="{Binding Path=WaitOther}"/>
</StackPanel >
<telerik:RadProgressBar Grid.Row="4" Height="10" Value="{Binding Path=BATERY}" Width="auto" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="5" x:Name="SPEEDLabel" VerticalAlignment="Center" Text="{Binding Path=SPEEDLabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="6" x:Name="ALTITUDELabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=ALTITUDELabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="7" x:Name="HDOPLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=HDOPLabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="8" x:Name="GPS_KMLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=GPS_KMLabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="9" x:Name="VEHICLE_KMLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=VEHICLE_KMLabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="10" x:Name="TEMPERATURELabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=TEMPERATURELabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock Grid.Row="11" x:Name="FUEL_TANKLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=FUEL_TANKLabelSource}" Visibility="{Binding Path=WaitOther}"/>
<StackPanel Grid.Row="12" Orientation="Horizontal">
<TextBlock x:Name="STREETLabelName" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="Adres:" FontWeight="Bold" Visibility="{Binding Path=WaitOther}"/>
<TextBlock x:Name="STREETLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=STREETLabelSource}" Visibility="{Binding Path=WaitOther}"/>
</StackPanel >
<StackPanel Grid.Row="13" Orientation="Horizontal" >
<TextBlock x:Name="QUARTERLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=QUARTERLabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock x:Name="COUNTYLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=COUNTYLabelSource}" Visibility="{Binding Path=WaitOther}"/>
<TextBlock x:Name="CITYLabel" FontFamily="Tahoma" FontSize="12" VerticalAlignment="Center" Text="{Binding Path=CITYLabelSource}" Visibility="{Binding Path=WaitOther}" />
</StackPanel >
<telerik:RadProgressBar Grid.Row="14" Name="ProgressWait" Height="50" Width="200" IsIndeterminate="True" Visibility="{Binding Path=Wait}" ></telerik:RadProgressBar>
</Grid>
</ToolTip.Content>
</ToolTip>
</ToolTipService.ToolTip>
<Canvas Background="Black">
<TextBlock Text="{Binding Path=ShortNameText}" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" Foreground="Red" >
<TextBlock.RenderTransform >
<RotateTransform x:Name="FireballTransform2" CenterX="0" CenterY="0" Angle="{Binding Path=DirectionText}"></RotateTransform>
</TextBlock.RenderTransform>
</TextBlock>
<Image x:Name="MapIcon" Stretch="Fill" Source="{Binding Path=MapIconSource}" >
<Image.RenderTransform >
<RotateTransform x:Name="FireballTransform" CenterX="0" CenterY="0" Angle="{Binding Path=Direction}"></RotateTransform>
</Image.RenderTransform>
</Image>
</Canvas>
</Grid>
</DataTemplate>
<DataTemplate x:Key="ShortCutTemplate">
<Grid x:Name="TopLevelGrid" Width="Auto" Height="Auto" telerik:MapLayer.Location="{Binding Path=Location}" >
<ToolTipService.ToolTip>
<ToolTip >
<ToolTip.Content>
<Grid x:Name="PopupGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" FontFamily="Tahoma" FontSize="12" FontWeight="Bold" Text="{Binding Path=STREETLabelSource}" Visibility="Visible"/>
<TextBlock Grid.Row="1" FontFamily="Tahoma" FontSize="12" FontWeight="Bold" Text="{Binding Path=SPEEDLabelSource}" Visibility="Visible"/>
</Grid>
</ToolTip.Content>
</ToolTip>
</ToolTipService.ToolTip>
<Canvas Background="Black">
<TextBlock Text="asda"></TextBlock>
<Image x:Name="MapIcon" Stretch="Fill" Source="{Binding Path=MapIconSource}" >
<Image.RenderTransform>
<TranslateTransform X="-16" Y="-37" />
</Image.RenderTransform>
</Image>
</Canvas>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<map:RadMap x:Name="PergoMap" ZoomLevel="13" ZoomBarVisibility="Visible" ZoomBarPresetsVisibility="Visible" Grid.Row="1" MapMouseClick="PergoMap_MapMouseClick" InitializeCompleted="PergoMap_InitializeCompleted" CommandBarVisibility="Visible" NavigationVisibility="Visible" ScaleVisibility="Visible">
<telerik:InformationLayer x:Name="InformationLayer" ItemTemplate="{StaticResource PointOfInterestTemplate}">
</telerik:InformationLayer>
<telerik:InformationLayer x:Name="ShortcutLayer" ItemTemplate="{StaticResource ShortCutTemplate}">
</telerik:InformationLayer>
<telerik:InformationLayer Name="RouteLayer">
<telerik:InformationLayer.ItemTemplate>
<DataTemplate>
<Border Background="#7FFFFFFF" BorderThickness="1" Padding="2,2,2,2">
<ToolTipService.ToolTip>
<ToolTip>
<ToolTip.Content>
<Grid>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Latitude=" />
<TextBlock Text="{Binding Path=Latitude}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Longitude=" />
<TextBlock Text="{Binding Path=Longitude}" />
</StackPanel>
</StackPanel>
</Grid>
</ToolTip.Content>
</ToolTip>
</ToolTipService.ToolTip>
<telerik:MapLayer.HotSpot>
<telerik:HotSpot X="0.5" Y="0.5" />
</telerik:MapLayer.HotSpot>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="14" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Path Fill="Red">
<Path.Data>
<GeometryGroup>
<EllipseGeometry Center="7,7" RadiusX="3" RadiusY="3" />
<EllipseGeometry Center="7,7" RadiusX="7" RadiusY="7" />
</GeometryGroup>
</Path.Data>
</Path>
</Grid>
</Border>
</DataTemplate>
</telerik:InformationLayer.ItemTemplate>
</telerik:InformationLayer>
<telerik:InformationLayer Name="RouteLayer2" />
<telerik:InformationLayer x:Name="mapShapeLayer">
</telerik:InformationLayer>
</map:RadMap>
</Grid>
</UserControl>
using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using Pergo.Silver.PergoWCF;
using Pergo.Silver.Views.ctrl.Map.MapClass;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Map;
using ItemsControl = Telerik.Windows.Controls.ItemsControl;
namespace Pergo.Silver.Views.ctrl.Map
{
public partial class Map : UserControl
{
public event EventHandler<FirstDataCompleted> IsFirstDataCompleted;
internal PergoWCF.WCFClient Client { get; set; }
private BingRouteProvider RouteProvider { get; set; }
public LocationCollection RoutePoints { get; set; }
private MapPolyline RouteLine { get; set; }
public bool IsNavigateMode = false;
public bool IsShourcutMode = false;
public ObservableCollection<string> TerminalIDList { get; set; }
public RadMapPointsCollection RadMapPoints { get; set; }
public RadMapPointsCollection ShortcutPictureCollection { get; set; }
public Map()
{
if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) return;
InitializeComponent();
InitControls();
Client.GetMapShortcutsAsync();
Client.GetAllTerminalAsync();
}
private void InitControls()
{
Client = new WCFClient();
PergoMap.Provider = new OpenStreetMapProvider();
this.InformationLayer.MapControl = this.PergoMap;
ShortcutPictureCollection = new RadMapPointsCollection();
RadMapPoints = new RadMapPointsCollection();
TerminalIDList = new ObservableCollection<string>();
RouteLine = new MapPolyline();
RouteProvider = new BingRouteProvider();
RoutePoints = new LocationCollection();
Binding binding = new Binding();
binding.Source = this.RoutePoints;
this.RouteLayer.SetBinding(ItemsControl.ItemsSourceProperty, binding);
Client.GetAllTerminalCompleted += new EventHandler<PergoWCF.GetAllTerminalCompletedEventArgs>(clnt_GetAllTerminalCompleted);
Client.GetSelectedTerminalCompleted += new EventHandler<GetSelectedTerminalCompletedEventArgs>(wcfclient_GetSelectedTerminalCompleted);
Client.GetMapShortcutsCompleted += new EventHandler<GetMapShortcutsCompletedEventArgs>(wcfclient_GetMapShortcutsCompleted);
this.PergoMap.UseSpringAnimations = true;
this.InformationLayer.ItemsSource = RadMapPoints;
this.ShortcutLayer.ItemsSource = ShortcutPictureCollection;
RouteProvider = new BingRouteProvider();
RouteProvider.ApplicationId = "AsCbczcL0kts76X68dhLEXq49yVJVZmwv6CKFoxPqjF0i-Id5DySm2mnXjUbY6Xw";
RouteProvider.MapControl = PergoMap;
RouteProvider.RoutingCompleted += new EventHandler<RoutingCompletedEventArgs>(routeProvider_RoutingCompleted);
PergoMap.Center = new Location { Latitude = 39, Longitude = 34 };
}
void wcfclient_GetMapShortcutsCompleted(object sender, GetMapShortcutsCompletedEventArgs e)
{
if (e.Error == null)
SetUp.ShowMapShortcutMarkers(this, e.Result);
}
void wcfclient_GetSelectedTerminalCompleted(object sender, GetSelectedTerminalCompletedEventArgs e)
{
if (e.Error == null)
foreach (Terminal terminalInfo in e.Result)
{
if (TerminalIDList.IndexOf(terminalInfo.TerminalID) == -1)
return;
addTerminal(terminalInfo);
}
}
internal void clnt_GetAllTerminalCompleted(object sender, PergoWCF.GetAllTerminalCompletedEventArgs e)
{
int i = 0;
if (e.Error == null)
if (e.Result != null)
foreach (Terminal terminalInfo in e.Result)
{
i = i + 1;
if (i > 100)
{
//MessageBox.Show("Haritaya En Fazla 100 Adet Araç Eklenebilir. Diğer Araçları Menüden Haritaya Ekleyebilirsiniz.", "Bilgilendirme", MessageBoxButton.OK);
return;
}
if (TerminalIDList.Count == 0)
addTerminal(terminalInfo);
else
if (TerminalIDList.Contains(terminalInfo.TerminalID))
addTerminal(terminalInfo);
}
if (RadMapPoints.Count > 0)
PergoMap.Center = RadMapPoints[0].Location;
}
public void addTerminal(Terminal terminalInfo)
{
//Pushpin pin = new Pushpin();
//InformationLayer.Items.Add(pin);
RadMapPoints.Add(new RadMapPoint
{
Location = new Telerik.Windows.Controls.Map.Location { Longitude = terminalInfo.Longitude, Latitude = terminalInfo.Latitude }, //Latitude = (terminalInfo.Latitude * 2) - 1.6 },
TERMINAL = terminalInfo.TerminalID,
MapIconSource = "/Pergo.Silver;component/Resources/Terminal/Symbol" + terminalInfo.Image_Index.ToString() + ".png",
WaitOther = System.Windows.Visibility.Visible,
Wait = System.Windows.Visibility.Collapsed,
SHORT_NAME = "Kısa Adı:" + terminalInfo.Short_Name,
ShortNameText = terminalInfo.Short_Name,
LONG_NAME = "Uzun Adı:" + terminalInfo.Long_Name,
BATERY = terminalInfo.Batery,
SATELLITELabelSource = terminalInfo.Satalite,
SPEEDLabelSource = "Hız:" + terminalInfo.Speed + " Km/h",
ALTITUDELabelSource = "Yükseklik:" + terminalInfo.Altitude + " m",
HDOPLabelSource = "Hassaslık:" + terminalInfo.Hdop,
GPS_KMLabelSource = "GPS Km:" + terminalInfo.Gps_Km + " Km",
VEHICLE_KMLabelSource = "Araç Km:" + terminalInfo.Vehicle_Km + " Km",
TEMPERATURELabelSource = "Sıcaklık:" + terminalInfo.Temprature + " C",
FUEL_TANKLabelSource = "Depo:" + terminalInfo.Fuel_Tank + " lt",
STREETLabelSource = "Adres: " + terminalInfo.Street,
QUARTERLabelSource = terminalInfo.Quarter + "- ",
COUNTYLabelSource = terminalInfo.County + "- ",
CITYLabelSource = terminalInfo.City,
ISONLINEImageSource = "/Pergo.Silver;component/Resources/Terminal/Status/StatusBlue.png",
SATELLITEImageSource = "/Pergo.Silver;component/Resources/Program/SatelliteSmall.png",
Direction = terminalInfo.Direction
});
//MapLayer.SetLocation(InformationLayer.Items[InformationLayer.Items.Count - 1], new Location { });
RadMapPoints[RadMapPoints.Count - 1].DirectionText = terminalInfo.Direction + 90;
if (RadMapPoints[RadMapPoints.Count - 1].DirectionText > 360)
RadMapPoints[RadMapPoints.Count - 1].DirectionText = RadMapPoints[RadMapPoints.Count - 1].DirectionText - 360;
if (RadMapPoints.Count == 1)
if (IsFirstDataCompleted != null)
{
IsFirstDataCompleted(this, new FirstDataCompleted { IsCompleted = true, ItemCount = RadMapPoints.Count });
}
}
private void Map_Loaded(object sender, RoutedEventArgs e)
{
}
void routeProvider_RoutingCompleted(object sender, RoutingCompletedEventArgs e)
{
ColorStringConverter converter = new ColorStringConverter();
RouteResponse routeResponse = e.Response as RouteResponse;
if (routeResponse != null)
{
if (routeResponse.Result == null) return;
if (routeResponse.Result.RoutePath != null)
{
RouteLine.Points = routeResponse.Result.RoutePath.Points;
SolidColorBrush brush = converter.ConvertBack("Black", typeof(SolidColorBrush), null, System.Globalization.CultureInfo.CurrentUICulture) as SolidColorBrush;
RouteLine.Stroke = brush;
RouteLine.StrokeThickness = 2;
RouteLayer2.Items.Add(RouteLine);
PergoMap.Center = RoutePoints[0];
}
else { }
}
}
public void FindRoute()
{
this.RouteLayer2.Items.Clear();
RouteRequest routeRequest = new RouteRequest()
{
Culture = new System.Globalization.CultureInfo("en-US")
};
routeRequest.Options.RoutePathType = RoutePathType.Points;
if (this.RoutePoints.Count > 1)
{
foreach (Location location in this.RoutePoints)
{
routeRequest.Waypoints.Add(location);
}
this.RouteProvider.CalculateRouteAsync(routeRequest);
}
}
//public void RouteClear()
//{
// this.routePoints.Clear();
// this.RouteLayer2.Items.Clear();
//}
private void PergoMap_InitializeCompleted(object sender, EventArgs e)
{ }
RadWindow rdWindow;
MapShortcut content;
public int? groupID = -1;
private void PergoMap_MapMouseClick(object sender, MapMouseRoutedEventArgs eventArgs)
{
if (IsNavigateMode)
this.RoutePoints.Add(eventArgs.Location);
else if (this.IsShourcutMode)
{
rdWindow = new RadWindow();
content = new MapShortcut(MapShortcut.OperationType.Adding);
content.SelectedLocation = eventArgs.Location;
content.ZoomLevel = Convert.ToDouble(this.PergoMap.ZoomLevel);
rdWindow.Content = content;
rdWindow.Header = "Harita Kısayol İşlemleri";
rdWindow.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
rdWindow.ShowDialog();
rdWindow.Closed += new EventHandler<WindowClosedEventArgs>(rdWindow_Closed);
content.btnCancel.Click += new RoutedEventHandler(btnCancel_Click);
content.btnSave.Click += new RoutedEventHandler(btnSave_Click);
}
}
Shortcut shControl = new Shortcut();
void btnSave_Click(object sender, RoutedEventArgs e)
{
if (content.txtShortcutName.Text.Trim() == string.Empty)
{
MessageBox.Show("Lütfen kısayolunuz için bir isim yazınız.", "Pergo Silver", MessageBoxButton.OK);
content.txtShortcutName.Focus();
return;
}
if (content.chbGroupShortcut.IsChecked == true)
{
if (content.cbxGroups.SelectedValue == null)
{
MessageBox.Show("Lütfen bir grup seçiniz.", "Pergo Silver", MessageBoxButton.OK);
return;
}
groupID = (int?)content.cbxGroups.SelectedValue;
}
PergoWCF.MapShortcut shortcut = new PergoWCF.MapShortcut();
shortcut.GroupID = groupID;
shortcut.ParentID = Shortcut.ParentID;
shortcut.ShortcutName = content.txtShortcutName.Text;
shortcut.Symbol = "1";
shortcut.SymbolFont = ((RadGalleryItem)content.shapesGallery.SelectedItem).Tag.ToString() + "#" + ((RadGalleryItem)content.shapesGallery.SelectedItem).Name;
shortcut.XLong = Convert.ToDecimal(content.SelectedLocation.Longitude);
shortcut.YLat = Convert.ToDecimal(content.SelectedLocation.Latitude);
shortcut.ZoomValue = Convert.ToDecimal(content.ZoomLevel);
SetUp.wcfclient.AddMapShortcutCompleted += new EventHandler<AddMapShortcutCompletedEventArgs>(wcfclient_AddMapShortcutCompleted);
SetUp.wcfclient.AddMapShortcutAsync(shortcut);
}
void wcfclient_AddMapShortcutCompleted(object sender, AddMapShortcutCompletedEventArgs e)
{
if (e.Result)
{
shControl.GetMapShortcuts();
rdWindow.Close();
}
else
MessageBox.Show("Kayıt esnasında bir sorun oluştu. Lütfen sistem yöneticinize danışın.", "Pergo Silver", MessageBoxButton.OK);
}
void btnCancel_Click(object sender, RoutedEventArgs e)
{
rdWindow.Close();
}
void rdWindow_Closed(object sender, WindowClosedEventArgs e)
{
this.IsShourcutMode = false;
}
}
}
public class FirstDataCompleted : EventArgs
{
public bool IsCompleted { get; set; }
public int ItemCount { get; set; }
}
public class RadMapPoint
{
public Location Location { get; set; }
public string TERMINAL { get; set; }
public string SHORT_NAME { get; set; }
public string LONG_NAME { get; set; }
public string ISONLINEImageSource { get; set; }
public int BATERY { get; set; }
public string SATELLITEImageSource { get; set; }
public string SATELLITELabelSource { get; set; }
public string SPEEDLabelSource { get; set; }
public string ALTITUDELabelSource { get; set; }
public string MapIconSource { get; set; }
public string HDOPLabelSource { get; set; }
public string GPS_KMLabelSource { get; set; }
public string VEHICLE_KMLabelSource { get; set; }
public string TEMPERATURELabelSource { get; set; }
public string FUEL_TANKLabelSource { get; set; }
public string STREETLabelSource { get; set; }
public string QUARTERLabelSource { get; set; }
public string COUNTYLabelSource { get; set; }
public string CITYLabelSource { get; set; }
public Visibility Wait { get; set; }
public Visibility WaitOther { get; set; }
public int Direction { get; set; }
public int DirectionText { get; set; }
public string ShortNameText { get; set; }
public RadMapPoint()
{
}
}
public class RadMapPointsCollection : ObservableCollection<RadMapPoint>
{
}