hansjoachimbutz / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Osmdroid does not apply screen dpi to rendering of map tiles #523

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
On devices with high dpi screens (xhdpi, e.g. SGS4 440dpi) the map tiles get 
physically so small that the writing on the maps becomes unreadable.

Osmdroid should scale the map tiles as per device dpi setting so that the map 
is always displayed at the same physical size.

Original issue reported on code.google.com by osei...@gmail.com on 6 Feb 2014 at 8:09

GoogleCodeExporter commented 9 years ago
Work around: 

double scale = getResources().getDisplayMetrics().density;
new GoogleSatelliteTileSource("GM", null, 7, 17, (int)(256 * scale), "" );

The scale will be the css pixel ratio (for example: Old Galaxy Mini Scale = 
0.75, Normal Scale = 1.0, Google Nexus 7 2013 Scale = 2.0 and Galaxy Note 3 
Scale = 3.0)

The tiles will now have the same 'size' on every screen density. However: when 
setting a scale bigger than 1.9999 the CurrentLocationOverlay is overlay is not 
working anymore! The pegman is not showing and the traveled path is not drawn 
anymore.

I didn't find a fix for this issue yet...

Original comment by jveldh...@gmail.com on 12 Feb 2014 at 12:28

GoogleCodeExporter commented 9 years ago
Issue 525 has been merged into this issue.

Original comment by kurtzm...@gmail.com on 12 Feb 2014 at 3:54

GoogleCodeExporter commented 9 years ago
The reason for this is located in MapViewConstants:

    public static final int MAXIMUM_ZOOMLEVEL = 22;

The MyLocationNewOverlay uses TileSystem.LatLongToPixelXY() with levelOfDetail 
set to MapViewConstants.MAXIMUM_ZOOMLEVEL. The LatLongToPixelXY() method itself 
uses TileSystem.MapSize():

    public static int MapSize(final int levelOfDetail) {
        return mTileSize << levelOfDetail;
    }

Since 512 << 22 gives -2147483648, the coordinate is set to 0/0 after being 
Clip()ped to the map boundaries in LatLongToPixelXY/().

A possible solution: Set MAXIMUM_ZOOMLEVEL to 21, then the bitshift won't give 
a negative result and the pegman should be back there on the map. 

Original comment by lorenz.s...@gmail.com on 25 Mar 2014 at 7:50

GoogleCodeExporter commented 9 years ago
Great! Changing the MAXIMUM_ZOOMLEVEL to 21 fixed the problem!

Original comment by jveldh...@gmail.com on 4 Apr 2014 at 12:52

GoogleCodeExporter commented 9 years ago
double scale = getResources().getDisplayMetrics().density;
new GoogleSatelliteTileSource("GM", null, 7, 17, (int)(256 * scale), "" );

I wonder how do osmdroid calculate the tile coordinate with a different tile 
size?

Original comment by apachema...@gmail.com on 25 Apr 2014 at 5:00