The app MacroDroid has a feature to set screen timeout to never. I did not test it for long but the app is free, so you can give it a try.
Install the app and enable the permission "modify system settings". Afterwards, setup a macro like this:
Trigger: setup a Trigger of your liking.
Action: Screen Timeout -> never
Constraint: only if you need, otherwise, leave untouched.
Now, whenever the condition for the macro would be fulfilled/triggered the action would run and timeout for screen would be changed to never.
To change the timeout after your work is done, say you're done with Maps app, you need another macro which would work for the rest of your phone's usage.
The trigger is I believe needs dependent. You can try with app launch and closure based triggers, optionally coupled with some constraints.