MapItemsLayerBase.InitialMapSize Property
Gets or sets the size of a map shape tile to provide a map projection.
Namespace: DevExpress.UI.Xaml.Map
Assembly: DevExpress.UI.Xaml.Map.v21.2.dll
NuGet Package: DevExpress.Uwp.Controls
Declaration
Property Value
Type | Description |
---|---|
Size | A Size value containing the size of the map tiles that correspond to the zero zoom level. |
Remarks
Use the InitialMapSize property to get a map projection (e.g., Lambert, Behrmann, Tristan Edwards equal map projections) and avoid distortions of a vector layer’s elements on a plane.
Example
To customize equal-area projection, do the following.
- Set an EqualAreaProjection object to the MapItemsLayerBase.MapProjection property of a vector data layer.
- Specify its Width/Height ratio. To do this, assign this ratio based size to the
MapItemsLayerBase.InitialMapSize
property of the vector data layer.
<Page xmlns:Map="using:DevExpress.UI.Xaml.Map"
x:Class="MapControl_CustomProjections.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MapControl_CustomProjections"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Loaded="Page_Loaded">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Map:MapControl x:Name="mapControl">
<Map:VectorFileLayer>
<Map:ShapefileReader>
<Map:MapPackageFileSource FileName="Assets\Countries.shp"/>
</Map:ShapefileReader>
</Map:VectorFileLayer>
</Map:MapControl>
<ListView Name="listView"
HorizontalAlignment="Right" VerticalAlignment="Top"
Header="Projection Ratio:"
ItemsSource="{Binding ProjectionRatios}"
FontSize="26.667" Margin="20" BorderThickness="2" BorderBrush="White"
MinWidth="250"
SelectionChanged="ListView_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" TextAlignment="Left" Margin="8" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>
using DevExpress.UI.Xaml.Map;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
namespace MapControl_CustomProjections {
public sealed partial class MainPage : Page {
ProjectionRatio[] projectionRatios = {
new ProjectionRatio("Lambert", 3.14),
new ProjectionRatio("Behrmann", 2.36),
new ProjectionRatio("Trystan Edwards", 2),
new ProjectionRatio("Gall-Peters", 1.57),
new ProjectionRatio("Balthasart", 1.3),
new ProjectionRatio("Default", 1)
};
int sizeValue = 512;
public ProjectionRatio[] ProjectionRatios{ get { return projectionRatios; } }
public MainPage() {
this.InitializeComponent();
this.DataContext = this;
}
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) {
ListView listView = sender as ListView;
if (listView == null) return;
((VectorFileLayer)mapControl.Layers[0]).InitialMapSize = new Size(
((ProjectionRatio)listView.SelectedItem).Value * sizeValue, sizeValue
);
}
private void Page_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) {
listView.SelectedIndex = ProjectionRatios.Length - 1;
}
}
public class ProjectionRatio {
public ProjectionRatio(string name, double value) {
Name = name;
Value = value;
}
public string Name { get; set; }
public double Value { get; set; }
}
}
See Also