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.
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.
As per this documentaion,(Read Specifying the Position section) you can specify area to display and at what zoom level.
this.mapView.setCenter(new LatLong(52.517037, 13.38886)); this.mapView.setZoomLevel((byte) 12);
Above solution will work as it is provided in official documentation.
Apart from this I have also searched regarding this and find out we can also set MapPosition to MapViewPosition like(See this link).
MapPosition mapPosition1 = new MapPosition(new LatLong(52.517037, 13.38886), (byte) 12); this.mapView.getModel().mapViewPosition.setMapPosition(mapPosition1);
Hope this will help you.
There are a lot of ways of 'scaling' in mapsforge.
As it is shown in this example, you can try to .zoom()
the mapViewPosition
instead of scaling the Model directly.
If that is what you're asking for, try the following:
Code:
MapViewPosition mapViewPosition = mapView.getModel().mapViewPosition; mapViewPosition.zoom((byte) XX); // Change it to a number (i.g. "(byte) 3")
I can't even read the street names.
But if you are talking about the UI TEXT instead, you can try to change it like this:
mapView.setTextScale(XX); // Again, number goes here
If only the text size isn't enough for you, you may try creating a new RenderTheme instead.
Docs' Example:
Code:
tileRendererLayer.setXmlRenderTheme(new ExternalRenderTheme(File)) // File should be // the XML file for the RenderTheme
XML:
<?xml version="1.0" encoding="UTF-8"?> <rendertheme xmlns="http://mapsforge.org/renderTheme" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mapsforge.org/renderTheme renderTheme.xsd" version="1"> <!-- matches all ways with a "highway=trunk" or a "highway=motorway" tag --> <rule e="way" k="highway" v="trunk|motorway"> <line stroke="#FF9900" stroke-width="2.5" /> </rule> <!-- matches all closed ways (first node equals last node) with an "amenity=…" tag --> <rule e="way" k="amenity" v="*" closed="yes"> <area fill="#DDEECC" stroke="#006699" stroke-width="0.3" /> </rule> <!-- matches all nodes with a "tourism=hotel" tag on zoom level 16 and above --> <rule e="node" k="tourism" v="hotel" zoom-min="16"> <symbol src="file:/path/to/symbol/icon/hotel.png" /> <caption k="name" font-style="bold" font-size="10" fill="#4040ff" /> </rule> </rendertheme>
I searched and found this link and this issue (Support resolution-dependent images in render-themes) about the unreadability problem in high resolution devices. It seem there are two concerns here:
Text rendering: How to make text (labels) larger?
Solution for this problem is to use TileRendererLayer.setTextScale(float textScale)
:
TileRendererLayer tileRendererLayer = new TileRendererLayer(...);
mapView.getLayerManager().getLayers().add(tileRendererLayer);
tileRendererLayer.setTextScale(...)
Symbols/Icons Rendering:
Ludwig Brinckmann says in second link:
There is quite a bit of support for this in the Rescue branch through the use of SVG images and tile scaling.
This is that branch but I think it's already merged to the project. So it seems for icons, you need to use SVG renderer which according to docs, scale automatically:
SVG Symbols
Symbols can be either defined in the raster PNG format or as vector graphics in SVG format.
...
SVG Scaling
SVG resources can now be automatically scaled to accommodate different device resolutions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With