-
Notifications
You must be signed in to change notification settings - Fork 75
Different device resolutions
Nutiteq SDK does not do automatic reconfiguration based on device screen size and display density, so with new "full HD" / XXHDPI screen you may see too small texts.
Most tile sources is that their texts and other styles are designed based on web usage, and desktop DPI is much lower than mobile device. So if you show the tiles with 1:1 pixels (as Nutiteq SDK by default also does) then you may see get something like (click on image to see full screenshot):
![Default map with XXHDPI device](https://dl.dropboxusercontent.com/u/3573333/public_web/noadjustmap%20copy.png)Nutiteq SDK has special method mapView.getOptions().setTileZoomLevelBias() to enforce loading lower zoom (therefore lower resolution) tiles, but you need to turn it on with following code:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
float dpi = metrics.densityDpi;
// you may want to adjust multipliers based on your tile source
// default adjustment is 0.0, use -1.0 to get tiles from 1 zoom level down, 1.0 for one zoom up.
float adjustment = (1.0f - ((float)dpi / (float) DisplayMetrics.DENSITY_DEFAULT)) / 2.0f;
Log.debug("adjust DPI = "+dpi+" as zoom adjustment = "+adjustment);
mapView.getOptions().setTileZoomLevelBias(adjustment);
Result:
![DPI adjusted map](https://dl.dropboxusercontent.com/u/3573333/public_web/dpiadjustmap%20copy.png)If you use DefaultLabels, then you have similar problem, texts are quite hard to read:
There are two elements in this label: title and description. You should set increased font size for both:
LabelStyle labelStyle =
LabelStyle.builder()
.setEdgePadding(24)
.setLinePadding(12)
.setTitleFont(Typeface.create("Arial", Typeface.BOLD), 32)
.setDescriptionFont(Typeface.create("Arial", Typeface.NORMAL), 32)
.build();
Label markerLabel = new DefaultLabel("San Francisco", "Here is a marker", labelStyle);
// ... now crete Marker with the markerLabel
In your case you may want to adjust the size based on real DPI, or use sample from this stackoverflow question, knowing that setTextSize is used from Paint.
The result:
For vector texts on map there is simply texts size parameter TextStyle.setSize(), so you may want to adjust it based on DPI.
To set Marker size use MarkerStyle.setSize() parameter. This size is in OpenGL units, not in pixels, and one size should remain quite same for different resolution screens, something between 0.5 and 1.0 should work fine. You may want to adjust this size based on physical screen size, not DPI, so it is smaller on small screens where too big screen portion would be taken otherwise.
Use higher resolution images, at least 64x64 pixels, so it looks good on XXHDPI screen also. We suggest to use UnscaledBitmapLoader.decodeResource() method, as in code samples to avoid Android builder to downscale the image.