2016-05-20 107 views
0

我想添加这里通过BruTile/SharpMap将地图贴图映射到我的地图。如何在BruTile/SharpMap中将地图添加到拼贴图层?

的URL方案是以下通过他们的文档:

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}

其中13是缩放级别,4400是列,2686是行。

这是我的代码,但超时了,地图是空的。应用程序ID和应用程序代码是正确的,它是100%确定的。可能是什么问题?

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

在此先感谢!

+0

您是否将其基于文档?如果是这样,哪个? – pauldendulk

+1

我使用了这个文档:https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/example-normal-day-view.html和我的代码,我已经成功地实现了几个瓷砖来源(osm的,MapQuest的,自定义的等),但我不能让这里地图工作 – Tom

+0

[这里](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)是您在顶部发布的具有Here地图网站的应用ID和应用代码的网址。它是否也会在浏览器中显示您的应用程序ID和代码? – pauldendulk

回答

1

您可以创建一个在此地图的图块来源是这样的:

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

我添加了一个例子来的Samples \ BruTile.Demo(底部按钮)。 Here是我添加的代码。

我不确定SharpMap使用的BruTile版本是否支持HttpTileSource。如果没有,您可以将HttpTileSource复制到您自己的项目中。

+0

谢谢Paul,非常友善!我会在星期一检查它! – Tom

相关问题