package org.osmdroid.samples;

import org.osmdroid.tileprovider.MapTileProviderBasic;
import org.osmdroid.tileprovider.tilesource.ITileSource;
import org.osmdroid.tileprovider.tilesource.XYTileSource;
import org.osmdroid.tileprovider.util.CloudmadeUtil;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.TilesOverlay;

import android.app.Activity;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

/**
 * 
 * @author Alex van der Linden
 * 
 */
public class SampleWithTilesOverlayAndCustomTileSource extends Activity {

	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	private MapView mOsmv;
	private TilesOverlay mTilesOverlay;
	private MapTileProviderBasic mProvider;
	private ITileSource mCustomTileSource;

	// ===========================================================
	// Constructors
	// ===========================================================
	/** Called when the activity is first created. */
	@Override
	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Setup base map
		final RelativeLayout rl = new RelativeLayout(this);

		CloudmadeUtil.retrieveCloudmadeKey(getApplicationContext());

		this.mOsmv = new MapView(this, 256);
		rl.addView(this.mOsmv, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.FILL_PARENT));
		this.mOsmv.setBuiltInZoomControls(true);

		// zoom to the netherlands
		this.mOsmv.getController().setZoom(7);
		this.mOsmv.getController().setCenter(new GeoPoint(51500000, 5400000));

		// Add tiles layer with custom tile source
		this.mProvider = new MapTileProviderBasic(getApplicationContext());
		this.mCustomTileSource = new XYTileSource("FietsRegionaal", null, 3, 18, 256, ".png",
				"http://overlay.openstreetmap.nl/openfietskaart-rcn/");
		this.mProvider.setTileSource(this.mCustomTileSource);
		this.mTilesOverlay = new TilesOverlay(mProvider, this.getBaseContext());
		this.mOsmv.getOverlays().add(this.mTilesOverlay);

		this.setContentView(rl);
	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	// ===========================================================
	// Methods from SuperClass/Interfaces
	// ===========================================================

	// ===========================================================
	// Methods
	// ===========================================================

	// ===========================================================
	// Inner and Anonymous Classes
	// ===========================================================
}
@@ -406,16 +406,48 @@
 ivity;%0D%0A
+import android.graphics.Color;%0D%0A
 import a
@@ -561,25 +561,24 @@
 ;%0D%0A%0D%0A/**%0D%0A *
- 
 %0D%0A * @author
@@ -601,17 +601,16 @@
 nden%0D%0A *
- 
 %0D%0A */%0D%0Ap
@@ -980,156 +980,8 @@
 %0D%0A%0D%0A
-%09private MapView mOsmv;%0D%0A%09private TilesOverlay mTilesOverlay;%0D%0A%09private MapTileProviderBasic mProvider;%0D%0A%09private ITileSource mCustomTileSource;%0D%0A%0D%0A
 %09// 
@@ -1433,23 +1433,31 @@
 );%0D%0A%0D%0A%09%09
-this.mO
+final MapView o
 smv = ne
@@ -1492,23 +1492,17 @@
 addView(
-this.mO
+o
 smv, new
@@ -1588,31 +1588,25 @@
 ARENT));%0D%0A%09%09
-this.mO
+o
 smv.setBuilt
@@ -1658,31 +1658,25 @@
 herlands%0D%0A%09%09
-this.mO
+o
 smv.getContr
@@ -1694,31 +1694,25 @@
 Zoom(7);%0D%0A%09%09
-this.mO
+o
 smv.getContr
@@ -1810,30 +1810,55 @@
 e source%0D%0A%09%09
-this.m
+final MapTileProviderBasic tile
 Provider = n
@@ -1910,29 +1910,35 @@
 ());%0D%0A%09%09
-this.mCustomT
+final ITileSource t
 ileSourc
@@ -2067,21 +2067,19 @@
 %22);%0D%0A%09%09t
-his.m
+ile
 Provider
@@ -2098,20 +2098,8 @@
 ce(t
-his.mCustomT
 ileS
@@ -2109,22 +2109,22 @@
 ce);%0D%0A%09%09
-this.m
+final 
 TilesOve
@@ -2128,16 +2128,29 @@
 Overlay 
+tilesOverlay 
 = new Ti
@@ -2160,17 +2160,20 @@
 Overlay(
-m
+tile
 Provider
@@ -2206,14 +2206,70 @@
 %0A%09%09t
-his.mO
+ilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);%0D%0A%09%09o
 smv.
@@ -2291,14 +2291,8 @@
 dd(t
-his.mT
 iles
@@ -2972,8 +2972,10 @@
 =====%0D%0A%7D
+%0D%0A

Change SampleWithTilesOverlayAndCustomTileSource to set draw tiles overlay without tile loading background. See issue 177.