【问题标题】:Here Map Tile API: Retrieve Map tile address from EPSG:3857 coordinateHere Map Tile API: Retrieve Map tile address from EPSG:3857坐标
【发布时间】:2015-04-21 13:55:50
【问题描述】:

我必须将现有 openlayers 2 应用程序的地图图块提供程序从 OpenStreetMaps 更改为 Here 地图。为此,我尝试实现与UsingCustomTiles 中描述的类似方法。

现在我不知道如何将我的 EPSG:3857 坐标(边界)映射到正确的 z/x/y 平铺地址。 Map Tile API Developer's Guide 中有一个计算示例来获取 EPSG:4326 坐标的正确图块地址,我认为不需要重新投影我的坐标,因为地图和坐标是墨卡托投影的。

我也不确定在 openlayers 地图中为 maxExtent 和 maxResolution 设置什么值,也许这就是我的 UsingCustomTiles 示例失败的原因。

有人可以提供提示吗?

【问题讨论】:

  • 如果不能使用 XYZ 层:var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); var y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)) 需要 maxResolution: 156543.0339 设置为地图选项

标签: javascript geolocation openlayers here-api


【解决方案1】:

使用 OpenLayers.Layer.XYZ() 方法怎么样?像下面这样的东西应该可以工作:

var map = new OpenLayers.Map({
        div: "map",
        projection: "EPSG:900913",
        displayProjection: "EPSG:4326",
        numZoomLevels: 21
    });

var normalDay = new OpenLayers.Layer.XYZ(
    "normal.day",
    [
        "http://1.maps.nlp.nokia.com/maptile/2.1/maptile/newest/normal.day/${z}/${x}/${y}/256/png8?app_id=" + app_id + "&app_code=" + app_code,
        "http://2.maps.nlp.nokia.com/maptile/2.1/maptile/newest/normal.day/${z}/${x}/${y}/256/png8?app_id=" + app_id + "&app_code=" + app_code,
        "http://3.maps.nlp.nokia.com/maptile/2.1/maptile/newest/normal.day/${z}/${x}/${y}/256/png8?app_id=" + app_id + "&app_code=" + app_code,
        "http://4.maps.nlp.nokia.com/maptile/2.1/maptile/newest/normal.day/${z}/${x}/${y}/256/png8?app_id=" + app_id + "&app_code=" + app_code
    ], {
        attribution: "Tiles &copy; <a href='http://here.com/'>Nokia</a>",
        sphericalMercator: true,
        wrapDateLine: true,
        transitionEffect: "resize",
        buffer: 1,
        numZoomLevels: 21
    }
);
 map.addLayers([
        normalDay
    ]);

【讨论】:

  • 工作完美,在我发现用于从后端传递脚本的框架 Tapestry 将占位符“${}”替换为空字符串后,我不得不转义它们。谢谢!
猜你喜欢
  • 1970-01-01
  • 2015-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-28
  • 2021-12-23
  • 2020-11-28
  • 1970-01-01
相关资源
最近更新 更多