TomTom Api for wpf application

how to Integrate tom tom map api in wpf application ?
can i get a sample exmple to refer.

We don’t provide WPF controls.
But you can try to build using SDK for Web with controls that can render HTML.

1 Like

Hi.

As @maloleps said, one of the solutions is to use web control. It’s a nice solution (visually the best solution) because it gives you all features which our Web SDK has. I’ve tested it on CEFSharp, which is based on Chromium and it works quite well. The downside of that solution is problematic communication between JS application and your WPF application (if needed). Screen:

The next solution which you can try to use is Bing Maps Control from Microsoft.Maps.MapControl.WPF namespace. To use it with TomTom maps you will have to create a CustomTileLayer and a CustomTileSource like in the following example:

internal class CustomTileSource: Microsoft.Maps.MapControl.WPF.TileSource
{
    public override Uri GetUri(int x, int y, int zoom)
    {
        return new Uri(UriFormat.
                       Replace("{x}", x.ToString()).
                       Replace("{y}", y.ToString()).
                       Replace("{z}", zoom.ToString()));
    }
}
internal class CustomTileLayer : Microsoft.Maps.MapControl.WPF.MapTileLayer
{
    public CustomTileLayer()
    {
        TileSource = new CustomTileSource();
    }
    public string UriFormat
    {
        get {return TileSource.UriFormat; }
        set { TileSource.UriFormat = value; }
    }
}

XAML:

<m:Map x:Name="tomtomMap" CredentialsProvider="KEY_NEEDED_FOR_BING_CONTROL">
    <m:Map.Mode>
        <m:MercatorMode/>
    </m:Map.Mode>
    <local:CustomTileLayer UriFormat="https://api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.png?key=YOUR_TOMTOM_API_KEY"/>
</m:Map>

It works quite well and fast but there is a need to provide a Bing API key even if you are not fetching bing tiles anymore and this WPF control is under a proprietary license which might not allow to use third party maps.

The third solution is to write a TomTom map provider and integrate GMaps.NET into your project.

I hope that helps a little bit at the start.

Regards,
Mateusz

1 Like