6

目前我正在使用 OSMdroid 底图加载一个瓦片数据层

final MapTileProviderBasic tileProvider = 
    new MapTileProviderBasic(getApplicationContext());
final ITileSource tileSource = 
    new XYTileSource("MyCustomTiles", null, 1, 16, 256, ".png",
            "http://a.url.to/custom-tiles/");
tileProvider.setTileSource(tileSource);
final TilesOverlay tilesOverlay = 
    new TilesOverlay(tileProvider, this.getBaseContext());
tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
osmv.getOverlays().add(tilesOverlay);

是否可以在 BaseMap 上渲染多个数据层,或者我一次只能显示一个数据层?我为 GoogleMaps 找到了这个示例,但没有找到一些一次处理 multipetileSources的示例 OSMdroid 代码。

4

1 回答 1

7

是的,当然可以。您只需将另一个 TilesOverlay 添加到地图中。叠加层(也是tilesOverlays)从列表的最低索引(= 0)开始连续绘制。这是一个例子:

//create the first tilesOverlay
final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());
final ITileSource tileSource = new XYTileSource("MyCustomTiles", null, 1, 16, 256, ".png",
        "http://a.url.to/custom-tiles/");
tileProvider.setTileSource(tileSource);
final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);

//create the second one
final MapTileProviderBasic anotherTileProvider = new MapTileProviderBasic(getApplicationContext());
final ITileSource anotherTileSource = new XYTileSource("MyCustomTiles", null, 1, 16, 256, ".png",
        "http://a.secondurl.to/custom-tiles/");
anotherTileProvider.setTileSource(anotherTileSource);
final TilesOverlay secondTilesOverlay = new TilesOverlay(anotherTileProvider, this.getBaseContext());
secondTilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);

// add the first tilesOverlay to the list
osmv.getOverlays().add(tilesOverlay);

// add the second tilesOverlay to the list
osmv.getOverlays().add(secondTilesOverlay);
于 2012-12-10T10:35:21.107 回答