How can I add Here maps tile layer?

Topics: General Topics, WinForms Controls
May 20 at 2:59 PM
I'd like to add Here maps map tiles to my map by BruTile / SharpMap.

The URL scheme is the following by their documentation: https://1.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/13/4400/2686/256/png8 ?app_id={YOUR_APP_ID} &app_code={YOUR_APP_CODE}

where 13 is zoomlevel, 4400 is column, 2686 is row.

Here is my code, but it times out, and map is empty. App id and app code are correct, it is 100% sure. What can be the problem?

var networkRes = Networking.HasInternetConnection();
                    if (networkRes.Result == false)
                        throw new Exception(networkRes.InfoMessage);

                    var uriString = "https://1.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8";

                    var customParams = new Dictionary<string, string>();
                    customParams.Add("app_id", "someappid");
                    customParams.Add("app_code", "someappcode");

                    var req = new TmsRequest(new Uri(uriString),"png" , customParams);

                    var provider = new WebTileProvider(req);

                    var tileSource = new TileSource(provider, new SphericalMercatorInvertedWorldSchema());

                    TileLayer tileLayer;

                    if (CacheWebMaps)
                    {
                        var path = Path.Combine(MapCacheRoot, HEREBASELAYERNAME);
                        tileLayer = new TileLayer(tileSource, HEREBASELAYERNAME, new Color(), true, path);
                    }
                    else
                    {
                        tileLayer = new TileLayer(tileSource, HEREBASELAYERNAME);
                    }

                    tileLayer.SRID = 3857;

                    MapBox.Map.Layers.Add(tileLayer);
Coordinator
May 23 at 8:19 AM
You must not pass the image format to the constructor of the TmsRequest as you have it hard coded in your base url:
var req = new TmsRequest(new Uri(uriString), string.Empty , customParams);