【问题标题】:Loading Open Cycle Map on OSMdroid在 OSMdroid 上加载 Open Cycle Map
【发布时间】:2018-09-29 07:05:56
【问题描述】:

抱歉,我是 Android 开发新手。 想知道是否有任何方法可以使用 OSMdroid 加载 Open Cycle Map 吗? 从网站上看,似乎没有简单的方法可以做到这一点: https://github.com/osmdroid/osmdroid/wiki/Map-Sources

因此,有人可以给我一些建议吗?

我认为唯一的方法是手动定义 Tile Source,如下所示。 请问有没有更简单的方法?

final String[] tileURLs = {"http://a.tile.thunderforest.com/cycle/",
              "http://b.tile.thunderforest.com/cycle/",                                              
               "http://c.tile.thunderforest.com/cycle/"};

final ITileSource OCM =
        new XYTileSource("Open Cycle Map",
                            0,
                            19,
                            512,
                            ".png",
                            tileUrls,
                            "from open cycle map");

非常感谢

【问题讨论】:

    标签: android osmdroid


    【解决方案1】:

    定义一个 tile-source 是一种正确的方法。这是一个非常好的方法,许多内置的 tile-sources 都在 same way 中定义。

    但是,根据http://thunderforest.com/maps/opencyclemap/ 的文档,您应该获取并使用 API 密钥:

    想使用这些图块吗?的通用切片格式字符串 OpenCycleMap图层是:

    https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=<insert-your-apikey-here>

    因此您应该包含您的 API 密钥:

    final ITileSource OCM =
            new XYTileSource("Open Cycle Map",
                                0,
                                19,
                                512,
                                ".png?apikey=<insert-your-apikey-here>",
                                tileUrls,
                                "from open cycle map");
    

    (这只是问题中的修改代码。我没有测试它,因此某些参数不必正确)

    【讨论】:

      猜你喜欢
      • 2014-05-01
      • 2017-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多