How to zoom on to center of the screen

Your problem is almost certainly the order of operations. You must 1) translate before 2) zooming.

For a detailed discussion of why, see:

“These operations are order dependent if you are scaling: you must center your coordinate system first, then scale from the center, then translate to your view. If you try to scale first or last then bad things happen: either scaling happens from the top left, or the view scale does not match the drawing scale and they are misaligned.”

Problems with view and frame of reference are really difficult to debug about by just posting snippets, because so many different things in the code could impact the state of the matrix stack. If you still have trouble, post a complete mini sketch – an MCVE – to get feedback.