MapEditor.SimplifyItems(IEnumerable<MapItem>, Double) Method
Reduces the number of vertices that form the vector layer’s items with specified tolerance.
Namespace: DevExpress.Xpf.Map
Assembly:
DevExpress.Xpf.Map.v24.2.dll
NuGet Package:
DevExpress.Wpf.Map
Declaration
public void SimplifyItems(
IEnumerable<MapItem> items,
double tolerance
)
Public Sub SimplifyItems(
items As IEnumerable(Of MapItem),
tolerance As Double
)
Parameters
Name |
Type |
Description |
items |
IEnumerable<MapItem> |
The items to be simplified.
|
tolerance |
Double |
A percent of vertices that vector shapes contain after simplification. This value should be in the (0;100) range.
|
Example
This example demonstrates how to reduce the number of vertices that form vector layer items.
To do this, use the MapEditor.SimplifyItems(IEnumerable<MapItem>, Double)
method.
The TrackBarEdit component is used to change the Tolerance parameter. The tolerance defines the percent of vertices that vector shapes should contain after simplification.
using System;
using System.Windows;
namespace SvgDataAdapterSample {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void OnTrackbarEditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) {
double tolerance = Convert.ToDouble(toleranceTrackbar.EditValue);
mapControl.MapEditor.SimplifyItems(adapter.DisplayItems, tolerance);
}
}
}
Imports System
Imports System.Windows
Namespace SvgDataAdapterSample
Public Class MainWindow
Inherits Window
Public Sub New()
MyBase.New
InitializeComponent
End Sub
Private Sub OnTrackbarEditValueChanged(ByVal sender As Object, ByVal e As DevExpress.Xpf.Editors.EditValueChangedEventArgs)
Dim tolerance As Double = Convert.ToDouble(toleranceTrackbar.EditValue)
mapControl.MapEditor.SimplifyItems(adapter.DisplayItems, tolerance)
End Sub
End Class
End Namespace
<Window
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"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
x:Class="SvgDataAdapterSample.MainWindow"
xmlns:local="clr-namespace:SvgDataAdapterSample"
Title="MainWindow" Height="360" Width="640">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<dxm:MapControl x:Name="mapControl" Grid.Column="0" Margin="10">
<dxm:VectorLayer x:Name="vectorLayer">
<dxm:SvgFileDataAdapter x:Name="adapter" FileUri="Data/countries.svg" />
</dxm:VectorLayer>
<dxm:MapControl.MapEditor>
<dxm:MapEditor x:Name="mapEditor">
<dxm:MapEditor.EditorPanelOptions>
<dxm:MapEditorPanelOptions Visible="False"/>
</dxm:MapEditor.EditorPanelOptions>
</dxm:MapEditor>
</dxm:MapControl.MapEditor>
</dxm:MapControl>
<dxe:TrackBarEdit x:Name="toleranceTrackbar" Grid.Column="1"
VerticalAlignment="Center" Margin="10"
Maximum="100" Minimum="0" EditValue="100"
EditValueChanged="OnTrackbarEditValueChanged"/>
</Grid>
</Window>
See Also