OSMDroid: how do I set a fixed layer alpha?

44 Views Asked by At

I want to set alpha level of layer, like is it done in Alpine Quest, but I don't know how. I have not found any information on this issue on the Internet. Maybe someone has come across something like this?

I did

tileOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);

But this does not work, for example, with Google Hybrid + OSM Topo. I need to increase and decrease the transparency from fully transparent to fully visible.

1

There are 1 best solutions below

0
Александр On BEST ANSWER

I found solution. I must create new MapView, and it works nice:

MapView nMap = new MapView(context, tileProvider);
        nMap.setAlpha(0.55F);
        org.osmdroid.views.MapView.LayoutParams mapParams = new org.osmdroid.views.MapView.LayoutParams(
                org.osmdroid.views.MapView.LayoutParams.MATCH_PARENT,
                org.osmdroid.views.MapView.LayoutParams.MATCH_PARENT,
                null, 0, 0, 0);
        IMapController mapController = nMap.getController();
        mapController.setZoom(12);
        GeoPoint startPoint = new GeoPoint(geoPoint);
        mapController.setCenter(startPoint);
        constraintLayout.addView(nMap, mapParams);

Then, I can create SeekBar, and set alpha level of nMap. And do not forget to associate the actions of one MapView with another/others.