同一图块的多个图像相互重叠

时间:2019-02-24 11:41:44

标签: android kotlin tiles osmdroid

我正在使用自定义图块源实现地图,但问题是它与具有自己图块源的图像地图重叠。enter image description here

这是我用自己的图块源实现地图的代码。

class OurTileSource(url: String) : XYTileSource("plan", 1, 
    20, 128, ".png", arrayOf(url.substring(0, url.indexOfFirst { it == '{' }))) {

   override fun getTileURLString(pMapTileIndex: Long): String {
       val url2 =(baseUrl +"/" +MapTileIndex.getZoom(pMapTileIndex) + 
       "/"
       + MapTileIndex.getX(pMapTileIndex) + "_" 
            + MapTileIndex.getY(pMapTileIndex) + mImageFilenameEnding)
       return url2
   }

}

设置地图的代码

    if (device.tileTemplate != null) {
        mapView.setTileSource(OurTileSource(device.tileTemplate!!))
        btnMap.visibility = View.GONE
    } else {
        mapView.setTileSource(TileSourceFactory.MAPNIK)
        btnMap.visibility = View.VISIBLE
    }
    val zoom = if (device.tileTemplate != null) 3.0 else 8.0

    mapView.setMultiTouchControls(false)
    mapView.setBuiltInZoomControls(false)
    mapView.setScrollableAreaLimitDouble(mapView.boundingBox)
    mapView.controller.setCenter(GeoPoint(device.lat, device.lon))
    mapView.controller.setZoom(zoom)
    mapView.invalidate()

0 个答案:

没有答案