java-osmdroid上的多个平铺层
作者:互联网
目前,我正在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上彼此叠加渲染多个数据层,或者我一次只能显示一个数据层?
我找到了this example for GoogleMaps,但没有找到一些示例OSMdroid代码,一次处理多片tileSource.
解决方法:
是的,当然可以.您只需向地图添加另一个TilesOverlay.从列表的最低索引(= 0)开始,连续绘制覆盖图(也称为tileOverlays).
这是一个例子:
//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);
标签:osmdroid,java,android 来源: https://codeday.me/bug/20191031/1977343.html