TGRHavoc / live_map

A FiveM addon for live maps
https://docs.tgrhavoc.co.uk/livemap-resource/
62 stars 38 forks source link

[question]: how to convert lng & lat to x, y ,z #52

Closed casperiv0 closed 3 years ago

casperiv0 commented 3 years ago

Hey!

This is somewhat related to #51. I've tried to convert the lat & lng from the moveend event in leaflet using map.project({ lat, lng }) but with no success. I think there is a simple solution but I can't come up with it, any suggestions how I could convert it?

Example:

marker.on("moveend", (e) => {
 const latLng = e.target._latlng;

 // This would return the converted values from the leaflet map back to the GTA map
 const xYZ = ConvertLatLngToXYZ(latLng);
})

Thanks!

TGRHavoc commented 3 years ago

Sorry for the late reply!

Anyways, you can find the (not so good) code to translate in-game coords to leaflet's lat-lang in the interface source code.

You might be able to just reverse the operations used here to convert back to game-coords.

Problem: they might not be accurate.

casperiv0 commented 3 years ago

Yeah, it doesn't seem to be very accurate. Unless I did some wrong calculation lol