Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Support dark mode #1804

Closed
bubelov opened this issue May 17, 2022 · 7 comments
Closed

Support dark mode #1804

bubelov opened this issue May 17, 2022 · 7 comments

Comments

@bubelov
Copy link

bubelov commented May 17, 2022

Not sure if it's even technically possible but it would be nice to have a built-in dark mode support

@spyhunter99
Copy link
Collaborator

spyhunter99 commented May 17, 2022 via email

@bubelov
Copy link
Author

bubelov commented May 17, 2022

@spyhunter99 I'm not deeply familiar with the internals, but is it possible to do it via a special "dark" tile provider? Not sure if it exists though

@bubelov
Copy link
Author

bubelov commented May 17, 2022

Might be related:

openstreetmap/openstreetmap-website#2332

Looks like OSM website maintainers can't agree on how to implement it and they are also blocked by Bootstrap (for non-map components styling)

@henrichg
Copy link

henrichg commented May 17, 2022

I'm using this in Android application, when system is in dark mode:

MapView mMap ...;
mMap.setTileSource(TileSourceFactory.MAPNIK);
mMap.getOverlayManager().getTilesOverlay().setColorFilter(TilesOverlay.INVERT_COLORS);

For light mode in system:

mMap.getOverlayManager().getTilesOverlay().setColorFilter(null);

@bubelov
Copy link
Author

bubelov commented May 17, 2022

@henrichg I ended up doing the same thing, based on the sample app:

val nightMode =
    resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK

if (nightMode == Configuration.UI_MODE_NIGHT_YES) {
    overlayManager.tilesOverlay.apply {
        setColorFilter(TilesOverlay.INVERT_COLORS)
        loadingBackgroundColor = android.R.color.black
        loadingLineColor = Color.argb(255, 0, 255, 0)
    }
}

It works pretty well and it seem to be the recommended pattern so I'm wondering maybe it makes sense for osmdroid to do it automatically when it detects dark mode? It would be consistent with other widgets which tend to work out of the box.

The ocean looks a bit odd though:

dark

And here is how Google Maps shows it:

darkgoog

@henrichg
Copy link

@bubelov yes, this also my own solution.

@spyhunter99
Copy link
Collaborator

google solves this problem, along with other tools like mapsforge, mapbox, etc by changing the way the map tiles are rendered. osmdroid only displays prerendered map tiles, we don't render the tiles on device. Beyond inverting the colors, the only other thing i can suggest is try finding a different tile source that has a night mode. Nothing else we can do, unless someone wants to add support for geotile json format and render on device.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants