-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converting ingame coordinates to pixels #16
Comments
Yes there is. The TileMapInfo.json file should give you the total width and height in in-game coordinates (or at least you can derive them from x1, x2, y1, y2). The tiles themselves give you the Rough example: function convertXY(xy) {
// Values from TileMapInfo.json
const xtot = x2 - x1; // Total X length
const ytot = y2 - y1; // Total Y length
const xrel = (xy[0] - x1) / xtot; // The fraction where the X is (between 0 and 1, 0 being fully left, 1 being fully right)
const yrel = (xy[1] - y1) / ytot; // The fraction where the Y is
return [
xrel * MAX_X, // Where X actually is, so multiplied the actual width
MAX_Y - (yrel * MAX_Y) // Where Y actually is, only Y is inverted
];
} |
Hello! |
You're welcome. The reason I inverted the Y-axis is because both OpenLayers and Leaflet start the Y at the bottom instead of at the top. Your map projection software may differ in this regard, but you'll find that out quickly enough. |
It's already been well over a year and I'm sorry for not responding sooner, but I would like to thank you as well. This has been very helpful. |
Hello! Is there a formula for converting ingame coordinates into pixels (on max zoom level 8)? Any help would be appreciated.
The text was updated successfully, but these errors were encountered: