I am writing a Android app that includes a map using the Google Maps API.
I load custom map tiles using a my own extension of com.google.android.gms.maps.model.UrlTileProvider
.
I have two sets of map tiles: one designed for higher density screens and one designed for lower density screens. The higher density map tile set features larger text and so on. Both sets use map tile size of 256x256 pixels.
I switch between the two sets depending on screen density as obtained from:
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
Float density = displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT;
So far so good.
The appropriate map tile set is displayed depending on density, as it should.
However, on higher density devices (where many pixels are treated as one logical density-independent-pixel (DiP/DP)) each map tile pixel is scaled to match one device DiP/DP. In other words the higher density the device features the worse the map tiles will look when rendered.
I have been playing around for a while with the UrlTileProvider
constructor width/height, but they do not seem to have any effect.
And I can not find any settings in the Google Maps API to help me resolve my issue.
I haven't found any solution on stackoverflow or other sites.
Does anyone know how to solve my problem?