Skip to main content

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.v24.1.dll

NuGet Package: DevExpress.Wpf.Map

Declaration

public class SvgFileDataAdapter :
    CoordinateSystemDataAdapterBase,
    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.

Map Control with data from 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:

<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.

<dxm:MapControl>
 <dxm:VectorLayer>
     <dxm:SvgFileDataAdapter FileUri="Data/countries.svg" ShapesLoaded="SvgFileDataAdapter_ShapesLoaded" />
 </dxm:VectorLayer>
</dxm:MapControl> 
private void SvgFileDataAdapter_ShapesLoaded(object sender, DevExpress.Xpf.Map.ShapesLoadedEventArgs e) {
  foreach (MapPath item in e.Shapes) {
      item.Fill = Brushes.Gray;
  }
}

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

<dxm:MapControl x:Name="mapControl">
 <dxm:VectorLayer x:Name="vectorLayer" DataLoaded="VectorLayer_DataLoaded" >
     <dxm:SvgFileDataAdapter FileUri="Data/countries.svg" />
 </dxm:VectorLayer>
</dxm:MapControl> 
 private void VectorLayer_DataLoaded(object sender, DataLoadedEventArgs e) {
  mapControl.ZoomToFitLayerItems(new LayerBase[] { vectorLayer });
}

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.

See Also