Map for WinForms | ComponentOne
In This Topic
    Virtualization
    In This Topic

    Sometimes, large number of items need to be visualized on a map surface. Virtualization can increase the overall performance of the map control, such as the loading, zooming and panning performance. The Map control provides the VirtualLayer to display elements over the map with virtualization and asynchronous data loading. It can be used to display an unlimited number of elements, as long as not many of them are visible at the same time. The VirtualLayer requires a division of the map space in regions, and the items' source must implement the IMapVirtualSource interface.

    The division of map space is defined using the VirtualLayer.Slices property, which specifies how the layer is partitioned for virtualization. Each map slice defines a minimum zoom level for its division, and the maximum zoom level for a slice is the minimum zoom layer of the next slice (or, if it is the last slice, its maximum zoom level is the maximum zoom of the map). In turn, each slice is divided into a grid of latitude/longitude divisions.

    Map showing virtualization

    For adding a virtual layer on a map, you need to create your own class that implements IMapVirtualSource interface. We have created a class named VirtualSource which consists of the geometries of placemarks and markers required to add a virtual layer on a map. On creating your class, you would be required to add C1.Win dll to it. The following code is used to add the virtual layer on a map:

    C#
    Copy Code
    c1Map1.TileLayer.TileSource = new VirtualEarthAerialSource();
    var vlayer = new C1.Win.Map.VirtualLayer();
    c1Map1.Layers.Add(vlayer);
    vlayer.LabelVisibility = LabelVisibility.Visible;
    // the Slices collection defines the regions that the virtual layer will get items for when needed.
    vlayer.Slices.Add(new MapSlice(0, 1, 1));
    vlayer.Slices.Add(new MapSlice(1, 4, 4));
    // needs provide a virtual source which implements C1.Win.Map.IMapVirtualSource interface.
    vlayer.ItemsSource = new VirtualSource();
    // the default style
    vlayer.Style.Stroke.Width = 1;
    vlayer.Style.Stroke.Color = Color.Blue;
    vlayer.Style.BackColor = Color.Aqua;
    

    As you zoom in the output, you will be able to see the marker split into multiple placemarks indicating virtualization.

     Map with virtual layer