RadMap - Cannot bind to Geo_Bounds property of rad map control

2 posts, 0 answers
  1. Sai
    Sai avatar
    2 posts
    Member since:
    Sep 2013

    Posted 02 Jun 2014 Link to this post

    Hi

    I am unable to bind to the Geo_Bounds property of the rad map control.

    If that's not possible, would it be possible to calculate the NW and SE Bounds of the map based on the Center and Zoom level (binding works on these 2 properties !!) of the rad map control ?


    Thanks,
    Sai Dhalli
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 03 Jun 2014 Link to this post

    Hi Sai,

    I've tested binding to the RadMap.GeoBounds property and all things seems to work fine. Here are the XAML and code behind I've used for testing:

    <UserControl x:Class="TestMapFeatures.Views.Integration.BindingGeoBounds"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 mc:Ignorable="d"
                 d:DesignHeight="300" d:DesignWidth="300">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
     
            <telerik:RadMap x:Name="radMap"
                            ZoomLevel="5"
                            GeoBounds="{Binding GeoBounds}">
                <telerik:RadMap.Provider>
                    <telerik:OpenStreetMapProvider />
                </telerik:RadMap.Provider>
                <telerik:VisualizationLayer Name="visualizationLayer" />
            </telerik:RadMap>
     
            <Button Grid.Column="1"
                    VerticalAlignment="Top"
                    Click="SetGeoBounds">
                <TextBlock Margin="4,2,4,2"
                           Text="Set geo bounds" />
            </Button>
        </Grid>
    </UserControl>

    public class MapViewModel : ViewModelBase
    {
        private LocationRect geoBounds;
     
        public LocationRect GeoBounds
        {
            get
            {
                return this.geoBounds;
            }
     
            set
            {
                this.geoBounds = value;
                this.OnPropertyChanged("GeoBounds");
            }
        }
    }

    public partial class BindingGeoBounds : UserControl
    {
        private MapViewModel model = new MapViewModel();
     
        public BindingGeoBounds()
        {
            InitializeComponent();
     
            this.DataContext = model;
        }
     
        private void SetGeoBounds(object sender, RoutedEventArgs e)
        {
            Location nw = new Location(30, 30);
            Location se = new Location(20, 50);
            this.model.GeoBounds = new LocationRect(nw, se);
     
            // Show rectangle for the geo bounds.
            // It is not necessary in the real-life applications
            // but demonstrates that binding works and geo bounds
            // are set.
            RectangleData rect = new RectangleData()
            {
                Location = new Telerik.Windows.Controls.Map.Location(30, 30),
                Height = 10,
                Width = 20,
                ShapeFill = new MapShapeFill()
                {
                    Stroke = new SolidColorBrush(Colors.Red),
                    StrokeThickness = 2
                }
            };
     
            this.visualizationLayer.Items.Clear();
            this.visualizationLayer.Items.Add(rect);
        }
    }

    Could you, please, provide us with your solution or with a small sample project which reproduces the problem you have? This will help us better understand your particular case.

    Thank you for your cooperation.

    Regards,
    Andrey Murzov
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top