MapPolylines

5 posts, 1 answers
  1. Simon
    Simon avatar
    34 posts
    Member since:
    Oct 2010

    Posted 09 Nov 2010 Link to this post

    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
  2. Answer
    Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 12 Nov 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Simon
    Simon avatar
    34 posts
    Member since:
    Oct 2010

    Posted 12 Nov 2010 Link to this post

    Thanks for the workaround.  It works well
  5. Roland
    Roland avatar
    1 posts
    Member since:
    Sep 2008

    Posted 14 Jan 2011 Link to this post

    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
  6. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 18 Jan 2011 Link to this post

    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>>
Back to Top
UI for WPF is Visual Studio 2017 Ready