I have to deal with this: https://minkarta.lantmateriet.se/?e=493056&n=6795776&z=3&profile=karta&background=1&boundaries=false
This is a URL which uses "e" and "n" in the "SWEREF 99 TM" GPS format.
But I have standard MapBox GL JS GPS coordinates, in the variables "longitude" and "latitude". I guess it's the WSG-84 or something. Which most map systems use.
If I simply put those coordinates for "e" and "n" (either way), it goes to the completely wrong place on the map.
How do I translate them properly so they make sense to that map system?
Best Answer
Library proj4.js (http://proj4js.org/) is usually used for coordinated transformation in JS. To use it one needs CRS definition, which can be easily found on epsg.io site.
SWEREF 99 TM coordinate system has CRS code
EPSG:3006
, proj4 definition string is"+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
.JS code to convert
[lon, lat]
coordinate[14.8704033, 61.2961005]
to projected Swedish coordinates could then look something like:If you have just a few coordinates to convert you can use epsg.io site for that: https://epsg.io/transform#s_srs=4326&t_srs=3006