Search code examples
javaandroidbitmapscalingmapsforge

Java: Scale Mapsforge Map when using online bitmap tiles instead of offline renderer


I use MapsForge 0.8 to display maps in my Android app. When using online tiles (which are just bitmaps and not vector data that can be adjusted in the runtime renderer), the map is really tiny on my Hi-resolution device and I can't read anything.

screenshot

I would like to scale the map and I have tried the following:

mapView.getModel().displayModel.setDefaultUserScaleFactor(2.0f);

And:

mapView.getModel().displayModel.setUserScaleFactor(2.0f);

But it does not change anything.
How to make it display the map bigger?

Update:

And I don't mean zooming in. I mean scaling the current zoom level to make it readable on high-resolution devices. Imagine the screenshot above on a small smartphone - it is tiny. I can't even read the street names.

2nd Update

The current answers below do NOT answer the question. This is about scaling Online tiles which are BITMAPS - and NOT how to influence rendering the vector data.

3rd Update

The accepted answer finally solved the issue!


Solution

  • Map view tile size is what defines the rendering, both in vector and raster maps.

    We have examples with raster tile sources in Mapsforge samples app, e.g. DownloadLayerViewer. There a fixed tile size 256px is used, as that is provided by the tile source:

    this.mapView.getModel().displayModel.setFixedTileSize(256);
    

    If you remove that line, then the map view tile size will be auto-calculated based on device dpi (like in vector maps) and so the raster tiles would appear bigger (though a bit blurry).

    Source: MapsForge Google Development Group

    Removing this line made it work. Previously I tried setting the tile size to a different value, but never tried to remove the setting completely.