3

I'm here because I'm trying to create a GTA V map with Leafletjs API. In deed, I've got my tiles that are ready. But the aim is to put markers on the map by using GTA V in-game coordinates. To achieve it, I need to convert the coordinates to LatLong but after many researches, I can't find a solution.

At Stackoverflow, they advise me to ask my question here.

For now, I have a simple function that help me to try to "calibrate" my coordinates :

function GTAVConverter(x,y)
{
    var ex = 0.01255;
    var ey = -0.01260;

    var x = ex * x;
    var y = ey * y;

    var x = x - 486.97;
    var y = y + 408.9;

    return map.containerPointToLatLng(new L.Point(x+1440.45,y+127.45));
}

But I think there is a better way to achieve my aim. This function isn't really accurate, and if the browser window is resized, all the coordinates are moved.

Example that I want to convert :

enter image description here

I know that Leaflet API has a coordinates system but I don't know how it works.

  • where did you get the existing equation to convert? Also curious why you subtract a constant 486.97 from x and then add 1440.45 back to it ? (same for y) – toms Aug 6 '15 at 17:48
  • I found it by trying to place my markers. I change the values, and I refresh to see the result. And this process again and again – Templeton Peck Aug 6 '15 at 18:17
1

How did you create your tiles?

If Leaflet knows how to read them, you may be able to read them in QGIS, a desktop GIS. If you can, then you could create a layer in QGIS, and then create your points, as well as test (like label, name, image etc.) on there, and then export this layer to GeoJSON, which Leaflet can use natively.

Are your tiles publicly accessible? If you sent a link, I may be able to help you get set up!

Another idea: set up a trigger for 'on click' in leaflet. Then you can console.log() the Lat Lon coordinates in LatLon. In this way, you can sort of digitise from the map. You can also use the Leaflet Draw plugin to digitise points straight on your map, and can probably work out how to export GeoJSON from that: https://github.com/Leaflet/Leaflet.draw.

1

This is an instance of the XY problem. You don't want to convert GTA coordinates to EPSG:4326, what you want to do is make Leaflet use a cartesian coordinate system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.