Hi Telerik team,
Thanks for the reply. It's working now.
One final question I have right now, Please respond.
Can we measure the openstreemap means you click on some points and it draws a poly line and during that time it shows the length of that polyline in meters / feet.
Please let me know if it possible or not?
If you have some sort of sample code please pass over it.
Thanks for your help.
Vivek,
Thanks for the reply. It's working now.
One final question I have right now, Please respond.
Can we measure the openstreemap means you click on some points and it draws a poly line and during that time it shows the length of that polyline in meters / feet.
Please let me know if it possible or not?
If you have some sort of sample code please pass over it.
Thanks for your help.
Vivek,
6 Answers, 1 is accepted
0
Accepted
Hello Vivek,
I have attached a sample solution which draws a polyline using the MapMouseClick event. The solution calculates the length of the polyline and shows the distance in the tooltip.
Greetings,
Andrey Murzov
the Telerik team
I have attached a sample solution which draws a polyline using the MapMouseClick event. The solution calculates the length of the polyline and shows the distance in the tooltip.
Greetings,
Andrey Murzov
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
0

Vivek
Top achievements
Rank 1
answered on 26 Jul 2011, 02:35 PM
Hi Andrey Murzov,
Thanks for the reply. Nice job Andrey.
One last question I have,Can we create a polyline, rectangle, and dot on map? means first click on polyline button and then on mouse drag draw the polyline and same for all .
Please pass some sample code to do the job.
Thanks in advance,
Vivek.
Thanks for the reply. Nice job Andrey.
One last question I have,Can we create a polyline, rectangle, and dot on map? means first click on polyline button and then on mouse drag draw the polyline and same for all .
Please pass some sample code to do the job.
Thanks in advance,
Vivek.
0
Accepted
Hi Vivek,
The example of polyline creation is included to the solution I've provided. You can use similar approach for adding other map shapes (MapRectangle, for example) to the information layer.
Regards,
Andrey Murzov
the Telerik team
The example of polyline creation is included to the solution I've provided. You can use similar approach for adding other map shapes (MapRectangle, for example) to the information layer.
Regards,
Andrey Murzov
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
0

Vivek
Top achievements
Rank 1
answered on 04 Aug 2011, 10:07 AM
Hi Support,
I tired to add sample exmaple project in my solutions, its giving me this error, Please guide how I can resolve this.
When I am clicking on the map to measure the point it showing me below error. Please note that I am using Search functionality, so we are binding the location, I think the error could be because of this.
Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
Also is it possible to have measured text in one label?
Please help me below is my code.
I tired to add sample exmaple project in my solutions, its giving me this error, Please guide how I can resolve this.
When I am clicking on the map to measure the point it showing me below error. Please note that I am using Search functionality, so we are binding the location, I think the error could be because of this.
Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
Also is it possible to have measured text in one label?
Please help me below is my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Reflection;
using System.Diagnostics;
using System.Windows.Threading;
using System.Globalization;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Threading;
using Telerik.Windows.Controls.Map;
using Telerik.Windows.Controls;
namespace OPTIClient
{
public partial class TfrmHome : Window
{
#if SILVERLIGHT
private string VEKey;
#endif
MapShape boundingArea;
private MapItemsCollection itemCollection = new MapItemsCollection();
private BingSearchProvider searchProvider;
private RadWindow window;
private Point topRightPoint;
private bool initialized;
private System.Windows.Threading.DispatcherTimer timer;
private double stepSize = 3;
private bool initialized_Measure;
private MapPolyline polyline;
private bool measureclick;
public TfrmHome()
{
InitializeComponent();
WindowMain.Title = "Ecomond TCS Opti" + " " + App_Version.Assemblyinfo();
CommandBinding helpBinding = new CommandBinding(ApplicationCommands.Help);
helpBinding.CanExecute += CanHelpExecute;
helpBinding.Executed += HelpExecuted;
CommandBindings.Add(helpBinding);
this.RadMap1.InitializeCompleted += new EventHandler(RadMap1_InitializeCompleted);
#if SILVERLIGHT
this.GetVEServiceKey();
#else
this.SetProvider();
#endif
this.informationLayer.DataMappings.Add(new DataMapping("Location", DataMember.Location));
Binding binding = new Binding();
binding.Source = this.itemCollection;
this.informationLayer.SetBinding(ItemsControl.ItemsSourceProperty, binding);
}
void RadMap1_InitializeCompleted(object sender, EventArgs e)
{
if (!this.initialized)
{
this.initialized = true;
// add pushpin
Pushpin pushpin = new Pushpin();
MapLayer.SetLocation(pushpin, new Location(60.1755556, 24.9341667));
Brush foreground = new SolidColorBrush(Colors.Yellow);
Brush background = new SolidColorBrush(Colors.Brown);
TextBlock text = new TextBlock()
{
Text = "Helsinki",
Background = background,
Foreground = foreground
};
pushpin.MouseDoubleClick += new MouseButtonEventHandler(pushpin_MouseDoubleClick);
InformationLayer layer = new InformationLayer();
layer.Items.Add(pushpin);
layer.Items.Add(text);
RadMap1.Items.Add(layer);
layer.MapControl = RadMap1;
}
}
private void pushpin_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var pushpin = sender as Pushpin;
if (pushpin != null)
{
e.Handled = true;
LocationRect bounds = this.informationLayer.GetGeoBounds(pushpin);
bounds.MapControl = this.RadMap1;
Location topRight = bounds.Northwest;
this.topRightPoint = topRight.GetPoint(this.RadMap1);
this.topRightPoint.X += this.Left;
this.topRightPoint.Y += this.Top;
if (this.window != null && this.window.IsOpen)
{
this.window.Close();
}
this.window = new RadWindow()
{
Content = "My first Pinpoint info"
};
window.ResizeMode = System.Windows.ResizeMode.NoResize;
this.window.SizeChanged += new System.Windows.SizeChangedEventHandler(window_SizeChanged);
this.window.ShowDialog();
}
}
private void window_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
{
var window = sender as RadWindow;
if (window != null && e.NewSize.Width > 0)
{
Canvas.SetLeft(window, this.topRightPoint.X - e.NewSize.Width);
Canvas.SetTop(window, this.topRightPoint.Y);
}
}
private void SetProvider()
{
#if SILVERLIGHT
BingMapProvider provider = new BingMapProvider(MapMode.Aerial, true, this.VEKey);
#else
OpenStreetMapProvider provider = new OpenStreetMapProvider();
provider.IsTileCachingEnabled = true;
#endif
this.RadMap1.Provider = provider;
RadMap1.Cursor = Cursors.Hand;
RadMap1.MouseDragMode = MouseDragBehavior.Drag;
searchProvider = new BingSearchProvider();
#if SILVERLIGHT
searchProvider.ApplicationId = this.VEKey;
#else
searchProvider.ApplicationId = MapHelper.VEKey;
#endif
searchProvider.MapControl = this.RadMap1;
searchProvider.SearchCompleted += new EventHandler<
SearchCompletedEventArgs
>(Provider_SearchCompleted);
}
#if SILVERLIGHT
private void GetVEServiceKey()
{
WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
Uri keyURI = new Uri(URIHelper.CurrentApplicationURL, "VEKey.txt");
wc.DownloadStringAsync(keyURI);
}
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
this.VEKey = e.Result;
this.SetProvider();
}
#endif
private void SearchHandler(object sender, RoutedEventArgs e)
{
this.itemCollection.Clear();
this.informationLayer2.Items.Clear();
string query = this.SearchCondition.Text;
if (!string.IsNullOrEmpty(query))
{
SearchRequest request = new SearchRequest();
request.Culture = new System.Globalization.CultureInfo("en-US");
request.Query = query;
this.searchProvider.SearchAsync(request);
}
}
private void Provider_SearchCompleted(object sender, SearchCompletedEventArgs args)
{
this.itemCollection.Clear();
SearchResponse response = args.Response;
if (response != null && response.ResultSets.Count > 0)
{
if (response.ResultSets[0].Results.Count > 0)
{
this.itemCollection.Clear();
foreach (SearchResultBase result in response.ResultSets[0].Results)
{
MyMapItem item = new MyMapItem()
{
Title = result.Name,
Location = result.LocationData.Locations[0]
};
this.itemCollection.Add(item);
}
}
if (response.ResultSets[0].SearchRegion != null)
{
// Set map viewport to the best view returned in the search result.
this.RadMap1.SetView(response.ResultSets[0].SearchRegion.GeocodeLocation.BestView);
// Show map shape around bounding area
if (response.ResultSets[0].SearchRegion.BoundingArea != null)
{
boundingArea = response.ResultSets[0].SearchRegion.BoundingArea;
boundingArea.Stroke = new SolidColorBrush(Colors.Red);
boundingArea.StrokeThickness = 1;
this.informationLayer2.Items.Add(boundingArea);
}
if (response.ResultSets[0].SearchRegion.GeocodeLocation.Address != null
&& response.ResultSets[0].SearchRegion.GeocodeLocation.Locations.Count > 0)
{
foreach (Location location in response.ResultSets[0].SearchRegion.GeocodeLocation.Locations)
{
MyMapItem item = new MyMapItem()
{
Title = response.ResultSets[0].SearchRegion.GeocodeLocation.Address.FormattedAddress,
Location = location
};
this.itemCollection.Add(item);
}
}
}
}
}
private void Rad_Pan_Click(object sender, RoutedEventArgs e)
{
RadMap1.MouseDragMode = MouseDragBehavior.Drag;
RadMap1.Cursor = Cursors.Hand;
RadMap1.MapMouseClick +=new MouseRoutedEventHandler(RadMap1_MapMouseClick);
}
private void Rad_BZoom_Click(object sender, RoutedEventArgs e)
{
RadMap1.MouseDragMode = MouseDragBehavior.Select;
RadMap1.Cursor = Cursors.Arrow;
}
}
}
0
Hello Vivek,
It is very complicated and it is hard for us to reproduce the problem without your solution, but using just the code snippets you sent. Could you, please, provide us with a small sample runnable solution which reproduces it?
Greetings,
Andrey Murzov
the Telerik team
It is very complicated and it is hard for us to reproduce the problem without your solution, but using just the code snippets you sent. Could you, please, provide us with a small sample runnable solution which reproduces it?
Greetings,
Andrey Murzov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0

Vivek
Top achievements
Rank 1
answered on 09 Aug 2011, 10:41 PM
Sure I will.
Thanks for the help.
Thanks for the help.