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

MapPolylines

4 Answers 299 Views
Map
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 09 Nov 2010, 06:56 PM
I have a map, and have a SelectionLayer defined.  I wish to build up a MapPolyline as the user clicks on the map

<telerik:RadMap Name="radMap" 
                                MapMouseClick="radMap_MapMouseClick" 
                                ZoomChanged="radMap_ZoomChanged" 
                                MouseMove="radMap_MouseMove" 
                                MouseDown="radMap_MouseDown"
                                MouseUp="radMap_MouseUp">
    <telerik:InformationLayer x:Name="SelectionLayer" Initialized="SelectionLayer_Initialized"/>
</telerik:RadMap>

I do the following

 

private void AddSelectShape(Location location)

 

{

 

    MapPolyline polyline = (MapPolyline)SelectionLayer.Items[0];

 

    polyline.Points.Add(location);

    polyline.ToolTip = polyline.Points.Count;

    SelectionLayer.ArrangeItem(polyline);

}

private void SelectionLayer_Initialized(object sender, EventArgs e)
{
    MapPolyline polyline = new MapPolyline();
    polyline.Points = new LocationCollection();
    SelectionLayer.Items.Add(polyline);
}

I have to call ArrangeItem otherwise I need to zoom the map a little to start the polyline being displayed.

The problem is that when I have 3 points, it does not draw the correct triangle, and only sorts itself out once I add a 4th point.  Is there something else that I need to do?

Thanks
Simon

4 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 12 Nov 2010, 02:33 PM
Hi Simon,

Thank you for the information.
We were able to reproduce the problem. It will be fixed in the nearest internal build. As a quick workaround I would recommend you to remove polyline from information layer and then add it again. For example:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
  
        MapPolyline polyline = new MapPolyline()
        {
            Points = new LocationCollection(),
            Fill = new SolidColorBrush(Color.FromArgb(90, 0, 0, 255)),
            Stroke = new SolidColorBrush(Colors.Blue),
            StrokeThickness = 2
        };
  
        this.informationLayer.Items.Add(polyline);
    }
  
    private void MapMouseClick(object sender, Telerik.Windows.Controls.Map.MapMouseRoutedEventArgs eventArgs)
    {
        MapPolyline polyline = (MapPolyline)this.informationLayer.Items[0];
        polyline.Points.Add(eventArgs.Location);
        polyline.ToolTip = polyline.Points.Count;
        this.informationLayer.Items.Remove(polyline);
        this.informationLayer.Items.Add(polyline);
    }
}


Kind regards,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simon
Top achievements
Rank 1
answered on 12 Nov 2010, 03:03 PM
Thanks for the workaround.  It works well
0
Roland
Top achievements
Rank 1
answered on 14 Jan 2011, 03:52 PM
Hello,

i have a radmap and an information layer and want to built up a mappolyline. The coordinates I fill the locationcollection with are in mercator format. I can't find a property to set the format for the map or a function to transform the coordinates. May you help me?

Some code:

 

 

this.radMap1.Provider = new OpenStreetMapProvider(MapMode.Aerial, true);

 

LocationCollection points = new LocationCollection();
points.Add(
new Location(6209354, 1005828));
points.Add(
new Location(6215914, 1007842));

 

 

MapPolyline route = new MapPolyline();
route.Points = points;
route.Stroke =
new SolidColorBrush(Colors.Red);
route.StrokeThickness = 3;
this.InformationLayer.Items.Add(route);

 

Thank you,
Max
0
Andrey
Telerik team
answered on 18 Jan 2011, 06:09 PM
Hello Simon,

It looks like you are using Spherical Mercator projection with coordinates in meters (also known as EPSG:900913 or EPSG:3857). Unfortunately RadMap currently supports Spherical Mercator projection with coordinates given as Latitude/Longitude (EPSG:4326 or WGS84).

We are planning to add converter between EPSG:900913 and EPSG:4326 for one of the future releases of our control, but currently you have to use EPSG:4326 or create converter by yourself. You can check availability of this feature using our public issue tracking system:

http://www.telerik.com/support/pits.aspx#/public/silverlight/4629

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>>
Tags
Map
Asked by
Simon
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Simon
Top achievements
Rank 1
Roland
Top achievements
Rank 1
Share this question
or