I am trying to create a popup dialog which allows users to select coordinates within Australia, however I am having trouble finding specific documentation for the WPF control, even though it is quite similar to the Silverlight control.
Basically what I want to do is center the map on Australia and then zoom to a level of 3.8 and after doing so prevent the user from scrolling the map outside of a range of Australian coordinates, zooming out further then 3.8 or re-centering the map on another location outside of the australian range.
Here is my code so far:
<Window x:Class="GetP51.Views.Dialogs.SelectCoordinatesDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
Title="GetP51 - Select Coordinates" MinHeight="525" Height="525" MaxHeight="525" MinWidth="500" Width="500" MaxWidth="500" Icon="../../GetP51.ico" WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox x:Name="AddressSearch" Grid.Row="0"></TextBox>
<m:Map x:Name="AustralianMap" Grid.Row="1" CredentialsProvider="key" Mode="Aerial"></m:Map>
</Grid>
</Window>
And the code behind:
public partial class SelectCoordinatesDialog : Window
{
public SelectCoordinatesDialog()
{
InitializeComponent();
AustralianMap.Center = new Location(-25.274398, 133.775136);
AustralianMap.ZoomLevel = 3.8;
}
}
Can someone please tell me how to accomplish what I am looking to do?
Thanks,
Alex.
You could simply disable the map control and overlay it with a transparent control (e.g. a Canvas) that gets mouse input (e.g. MouseLeftButtonUp):
In the input event handler you could get a Location like this:
And here is the Bing Maps WPF Control API Reference.