You can not assign a javascript value to php that way.
I quote another user's response
PHP runs on the server side, and JS on the client side. The
sequence would be more or less like this:
-The client requests the server to view a page .php
-The server executes the PHP code to generate a plain text file. This plain text will normally be HTML, which may contain
JS code between "script" tags
-The server sends the generated text and the client receives it (the client will normally be a browser, such as firefox or chrome)
-The client will interpret the HTML and will show it properly, also executing the javascript code that it contains, but it is executed
IN THE CUSTOMER
As you can see, the execution of the PHP code has already finished by
complete in step 2, but the execution of the JS code is done in
step 4 and on a different machine (the PHP has been executed in the
server, the JS has been executed on the client).
link
What you can do is send the javascript value through ajax to process it in a php, and if what you need is to print the value so nothing else, you simply select the element and add the value:
document.getElementById("myText").value = latitude;