目前我正在使用
在OSMdroid底图上加载一个tile数据层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在彼此之上渲染多个数据层,或者我一次只能显示一个数据层?
我找到了this example for GoogleMaps,但是一次没有找到一些处理multipe tileSources
的示例OSMdroid代码。
答案 0 :(得分:4)
是的,当然可以。你只需要在地图上添加另一个TilesOverlay。从列表的最低索引(= 0)开始,连续绘制叠加层(也称为tilesOverlays)。 这是一个例子:
//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);