How do I provide a custom data as a DataProvider for ImageTilesLayer on a mapControl in XAML file?

659 views Asked by At

How do I provide a custom data as a DataProvider for ImageTilesLayer on a mapControl in XAML file?

I am new to WPF and DevExpress. I was trying a few examples given in the DevExpress documentation site.

Link: How to Load Image Tiles from Another Source

In the example, How to Load Image Tiles from Another Source given in their site, the DataProvider for a ImageTilesLayer is assigned in the code behind file. Is it possible to mention the same DataProvider in the XAML instead of the code behind file?

2

There are 2 answers

0
DmitryG On BEST ANSWER

You can assign the ImageTilesLayer.DataProvider property in XAML as follows:

<dxc:MapControl>
    <dxc:ImageTilesLayer>
        <dxc:ImageTilesLayer.DataProvider>
            <local:CustomMapDataProvider/>
        </dxc:ImageTilesLayer.DataProvider>
    </dxc:ImageTilesLayer>
</dxc:MapControl>

P.S.
For more information about XAML properties syntax, see XAML Overview (WPF)-> Property Element Syntax MSDN article.
For more information about custom types in XAML, see XAML and Custom Classes for WPF.

0
Tejus On

Coding Horror, I would suggest you first read the tutorials given by DevExpress. Link to the tutorials is below.

https://documentation.devexpress.com/#WPF/CustomDocument10682

It explains the different layers on map control.

Once you have read that, read on how to load images from different source https://documentation.devexpress.com/#wpf/CustomDocument11174

In the code, instead of giving a url, change it to a local image folder where you have cached all the map tiles.

 public class CustomTileSource : MapTileSourceBase {
    const string roadUrlTemplate = 
        @"http://{subdomain}.tile.openstreetmap.org/{tileLevel}/{tileX}/{tileY}.png";

You can know more about caching at https://documentation.devexpress.com/#WPF/CustomDocument12205