1

I'd like to use GTA V coordinates in leaflet to show some markers on the map.

How to do a transformation between the (unknown) coordinate system of GTA V to WGS84 (leaflet)?

I already tried to write a function for that. Sometimes the coordinates are correct but not always. I'm not sure what I did wrong. Is there a more simple way to achieve this? Perhaps with leaflet's Transformation system?

function convertCoords(x, y) {
    var game_1_x = 1972.606;     // random lng point (GTA)
    var game_1_y = 3817.044;     // random lat point (GTA)
    var map_1_lat = 80.751791;   // same lng point (WGS84)
    var map_1_lng = -121.717529; // same lat point (WGS84)

    var game_2_x = -1154.11;    // random lng point (GTA)
    var game_2_y = -2715.203;   // random lat point (GTA)
    var map_2_lat = 71.3602;    // same lng point (WGS84)
    var map_2_lng = -144.30542; // same lat point (WGS84)

    var rLat = map_1_lat + (y - game_1_y) * (map_1_lat - map_2_lat) / (game_1_y - game_2_y);
    var rLng = map_1_lng + (x - game_1_x) * (map_1_lng - map_2_lng) / (game_1_x - game_2_x);

    return L.latLng(rLat, rLng);
}

Here is a gridded map of GTA V: https://drive.google.com/file/d/0B-zvE86DVcv2MXhVSHZnc01QWm8/view

3
  • 2
    Have you read leafletjs.com/examples/crs-simple/crs-simple.html ? Jun 7, 2018 at 7:25
  • Thank you. Does that make a difference if I use tiles instead of an image Overlay? The map is about 70MB, so I have to use tiles. How are the values in var bounds = [[-26.5,-25], [1021.5,1023]]; calculated? I don't get it.
    – Vince
    Jun 7, 2018 at 9:08
  • A map with L.CRS.Simple can use tiles as well - default zoom 0 tiles will spawn 256 map units. As the tutorial says, think in terms of map units, not in terms of pixels. Those values are extrapolated from the image, so that the coordinates of the corners of the square fit [0, 0] and [1000, 1000]. Jun 7, 2018 at 9:21

0

Browse other questions tagged or ask your own question.