My-Location Button of GoogleMaps v2 Android, not displayed
The myLocationButtonEnabled
is true by default and shown when the setMyLocationEnabled
layer is enabled.
try this:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
// Add this line
map.setMyLocationEnabled(true);
locManager = (LocationManager)getSystemService(LOCATION_SERVICE);
providersList = locManager.getAllProviders();
provider =locManager.getProvider(providersList.get(0));
precision = provider.getAccuracy();
req = new Criteria();
req.setAccuracy(Criteria.ACCURACY_FINE);
inside = false;
//map.getUiSettings().setMyLocationButtonEnabled(true);
buildPolygon();
drawPolygon();
startLocalization();
}
setMyLocationEnabled
DocumentationsetMyLocationButtonEnabled
Documentation
Add the following line.
Kotlin:
map.isMyLocationEnabled = true
map
is a GoogleMap object.
(More detailed answer(s) in this question: https://stackoverflow.com/a/15142091/11211963 )
just add map.setMyLocationEnabled(true);
after create your map
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
to be like this
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
map.setMyLocationEnabled(true);