elya_a
elya_a

Reputation: 195

MapBox Android how to hide mapbox label

Screenshot

How to hide mapbox info label at bottom left corner?

Upvotes: 9

Views: 9024

Answers (5)

kosert
kosert

Reputation: 190

The approved answer doesn't work anymore as of Mapbox 10.0.

In the newest mapbox you can change logo and attributions visibility like this, from code:

mapView.logo.updateSettings {
    enabled = false
}

mapView.attribution.updateSettings {
    enabled = false
}

From XML:

app:mapbox_logoEnabled="false"
app:mapbox_attributionEnabled="false"

Upvotes: 11

ch65
ch65

Reputation: 323

Try this,please:

 mapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(MapboxMap mapboxMap) {
            mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder()
                            .target(new LatLng(36,50))
                            .zoom(10)
                            .tilt(45.0)
                            .build()),
                    10000);

            mapboxMap.getUiSettings().setAttributionEnabled(false);
            mapboxMap.getUiSettings().setLogoEnabled(false);

        }
    });

Upvotes: 5

aminography
aminography

Reputation: 22832

To hide Mapbox attribution and logo, we can access corresponding views by reflection then change their visibility using below method:

private void hideAttributionsView(){
    UiSettings uiSettings = mMapBoxMap.getUiSettings();
    try {
        Field attributionsViewField = UiSettings.class.getDeclaredField("attributionsView");
        attributionsViewField.setAccessible(true);
        Field logoViewField = UiSettings.class.getDeclaredField("logoView");
        logoViewField.setAccessible(true);

        View attributionsView = (View) attributionsViewField.get(uiSettings);
        View logoView = (View) logoViewField.get(uiSettings);

        attributionsView.setVisibility(View.GONE);
        logoView.setVisibility(View.GONE);
    } catch (Exception e) {
        // Nothing
    }
}

Upvotes: 2

Gabriel Perez
Gabriel Perez

Reputation: 403

Just disable the attribution and logo, as follows:

mapboxMap.getUiSettings().setAttributionEnabled(false);
mapboxMap.getUiSettings().setLogoEnabled(false);

Upvotes: 18

cammace
cammace

Reputation: 3168

The marked answer is wrong, incanus was referring to the older, now deprecated, SDK. Attribution is required because:

  • Mapbox’s map designs are copyrighted
  • The OpenStreetMap data source’s ODbL license requires attribution
  • Other data sources used in our satellite, streets, and terrain maps also require attribution

If your map does not use any of these data sources, and does not use Mapbox’s designs, like Streets, Light, or Outdoors, then you are not required to provide attribution.

In Android you can move the attribution to another position if you need to using the correct attribute in the mapview XML. If your map doesn't fit any of the cases listed above, removing the attribution can be done in XML like so:

mapbox:attribution_enabled="false"

When it comes to hiding the Mapbox logo, All non-Enterprise accounts are required to display the Mapbox logo when using any Mapbox maps. Therefore, you can't remove it.

Sources: https://www.mapbox.com/help/attribution/, https://www.mapbox.com/help/mapbox-logo/

Upvotes: 11

Related Questions