I will give a nephew and I will suggest a solution with plugin jQuery:
https://igorescobar.github.io/jQuery-Mask-Plugin/
In the block of examples, take a look at the functionality of "Translate". Adapting to the rules of longitude would look something like this:
$('input.longitude').mask('99Z.99999999', {
translation: {
'Z': {
pattern: /[0-9]/,
optional: true
}
}
});
Thus, if the user enters two digits and then the dot, the mask will not move the place point. But it is mandatory that the user enters the point.
The number of decimals is at the project’s discretion -- Google Maps uses 8 houses after the comma, but if I’m not mistaken, the longitude pattern can be up to 13 digits after the dot.
Put in the relevant part of the code so we can see how you’re assembling the coordinate pair. Assuming they are numerical values, in principle it is only divided by 1000000, no?
– Bacco
Doing what you need is relatively easy, the problem is that the longitude goes from -180 to 180. If Voce has a number -179361808, it is a little complicated to know if it is -179.361808 or -17.9361808. If the houses after the point are always 6 there is quiet, but the accuracy may vary if I am not mistaken.
– Neuber Oliveira
I think you need to give more details of the problem because it may not be a question of just putting the decimal point in the right place. Seems to be a coordinate conversion/projection problem.
– Pagotti