2016-05-20 156 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

相關問題