I did this.
When the camera is installed at the distance of 1610, the resolution 720х1480, I have to get a result, which is sent to the input(the value markerHeight). I pass 40 and get -77. Must be -40, right?
What's wrong?
public void CalculateScaleByResolution() {
if (OnlineMaps.instance == null) {
return;
}
float lon = 38;
float lat = 45;
int zoom = OnlineMaps.instance.zoom;
OnlineMaps.instance.projection.CoordinatesToTile(lon, lat, zoom, out double tx, out double ty);
float markerHeight = JourneyObject.instance.sizeElement;
double ty2 = ty - markerHeight / 256;
OnlineMaps.instance.projection.TileToCoordinates(tx, ty2, zoom, out double lon2, out double lat2);
var res1 = OnlineMapsControlBase.instance.GetScreenPosition(new Vector2(lon, lat));
var res2 = OnlineMapsControlBase.instance.GetScreenPosition(new Vector2((float)lon2, (float)lat2));
Debug.Log("res1 = " + res1);
Debug.Log("res2 = " + res2);
res1 -= res2;
Debug.Log("res3 = " + res1);
var val = markerHeight / res1.y;
Debug.Log("val = " + val);
}