This is cleaner, hopefully less buggy and barely any slower.
Split the input element better.
Fix latitude cap.
Longitude and latitude are handles acceptably now.
We no longer need those variables.
More senible (maybe?).