mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
- added MapBase.ZoomToBounds method - fixed coercing property values in MapBase - improved Location property handling in MapPanel to keep viewport positions near map center - use common view model in sample applications
59 lines
2 KiB
C#
59 lines
2 KiB
C#
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using MapControl;
|
|
|
|
namespace SilverlightApplication
|
|
{
|
|
public partial class MainPage : UserControl
|
|
{
|
|
public MainPage()
|
|
{
|
|
InitializeComponent();
|
|
tileLayerComboBox.SelectedIndex = 0;
|
|
}
|
|
|
|
private void MapMouseLeave(object sender, MouseEventArgs e)
|
|
{
|
|
mouseLocation.Text = string.Empty;
|
|
}
|
|
|
|
private void MapMouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
var location = map.ViewportPointToLocation(e.GetPosition(map));
|
|
var longitude = Location.NormalizeLongitude(location.Longitude);
|
|
var latString = location.Latitude < 0 ?
|
|
string.Format(CultureInfo.InvariantCulture, "S {0:00.00000}", -location.Latitude) :
|
|
string.Format(CultureInfo.InvariantCulture, "N {0:00.00000}", location.Latitude);
|
|
var lonString = longitude < 0 ?
|
|
string.Format(CultureInfo.InvariantCulture, "W {0:000.00000}", -longitude) :
|
|
string.Format(CultureInfo.InvariantCulture, "E {0:000.00000}", longitude);
|
|
mouseLocation.Text = latString + "\n" + lonString;
|
|
}
|
|
|
|
private void TileLayerSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
var comboBox = (ComboBox)sender;
|
|
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
|
map.TileLayer = tileLayers[(string)comboBox.SelectedItem];
|
|
}
|
|
|
|
private void SeamarksClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var checkBox = (CheckBox)sender;
|
|
var tileLayers = (TileLayerCollection)Resources["TileLayers"];
|
|
var tileLayer = tileLayers["Seamarks"];
|
|
|
|
if ((bool)checkBox.IsChecked)
|
|
{
|
|
map.TileLayers.Add(tileLayer);
|
|
}
|
|
else
|
|
{
|
|
map.TileLayers.Remove(tileLayer);
|
|
}
|
|
}
|
|
}
|
|
}
|