osmdroid - higher zoom level?

后端 未结 3 1004

I\'m trying to implement a MapView using the osmdroid library.

However at the moment the furthest I seem to be able to zoom in isn\'t sufficient enough for my purposes.

3条回答
  •  醉话见心
    2021-02-03 12:12

    I had a similar problem to this while using a new HTC One today. Owing to the very high screen density, the maximum zoom level rendered the map tiles in such a manner as to make the street names and locations almost unreadable (I'm using OpenStreetMap). The best solution that I found was to scale the images in the tile source:

    final float scale = getBaseContext().getResources().getDisplayMetrics().density;
    final int newScale = (int) (256 * scale);
    String[] OSMSource = new String[2];
    OSMSource[0] = "http://a.tile.openstreetmap.org/";
    OSMSource[1] = "http://b.tile.openstreetmap.org/";  
    XYTileSource MapSource = new XYTileSource("OSM", null, 1, 18, newScale, ".png", OSMSource);  
    map.setTileSource(MapSource);
    

    Varying the scale in accordance with the screen density is a relatively good solution, provided you add some contingency to prevent the tiles becoming too blurry.

    This is not my solution BTW, I found it among the OSMDROID issues on Github. Thanks goes to stefangab95.

    EDIT: If the screen density is too high then scaling the tiles can also have the negative impact of making routes paths (generated using RoadManager) invisible. This problem has been recorded as an issue on the OSMBonusPack web site - No Polyline drawn. There is no resolution as yet.

提交回复
热议问题