VectorLayerBase.InitialMapSize Property
OBSOLETE
The Vector
Gets or sets the size of a map shape tile to provide a map projection.
Namespace: DevExpress.Xpf.Map
Assembly: DevExpress.Xpf.Map.v24.2.dll
NuGet Package: DevExpress.Wpf.Map
#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
This example illustrates how to get equal-area map projections (Lambert, Behrmann, Tristan Edwards, Peters, Gall orthographic and Balthasart) for the shapes loaded from the Shapefiles (Countries.shp, Countries.dbf).
To accomplish this task, create an EqualAreaProjection object and assign it to the ((GeoMapCoordinateSystem)MapControl.CoordinateSystem).Projection property. Then, specify the Width/height aspect ratio for each equal area projection using the MapControl.InitialMapSize property.
To learn more about the equal-area projections, see Cylindrical_equal-area_projection.
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace AvoidMapDistortion {
public partial class MainWindow : Window {
public struct WidthHeightRatio {
public string Name { get; set; }
public double Value { get; set; }
}
int defaultSideSize = 512;
List<WidthHeightRatio> ratios = new List<WidthHeightRatio>() {
new WidthHeightRatio() { Name = "(Default)", Value = 1 },
new WidthHeightRatio() { Name = "Lambert", Value = 3.14 },
new WidthHeightRatio() { Name = "Behrmann", Value = 2.36 },
new WidthHeightRatio() { Name = "Trystan Edwards", Value = 2.0 },
new WidthHeightRatio() { Name = "Gall-Peters", Value = 1.57 },
new WidthHeightRatio() { Name = "Balthasart", Value = 1.3 }
};
public List<WidthHeightRatio> Ratios { get { return ratios; } }
public MainWindow() {
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
this.DataContext = Ratios;
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
mapControl.InitialMapSize = new Size() {
Width = defaultSideSize,
Height = (int)(defaultSideSize / ((WidthHeightRatio)lbRatio.SelectedValue).Value)
};
}
}
}
<Window x:Class="AvoidMapDistortion.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"
Title="MainWindow" Height="557" Width="707" Loaded="Window_Loaded">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<dxm:MapControl Name="mapControl" Margin="4,4,2,4"
Grid.Row="0" Grid.Column="0">
<dxm:VectorLayer>
<dxm:ShapefileDataAdapter
FileUri="Shapefiles/Countries.shp"/>
</dxm:VectorLayer>
</dxm:MapControl>
<StackPanel Orientation="Vertical" Margin="2,4,4,4"
Grid.Row="0" Grid.Column="1">
<Label Content="Width/Height Ratio:"/>
<ListBox Name="lbRatio" ItemsSource="{Binding}"
DisplayMemberPath="Name" SelectedIndex="0"
SelectionChanged="ListBox_SelectionChanged"/>
</StackPanel>
</Grid>
</Window>