I'm using OSMDroid in my Android App. Everything works fine except I can not display the Icon to show my current Location. Following my Code:
openMapView = (org.osmdroid.views.MapView) v.findViewById(R.id.openmapview);
openMapView.setClickable(true);
openMapView.setMultiTouchControls(true);
final float scale = getResources().getDisplayMetrics().density;
final int newScale = (int) (256 * scale);
String[] OSMSource = new String[2];
OSMSource[0] = "http://a.tile.openstreetmap.org/";
OSMSource[1] = "http://b.tile.openstreetmap.org/";
XYTileSource MapSource = new XYTileSource(
"OSM",
null,
1,
18,
newScale,
".png",
OSMSource
);
openMapView.setTileSource(MapSource);
mapController = (MapController) openMapView.getController();
mapController.setZoom(14);
// My Location Overlay
myLocationoverlay = new MyLocationOverlay(getActivity(), openMapView);
myLocationoverlay.enableMyLocation(); // not on by default
myLocationoverlay.enableCompass();
myLocationoverlay.disableFollowLocation();
myLocationoverlay.setDrawAccuracyEnabled(true);
myLocationoverlay.runOnFirstFix(new Runnable() {
public void run() {
mapController.animateTo(myLocationoverlay.getMyLocation());
}
});
Can anyone give my an idea where I am going wrog and what I should change in my code.
To enable MyLocationOverlay you need to call:
myLocationoverlay.enableMyLocation();
mMapView.getOverlays().add(mMyLocationNewOverlay);
In addition remove this line from you code:
myLocationoverlay.disableFollowLocation();