如何更改 OSM 地图自定义主题?

问题描述

我正在使用 osm 地图,我想更改地图样式

如何在开放街道地图中更改android地图的主题颜色和样式-我想针对特定目的完全简化地图并删除特定元素的颜色。

binding!!.mapView.apply {

             
                            setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE)
                            zoomController.setVisibility(CustomZoomButtonsController.Visibility.NEVER)
                            setMultiTouchControls(true)
                            val mapController: IMapController = controller
                            mapController.setZoom(12.0)

                            val zoomLocation =  GeoPoint(it.from_lat.todouble(),it.from_lng.todouble())

                            mapController.setCenter(zoomLocation)
                            startMarker.position = zoomLocation // marker location

                      

                }

enter image description here

看起来像这个屏幕截图(电影应用)的 android 主题。 ** 我正在寻找免费的解决方案**

enter image description here

解决方法

试试这个,enter image description here

binding.osmView.apply {
      val matrixA = ColorMatrix()
            matrixA.setSaturation(0.3f)
            val matrixB = ColorMatrix()
            matrixB.setScale(1.12f,1.13f,1.0f)
            matrixA.setConcat(matrixB,matrixA)
            val filter = ColorMatrixColorFilter(matrixA)
            overlayManager.tilesOverlay.setColorFilter(filter)
}
,

屏幕截图中的传输地图图层是 Thunderforest 的产品。

因此,您必须在 Thunderforest.com 上注册才能使用传输层(如果该传输层足以满足您的风格需求),然后查看您的代码库以包含一个 TileSourceFactory,其中包含了 Thunderforest 传输地图层。

如果您不想通过 Thunderforest 使用传输层,则需要渲染自己的地图(请参阅 https://switch2osm.org 了解说明)并自己更改 mapnik 样式。但这将意味着大量工作(取决于您需要的地图区域大小,还需要大量服务器资源)。

,

您可以使用 MapBox 平铺源,以及您自己自定义的 MapBox 样式。

,

试试这个解决方案:会减少一些加载时间

binding.osmView.apply {


          
      val matrixA = ColorMatrix()
            matrixA.setSaturation(0.3f)
            val matrixB = ColorMatrix()
            matrixB.setScale(1.12f,matrixA)
            val filter = ColorMatrixColorFilter(matrixA)
            overlayManager.tilesOverlay.setColorFilter(filter) // TilesOverlay.INVERT_COLORS
}
,

这可行

binding.osmView.apply {

  val matrixA = ColorMatrix()
        matrixA.setSaturation(0.3f)
        val matrixB = ColorMatrix()
        matrixB.setScale(1.12f,1.0f)
        matrixA.setConcat(matrixB,matrixA)
        val filter = ColorMatrixColorFilter(matrixA)
        overlayManager.tilesOverlay.setColorFilter(filter) // TilesOverlay.INVERT_COLORS

}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...