I was looking at geodesy's library, but it seems buggy since the parser breaks using the wikipedia examples.
For example, Wikipedia's "4QFJ 12345 67890" value throws an error, because the first two characters are not a number.
Here is the Wikipedia article for reference. https://en.wikipedia.org/wiki/Military_Grid_Reference_System
I also saw https://github.com/codice/usng.js/ but it only has lat Lon to MGRS. Is there a library that already does this conversion?
What I gather from looking at the source code of the library is that MGRS is assumed to be the same as USNG but without spaces. When you call the LLtoMGRS function, behind the scenes all the library is doing is removing the spaces and calling the LLtoUSNG function. The library does have a USNGtoLL function, so I assume if you remove the spaces from the MGRS, you can just call the USBGtoLL function? Alternatively, this exists https://github.com/proj4js/mgrs I've not used it but it says that it converts both way between LL and MGRS