@Override public void onLocationChanged(Location location) { if (mapboxMap != null && firstRun) { mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15)); firstRun = false; } }
private void enableLocation(boolean enabled) { if (enabled) { mapboxMap.setMyLocationEnabled(true); if (mapboxMap.getMyLocation() != null) { mapboxMap.moveCamera( CameraUpdateFactory.newLatLngZoom( new LatLng( mapboxMap.getMyLocation().getLatitude(), mapboxMap.getMyLocation().getLongitude()), 15)); } } else { mapboxMap.setMyLocationEnabled(false); } }