Skip to content

Commit

Permalink
OSM: add attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
johan12345 committed Jul 24, 2020
1 parent 9498a60 commit 2a2c032
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions anymaps-osm/src/main/java/com/car2go/maps/osm/MapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import android.content.res.TypedArray;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.TypedValue;

import com.car2go.maps.MapContainerView;
import com.car2go.maps.OnMapReadyCallback;

import org.osmdroid.tileprovider.tilesource.XYTileSource;
import org.osmdroid.views.CustomZoomButtonsController;
import org.osmdroid.views.overlay.CopyrightOverlay;

/**
* @see MapContainerView
Expand Down Expand Up @@ -47,13 +49,25 @@ private void initView(Context context, AttributeSet attrs) {
mapView.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
mapView.setTilesScaledToDpi(true);

CopyrightOverlay co = new CopyrightOverlay(context);
co.setTextColor(getSecondaryTextColor());
mapView.getOverlays().add(co);

anyMap = new OsmMap(mapView);

setClipToPadding(false);

applyAttributes(context, attrs);
}

private int getSecondaryTextColor() {
TypedValue typedValue = new TypedValue();
TypedArray a = getContext().obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.textColorSecondary });
int color = a.getColor(0, 0);
a.recycle();
return color;
}

private XYTileSource getTileSource() {
int density = (int) Math.ceil(getResources().getDisplayMetrics().density);
density = Math.min(density, 8); // maximum supported size is 8x
Expand Down

0 comments on commit 2a2c032

Please sign in to comment.