Vivek Mishra
Vivek Mishra

Reputation: 5705

Osmdroid map blurred in android devices

I am using osmdroid library for having osm maps functionality in my app.

compile 'org.osmdroid:osmdroid-android:6.0.2'

Everything is working fine functionality wise, but I have one issue related to map appearance. A website is also being developed for the same functionality as of the app and in the web they are also using osm maps. Now the issue is the map looks much clear on the website while it looks blurred on the android devices.

See the attached screenshots

Mobile Screenshot

Android Screenshot

Web Screenshot

Web

Below is my code for loading the maps in my android app.

 binding.map.setTileSource(TileSourceFactory.MAPNIK);
                        binding.map.setTilesScaledToDpi(true);
                        binding.map.setBuiltInZoomControls(false);
                        binding.map.setMultiTouchControls(true);
                        if (gpsTracker.canGetLocation()) {
                            if (gpsTracker.getLocation() != null) {
                                currentLocation = gpsTracker.getLocation();
                                centreLocation = gpsTracker.getLocation();
                                addCurrentLocationMarker(currentLocation);
                                getMarkersInCurrentLocation(currentLocation);
                            } else {
                                gpsTracker.showSettingsAlert();
                            }

                        } else {
                            gpsTracker.showSettingsAlert();
                            //Toast.makeText(getApplicationContext(), "Unable to get current location", Toast.LENGTH_LONG).show();
                        }

Is this related to the tile source that I am using ?

Upvotes: 0

Views: 835

Answers (1)

MKer
MKer

Reputation: 3450

This is due to binding.map.setTilesScaledToDpi(true) which scales the tiles depending to your device resolution. Try without: the image will be clean, but labels should be too small, less readable.

AFAIK, no good solution yet: OpenStreetMap tiles are not available at the resolution of current mobile devices.

-- EDIT 12/12/2018 -- See https://github.com/osmdroid/osmdroid/issues/1217

Upvotes: 4

Related Questions