I'm working in an android mapping application using osmdroid mapping API, until now I'm being able to show the map(using MapView class) ,but I want to know how I can show my location on the map ,after I read about it I know that there is a class called MyLocationOverlay I'm trying to use it but the application return a blank page.here is my code:
public class AbodyActivity extends Activity
{
private MapView mapView;
private MapController mapController;
private MyLocationOverlay myLocationoverlay;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initializemap();
myLocationoverlay = new MyLocationOverlay(this, mapView);
myLocationoverlay.disableMyLocation(); // not on by default
myLocationoverlay.disableCompass();
myLocationoverlay.disableFollowLocation();
myLocationoverlay.setDrawAccuracyEnabled(true);
myLocationoverlay.runOnFirstFix(new Runnable() {
public void run() {
mapController.animateTo(myLocationoverlay
.getMyLocation());
}
});
mapView.getOverlays().add(myLocationoverlay);
}
public void initializemap()
{
mapView = (MapView) this.findViewById(R.id.mapView);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
mapController = this.mapView.getController();
mapController.setZoom(6);
}
}
and also here is the permissions which I used:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Are you sure that:
myLocationoverlay.disableMyLocation();
Doesn't disable the location finder methods so your Runnable
is never called?