i reached there at last...
i adapted the layout sample and still the same, what can i do???
android:id="@+id/mainView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.mapsforge.samples.android.rotation.RotateView
android:id="@+id/rotateView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.mapsforge.map.android.view.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</org.mapsforge.samples.android.rotation.RotateView>
<org.mapsforge.samples.android.scalebar.MapScaleBarView
android:id="@+id/mapScaleBarView"
android:layout_above="@id/zoomOutButton"
android:layout_alignParentRight="true"
android:background="@android:color/transparent"
android:src="@drawable/radiobuton_activado" />
</RelativeLayout>
and my code(u helped me on this...)
package com.example.alain.entrecalles;
import android.os.Bundle;
import android.os.Environment;
import android.os.StrictMode;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.graphics.drawable.Drawable;
import android.view.Menu;
import android.view.View;
import org.mapsforge.core.graphics.Bitmap;
import org.mapsforge.core.model.LatLong;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.datastore.MapDataStore;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.renderer.TileRendererLayer;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.rendertheme.InternalRenderTheme;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class MainActivity extends AppCompatActivity {
// name of the map file in the external storage
private static final String MAPFILE = "cuba.map";
private MyLocationOverlay myLocationOverlay;
private TileCache tileCache;
private TileRendererLayer tileRendererLayer;
private MapView mapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidGraphicFactory.createInstance(this.getApplication());
this.mapView = new MapView(this);
setContentView(this.mapView);
this.mapView.setClickable(true);
this.mapView.getMapScaleBar().setVisible(true);
this.mapView.setBuiltInZoomControls(false);
this.mapView.getMapZoomControls().setZoomLevelMin((byte) 10);
this.mapView.getMapZoomControls().setZoomLevelMax((byte) 20);
// create a tile cache of suitable size
this.tileCache = AndroidUtil.createTileCache(this, "mapcache",
mapView.getModel().displayModel.getTileSize(), 1f,
this.mapView.getModel().frameBufferModel.getOverdrawFactor());
// tile renderer layer using internal render theme
MapDataStore mapDataStore = new MapFile(getMapFile());
this.tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
this.mapView.getModel().mapViewPosition, false, true, AndroidGraphicFactory.INSTANCE);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
// only once a layer is associated with a mapView the rendering starts
this.mapView.getLayerManager().getLayers().add(tileRendererLayer);
Drawable drawable = getResources().getDrawable(R.drawable.marker_red);
Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(drawable);
// create the overlay and tell it to follow the location
this.myLocationOverlay = new MyLocationOverlay(this, mapView.getModel().mapViewPosition, bitmap);
this.mapView.getLayerManager().getLayers().add(this.myLocationOverlay);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_scrolling, menu);
return true;
}
@Override
protected void onResume() {
super.onResume();
this.mapView.getModel().mapViewPosition.setCenter(new LatLong(21.847037, -78.75886));
this.mapView.getModel().mapViewPosition.setZoomLevel((byte) 12);
this.myLocationOverlay.setSnapToLocationEnabled(true);
this.myLocationOverlay.enableMyLocation(true);
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onDestroy() {
this.mapView.destroyAll();
AndroidGraphicFactory.clearResourceMemoryCache();
super.onDestroy();
}
private File copyFileToSdcard(int resid, String filename, String sdcardDirectoryName) {
Log.d("HAL", "copyFileToSdcard()");
String dirpath = Environment.getExternalStorageDirectory().getPath() + "/" + sdcardDirectoryName;
File dir = new File(dirpath);
if (dir.exists() == false) {
Log.d("HAL", "Creando directorio " + dir.getAbsolutePath());
dir.mkdir();
}
File file = new File(dirpath, filename);
try {
InputStream is = getResources().openRawResource(resid);
OutputStream os = new FileOutputStream(file);
byte[] data = new byte[is.available()];
is.read(data);
os.write(data);
is.close();
os.close();
} catch (IOException e) {
// No fue posible crear el ficher0. ¿Está montado el sdcard?
Log.w("ExternalStorage", "Error de escritura " + file, e);
return null;
}
return file;
}
private File getMapFile() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String filepath = Environment.getExternalStorageDirectory().getPath() + "/maps/cuba.map";
File file = new File("/mnt/sdcard/mapas/" + MAPFILE);
File mapfile = new File(filepath);
try {
if (mapfile.exists() == false) {
mapfile = copyFileToSdcard(R.raw.cuba, "cuba.map", "maps");
}
} catch (Exception e) {
Log.e("HAL", "Error" + e.getMessage());
}
return mapfile;
}
}