Supply a more specific user agent to tile provider
as required by osm policy
@@ -7,12 +7,17 @@ import org.osmdroid.config.Configuration;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.views.MapView;
+import de.stephanlindauer.criticalmaps.BuildConfig;
+
public class MapViewUtils {
private MapViewUtils() {}
public static MapView createMapView(Activity activity) {
Configuration.getInstance().setMapViewHardwareAccelerated(true);
+ Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID + "/"
+ + BuildConfig.VERSION_NAME + " " + org.osmdroid.library.BuildConfig.APPLICATION_ID
+ + "/" + org.osmdroid.library.BuildConfig.VERSION_NAME);
MapView mapView = new MapView(activity);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
@@ -20,7 +25,8 @@ public class MapViewUtils {
mapView.getController().setZoom(12);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
- mapView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ mapView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT));
mapView.setTilesScaledToDpi(true);
return mapView;
