【问题标题】:How can I add here map as tile layer by BruTile / SharpMap?如何通过 BruTile / SharpMap 在此处添加地图作为切片图层?
【发布时间】:2016-05-20 13:56:36
【问题描述】:

我想通过 BruTile / SharpMap 将 Here 地图图块添加到我的地图中。

他们的文档中的 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);

提前致谢!

【问题讨论】:

  • 您是否在他们的文档中将此作为基础?如果有,是哪个?
  • 我使用了这个文档:developer.here.com/rest-apis/documentation/enterprise-map-tile/… 和我自己编写的代码,我已经成功实现了几个瓦片源(osm 的、MapQuest、自定义的等),但我无法让 Here 地图工作
  • Here 是您在顶部发布的url,其中包含Here maps 网站的app id 和app code。它是否还会在浏览器中显示带有您的应用 ID 和代码的磁贴?
  • 是的,我可以通过浏览器获取图块

标签: c# gis sharpmap


【解决方案1】:

您可以像这样创建 Here Maps 瓦片源:

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 复制到您自己的项目中。

【讨论】:

  • 感谢保罗,您的好意!我会在星期一检查它!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-27
  • 1970-01-01
  • 1970-01-01
  • 2010-12-08
  • 1970-01-01
相关资源
最近更新 更多