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

Map - Prevent Panning Map off the screen

1 Answer 94 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 24 Mar 2011, 10:52 PM
When running the demo of the wpf controls and running the map example "First Look". Its possible to pan the map right off the screen.
I have the same issue in my application and I need to stop this from happening.

I see this was a previous issue under Issue ID 3713 - Map: Ability to limit panning and zoom ranges.
This issue has the status of resolved but I don't see what the solution is.

I figured out how to limit zoom ok by using MinZoomLevel and MaxZoomLevel but I see nothing for limiting panning.

I still need a solution for panning?

Please help.

Thanks

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 29 Mar 2011, 09:28 AM
Hello Jim,

You can use the GeoBounds property of RadMap for limiting panning. The sample following code restricts panning to whole world map:
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();

        
var provider = new BingMapProvider(MapMode.Aerial, true, "My BingMap Key");
        this.radMap.InitializeCompleted += new EventHandler(radMap_InitializeCompleted);
        this.radMap.Provider = provider;
    }

    
private void radMap_InitializeCompleted(object sender, EventArgs e)
    {
        this.radMap.GeoBounds = new LocationRect(new Location(this.radMap.SpatialReference.MinLatitude, this.radMap.SpatialReference.MinLongitude),
            new Location(this.radMap.SpatialReference.MaxLatitude, this.radMap.SpatialReference.MaxLongitude));
    }
}

All the best,
Andrey Murzov
the Telerik team
Tags
Map
Asked by
Jim
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or