0

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);

Thanks in advance!

Community
  • 1
  • 1
Tom
  • 3,899
  • 22
  • 78
  • 137
  • Did you base this in their documentation? If so, which? – pauldendulk May 20 '16 at 14:50
  • 1
    I used this doc: https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/example-normal-day-view.html And code by me, I have successfully implemented several tile sources (osm ones, MapQuest, custom ones etc) but I can not make Here maps work – Tom May 20 '16 at 14:55
  • [Here](https://1.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/13/4400/2686/256/png8?app_id=xWVIueSv6JL0aJ5xqTxb&app_code=djPZyynKsbTjIUDOBcHZ2g) is the url you posted at the top with the app id and app code of the web site of Here maps. Does it also show the tile in the browser with your app id and code? – pauldendulk May 20 '16 at 18:21
  • Yep, I can get tiles by browser – Tom May 20 '16 at 22:59

1 Answers1

1

You can create a Here Maps tiles source like this:

var hereMapsTileSource = new HttpTileSource(new GlobalSphericalMercator(0, 8), "https://{s}.base.maps.cit.api.here.com/maptile/2.1/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?app_id=xWVIueSv6JL0aJ5xqTxb&app_code=djPZyynKsbTjIUDOBcHZ2g", new[] {"1", "2", "3", "4"}, name: "Here Maps Source");

I added an example to Samples\BruTile.Demo (bottom radio button). Here is the code I added.

I am not sure if the BruTile version that SharpMap is using supports HttpTileSource. If not you could copy HttpTileSource to your own project.

pauldendulk
  • 1,378
  • 12
  • 23