All docs
V20.1
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

ImageTileSource.GetImageSource(Int64, Int64, Int32, Size) Method

Returns an image by the specified indices at a given map control zoom level.

Namespace: DevExpress.Xpf.Map

Assembly: DevExpress.Xpf.Map.v20.1.dll

Declaration

public abstract ImageSource GetImageSource(
    long x,
    long y,
    int level,
    Size size
)
Public MustOverride Function GetImageSource(
    x As Long,
    y As Long,
    level As Integer,
    size As Size
) As ImageSource

Parameters

Name Type Description
x Int64

The tile x-index.

y Int64

The tile y-index.

level Int32

The map control's zoom level.

size Size

The tile size.

Returns

Type Description
ImageSource

A ImageSource descendant object that represents a map tile.

Examples

This example shows how to use an ImageTileDataProvider instance to generate map tiles.

Markup

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:DXMapInMemoryTileProvider"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" 
        x:Class="DXMapInMemoryTileProvider.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <dxm:MapControl>
            <dxm:ImageLayer x:Name="imageLayer"/>
        </dxm:MapControl>
    </Grid>
</Window>

Code-Behind

using DevExpress.Xpf.Map;
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace DXMapInMemoryTileProvider {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            ImageTileDataProvider tileDataProvider = new ImageTileDataProvider();
            tileDataProvider.TileSource = new SimpleTileGenerator();
            this.imageLayer.DataProvider = tileDataProvider;
        }
    }
    public class SimpleTileGenerator : ImageTileSource {
        Random rnd = new Random();
        public override string Name => nameof(SimpleTileGenerator);
        public override ImageSource GetImageSource(long x, long y, int level, Size size) {
            DrawingVisual drawingVisual = new DrawingVisual();
            using (DrawingContext drawingContext = drawingVisual.RenderOpen()) {
                FormattedText text = new FormattedText($"{x}:{y}:{level}", new CultureInfo("en-us"),
                                     FlowDirection.LeftToRight, new Typeface("Arial"), 14, Brushes.Black);
                drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(128, (byte)rnd.Next(255),
                                                                        (byte)rnd.Next(255), (byte)rnd.Next(255))), null, 
                                                                        new Rect(new Point(), size));
                drawingContext.DrawText(text, new Point(5, 5));
                drawingContext.Close();
            }
            RenderTargetBitmap bmp = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Pbgra32);
            bmp.Render(drawingVisual);
            return bmp;
        }
        protected override MapDependencyObject CreateObject() {
            return new SimpleTileGenerator();
        }
    }
}

Implements

DevExpress.Xpf.Map.Native.IImageTileSource.GetImageSource(Int64, Int64, Int32, Size)
See Also