Can we enable a 'GotoMyLocation' button on OSMDroid like mMap.setMyLocationEnabled(true);
on GoogleMap?
I didn't find such feature in MapView class.
Can we enable a 'GotoMyLocation' button on OSMDroid like mMap.setMyLocationEnabled(true);
on GoogleMap?
I didn't find such feature in MapView class.
Create one of these
org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay mylocation = new MyLocationNewOverlay(...);
Add it to your MapView
mMapView.getOverlays().add(mylocation);
Then try
mylocation.enableFollowLocation();
To set your current location use, LOCATION_SERVICE of LocationManager. This will listen your gps location and will set your center to the present location.
LocationManager myLocationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
LocationListenerProxy llp=new LocationListenerProxy(myLocationManager);
llp.startListening(gpsLocationListener, 1, 1) ;
place this code in your onCreate Activity and then define locationlistener in a different class
public final LocationListener gpsLocationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location){
textView.setText(location.getLatitude()+","+location.getLongitude());
Log.d("Location Changed >>> ", location.getLatitude()+","+location.getLongitude());
}
public void onProviderDisabled(String provider){}
public void onProviderEnabled(String provider){}
public void onStatusChanged(String provider, int status, Bundle extras){}
};