Back to Devexpress

SvgFileDataAdapter Class

wpf-devexpress-dot-xpf-dot-map-750e4e33.md

latest5.6 KB
Original Source

SvgFileDataAdapter Class

A data adapter that loads data from SVG files, and displays it on vector layers.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
public class SvgFileDataAdapter :
    CoordinateSystemDataAdapterBase,
    ISvgPointConverterFactory
vb
Public Class SvgFileDataAdapter
    Inherits CoordinateSystemDataAdapterBase
    Implements ISvgPointConverterFactory

Remarks

SVG is a two-dimensional vector graphic format that uses an XML-based text format to describe images.

The image below shows a vector map loaded from an SVG file.

The following table lists supported SVG elements and related map items:

|

SVG element

|

Map item

| | --- | --- | |

<circle>

|

MapEllipse

| |

<ellipse>

|

MapEllipse

| |

<line>

|

MapLine

| |

<path>
(M,m,L,l,H,h,V,v,Z,z commands are supported)

|

MapPath

| |

<polyline>

|

MapPolyline

| |

<polygon>

|

MapPolygon

| |

<rect>

|

MapRectangle

|

Note

The Map Control does not support the style element and style tag in the SVG markup.

Load Data

Follow the steps below to load data from an SVG file:

xaml
<dxm:MapControl>
    <dxm:VectorLayer>
        <dxm:SvgFileDataAdapter FileUri="Data/countries.svg" />
    </dxm:VectorLayer>
</dxm:MapControl>

Access and Customize Map Items

When vector items are loaded, the MapGeoDataAdapter.ShapesLoaded event occurs. Use the e.Shapes property to access loaded shapes.

xaml
<dxm:MapControl>
 <dxm:VectorLayer>
     <dxm:SvgFileDataAdapter FileUri="Data/countries.svg" ShapesLoaded="SvgFileDataAdapter_ShapesLoaded" />
 </dxm:VectorLayer>
</dxm:MapControl>
csharp
private void SvgFileDataAdapter_ShapesLoaded(object sender, DevExpress.Xpf.Map.ShapesLoadedEventArgs e) {
  foreach (MapPath item in e.Shapes) {
      item.Fill = Brushes.Gray;
  }
}
vb
Private Sub SvgFileDataAdapter_ShapesLoaded(ByVal sender As Object, ByVal e As DevExpress.Xpf.Map.ShapesLoadedEventArgs)
    For Each item As MapPath In e.Shapes
        item.Fill = Brushes.Gray
    Next
End Sub

Use the MapControl.ZoomToFitLayerItems method to zoom a map to fit layer items.

xaml
<dxm:MapControl x:Name="mapControl">
 <dxm:VectorLayer x:Name="vectorLayer" DataLoaded="VectorLayer_DataLoaded" >
     <dxm:SvgFileDataAdapter FileUri="Data/countries.svg" />
 </dxm:VectorLayer>
</dxm:MapControl>
csharp
private void VectorLayer_DataLoaded(object sender, DataLoadedEventArgs e) {
  mapControl.ZoomToFitLayerItems(new LayerBase[] { vectorLayer });
}
vb
Private Sub VectorLayer_DataLoaded(ByVal sender As Object, ByVal e As DataLoadedEventArgs)
    mapControl.ZoomToFitLayerItems(New LayerBase() {vectorLayer})
End Sub

You can change shape colors based on shape data. Refer to the following help topic for more information: Colorizers.

You can also group items of the same type. To do this, initialize the MapDataAdapterBase.Clusterer property with a clusterer.

Inheritance

Object DispatcherObject DependencyObject Freezable MapDependencyObject MapDataAdapterBase CoordinateSystemDataAdapterBase SvgFileDataAdapter

See Also

SvgFileDataAdapter Members

Load Vector Items from Vector Format Source

DevExpress.Xpf.Map Namespace