问题描述
我正在使用 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
}
看起来像这个屏幕截图(电影应用)的 android 主题。 ** 我正在寻找免费的解决方案**
解决方法
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
}