I'm working on an little mapbox based game and I'm currently working on an latitude/longitude-based chunk system. The distance between each of them should be the same. As you can see in the example the width and height of each chunk are equal. The little grey square is just the chunk middle. Those chunks were created near latitude/longitude zero, where they aren't effected by the Mercator projection.
But due to the Mercator projection the distances between the chunks are increasing as more as they move away from the middle (they look kinda stretched).
As you can see the distances between each one aren't equal anymore. The height of each of those chunks did increase. Here's another picture of the Mercator projection to visualize what I mean:
The chunks of the first picture were created near the middle of the word map (where the big black upper arrow points towards). The chunks from the second pictures were created near the bottom of the world map, where the other arrow points towards.
The type of game I'm developing requires equal chunk sizes and also it doesn't look that good when at some point the chunks look different due to the stretching.
I want to achieve a chunk system like this on the mercator projection :
I calculate the chunks as follows:
First we need the player latitude/longitude coordinates : 3.0146683, 5.3046076
One latitude is about: 110.57 km -> 110570 meters.
One longitude is about: 111.32 km -> 111320 meters.
One chunk should be about 750 meters on the map.
Because latitude and longitude got different ranges we need to adjust the chunk size.
One latitude factor = 110570 / 750 = 147,43.
One longitude factor = 111320 / 750 = 148,42.
One latitude chunk size = 110570 / 147 = 750 meters.
One longitude chunk size = 111320 / 148,42 = 750 meters.
(Maybe this step is unnecessary)
Now we convert the Lat/Lng to meters.
Latitude in Meter = 3.0146683 * 110570 meters = 333 331.873931 Meters.
Longitude in Meter = 5.3046076* 111320 meters = 590 508.918032 Meters.
Now we need to calculate the meters till the last chunk by using modulo.
Latitude Modulo => 333 331.873931 modulo 750 = 331 meter.
Longitude Modulo => 590 508.918032 modulo 750 = 258 meter.
After that we are able to calculate the Latitude and Longitude chunks.
Latitude chunk position = 333 331.873931 - 331 = 333 000.873931.
Longitude chunk position = 590 508.918032 -258 = 590 250.918032.
When we didive that now through the chunk size we get the actual chunk position.
Chunk X = 333 000.873931 / 750 = 444,0011.
Chunk Y = 590 250.918032 / 750 = 787,001.
Rounded: Chunk X = 444; Chunk Y = 787.
Now we know that the player stands right in this chunk [444;787].
In the next step I just calculate the Chunk X and Y back to latitude and
longitude and convert them via transform.AsUnityPosition to 3D coordinates,
where I place those grey objects then.
So basically I need a way to have the same visual distance between each of those chunks. Or either a way to change the projection from Mercator to a square projection, where nothing is stretched. I never worked with mapbox/Google Maps before... so I'm a newbie. Or is there maybe a formula I can use to prevent my chunks from being stretched by the projection?
Thanks for your time and attention! :)