Skip to content

Different device resolutions

Nutiteq edited this page Jul 5, 2013 · 17 revisions

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.

Map tile adjustment

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)

DefaultLabel text size adjustment

If you use DefaultLabels, then you have similar problem, texts are quite hard to read:

Label without DPI adjustment

There are two elements in this label: title and description. You should set increased font size for both:

   LabelStyle labelStyle = 
      LabelStyle.builder()
             .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.

Of course you may want to increase size of markers also

The result:

![https://dl.dropboxusercontent.com/u/3573333/public_web/dpilabel.png](adjusted font in Label)

Text sizes

For vector texts on map there is simply texts size parameter in TextStyle .setSize(), so you may want to adjust it based on DPI.

Clone this wiki locally